From 36ee5561035af335bc3c900ded7aa89066421226 Mon Sep 17 00:00:00 2001 From: Loui Chang Date: Tue, 24 Jun 2008 02:53:16 -0400 Subject: Move code out of index.php Move database queries to functions and html to templates. Signed-off-by: Loui Chang --- web/html/index.php | 182 +++-------------------------------------------------- 1 file changed, 10 insertions(+), 172 deletions(-) (limited to 'web/html') diff --git a/web/html/index.php b/web/html/index.php index 7a95abfc..ce5e0091 100644 --- a/web/html/index.php +++ b/web/html/index.php @@ -5,66 +5,13 @@ set_include_path(get_include_path() . PATH_SEPARATOR . '../lib' . PATH_SEPARATOR # Add to handle the i18n of My Packages include("pkgfuncs_po.inc"); include("aur.inc"); +include('stats.inc'); set_lang(); check_sid(); html_header( __("Home") ); - -# Newest packages -$q = "SELECT * FROM Packages WHERE DummyPkg != 1 ORDER BY GREATEST(SubmittedTS,ModifiedTS) DESC LIMIT 0 , 10"; -$newest_packages = db_query($q, $dbh); - -# AUR statistics -$q = "SELECT count(*) FROM Packages,PackageLocations WHERE Packages.LocationID = PackageLocations.ID AND PackageLocations.Location = 'unsupported'"; -$result = db_query($q, $dbh); -$row = mysql_fetch_row($result); -$unsupported_count = $row[0]; - -$q = "SELECT count(*) FROM Packages,PackageLocations WHERE Packages.LocationID = PackageLocations.ID AND PackageLocations.Location = 'community'"; -$result = db_query($q, $dbh); -$row = mysql_fetch_row($result); -$community_count = $row[0]; - -$q = "SELECT count(*) from Users"; -$result = db_query($q, $dbh); -$row = mysql_fetch_row($result); -$user_count = $row[0]; - -$q = "SELECT count(*) from Users,AccountTypes WHERE Users.AccountTypeID = AccountTypes.ID AND AccountTypes.AccountType = 'Trusted User'"; -$result = db_query($q, $dbh); -$row = mysql_fetch_row($result); -$tu_count = $row[0]; - -$targstamp = intval(strtotime("-7 days")); -$q = "SELECT count(*) from Packages WHERE (Packages.SubmittedTS >= $targstamp OR Packages.ModifiedTS >= $targstamp)"; -$result = db_query($q, $dbh); -$row = mysql_fetch_row($result); -$update_count = $row[0]; - -$user = username_from_sid($_COOKIE["AURSID"]); - -if (!empty($user)) { - $q = "SELECT count(*) FROM Packages,PackageLocations,Users WHERE Packages.MaintainerUID = Users.ID AND Packages.LocationID = PackageLocations.ID AND PackageLocations.Location = 'unsupported' AND Users.Username='".mysql_real_escape_string($user)."'"; - $result = db_query($q, $dbh); - $row = mysql_fetch_row($result); - $maintainer_unsupported_count = $row[0]; - - $q = "SELECT count(*) FROM Packages,Users WHERE Packages.OutOfDate = 1 AND Packages.MaintainerUID = Users.ID AND Users.Username='".mysql_real_escape_string($user)."'"; - $result = db_query($q, $dbh); - $row = mysql_fetch_row($result); - $flagged_outdated = $row[0]; - - # If the user is a TU calculate the number of the packages - $atype = account_from_sid($_COOKIE["AURSID"]); - - if ($atype == 'Trusted User') { - $q = "SELECT count(*) FROM Packages,PackageLocations,Users WHERE Packages.MaintainerUID = Users.ID AND Packages.LocationID = PackageLocations.ID AND PackageLocations.Location = 'community' AND Users.Username='".mysql_real_escape_string($user)."'"; - $result = db_query($q, $dbh); - $row = mysql_fetch_row($result); - $maintainer_community_count = $row[0]; - } -} +$dbh = db_connect(); ?> @@ -106,127 +53,19 @@ print __( 'Contributed PKGBUILDs must conform to the %hArch Packaging Sta - - - - - - - - - - - - - - - - -
- -
-"> - - + - + '; +} -if ($mod_int != 0): - $modstring = gmdate("r", $mod_int); -elseif ($sub_int != 0): - $modstring = ' ' . gmdate("r", $sub_int); -else: - $modstring = '(unknown)'; -endif; +general_stats_table($dbh); ?> - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- - - -
- - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- -
- -
- -
- -
- -
@@ -236,4 +75,3 @@ endif; -- cgit v1.2.3-24-g4f1b