[aur-dev] [PATCH 1/6] Remove a boatload of inline table styles
Replacing with CSS styles where appropriate. A previously unused CSS style is tweaked in the stylesheet to match most of what was done via non-CSS styling. Signed-off-by: Dan McGee <dan@archlinux.org> --- Things look mostly the same on all these pages. However, there are a few exceptions- for example, the removal of the needless centering of the account search form. web/html/css/arch.css | 9 +++++---- web/html/index.php | 2 +- web/html/pkgsubmit.php | 2 +- web/lib/acctfuncs.inc.php | 14 ++++---------- web/template/pkg_search_results.php | 18 +++++++++--------- web/template/search_accounts_form.php | 2 +- web/template/tu_details.php | 12 ++++++------ web/template/tu_list.php | 16 ++++++++-------- 8 files changed, 35 insertions(+), 40 deletions(-) diff --git a/web/html/css/arch.css b/web/html/css/arch.css index eec02ee..1e588f1 100644 --- a/web/html/css/arch.css +++ b/web/html/css/arch.css @@ -244,13 +244,14 @@ table.center { } table.results { padding: 0px; + width: 100%; border-collapse: collapse; } .results th { - background-color: #e1e3e6; - border-bottom: 1px solid #46494d; - border-top: 1px solid #46494d; - padding: 0px 5px 0px 0px; + text-align: center; +} +.results th, .results td { + padding: 1px; } .results th>a { text-decoration: none; diff --git a/web/html/index.php b/web/html/index.php index 138541f..0d513d3 100644 --- a/web/html/index.php +++ b/web/html/index.php @@ -50,7 +50,7 @@ echo __( <br /> <?php echo __('Some packages may be provided as binaries in [community].'); ?> </p> -<table border='0' cellpadding='0' cellspacing='3' width='90%'> +<table> <tr> <td class='boxSoft' valign='top'> <?php updates_table($dbh); ?> diff --git a/web/html/pkgsubmit.php b/web/html/pkgsubmit.php index a5cc0c0..54c4b3e 100644 --- a/web/html/pkgsubmit.php +++ b/web/html/pkgsubmit.php @@ -437,7 +437,7 @@ html_header("Submit"); <form action='pkgsubmit.php' method='post' enctype='multipart/form-data'> <div> <input type='hidden' name='pkgsubmit' value='1' /> </div> - <table border='0' cellspacing='5'> + <table> <tr> <td class='f4' align='right'><?php print __("Package Category"); ?>:</td> <td class='f4' align='left'> diff --git a/web/lib/acctfuncs.inc.php b/web/lib/acctfuncs.inc.php index 59fa730..4c6da9f 100644 --- a/web/lib/acctfuncs.inc.php +++ b/web/lib/acctfuncs.inc.php @@ -35,7 +35,7 @@ function display_account_form($UTYPE,$A,$U="",$T="",$S="", print "<input type='hidden' name='ID' value='".$UID."' />\n"; } print "</fieldset>"; - print "<table border='0' cellpadding='0' cellspacing='0' width='80%' style=\"margin:0 auto;\">\n"; + print "<table>\n"; print "<tr><td colspan='2'> </td></tr>\n"; print "<tr>"; @@ -415,13 +415,7 @@ function search_results_page($UTYPE,$O=0,$SB="",$U="",$T="", } else { $num_rows = mysql_num_rows($result); if ($num_rows) { - print "<table border='0' cellpadding='0'"; - print " cellspacing='0' width='90%'"; - print " style=\"margin:0 auto\">\n"; - print "<tr>"; - print "<td colspan='2'>"; - print "<table border='0' cellpadding='0'"; - print " cellspacing='0' width='100%'>\n"; + print "<table class='results'>\n"; print "<tr>"; print "<th class='header'>"; print "<span class='f2'>".__("Username")."</span></th>"; @@ -483,8 +477,8 @@ function search_results_page($UTYPE,$O=0,$SB="",$U="",$T="", $i++; } print "</table>\n"; - print "</td></tr>\n"; + print "<table class='results'>\n"; print "<tr>"; print "<td align='left'>"; print "<form action='account.php' method='post'>\n"; @@ -540,7 +534,7 @@ function display_account_info($U="", $T="", $E="", $R="", $I="") { global $SUPPORTED_LANGS; - print "<table border='0' cellpadding='0' cellspacing='0' width='33%' style=\"margin:0 auto;\">\n"; + print "<table>\n"; print " <tr>\n"; print " <td colspan='2'> </td>\n"; print " </tr>\n"; diff --git a/web/template/pkg_search_results.php b/web/template/pkg_search_results.php index e576e6e..8ef352b 100644 --- a/web/template/pkg_search_results.php +++ b/web/template/pkg_search_results.php @@ -12,32 +12,32 @@ -<table width='100%' cellspacing='0' cellpadding='2'> +<table class='results'> <tr> <?php if ($SID): ?> - <th style='border-bottom: #666 1px solid; vertical-align: bottom'> </th> + <th class='header'> </th> <?php endif; ?> - <th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'> + <th class='header'><span class='f2'> <a href='?<?php print mkurl('SB=c&SO=' . $SO_next) ?>'><?php print __("Category") ?></a> </span></th> - <th style='border-bottom: #666 1px solid; vertical-align: bottom; text-align: center;'><span class='f2'> + <th class='header'><span class='f2'> <a href='?<?php print mkurl('SB=n&SO=' . $SO_next) ?>'><?php print __("Name") ?></a> </span></th> - <th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'> + <th class='header'><span class='f2'> <a href='?<?php print mkurl('SB=v&SO=' . $SO_next) ?>'><?php print __("Votes") ?></a> </span></th> <?php if ($SID): ?> - <th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'> + <th class='header'><span class='f2'> <a href='?<?php print mkurl('SB=w&SO=' . $SO_next) ?>'><?php print __("Voted") ?></a> </span></th> - <th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'> + <th class='header'><span class='f2'> <a href='?<?php print mkurl('SB=o&SO=' . $SO_next) ?>'><?php print __("Notify") ?></a> </span></th> <?php endif; ?> - <th style='border-bottom: #666 1px solid; vertical-align: bottom; text-align: center;'><span class='f2'><?php print __("Description") ?></span></th> - <th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'> + <th class='header'><span class='f2'><?php print __("Description") ?></span></th> + <th class='header'><span class='f2'> <a href='?<?php print mkurl('SB=m&SO=' . $SO_next) ?>'><?php print __("Maintainer") ?></a> </span></th> </tr> diff --git a/web/template/search_accounts_form.php b/web/template/search_accounts_form.php index 9d6c40d..9b0d8e2 100644 --- a/web/template/search_accounts_form.php +++ b/web/template/search_accounts_form.php @@ -1,6 +1,6 @@ <br /> <form action='account.php' method='post'> - <table border='0' cellpadding='0' cellspacing='0' width='80%' style="margin:0 auto;"> + <table> <tr> <td align='left'><?php print __("Username"); ?>:</td> diff --git a/web/template/tu_details.php b/web/template/tu_details.php index 7d6c305..c48f603 100644 --- a/web/template/tu_details.php +++ b/web/template/tu_details.php @@ -24,13 +24,13 @@ N/A <?php print str_replace("\n", "<br />\n", htmlspecialchars($row['Agenda'])) ?> </p> -<table class="boxSoft" width='100%' cellspacing='0' cellpadding='2'> +<table class="boxSoft"> <tr> -<th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __("Yes") ?></span></th> -<th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __("No") ?></span></th> -<th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __("Abstain") ?></span></th> -<th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __("Total") ?></span></th> -<th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __('Voted') ?></span></th> +<th class='boxSoftTitle'><span class='f2'><?php print __("Yes") ?></span></th> +<th class='boxSoftTitle'><span class='f2'><?php print __("No") ?></span></th> +<th class='boxSoftTitle'><span class='f2'><?php print __("Abstain") ?></span></th> +<th class='boxSoftTitle'><span class='f2'><?php print __("Total") ?></span></th> +<th class='boxSoftTitle'><span class='f2'><?php print __('Voted') ?></span></th> </tr> <tr> <td class='data1'><span class='f5'><span class='blue'><?php print $row['Yes'] ?></span></span></td> diff --git a/web/template/tu_list.php b/web/template/tu_list.php index 75d9414..0966a4c 100644 --- a/web/template/tu_list.php +++ b/web/template/tu_list.php @@ -2,17 +2,17 @@ <div class="pgboxtitle" style="text-align:right;"> <span class='f3'><?php print $type ?></span> </div> - <table width='100%' cellspacing='0' cellpadding='2'> + <table class='results'> <tr> - <th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __("Proposal") ?></span></th> - <th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'> + <th class='header'><span class='f2'><?php print __("Proposal") ?></span></th> + <th class='header'><span class='f2'> <a href='?off=<?php print $off ?>&by=<?php print $by_next ?>'><?php print __("Start") ?></a> </span></th> - <th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __("End") ?></span></th> - <th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __("User") ?></span></th> - <th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __("Yes") ?></span></th> - <th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __("No") ?></span></th> - <th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __('Voted') ?></span></th> + <th class='header'><span class='f2'><?php print __("End") ?></span></th> + <th class='header'><span class='f2'><?php print __("User") ?></span></th> + <th class='header'><span class='f2'><?php print __("Yes") ?></span></th> + <th class='header'><span class='f2'><?php print __("No") ?></span></th> + <th class='header'><span class='f2'><?php print __('Voted') ?></span></th> </tr> <?php if (mysql_num_rows($result) == 0) { ?> <tr><td align='center' colspan='0'><?php print __("No results found.") ?></td></tr> -- 1.7.6
This affects login the most, where we save about 4 calls to db_connect() by passing a single handle into functions where necessary. Signed-off-by: Dan McGee <dan@archlinux.org> --- web/html/logout.php | 3 +-- web/lib/acctfuncs.inc.php | 38 ++++++++++++++------------------------ 2 files changed, 15 insertions(+), 26 deletions(-) diff --git a/web/html/logout.php b/web/html/logout.php index 1cdf453..9d0e7a9 100644 --- a/web/html/logout.php +++ b/web/html/logout.php @@ -17,9 +17,8 @@ if (isset($_COOKIE["AURSID"])) { # setting expiration to 1 means '1 second after midnight January 1, 1970' setcookie("AURSID", "", 1, "/", null, !empty($_SERVER['HTTPS']), true); unset($_COOKIE['AURSID']); + clear_expired_sessions($dbh); } -clear_expired_sessions(); - header('Location: index.php'); diff --git a/web/lib/acctfuncs.inc.php b/web/lib/acctfuncs.inc.php index 4c6da9f..087aea3 100644 --- a/web/lib/acctfuncs.inc.php +++ b/web/lib/acctfuncs.inc.php @@ -171,14 +171,15 @@ function process_account_form($UTYPE,$TYPE,$A,$U="",$T="",$S="",$E="", # error check and process request for a new/modified account global $SUPPORTED_LANGS; + $dbh = db_connect(); + if(isset($_COOKIE['AURSID'])) { - $editor_user = uid_from_sid($_COOKIE['AURSID']); + $editor_user = uid_from_sid($_COOKIE['AURSID'], $dbh); } else { $editor_user = null; } - $dbh = db_connect(); $error = ""; if (empty($E) || empty($U)) { $error = __("Missing a required field."); @@ -196,7 +197,7 @@ function process_account_form($UTYPE,$TYPE,$A,$U="",$T="",$S="",$E="", } } - if (!$error && !valid_username($U) && !user_is_privileged($editor_user)) + if (!$error && !valid_username($U) && !user_is_privileged($editor_user, $dbh)) $error = __("The username is invalid.") . "<ul>\n" ."<li>" . __("It must be between %s and %s characters long", USERNAME_MIN_LEN, USERNAME_MAX_LEN ) @@ -592,21 +593,20 @@ function try_login() { $userID = null; if ( isset($_REQUEST['user']) || isset($_REQUEST['passwd']) ) { + $dbh = db_connect(); + $userID = valid_user($_REQUEST['user'], $dbh); - $userID = valid_user($_REQUEST['user']); - - if ( user_suspended( $userID ) ) { + if ( user_suspended($userID, $dbh) ) { $login_error = "Account Suspended."; } elseif ( $userID && isset($_REQUEST['passwd']) - && valid_passwd($userID, $_REQUEST['passwd']) ) { + && valid_passwd($userID, $_REQUEST['passwd'], $dbh) ) { $logged_in = 0; $num_tries = 0; # Account looks good. Generate a SID and store it. - $dbh = db_connect(); while (!$logged_in && $num_tries < 5) { if ($MAX_SESSIONS_PER_USER) { # Delete all user sessions except the @@ -704,11 +704,10 @@ function valid_username( $user ) * Checks if the username is valid and if it exists in the database * Returns the username ID or nothing */ -function valid_user( $user ) +function valid_user( $user, $dbh ) { /* if ( $user = valid_username($user) ) { */ if ( $user ) { - $dbh = db_connect(); $q = "SELECT ID FROM Users WHERE Username = '" . mysql_real_escape_string($user). "'"; @@ -733,11 +732,9 @@ function good_passwd( $passwd ) /* Verifies that the password is correct for the userID specified. * Returns true or false */ -function valid_passwd( $userID, $passwd ) +function valid_passwd( $userID, $passwd, $dbh ) { if ( strlen($passwd) > 0 ) { - $dbh = db_connect(); - # get salt for this user $salt = get_salt($userID); if ($salt) { @@ -778,12 +775,11 @@ function valid_passwd( $userID, $passwd ) /* * Is the user account suspended? */ -function user_suspended( $id ) +function user_suspended( $id, $dbh ) { if (!$id) { return false; } - $dbh = db_connect(); $q = "SELECT Suspended FROM Users WHERE ID = " . $id; $result = db_query($q, $dbh); if ($result) { @@ -798,9 +794,8 @@ function user_suspended( $id ) /* * This should be expanded to return something */ -function user_delete( $id ) +function user_delete( $id, $dbh ) { - $dbh = db_connect(); $q = "DELETE FROM Users WHERE ID = " . $id; db_query($q, $dbh); return; @@ -810,9 +805,8 @@ function user_delete( $id ) * A different way of determining a user's privileges * rather than account_from_sid() */ -function user_is_privileged( $id ) +function user_is_privileged( $id, $dbh ) { - $dbh = db_connect(); $q = "SELECT AccountTypeID FROM Users WHERE ID = " . $id; $result = db_query($q, $dbh); if ($result) { @@ -826,13 +820,9 @@ function user_is_privileged( $id ) } # Clear out old expired sessions. -function clear_expired_sessions($dbh = null) { +function clear_expired_sessions( $dbh ) { global $LOGIN_TIMEOUT; - if (empty($dbh)) { - $dbh = db_connect(); - } - $q = "DELETE FROM Sessions WHERE LastUpdateTS < (UNIX_TIMESTAMP() - $LOGIN_TIMEOUT)"; db_query($q, $dbh); -- 1.7.6
Signed-off-by: Dan McGee <dan@archlinux.org> --- UPGRADING | 7 +++++++ support/schema/aur-schema.sql | 1 + web/lib/acctfuncs.inc.php | 5 ++++- 3 files changed, 12 insertions(+), 1 deletions(-) diff --git a/UPGRADING b/UPGRADING index c0866e5..863fbd8 100644 --- a/UPGRADING +++ b/UPGRADING @@ -1,6 +1,13 @@ Upgrading ========= +From 1.9.0 to 1.9.X +------------------- + +1. Add new "Users" table login date column: + +ALTER TABLE Users ADD COLUMN LastLogin BIGINT NOT NULL DEFAULT 0; + From 1.8.2 to 1.9.0 ------------------- diff --git a/support/schema/aur-schema.sql b/support/schema/aur-schema.sql index 544ed94..6c8feca 100644 --- a/support/schema/aur-schema.sql +++ b/support/schema/aur-schema.sql @@ -32,6 +32,7 @@ CREATE TABLE Users ( LangPreference VARCHAR(5) NOT NULL DEFAULT 'en', IRCNick VARCHAR(32) NOT NULL DEFAULT '', LastVoted BIGINT UNSIGNED NOT NULL DEFAULT 0, + LastLogin BIGINT UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (ID), UNIQUE (Username), UNIQUE (Email), diff --git a/web/lib/acctfuncs.inc.php b/web/lib/acctfuncs.inc.php index 087aea3..969fb60 100644 --- a/web/lib/acctfuncs.inc.php +++ b/web/lib/acctfuncs.inc.php @@ -637,8 +637,11 @@ function try_login() { } if ($logged_in) { - # set our SID cookie + $q = "UPDATE Users SET LastLogin = UNIX_TIMESTAMP() "; + $q.= "WHERE ID = '$userID'"; + db_query($q, $dbh); + # set our SID cookie if (isset($_POST['remember_me']) && $_POST['remember_me'] == "on") { # Set cookies for 30 days. -- 1.7.6
We already show it in the account listing page as well, so we should show it here too. Also use a standard date format; we weren't using this non-punctuated format anywhere else. Signed-off-by: Dan McGee <dan@archlinux.org> --- web/html/account.php | 2 +- web/lib/acctfuncs.inc.php | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/web/html/account.php b/web/html/account.php index ca05d1a..d42c61b 100644 --- a/web/html/account.php +++ b/web/html/account.php @@ -82,7 +82,7 @@ if (isset($_COOKIE["AURSID"])) { $row = mysql_fetch_assoc($result); display_account_info($row["Username"], $row["AccountType"], $row["Email"], $row["RealName"], - $row["IRCNick"]); + $row["IRCNick"], $row["LastVoted"]); } } elseif ($action == "UpdateAccount") { diff --git a/web/lib/acctfuncs.inc.php b/web/lib/acctfuncs.inc.php index 969fb60..94e2e72 100644 --- a/web/lib/acctfuncs.inc.php +++ b/web/lib/acctfuncs.inc.php @@ -461,7 +461,7 @@ function search_results_page($UTYPE,$O=0,$SB="",$U="",$T="", print "</span></td>"; print "<td class='".$c."'><span class='f5'>"; $row["LastVoted"] - ? print date("Ymd", $row["LastVoted"]) + ? print date("Y-m-d", $row["LastVoted"]) : print __("Never"); print "</span></td>"; print "<td class='".$c."'><span class='f5'>"; @@ -526,12 +526,13 @@ function search_results_page($UTYPE,$O=0,$SB="",$U="",$T="", # Display non-editable account info # -function display_account_info($U="", $T="", $E="", $R="", $I="") { +function display_account_info($U="", $T="", $E="", $R="", $I="", $LV="") { # U: value to display for username # T: value to display for account type # E: value to display for email address # R: value to display for RealName # I: value to display for IRC nick + # LV: value to display for last voted global $SUPPORTED_LANGS; @@ -574,6 +575,13 @@ function display_account_info($U="", $T="", $E="", $R="", $I="") { print " </tr>\n"; print " <tr>\n"; + print " <td align='left'>".__("Last Voted").":</td>\n"; + print " <td align='left'>"; + print $LV ? date("Y-m-d", $LV) : __("Never"); + print "</td>\n"; + print " </tr>\n"; + + print " <tr>\n"; print " <td colspan='2'><a href='packages.php?K=".$U."&SeB=m'>".__("View this user's packages")."</a></td>\n"; print " </tr>\n"; -- 1.7.6
This drops the MySQL traffic from 55+ actions to under 20. The majority of it is the needless two operations sent on every db_connect, whether the connection is new or not: <connect to database aur> SET NAMES 'utf8' COLLATE 'utf8_general_ci' Get a handle early, and use it often. Obviously this performance boost can be applied to other pages as well, but this seemed like the best one to tackle first as it is likely the most viewed page, outside of the crazy amounts of RPC traffic. Signed-off-by: Dan McGee <dan@archlinux.org> --- Before: http://paste.pocoo.org/show/462712/ After: http://paste.pocoo.org/show/462725/ Pretty stark difference. web/html/packages.php | 25 ++++++++++++------------- web/lib/aur.inc.php | 6 +++--- web/template/header.php | 11 +++++++---- web/template/login_form.php | 2 +- web/template/pkg_comments.php | 3 +-- web/template/pkg_details.php | 15 ++++++--------- 6 files changed, 30 insertions(+), 32 deletions(-) diff --git a/web/html/packages.php b/web/html/packages.php index dc06c7e..0a7c8d7 100644 --- a/web/html/packages.php +++ b/web/html/packages.php @@ -2,13 +2,14 @@ set_include_path(get_include_path() . PATH_SEPARATOR . '../lib'); -include_once("aur.inc.php"); # access AUR common functions -set_lang(); # this sets up the visitor's language -include_once('pkgfuncs.inc.php'); # package specific functions -check_sid(); # see if they're still logged in +include_once("aur.inc.php"); +include_once('pkgfuncs.inc.php'); +$dbh = db_connect(); +set_lang($dbh); +check_sid($dbh); # Set the title to the current query if required -if (isset($_GET['ID']) && ($pkgname = pkgname_from_id($_GET['ID']))) { +if (isset($_GET['ID']) && ($pkgname = pkgname_from_id($_GET['ID'], $dbh))) { $title = $pkgname; } else if (!empty($_GET['K'])) { $title = __("Search Criteria") . ": " . $_GET['K']; @@ -18,9 +19,11 @@ if (isset($_GET['ID']) && ($pkgname = pkgname_from_id($_GET['ID']))) { # Retrieve account type if (isset($_COOKIE["AURSID"])) { - $atype = account_from_sid($_COOKIE["AURSID"]); + $atype = account_from_sid($_COOKIE["AURSID"], $dbh); + $uid = uid_from_sid($SID, $dbh); } else { $atype = ""; + $uid = null; } # Grab the list of Package IDs to be operated on @@ -78,7 +81,7 @@ if (current_action("do_Flag")) { $output = pkg_change_category($atype); } -html_header($title); +html_header($title, $dbh); ?> <?php if ($output): ?> @@ -91,12 +94,8 @@ if (isset($_GET['ID'])) { if (!$_GET['ID'] = intval($_GET['ID'])) { print __("Error trying to retrieve package details.")."<br />\n"; } else { - if (isset($_COOKIE["AURSID"])) { - package_details($_GET['ID'], $_COOKIE["AURSID"]); - } - else { - package_details($_GET['ID'], null); - } + $sid = isset($_COOKIE["AURSID"]) ? $_COOKIE["AURSID"] : null; + package_details($_GET['ID'], $sid, $dbh); } } else { if (!isset($_GET['K']) && !isset($_GET['SB'])) { diff --git a/web/lib/aur.inc.php b/web/lib/aur.inc.php index f432697..4b8a8c8 100644 --- a/web/lib/aur.inc.php +++ b/web/lib/aur.inc.php @@ -320,7 +320,7 @@ function set_lang($dbh=NULL) { # common header # -function html_header($title="") { +function html_header($title="", $dbh=NULL) { global $_SERVER; global $_COOKIE; global $_POST; @@ -462,9 +462,9 @@ function uid_from_email($email="", $dbh=NULL) # check user privileges # -function check_user_privileges() +function check_user_privileges($dbh=NULL) { - $type = account_from_sid($_COOKIE['AURSID']); + $type = account_from_sid($_COOKIE['AURSID'], $dbh); return ($type == 'Trusted User' || $type == 'Developer'); } diff --git a/web/template/header.php b/web/template/header.php index 8313bb3..c56a226 100644 --- a/web/template/header.php +++ b/web/template/header.php @@ -1,4 +1,8 @@ -<?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?> +<?php echo '<?xml version="1.0" encoding="UTF-8"?>'; +if (!isset($dbh)) { + $dbh = db_connect(); +} +$username = username_from_sid($_COOKIE["AURSID"], $dbh); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" @@ -37,8 +41,8 @@ <li><a href="http://bugs.archlinux.org/index.php?tasks=all&project=2"><?php print __("Bugs"); ?></a></li> <li><a href="http://archlinux.org/mailman/listinfo/aur-general"><?php print __("Discussion"); ?></a></li> <?php if (isset($_COOKIE['AURSID'])): ?> - <?php if (check_user_privileges()): ?><li><a href="tu.php"><?php print __("Trusted User"); ?></a></li><?php endif; ?> - <li><a href="packages.php?SeB=m&K=<?php print username_from_sid($_COOKIE["AURSID"]); ?>"><?php print __("My Packages"); ?></a></li> + <?php if (check_user_privileges($dbh)): ?><li><a href="tu.php"><?php print __("Trusted User"); ?></a></li><?php endif; ?> + <li><a href="packages.php?SeB=m&K=<?php print $username; ?>"><?php print __("My Packages"); ?></a></li> <li><a href="pkgsubmit.php"><?php print __("Submit"); ?></a></li> <?php endif; ?> </ul> @@ -59,4 +63,3 @@ foreach ($SUPPORTED_LANGS as $lang => $lang_name) { </div> <!-- Start of main content --> - diff --git a/web/template/login_form.php b/web/template/login_form.php index b351a27..419e031 100644 --- a/web/template/login_form.php +++ b/web/template/login_form.php @@ -1,7 +1,7 @@ <div id="login_bar" class="pgbox"> <?php if (isset($_COOKIE["AURSID"])) { - print __("Logged-in as: %s", '<b>' . username_from_sid($_COOKIE["AURSID"]) . '</b>'); + print __("Logged-in as: %s", '<b>' . $username . '</b>'); ?> <a href="logout.php">[<?php print __("Logout"); ?>]</a> <?php diff --git a/web/template/pkg_comments.php b/web/template/pkg_comments.php index aed9ca8..94e6f08 100644 --- a/web/template/pkg_comments.php +++ b/web/template/pkg_comments.php @@ -1,6 +1,5 @@ <div class="pgbox"> <?php -$uid = uid_from_sid($SID); while (list($indx, $carr) = each($comments)) { ?> <div class="comment-header"><?php @@ -36,7 +35,7 @@ while (list($indx, $carr) = each($comments)) { ?> </div> <?php -$count = package_comments_count($_GET['ID']); +$count = package_comments_count($_GET['ID'], $dbh); if ($count > 10 && !isset($_GET['comments'])) { echo '<div class="pgbox">'; echo '<a href="'. $_SERVER['REQUEST_URI'] . '&comments=all">'. __('Show all %s comments', $count) . '</a>'; diff --git a/web/template/pkg_details.php b/web/template/pkg_details.php index 880a675..599b603 100644 --- a/web/template/pkg_details.php +++ b/web/template/pkg_details.php @@ -1,12 +1,9 @@ <?php -$atype = account_from_sid($SID); -$uid = uid_from_sid($SID); - $pkgid = intval($_REQUEST['ID']); if ($uid == $row["MaintainerUID"] or ($atype == "Developer" or $atype == "Trusted User")) { - $catarr = pkgCategories(); + $catarr = pkgCategories($dbh); $edit_cat = "<form method='post' action='packages.php?ID=".$pkgid."'>\n"; $edit_cat.= "<p>"; $edit_cat.= "<input type='hidden' name='action' value='do_ChangeCategory' />"; @@ -29,7 +26,7 @@ else { } if ($row["SubmitterUID"]) { - $submitter = username_from_id($row["SubmitterUID"]); + $submitter = username_from_id($row["SubmitterUID"], $dbh); if ($SID) { $submitter = '<a href="account.php?Action=AccountInfo&ID=' . htmlspecialchars($row['SubmitterUID'], ENT_QUOTES) . '">' . htmlspecialchars($submitter) . '</a>'; } @@ -39,7 +36,7 @@ if ($row["SubmitterUID"]) { } if ($row["MaintainerUID"]) { - $maintainer = username_from_id($row["MaintainerUID"]); + $maintainer = username_from_id($row["MaintainerUID"], $dbh); if ($SID) { $maintainer = '<a href="account.php?Action=AccountInfo&ID=' . htmlspecialchars($row['MaintainerUID'], ENT_QUOTES) . '">' . htmlspecialchars($maintainer) . '</a>'; } @@ -103,8 +100,8 @@ $out_of_date_time = ($row["OutOfDateTS"] == 0) ? $msg : gmdate("r", intval($row[ </p> <?php - $deps = package_dependencies($row["ID"]); - $requiredby = package_required($row["Name"]); + $deps = package_dependencies($row["ID"], $dbh); + $requiredby = package_required($row["Name"], $dbh); if (count($deps) > 0 || count($requiredby) > 0) { echo '<p>'; @@ -142,7 +139,7 @@ $out_of_date_time = ($row["OutOfDateTS"] == 0) ? $msg : gmdate("r", intval($row[ # $sources[0] = 'src'; - $sources = package_sources($row["ID"]); + $sources = package_sources($row["ID"], $dbh); if (count($sources) > 0) { -- 1.7.6
On Mon, Aug 22, 2011 at 07:18:55PM -0500, Dan McGee wrote:
This drops the MySQL traffic from 55+ actions to under 20. The majority of it is the needless two operations sent on every db_connect, whether the connection is new or not: <connect to database aur> SET NAMES 'utf8' COLLATE 'utf8_general_ci'
Get a handle early, and use it often.
Obviously this performance boost can be applied to other pages as well, but this seemed like the best one to tackle first as it is likely the most viewed page, outside of the crazy amounts of RPC traffic.
Signed-off-by: Dan McGee <dan@archlinux.org> ---
Before: http://paste.pocoo.org/show/462712/ After: http://paste.pocoo.org/show/462725/
Pretty stark difference.
web/html/packages.php | 25 ++++++++++++------------- web/lib/aur.inc.php | 6 +++--- web/template/header.php | 11 +++++++---- web/template/login_form.php | 2 +- web/template/pkg_comments.php | 3 +-- web/template/pkg_details.php | 15 ++++++--------- 6 files changed, 30 insertions(+), 32 deletions(-)
diff --git a/web/html/packages.php b/web/html/packages.php index dc06c7e..0a7c8d7 100644 --- a/web/html/packages.php +++ b/web/html/packages.php @@ -2,13 +2,14 @@
set_include_path(get_include_path() . PATH_SEPARATOR . '../lib');
-include_once("aur.inc.php"); # access AUR common functions -set_lang(); # this sets up the visitor's language -include_once('pkgfuncs.inc.php'); # package specific functions -check_sid(); # see if they're still logged in +include_once("aur.inc.php"); +include_once('pkgfuncs.inc.php'); +$dbh = db_connect(); +set_lang($dbh); +check_sid($dbh);
# Set the title to the current query if required -if (isset($_GET['ID']) && ($pkgname = pkgname_from_id($_GET['ID']))) { +if (isset($_GET['ID']) && ($pkgname = pkgname_from_id($_GET['ID'], $dbh))) { $title = $pkgname; } else if (!empty($_GET['K'])) { $title = __("Search Criteria") . ": " . $_GET['K']; @@ -18,9 +19,11 @@ if (isset($_GET['ID']) && ($pkgname = pkgname_from_id($_GET['ID']))) {
# Retrieve account type if (isset($_COOKIE["AURSID"])) { - $atype = account_from_sid($_COOKIE["AURSID"]); + $atype = account_from_sid($_COOKIE["AURSID"], $dbh); + $uid = uid_from_sid($SID, $dbh); } else { $atype = ""; + $uid = null; }
# Grab the list of Package IDs to be operated on @@ -78,7 +81,7 @@ if (current_action("do_Flag")) { $output = pkg_change_category($atype); }
-html_header($title); +html_header($title, $dbh); ?>
<?php if ($output): ?> @@ -91,12 +94,8 @@ if (isset($_GET['ID'])) { if (!$_GET['ID'] = intval($_GET['ID'])) { print __("Error trying to retrieve package details.")."<br />\n"; } else { - if (isset($_COOKIE["AURSID"])) { - package_details($_GET['ID'], $_COOKIE["AURSID"]); - } - else { - package_details($_GET['ID'], null); - } + $sid = isset($_COOKIE["AURSID"]) ? $_COOKIE["AURSID"] : null; + package_details($_GET['ID'], $sid, $dbh); } } else { if (!isset($_GET['K']) && !isset($_GET['SB'])) { diff --git a/web/lib/aur.inc.php b/web/lib/aur.inc.php index f432697..4b8a8c8 100644 --- a/web/lib/aur.inc.php +++ b/web/lib/aur.inc.php @@ -320,7 +320,7 @@ function set_lang($dbh=NULL) {
# common header # -function html_header($title="") { +function html_header($title="", $dbh=NULL) { global $_SERVER; global $_COOKIE; global $_POST; @@ -462,9 +462,9 @@ function uid_from_email($email="", $dbh=NULL)
# check user privileges # -function check_user_privileges() +function check_user_privileges($dbh=NULL) { - $type = account_from_sid($_COOKIE['AURSID']); + $type = account_from_sid($_COOKIE['AURSID'], $dbh); return ($type == 'Trusted User' || $type == 'Developer'); }
diff --git a/web/template/header.php b/web/template/header.php index 8313bb3..c56a226 100644 --- a/web/template/header.php +++ b/web/template/header.php @@ -1,4 +1,8 @@ -<?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?> +<?php echo '<?xml version="1.0" encoding="UTF-8"?>'; +if (!isset($dbh)) { + $dbh = db_connect(); +} +$username = username_from_sid($_COOKIE["AURSID"], $dbh); ?>
You should add some isset() check here to make sure we don't try to access '$_COOKIE["AURSID"]' if it is unset.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" @@ -37,8 +41,8 @@ <li><a href="http://bugs.archlinux.org/index.php?tasks=all&project=2"><?php print __("Bugs"); ?></a></li> <li><a href="http://archlinux.org/mailman/listinfo/aur-general"><?php print __("Discussion"); ?></a></li> <?php if (isset($_COOKIE['AURSID'])): ?> - <?php if (check_user_privileges()): ?><li><a href="tu.php"><?php print __("Trusted User"); ?></a></li><?php endif; ?> - <li><a href="packages.php?SeB=m&K=<?php print username_from_sid($_COOKIE["AURSID"]); ?>"><?php print __("My Packages"); ?></a></li> + <?php if (check_user_privileges($dbh)): ?><li><a href="tu.php"><?php print __("Trusted User"); ?></a></li><?php endif; ?> + <li><a href="packages.php?SeB=m&K=<?php print $username; ?>"><?php print __("My Packages"); ?></a></li> <li><a href="pkgsubmit.php"><?php print __("Submit"); ?></a></li> <?php endif; ?> </ul> @@ -59,4 +63,3 @@ foreach ($SUPPORTED_LANGS as $lang => $lang_name) { </div> <!-- Start of main content -->
- diff --git a/web/template/login_form.php b/web/template/login_form.php index b351a27..419e031 100644 --- a/web/template/login_form.php +++ b/web/template/login_form.php @@ -1,7 +1,7 @@ <div id="login_bar" class="pgbox"> <?php if (isset($_COOKIE["AURSID"])) { - print __("Logged-in as: %s", '<b>' . username_from_sid($_COOKIE["AURSID"]) . '</b>'); + print __("Logged-in as: %s", '<b>' . $username . '</b>'); ?> <a href="logout.php">[<?php print __("Logout"); ?>]</a> <?php diff --git a/web/template/pkg_comments.php b/web/template/pkg_comments.php index aed9ca8..94e6f08 100644 --- a/web/template/pkg_comments.php +++ b/web/template/pkg_comments.php @@ -1,6 +1,5 @@ <div class="pgbox"> <?php -$uid = uid_from_sid($SID);
See below.
while (list($indx, $carr) = each($comments)) { ?> <div class="comment-header"><?php
@@ -36,7 +35,7 @@ while (list($indx, $carr) = each($comments)) { ?> </div>
<?php -$count = package_comments_count($_GET['ID']); +$count = package_comments_count($_GET['ID'], $dbh); if ($count > 10 && !isset($_GET['comments'])) { echo '<div class="pgbox">'; echo '<a href="'. $_SERVER['REQUEST_URI'] . '&comments=all">'. __('Show all %s comments', $count) . '</a>'; diff --git a/web/template/pkg_details.php b/web/template/pkg_details.php index 880a675..599b603 100644 --- a/web/template/pkg_details.php +++ b/web/template/pkg_details.php @@ -1,12 +1,9 @@ <?php -$atype = account_from_sid($SID); -$uid = uid_from_sid($SID); -
You did it again! :) "web/template/pkg_details.php" is included in package_details() where these variables are not visible. Removing these lines breaks all forms that should be visible to logged in users only. Same thing happens with the "$uid" initialization that you removed from "web/template/pkg_comments.php". Adding "global $uid, $atype;" to package_details() might help as a workaround - this needs urgent refactoring anyway. I do not blame you here as our code isn't clear at all and this is almost impossible to spot without having a very close look. Maybe you could try to check if all important parts of the AUR still work and do not issue any warnings after removing some variable initializations next time - just as a tip for the future. Our code is a maze and it's almost impossible to do it right at the first go.
$pkgid = intval($_REQUEST['ID']); if ($uid == $row["MaintainerUID"] or ($atype == "Developer" or $atype == "Trusted User")) {
- $catarr = pkgCategories(); + $catarr = pkgCategories($dbh); $edit_cat = "<form method='post' action='packages.php?ID=".$pkgid."'>\n"; $edit_cat.= "<p>"; $edit_cat.= "<input type='hidden' name='action' value='do_ChangeCategory' />"; @@ -29,7 +26,7 @@ else { }
if ($row["SubmitterUID"]) { - $submitter = username_from_id($row["SubmitterUID"]); + $submitter = username_from_id($row["SubmitterUID"], $dbh); if ($SID) { $submitter = '<a href="account.php?Action=AccountInfo&ID=' . htmlspecialchars($row['SubmitterUID'], ENT_QUOTES) . '">' . htmlspecialchars($submitter) . '</a>'; } @@ -39,7 +36,7 @@ if ($row["SubmitterUID"]) { }
if ($row["MaintainerUID"]) { - $maintainer = username_from_id($row["MaintainerUID"]); + $maintainer = username_from_id($row["MaintainerUID"], $dbh); if ($SID) { $maintainer = '<a href="account.php?Action=AccountInfo&ID=' . htmlspecialchars($row['MaintainerUID'], ENT_QUOTES) . '">' . htmlspecialchars($maintainer) . '</a>'; } @@ -103,8 +100,8 @@ $out_of_date_time = ($row["OutOfDateTS"] == 0) ? $msg : gmdate("r", intval($row[ </p> <?php
- $deps = package_dependencies($row["ID"]); - $requiredby = package_required($row["Name"]); + $deps = package_dependencies($row["ID"], $dbh); + $requiredby = package_required($row["Name"], $dbh);
if (count($deps) > 0 || count($requiredby) > 0) { echo '<p>'; @@ -142,7 +139,7 @@ $out_of_date_time = ($row["OutOfDateTS"] == 0) ? $msg : gmdate("r", intval($row[
# $sources[0] = 'src'; - $sources = package_sources($row["ID"]); + $sources = package_sources($row["ID"], $dbh);
if (count($sources) > 0) {
-- 1.7.6
This ensures we are passing around a single database handle the whole time, and reusing data if we already have it in request scope. Signed-off-by: Dan McGee <dan@archlinux.org> --- Not as big of difference as the package details one, but pretty low-handing fruit. web/html/index.php | 13 +++++-------- web/lib/stats.inc.php | 8 ++++---- web/template/stats/user_table.php | 4 ---- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/web/html/index.php b/web/html/index.php index 0d513d3..e7b7139 100644 --- a/web/html/index.php +++ b/web/html/index.php @@ -3,17 +3,14 @@ set_include_path(get_include_path() . PATH_SEPARATOR . '../lib'); include_once("aur.inc.php"); -set_lang(); -check_sid(); - include_once('stats.inc.php'); +$dbh = db_connect(); +set_lang($dbh); +check_sid($dbh); -html_header( __("Home") ); +html_header(__("Home"), $dbh); include('pkg_search_form.php'); - -$dbh = db_connect(); - ?> <div class="pgbox"> @@ -58,7 +55,7 @@ echo __( <td class='boxSoft' valign='top'> <?php if (!empty($_COOKIE["AURSID"])) { - $user = username_from_sid($_COOKIE["AURSID"]); + $user = username_from_sid($_COOKIE["AURSID"], $dbh); user_table($user, $dbh); echo '<br />'; } diff --git a/web/lib/stats.inc.php b/web/lib/stats.inc.php index 2690a5c..a8e4605 100644 --- a/web/lib/stats.inc.php +++ b/web/lib/stats.inc.php @@ -6,7 +6,7 @@ function updates_table($dbh) { $key = 'recent_updates'; if(!($newest_packages = get_cache_value($key))) { - $q = 'SELECT * FROM Packages ORDER BY ModifiedTS DESC LIMIT 10'; + $q = 'SELECT ID, Name, Version, ModifiedTS, SubmittedTS FROM Packages ORDER BY ModifiedTS DESC LIMIT 10'; $result = db_query($q, $dbh); $newest_packages = new ArrayObject(); @@ -18,9 +18,9 @@ function updates_table($dbh) include('stats/updates_table.php'); } -function user_table($user, $dbh) +function user_table($username, $dbh) { - $escuser = mysql_real_escape_string($user); + $escuser = mysql_real_escape_string($username); $base_q = "SELECT count(*) FROM Packages,Users WHERE Packages.MaintainerUID = Users.ID AND Users.Username='" . $escuser . "'"; $maintainer_unsupported_count = db_cache_value($base_q, $dbh, @@ -32,7 +32,7 @@ function user_table($user, $dbh) 'user_flagged_outdated:' . $escuser); # If the user is a TU calculate the number of the packages - $atype = account_from_sid($_COOKIE["AURSID"]); + $atype = account_from_sid($_COOKIE["AURSID"], $dbh); include('stats/user_table.php'); } diff --git a/web/template/stats/user_table.php b/web/template/stats/user_table.php index 36a6b10..6e8aa0f 100644 --- a/web/template/stats/user_table.php +++ b/web/template/stats/user_table.php @@ -1,6 +1,3 @@ -<?php - $username = username_from_sid($_COOKIE["AURSID"]); -?> <table class='boxSoft'> <tr> <th colspan='2' class='boxSoftTitle'> @@ -28,4 +25,3 @@ </td> </tr> </table> - -- 1.7.6
Replacing with CSS styles where appropriate. A previously unused CSS style is tweaked in the stylesheet to match most of what was done via non-CSS styling.
Signed-off-by: Dan McGee <dan@archlinux.org> ---
Things look mostly the same on all these pages. However, there are a few exceptions- for example, the removal of the needless centering of the account search form. Ping on this, and all the other patches from this day? Lukas, you had
On Mon, Aug 22, 2011 at 7:18 PM, Dan McGee <dan@archlinux.org> wrote: them on your WIP branch, but then they all disappeared...
web/html/css/arch.css | 9 +++++---- web/html/index.php | 2 +- web/html/pkgsubmit.php | 2 +- web/lib/acctfuncs.inc.php | 14 ++++---------- web/template/pkg_search_results.php | 18 +++++++++--------- web/template/search_accounts_form.php | 2 +- web/template/tu_details.php | 12 ++++++------ web/template/tu_list.php | 16 ++++++++-------- 8 files changed, 35 insertions(+), 40 deletions(-)
diff --git a/web/html/css/arch.css b/web/html/css/arch.css index eec02ee..1e588f1 100644 --- a/web/html/css/arch.css +++ b/web/html/css/arch.css @@ -244,13 +244,14 @@ table.center { } table.results { padding: 0px; + width: 100%; border-collapse: collapse; } .results th { - background-color: #e1e3e6; - border-bottom: 1px solid #46494d; - border-top: 1px solid #46494d; - padding: 0px 5px 0px 0px; + text-align: center; +} +.results th, .results td { + padding: 1px; } .results th>a { text-decoration: none; diff --git a/web/html/index.php b/web/html/index.php index 138541f..0d513d3 100644 --- a/web/html/index.php +++ b/web/html/index.php @@ -50,7 +50,7 @@ echo __( <br /> <?php echo __('Some packages may be provided as binaries in [community].'); ?> </p> -<table border='0' cellpadding='0' cellspacing='3' width='90%'> +<table> <tr> <td class='boxSoft' valign='top'> <?php updates_table($dbh); ?> diff --git a/web/html/pkgsubmit.php b/web/html/pkgsubmit.php index a5cc0c0..54c4b3e 100644 --- a/web/html/pkgsubmit.php +++ b/web/html/pkgsubmit.php @@ -437,7 +437,7 @@ html_header("Submit");
<form action='pkgsubmit.php' method='post' enctype='multipart/form-data'> <div> <input type='hidden' name='pkgsubmit' value='1' /> </div> - <table border='0' cellspacing='5'> + <table> <tr> <td class='f4' align='right'><?php print __("Package Category"); ?>:</td> <td class='f4' align='left'> diff --git a/web/lib/acctfuncs.inc.php b/web/lib/acctfuncs.inc.php index 59fa730..4c6da9f 100644 --- a/web/lib/acctfuncs.inc.php +++ b/web/lib/acctfuncs.inc.php @@ -35,7 +35,7 @@ function display_account_form($UTYPE,$A,$U="",$T="",$S="", print "<input type='hidden' name='ID' value='".$UID."' />\n"; } print "</fieldset>"; - print "<table border='0' cellpadding='0' cellspacing='0' width='80%' style=\"margin:0 auto;\">\n"; + print "<table>\n"; print "<tr><td colspan='2'> </td></tr>\n";
print "<tr>"; @@ -415,13 +415,7 @@ function search_results_page($UTYPE,$O=0,$SB="",$U="",$T="", } else { $num_rows = mysql_num_rows($result); if ($num_rows) { - print "<table border='0' cellpadding='0'"; - print " cellspacing='0' width='90%'"; - print " style=\"margin:0 auto\">\n"; - print "<tr>"; - print "<td colspan='2'>"; - print "<table border='0' cellpadding='0'"; - print " cellspacing='0' width='100%'>\n"; + print "<table class='results'>\n"; print "<tr>"; print "<th class='header'>"; print "<span class='f2'>".__("Username")."</span></th>"; @@ -483,8 +477,8 @@ function search_results_page($UTYPE,$O=0,$SB="",$U="",$T="", $i++; } print "</table>\n"; - print "</td></tr>\n";
+ print "<table class='results'>\n"; print "<tr>"; print "<td align='left'>"; print "<form action='account.php' method='post'>\n"; @@ -540,7 +534,7 @@ function display_account_info($U="", $T="", $E="", $R="", $I="") {
global $SUPPORTED_LANGS;
- print "<table border='0' cellpadding='0' cellspacing='0' width='33%' style=\"margin:0 auto;\">\n"; + print "<table>\n"; print " <tr>\n"; print " <td colspan='2'> </td>\n"; print " </tr>\n"; diff --git a/web/template/pkg_search_results.php b/web/template/pkg_search_results.php index e576e6e..8ef352b 100644 --- a/web/template/pkg_search_results.php +++ b/web/template/pkg_search_results.php @@ -12,32 +12,32 @@
-<table width='100%' cellspacing='0' cellpadding='2'> +<table class='results'> <tr> <?php if ($SID): ?> - <th style='border-bottom: #666 1px solid; vertical-align: bottom'> </th> + <th class='header'> </th> <?php endif; ?>
- <th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'> + <th class='header'><span class='f2'> <a href='?<?php print mkurl('SB=c&SO=' . $SO_next) ?>'><?php print __("Category") ?></a> </span></th> - <th style='border-bottom: #666 1px solid; vertical-align: bottom; text-align: center;'><span class='f2'> + <th class='header'><span class='f2'> <a href='?<?php print mkurl('SB=n&SO=' . $SO_next) ?>'><?php print __("Name") ?></a> </span></th> - <th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'> + <th class='header'><span class='f2'> <a href='?<?php print mkurl('SB=v&SO=' . $SO_next) ?>'><?php print __("Votes") ?></a> </span></th>
<?php if ($SID): ?> - <th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'> + <th class='header'><span class='f2'> <a href='?<?php print mkurl('SB=w&SO=' . $SO_next) ?>'><?php print __("Voted") ?></a> </span></th> - <th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'> + <th class='header'><span class='f2'> <a href='?<?php print mkurl('SB=o&SO=' . $SO_next) ?>'><?php print __("Notify") ?></a> </span></th> <?php endif; ?> - <th style='border-bottom: #666 1px solid; vertical-align: bottom; text-align: center;'><span class='f2'><?php print __("Description") ?></span></th> - <th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'> + <th class='header'><span class='f2'><?php print __("Description") ?></span></th> + <th class='header'><span class='f2'> <a href='?<?php print mkurl('SB=m&SO=' . $SO_next) ?>'><?php print __("Maintainer") ?></a> </span></th> </tr> diff --git a/web/template/search_accounts_form.php b/web/template/search_accounts_form.php index 9d6c40d..9b0d8e2 100644 --- a/web/template/search_accounts_form.php +++ b/web/template/search_accounts_form.php @@ -1,6 +1,6 @@ <br /> <form action='account.php' method='post'> - <table border='0' cellpadding='0' cellspacing='0' width='80%' style="margin:0 auto;"> + <table>
<tr> <td align='left'><?php print __("Username"); ?>:</td> diff --git a/web/template/tu_details.php b/web/template/tu_details.php index 7d6c305..c48f603 100644 --- a/web/template/tu_details.php +++ b/web/template/tu_details.php @@ -24,13 +24,13 @@ N/A <?php print str_replace("\n", "<br />\n", htmlspecialchars($row['Agenda'])) ?> </p>
-<table class="boxSoft" width='100%' cellspacing='0' cellpadding='2'> +<table class="boxSoft"> <tr> -<th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __("Yes") ?></span></th> -<th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __("No") ?></span></th> -<th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __("Abstain") ?></span></th> -<th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __("Total") ?></span></th> -<th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __('Voted') ?></span></th> +<th class='boxSoftTitle'><span class='f2'><?php print __("Yes") ?></span></th> +<th class='boxSoftTitle'><span class='f2'><?php print __("No") ?></span></th> +<th class='boxSoftTitle'><span class='f2'><?php print __("Abstain") ?></span></th> +<th class='boxSoftTitle'><span class='f2'><?php print __("Total") ?></span></th> +<th class='boxSoftTitle'><span class='f2'><?php print __('Voted') ?></span></th> </tr> <tr> <td class='data1'><span class='f5'><span class='blue'><?php print $row['Yes'] ?></span></span></td> diff --git a/web/template/tu_list.php b/web/template/tu_list.php index 75d9414..0966a4c 100644 --- a/web/template/tu_list.php +++ b/web/template/tu_list.php @@ -2,17 +2,17 @@ <div class="pgboxtitle" style="text-align:right;"> <span class='f3'><?php print $type ?></span> </div> - <table width='100%' cellspacing='0' cellpadding='2'> + <table class='results'> <tr> - <th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __("Proposal") ?></span></th> - <th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'> + <th class='header'><span class='f2'><?php print __("Proposal") ?></span></th> + <th class='header'><span class='f2'> <a href='?off=<?php print $off ?>&by=<?php print $by_next ?>'><?php print __("Start") ?></a> </span></th> - <th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __("End") ?></span></th> - <th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __("User") ?></span></th> - <th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __("Yes") ?></span></th> - <th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __("No") ?></span></th> - <th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __('Voted') ?></span></th> + <th class='header'><span class='f2'><?php print __("End") ?></span></th> + <th class='header'><span class='f2'><?php print __("User") ?></span></th> + <th class='header'><span class='f2'><?php print __("Yes") ?></span></th> + <th class='header'><span class='f2'><?php print __("No") ?></span></th> + <th class='header'><span class='f2'><?php print __('Voted') ?></span></th> </tr> <?php if (mysql_num_rows($result) == 0) { ?> <tr><td align='center' colspan='0'><?php print __("No results found.") ?></td></tr> -- 1.7.6
On Thu, Oct 20, 2011 at 09:32:13AM -0500, Dan McGee wrote:
Replacing with CSS styles where appropriate. A previously unused CSS style is tweaked in the stylesheet to match most of what was done via non-CSS styling.
Signed-off-by: Dan McGee <dan@archlinux.org> ---
Things look mostly the same on all these pages. However, there are a few exceptions- for example, the removal of the needless centering of the account search form. Ping on this, and all the other patches from this day? Lukas, you had
On Mon, Aug 22, 2011 at 7:18 PM, Dan McGee <dan@archlinux.org> wrote: them on your WIP branch, but then they all disappeared...
I'm still waiting for that patch set (patch 5, actually) to be resubmitted. If you're too busy, just let me know and I'll look into that. I just thought I'd wait since you sent me a mail saying that you will fix and resend that patch later.
web/html/css/arch.css | 9 +++++---- web/html/index.php | 2 +- web/html/pkgsubmit.php | 2 +- web/lib/acctfuncs.inc.php | 14 ++++---------- web/template/pkg_search_results.php | 18 +++++++++--------- web/template/search_accounts_form.php | 2 +- web/template/tu_details.php | 12 ++++++------ web/template/tu_list.php | 16 ++++++++-------- 8 files changed, 35 insertions(+), 40 deletions(-)
diff --git a/web/html/css/arch.css b/web/html/css/arch.css index eec02ee..1e588f1 100644 --- a/web/html/css/arch.css +++ b/web/html/css/arch.css @@ -244,13 +244,14 @@ table.center { } table.results { padding: 0px; + width: 100%; border-collapse: collapse; } .results th { - background-color: #e1e3e6; - border-bottom: 1px solid #46494d; - border-top: 1px solid #46494d; - padding: 0px 5px 0px 0px; + text-align: center; +} +.results th, .results td { + padding: 1px; } .results th>a { text-decoration: none; diff --git a/web/html/index.php b/web/html/index.php index 138541f..0d513d3 100644 --- a/web/html/index.php +++ b/web/html/index.php @@ -50,7 +50,7 @@ echo __( <br /> <?php echo __('Some packages may be provided as binaries in [community].'); ?> </p> -<table border='0' cellpadding='0' cellspacing='3' width='90%'> +<table> <tr> <td class='boxSoft' valign='top'> <?php updates_table($dbh); ?> diff --git a/web/html/pkgsubmit.php b/web/html/pkgsubmit.php index a5cc0c0..54c4b3e 100644 --- a/web/html/pkgsubmit.php +++ b/web/html/pkgsubmit.php @@ -437,7 +437,7 @@ html_header("Submit");
<form action='pkgsubmit.php' method='post' enctype='multipart/form-data'> <div> <input type='hidden' name='pkgsubmit' value='1' /> </div> - <table border='0' cellspacing='5'> + <table> <tr> <td class='f4' align='right'><?php print __("Package Category"); ?>:</td> <td class='f4' align='left'> diff --git a/web/lib/acctfuncs.inc.php b/web/lib/acctfuncs.inc.php index 59fa730..4c6da9f 100644 --- a/web/lib/acctfuncs.inc.php +++ b/web/lib/acctfuncs.inc.php @@ -35,7 +35,7 @@ function display_account_form($UTYPE,$A,$U="",$T="",$S="", print "<input type='hidden' name='ID' value='".$UID."' />\n"; } print "</fieldset>"; - print "<table border='0' cellpadding='0' cellspacing='0' width='80%' style=\"margin:0 auto;\">\n"; + print "<table>\n"; print "<tr><td colspan='2'> </td></tr>\n";
print "<tr>"; @@ -415,13 +415,7 @@ function search_results_page($UTYPE,$O=0,$SB="",$U="",$T="", } else { $num_rows = mysql_num_rows($result); if ($num_rows) { - print "<table border='0' cellpadding='0'"; - print " cellspacing='0' width='90%'"; - print " style=\"margin:0 auto\">\n"; - print "<tr>"; - print "<td colspan='2'>"; - print "<table border='0' cellpadding='0'"; - print " cellspacing='0' width='100%'>\n"; + print "<table class='results'>\n"; print "<tr>"; print "<th class='header'>"; print "<span class='f2'>".__("Username")."</span></th>"; @@ -483,8 +477,8 @@ function search_results_page($UTYPE,$O=0,$SB="",$U="",$T="", $i++; } print "</table>\n"; - print "</td></tr>\n";
+ print "<table class='results'>\n"; print "<tr>"; print "<td align='left'>"; print "<form action='account.php' method='post'>\n"; @@ -540,7 +534,7 @@ function display_account_info($U="", $T="", $E="", $R="", $I="") {
global $SUPPORTED_LANGS;
- print "<table border='0' cellpadding='0' cellspacing='0' width='33%' style=\"margin:0 auto;\">\n"; + print "<table>\n"; print " <tr>\n"; print " <td colspan='2'> </td>\n"; print " </tr>\n"; diff --git a/web/template/pkg_search_results.php b/web/template/pkg_search_results.php index e576e6e..8ef352b 100644 --- a/web/template/pkg_search_results.php +++ b/web/template/pkg_search_results.php @@ -12,32 +12,32 @@
-<table width='100%' cellspacing='0' cellpadding='2'> +<table class='results'> <tr> <?php if ($SID): ?> - <th style='border-bottom: #666 1px solid; vertical-align: bottom'> </th> + <th class='header'> </th> <?php endif; ?>
- <th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'> + <th class='header'><span class='f2'> <a href='?<?php print mkurl('SB=c&SO=' . $SO_next) ?>'><?php print __("Category") ?></a> </span></th> - <th style='border-bottom: #666 1px solid; vertical-align: bottom; text-align: center;'><span class='f2'> + <th class='header'><span class='f2'> <a href='?<?php print mkurl('SB=n&SO=' . $SO_next) ?>'><?php print __("Name") ?></a> </span></th> - <th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'> + <th class='header'><span class='f2'> <a href='?<?php print mkurl('SB=v&SO=' . $SO_next) ?>'><?php print __("Votes") ?></a> </span></th>
<?php if ($SID): ?> - <th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'> + <th class='header'><span class='f2'> <a href='?<?php print mkurl('SB=w&SO=' . $SO_next) ?>'><?php print __("Voted") ?></a> </span></th> - <th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'> + <th class='header'><span class='f2'> <a href='?<?php print mkurl('SB=o&SO=' . $SO_next) ?>'><?php print __("Notify") ?></a> </span></th> <?php endif; ?> - <th style='border-bottom: #666 1px solid; vertical-align: bottom; text-align: center;'><span class='f2'><?php print __("Description") ?></span></th> - <th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'> + <th class='header'><span class='f2'><?php print __("Description") ?></span></th> + <th class='header'><span class='f2'> <a href='?<?php print mkurl('SB=m&SO=' . $SO_next) ?>'><?php print __("Maintainer") ?></a> </span></th> </tr> diff --git a/web/template/search_accounts_form.php b/web/template/search_accounts_form.php index 9d6c40d..9b0d8e2 100644 --- a/web/template/search_accounts_form.php +++ b/web/template/search_accounts_form.php @@ -1,6 +1,6 @@ <br /> <form action='account.php' method='post'> - <table border='0' cellpadding='0' cellspacing='0' width='80%' style="margin:0 auto;"> + <table>
<tr> <td align='left'><?php print __("Username"); ?>:</td> diff --git a/web/template/tu_details.php b/web/template/tu_details.php index 7d6c305..c48f603 100644 --- a/web/template/tu_details.php +++ b/web/template/tu_details.php @@ -24,13 +24,13 @@ N/A <?php print str_replace("\n", "<br />\n", htmlspecialchars($row['Agenda'])) ?> </p>
-<table class="boxSoft" width='100%' cellspacing='0' cellpadding='2'> +<table class="boxSoft"> <tr> -<th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __("Yes") ?></span></th> -<th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __("No") ?></span></th> -<th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __("Abstain") ?></span></th> -<th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __("Total") ?></span></th> -<th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __('Voted') ?></span></th> +<th class='boxSoftTitle'><span class='f2'><?php print __("Yes") ?></span></th> +<th class='boxSoftTitle'><span class='f2'><?php print __("No") ?></span></th> +<th class='boxSoftTitle'><span class='f2'><?php print __("Abstain") ?></span></th> +<th class='boxSoftTitle'><span class='f2'><?php print __("Total") ?></span></th> +<th class='boxSoftTitle'><span class='f2'><?php print __('Voted') ?></span></th> </tr> <tr> <td class='data1'><span class='f5'><span class='blue'><?php print $row['Yes'] ?></span></span></td> diff --git a/web/template/tu_list.php b/web/template/tu_list.php index 75d9414..0966a4c 100644 --- a/web/template/tu_list.php +++ b/web/template/tu_list.php @@ -2,17 +2,17 @@ <div class="pgboxtitle" style="text-align:right;"> <span class='f3'><?php print $type ?></span> </div> - <table width='100%' cellspacing='0' cellpadding='2'> + <table class='results'> <tr> - <th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __("Proposal") ?></span></th> - <th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'> + <th class='header'><span class='f2'><?php print __("Proposal") ?></span></th> + <th class='header'><span class='f2'> <a href='?off=<?php print $off ?>&by=<?php print $by_next ?>'><?php print __("Start") ?></a> </span></th> - <th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __("End") ?></span></th> - <th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __("User") ?></span></th> - <th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __("Yes") ?></span></th> - <th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __("No") ?></span></th> - <th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __('Voted') ?></span></th> + <th class='header'><span class='f2'><?php print __("End") ?></span></th> + <th class='header'><span class='f2'><?php print __("User") ?></span></th> + <th class='header'><span class='f2'><?php print __("Yes") ?></span></th> + <th class='header'><span class='f2'><?php print __("No") ?></span></th> + <th class='header'><span class='f2'><?php print __('Voted') ?></span></th> </tr> <?php if (mysql_num_rows($result) == 0) { ?> <tr><td align='center' colspan='0'><?php print __("No results found.") ?></td></tr> -- 1.7.6
On Thu, Oct 20, 2011 at 10:17 AM, Lukas Fleischer <archlinux@cryptocrack.de> wrote:
On Thu, Oct 20, 2011 at 09:32:13AM -0500, Dan McGee wrote:
Replacing with CSS styles where appropriate. A previously unused CSS style is tweaked in the stylesheet to match most of what was done via non-CSS styling.
Signed-off-by: Dan McGee <dan@archlinux.org> ---
Things look mostly the same on all these pages. However, there are a few exceptions- for example, the removal of the needless centering of the account search form. Ping on this, and all the other patches from this day? Lukas, you had
On Mon, Aug 22, 2011 at 7:18 PM, Dan McGee <dan@archlinux.org> wrote: them on your WIP branch, but then they all disappeared...
I'm still waiting for that patch set (patch 5, actually) to be resubmitted. If you're too busy, just let me know and I'll look into that. I just thought I'd wait since you sent me a mail saying that you will fix and resend that patch later.
We work differently. :) Usually if patches that don't have dependencies on each other look good, I tend to merge them and not wait for the whole set to be resubmitted. In this case, since it was 1/6, it shouldn't have any dependencies. Given that I got no feedback on either the utf8 one or this one, I either assume 1) you didn't originally see it or 2) you forgot to merge it. I'll be happy to fill people's inboxes with an identical patch 2 months later, but I don't want to waste time when people review it and wonder what has changed, that's all. -Dan
On Fri, Oct 21, 2011 at 03:29:28PM -0500, Dan McGee wrote:
On Thu, Oct 20, 2011 at 10:17 AM, Lukas Fleischer <archlinux@cryptocrack.de> wrote:
On Thu, Oct 20, 2011 at 09:32:13AM -0500, Dan McGee wrote:
Replacing with CSS styles where appropriate. A previously unused CSS style is tweaked in the stylesheet to match most of what was done via non-CSS styling.
Signed-off-by: Dan McGee <dan@archlinux.org> ---
Things look mostly the same on all these pages. However, there are a few exceptions- for example, the removal of the needless centering of the account search form. Ping on this, and all the other patches from this day? Lukas, you had
On Mon, Aug 22, 2011 at 7:18 PM, Dan McGee <dan@archlinux.org> wrote: them on your WIP branch, but then they all disappeared...
I'm still waiting for that patch set (patch 5, actually) to be resubmitted. If you're too busy, just let me know and I'll look into that. I just thought I'd wait since you sent me a mail saying that you will fix and resend that patch later.
We work differently. :)
Usually if patches that don't have dependencies on each other look good, I tend to merge them and not wait for the whole set to be resubmitted. In this case, since it was 1/6, it shouldn't have any dependencies. Given that I got no feedback on either the utf8 one or this one, I either assume 1) you didn't originally see it or 2) you forgot to merge it.
Agreed, yeah. We should only hold pack patches if they might be affected by refactoring/resubmissions. I guess that it was a conjunction of the fact that I was really busy when you submitted the patches for the first time (exam time :) ) and the fact that you told me you will fix the outstanding issues when you get round to it that put me into some kind of an "idle mode" :) I'll have a look at your patches as soon as possible!
I'll be happy to fill people's inboxes with an identical patch 2 months later, but I don't want to waste time when people review it and wonder what has changed, that's all.
I'm all for adding small comments to resubmitted patches, unless their changelog is obvious if you follow the discussion on the mailing list :)
-Dan
participants (3)
-
Dan McGee
-
Dan McGee
-
Lukas Fleischer