From 8ccc06ba4bf58785986c7c2aae0dc8f0062f88df Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Wed, 1 Dec 2004 22:26:50 +0000 Subject: [PATCH] Add a statistics page that displays the number of users, active users, comments and applications. --- include/sidebar.php | 1 + include/user.php | 16 ++++++++++++++++ include/util.php | 32 ++++++++++++++++++++++++++++++++ index.php | 6 +----- 4 files changed, 50 insertions(+), 5 deletions(-) diff --git a/include/sidebar.php b/include/sidebar.php index 728ff49..137d300 100644 --- a/include/sidebar.php +++ b/include/sidebar.php @@ -20,6 +20,7 @@ function global_sidebar_menu() { $g->add("Submit App", $apidb_root."appsubmit.php"); $g->add("Documentation", $apidb_root."help/"); $g->add("Help & Support", $apidb_root."support.php"); + $g->add("Appdb Stats", $apidb_root."appdbStats.php"); $g->done(); $g = new htmlmenu("Search"); diff --git a/include/user.php b/include/user.php index 670732a..c6b8f87 100644 --- a/include/user.php +++ b/include/user.php @@ -412,4 +412,20 @@ function getNotifyEmailAddressList($appId, $versionId) return $retval; } +/* Get the number of users in the database */ +function getNumberOfUsers() +{ + $result = mysql_query("SELECT count(*) as num_users FROM user_list;"); + $row = mysql_fetch_object($result); + return $row->num_users; +} + +/* Get the number of active users within $days of the current day */ +function getActiveUsersWithinDays($days) +{ + $result = mysql_query("SELECT count(*) as num_users FROM user_list WHERE stamp >= 'NOW() - $days';"); + $row = mysql_fetch_object($result); + return $row->num_users; +} + ?> diff --git a/include/util.php b/include/util.php index eb58616..11d5bd7 100644 --- a/include/util.php +++ b/include/util.php @@ -189,4 +189,36 @@ function getQueuedMaintainerCount() return $ob->queued_maintainers; } +/* Get the number of users in the database */ +function getNumberOfComments() +{ + $result = mysql_query("SELECT count(*) as num_comments FROM appComments;"); + $row = mysql_fetch_object($result); + return $row->num_comments; +} + +/* Get the number of versions in the database */ +function getNumberOfVersions() +{ + $result = mysql_query("SELECT count(versionId) as num_versions FROM appVersion WHERE versionName != 'NONAME';"); + $row = mysql_fetch_object($result); + return $row->num_versions; +} + +/* Get the number of app familes in the database */ +function getNumberOfAppFamilies() +{ + $result = mysql_query("SELECT count(*) as num_appfamilies FROM appFamily;"); + $row = mysql_fetch_object($result); + return $row->num_appfamilies; +} + +/* Get the number of images in the database */ +function getNumberOfImages() +{ + $result = mysql_query("SELECT count(*) as num_images FROM appData WHERE type='image';"); + $row = mysql_fetch_object($result); + return $row->num_images; +} + ?> diff --git a/index.php b/index.php index f7fa2c1..834a2fa 100644 --- a/index.php +++ b/index.php @@ -42,11 +42,7 @@ apidb_header("Wine Application Database");

hits; + $numApps = getNumberOfVersions(); $voteQuery = "SELECT appVotes.appId, appName, count(userId) as count ". "FROM appVotes, appFamily ".