aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/functions/functions.php
diff options
context:
space:
mode:
authorBart van Bragt <bartvb@users.sourceforge.net>2001-03-10 11:49:20 +0000
committerBart van Bragt <bartvb@users.sourceforge.net>2001-03-10 11:49:20 +0000
commitdafd3e778cfb3f22bf886e00f8ad63185f0ae038 (patch)
treed29bde464f88d4e493441f290d350ee76d0ce474 /phpBB/functions/functions.php
parentafae95b90f159d4531ec48f9b320938181dd6292 (diff)
downloadforums-dafd3e778cfb3f22bf886e00f8ad63185f0ae038.tar
forums-dafd3e778cfb3f22bf886e00f8ad63185f0ae038.tar.gz
forums-dafd3e778cfb3f22bf886e00f8ad63185f0ae038.tar.bz2
forums-dafd3e778cfb3f22bf886e00f8ad63185f0ae038.tar.xz
forums-dafd3e778cfb3f22bf886e00f8ad63185f0ae038.zip
Merged some stat functions (total users/posts etc)
git-svn-id: file:///svn/phpbb/trunk@97 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/functions/functions.php')
-rw-r--r--phpBB/functions/functions.php118
1 files changed, 39 insertions, 79 deletions
diff --git a/phpBB/functions/functions.php b/phpBB/functions/functions.php
index 24f69ad180..53e3cd8114 100644
--- a/phpBB/functions/functions.php
+++ b/phpBB/functions/functions.php
@@ -22,63 +22,54 @@
*
***************************************************************************/
-function get_total_posts($db, $forums_table)
+function get_db_stat($db, $mode)
{
- $sql = "SELECT sum(forum_posts) AS total FROM ".FORUMS_TABLE;
- if(!$result = $db->sql_query($sql))
- {
- return "ERROR";
- }
- else
- {
- $rowset = $db->sql_fetchrowset($result);
- return($rowset[0]["total"]);
- }
-}
+ switch($mode){
+ case 'postcount':
+ $sql = 'SELECT count(*) AS total FROM '.POSTS_TABLE;
+ break;
-function get_user_count($db)
-{
- $sql = "SELECT count(user_id) AS total
- FROM ". USERS_TABLE ."
- WHERE user_id != ".ANONYMOUS."
- AND user_level != ".DELETED;
+ case 'usercount':
+ $sql = 'SELECT count(*) AS total
+ FROM '. USERS_TABLE .'
+ WHERE user_id != '.ANONYMOUS.'
+ AND user_level != '.DELETED;
+ break;
- if(!$result = $db->sql_query($sql))
- {
- return "ERROR";
- }
- else
- {
- $rowset = $db->sql_fetchrowset($result);
- return($rowset[0]["total"]);
- }
-}
+ case 'newestuser':
+ $sql = 'SELECT user_id, username
+ FROM '.USERS_TABLE.'
+ WHERE user_id != ' . ANONYMOUS. '
+ AND user_level != '. DELETED .'
+ ORDER BY user_id DESC LIMIT 1';
+ break;
+ }
-function get_newest_user($db)
-{
- $sql = "SELECT user_id, username
- FROM ".USERS_TABLE."
- WHERE user_id != " . ANONYMOUS. "
- AND user_level != ". DELETED ."
- ORDER BY user_id DESC LIMIT 1";
- if(!$result = $db->sql_query($sql))
- {
- return array("user_id" => "-1", "username" => "ERROR");
- }
- else
- {
- $rowset = $db->sql_fetchrowset($result);
- $return_data = array("user_id" => $rowset[0]["user_id"],
- "username" => $rowset[0]["username"]);
- return($return_data);
- }
+
+ if(!$result = $db->sql_query($sql))
+ {
+ return 'ERROR';
+ }
+ else
+ {
+ $row = $db->sql_fetchrow($result);
+ if($mode == 'newestuser')
+ {
+ return($row);
+ }
+ else
+ {
+ return($row['total']);
+ }
+ }
}
+
function make_jumpbox($db)
{
- $sql = "SELECT cat_id, cat_title FROM ".CATEGORIES_TABLE." ORDER BY cat_order";
+ $sql = 'SELECT cat_id, cat_title FROM '.CATEGORIES_TABLE.' ORDER BY cat_order';
- $boxstring = "";
+ $boxstring = '';
if($result = $db->sql_query($sql))
{
if($total_cats = $db->sql_numrows($result))
@@ -126,35 +117,4 @@ function make_jumpbox($db)
return($boxstring);
}
-function get_moderators($db, $forum_id)
-{
- $sql = "SELECT u.username, u.user_id FROM " . FORUM_MODS_TABLE ." f, " . USERS_TABLE . " u
- WHERE f.forum_id = '$forum_id' AND u.user_id = f.user_id";
- if($result = $db->sql_query($sql))
- {
- if($total_mods = $db->sql_numrows($result))
- {
- $rowset = $db->sql_fetchrowset($result);
- for($x = 0; $x < $total_mods; $x++)
- {
- $modArray[] = array("id" => $rowset[$x]["user_id"],
- "name" => $rowset[$x]["username"]);
- }
- }
- else
- {
- $modArray[] = array("id" => "-1",
- "name" => "ERROR");
- }
-
- }
- else
- {
- $modArray[] = array("id" => "-1",
- "name" => "ERROR");
- }
-
- return($modArray);
-}
-
?>