[aur-dev] [PATCH 1/6] Move web/README to README
The existing README file at the root level is not at all helpful to the end user of this repository as it is an old document describing the origins of the AUR, rather than a helpful "how to get this running" text file. Move web/README to README so it is obvious where to find said instructions. Signed-off-by: Dan McGee <dan@archlinux.org> --- This is a resubmit of all the patches I have queued that had no feedback last time I submitted them (or haven't been submitted but seem pretty low-impact, like this one). Nothing messing with db_connect() on the package details page, index, etc. is included here as those need changes, but should not be holding up merging of this stuff if there are no other problems. For this patch: I used `-M -B -C` options to generate this patch, thus the lack of diff, but it does exactly what the commit message says. web/README => README | 0 1 files changed, 0 insertions(+), 0 deletions(-) rename web/README => README (100%) diff --git a/web/README b/README similarity index 100% rename from web/README rename to README -- 1.7.7
The create database statement sets the default character set of the database to UTF-8, so no need to do it down below. Signed-off-by: Dan McGee <dan@archlinux.org> --- support/schema/aur-schema.sql | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/support/schema/aur-schema.sql b/support/schema/aur-schema.sql index 88d074e..544ed94 100644 --- a/support/schema/aur-schema.sql +++ b/support/schema/aur-schema.sql @@ -190,8 +190,8 @@ CREATE TABLE PackageBlacklist ( -- CREATE TABLE IF NOT EXISTS TU_VoteInfo ( ID int(10) unsigned NOT NULL auto_increment, - Agenda text COLLATE utf8_general_ci NOT NULL, - User VARCHAR(32) COLLATE utf8_general_ci NOT NULL, + Agenda text NOT NULL, + User VARCHAR(32) NOT NULL, Submitted bigint(20) unsigned NOT NULL, End bigint(20) unsigned NOT NULL, SubmitterID int(10) unsigned NOT NULL, -- 1.7.7
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> --- 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 36f74bf..f715e15 100644 --- a/web/html/pkgsubmit.php +++ b/web/html/pkgsubmit.php @@ -449,7 +449,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.7
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.7
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.7
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.7
participants (1)
-
Dan McGee