summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--UPGRADING7
-rw-r--r--scripts/aurblup/aurblup.c84
-rw-r--r--support/schema/aur-schema.sql5
-rw-r--r--web/html/account.php2
-rw-r--r--web/html/css/arch.css9
-rw-r--r--web/html/index.php6
-rw-r--r--web/html/logout.php3
-rw-r--r--web/html/passreset.php2
-rw-r--r--web/html/pkgsubmit.php4
-rw-r--r--web/html/rpc.php11
-rw-r--r--web/lib/acctfuncs.inc.php81
-rw-r--r--web/lib/aur.inc.php57
-rw-r--r--web/lib/aurjson.class.php17
-rw-r--r--web/lib/config.inc.php.proto28
-rw-r--r--web/lib/pkgfuncs.inc.php38
-rw-r--r--web/lib/translator.inc.php101
-rw-r--r--web/template/pkg_search_results.php18
-rw-r--r--web/template/search_accounts_form.php2
-rw-r--r--web/template/tu_details.php12
-rw-r--r--web/template/tu_list.php16
20 files changed, 280 insertions, 223 deletions
diff --git a/UPGRADING b/UPGRADING
index c0866e5e..863fbd84 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/scripts/aurblup/aurblup.c b/scripts/aurblup/aurblup.c
index 6a67d68d..32365548 100644
--- a/scripts/aurblup/aurblup.c
+++ b/scripts/aurblup/aurblup.c
@@ -11,7 +11,7 @@
#include "config.h"
-#define alpm_die(...) die(__VA_ARGS__, alpm_strerrorlast());
+#define alpm_die(...) die(__VA_ARGS__, alpm_strerror(alpm_errno(handle)));
#define mysql_die(...) die(__VA_ARGS__, mysql_error(c));
static void die(const char *, ...);
@@ -34,6 +34,8 @@ static char *mysql_db = NULL;
static MYSQL *c;
+static alpm_handle_t *handle;
+
static void
die(const char *format, ...)
{
@@ -52,12 +54,13 @@ static alpm_list_t *
pkglist_append(alpm_list_t *pkglist, const char *pkgname)
{
int len = strcspn(pkgname, "<=>");
- if (!len) len = strlen(pkgname);
+ if (!len)
+ len = strlen(pkgname);
char *s = malloc(len + 1);
strncpy(s, pkgname, len);
- s[len] = 0;
+ s[len] = '\0';
if (alpm_list_find_str(pkglist, s))
free(s);
@@ -74,7 +77,7 @@ blacklist_get_pkglist()
MYSQL_ROW row;
alpm_list_t *pkglist = NULL;
- if (mysql_query(c, "SELECT Name FROM PackageBlacklist;"))
+ if (mysql_query(c, "SELECT Name FROM PackageBlacklist"))
mysql_die("failed to read blacklist from MySQL database: %s\n");
if (!(res = mysql_store_result(c)))
@@ -96,7 +99,7 @@ blacklist_add(const char *name)
mysql_real_escape_string(c, esc, name, strlen(name));
snprintf(query, 1024, "INSERT INTO PackageBlacklist (Name) "
- "VALUES ('%s');", esc);
+ "VALUES ('%s')", esc);
free(esc);
if (mysql_query(c, query))
@@ -110,7 +113,7 @@ blacklist_remove(const char *name)
char query[1024];
mysql_real_escape_string(c, esc, name, strlen(name));
- snprintf(query, 1024, "DELETE FROM PackageBlacklist WHERE Name = '%s';", esc);
+ snprintf(query, 1024, "DELETE FROM PackageBlacklist WHERE Name = '%s'", esc);
free(esc);
if (mysql_query(c, query))
@@ -125,16 +128,16 @@ blacklist_sync(alpm_list_t *pkgs_cur, alpm_list_t *pkgs_new)
pkgs_add = alpm_list_diff(pkgs_new, pkgs_cur, (alpm_list_fn_cmp)strcmp);
pkgs_rem = alpm_list_diff(pkgs_cur, pkgs_new, (alpm_list_fn_cmp)strcmp);
- if (mysql_query(c, "START TRANSACTION;"))
+ if (mysql_query(c, "START TRANSACTION"))
mysql_die("failed to start MySQL transaction: %s\n");
for (p = pkgs_add; p; p = alpm_list_next(p))
- blacklist_add(alpm_list_getdata(p));
+ blacklist_add(p->data);
for (p = pkgs_rem; p; p = alpm_list_next(p))
- blacklist_remove(alpm_list_getdata(p));
+ blacklist_remove(p->data);
- if (mysql_query(c, "COMMIT;"))
+ if (mysql_query(c, "COMMIT"))
mysql_die("failed to commit MySQL transaction: %s\n");
alpm_list_free(pkgs_add);
@@ -148,25 +151,29 @@ dblist_get_pkglist(alpm_list_t *dblist)
alpm_list_t *pkglist = NULL;
for (d = dblist; d; d = alpm_list_next(d)) {
- pmdb_t *db = alpm_list_getdata(d);
+ alpm_db_t *db = d->data;
- if (alpm_trans_init(0, NULL, NULL, NULL))
+ if (alpm_trans_init(handle, 0))
alpm_die("failed to initialize ALPM transaction: %s\n");
if (alpm_db_update(0, db) < 0)
alpm_die("failed to update ALPM database: %s\n");
- if (alpm_trans_release())
+ if (alpm_trans_release(handle))
alpm_die("failed to release ALPM transaction: %s\n");
for (p = alpm_db_get_pkgcache(db); p; p = alpm_list_next(p)) {
- pmpkg_t *pkg = alpm_list_getdata(p);
+ alpm_pkg_t *pkg = p->data;
pkglist = pkglist_append(pkglist, alpm_pkg_get_name(pkg));
- for (q = alpm_pkg_get_provides(pkg); q; q = alpm_list_next(q))
- pkglist = pkglist_append(pkglist, alpm_list_getdata(q));
+ for (q = alpm_pkg_get_provides(pkg); q; q = alpm_list_next(q)) {
+ alpm_depend_t *provide = q->data;
+ pkglist = pkglist_append(pkglist, provide->name);
+ }
- for (q = alpm_pkg_get_replaces(pkg); q; q = alpm_list_next(q))
- pkglist = pkglist_append(pkglist, alpm_list_getdata(q));
+ for (q = alpm_pkg_get_replaces(pkg); q; q = alpm_list_next(q)) {
+ alpm_depend_t *replace = q->data;
+ pkglist = pkglist_append(pkglist, replace->name);
+ }
}
}
@@ -181,20 +188,20 @@ dblist_create(void)
int i;
for (i = 0; i < sizeof(alpm_repos) / sizeof(char *); i++) {
- if (!alpm_db_register_sync(alpm_repos[i]))
+ if (!alpm_db_register_sync(handle, alpm_repos[i], 0))
alpm_die("failed to register sync db \"%s\": %s\n", alpm_repos[i]);
}
- if (!(dblist = alpm_option_get_syncdbs()))
+ if (!(dblist = alpm_option_get_syncdbs(handle)))
alpm_die("failed to get sync DBs: %s\n");
for (d = dblist; d; d = alpm_list_next(d)) {
- pmdb_t *db = alpm_list_getdata(d);
+ alpm_db_t *db = d->data;
char server[1024];
snprintf(server, 1024, ALPM_MIRROR, alpm_db_get_name(db));
- if (alpm_db_setserver(db, server))
+ if (alpm_db_add_server(db, server))
alpm_die("failed to set server \"%s\": %s\n", server);
}
@@ -217,10 +224,14 @@ read_config(const char *fn)
t = &mysql_host;
u = &mysql_socket;
}
- else if (strstr(line, CONFIG_KEY_USER)) t = &mysql_user;
- else if (strstr(line, CONFIG_KEY_PASSWD)) t = &mysql_passwd;
- else if (strstr(line, CONFIG_KEY_DB)) t = &mysql_db;
- else t = NULL;
+ else if (strstr(line, CONFIG_KEY_USER))
+ t = &mysql_user;
+ else if (strstr(line, CONFIG_KEY_PASSWD))
+ t = &mysql_passwd;
+ else if (strstr(line, CONFIG_KEY_DB))
+ t = &mysql_db;
+ else
+ t = NULL;
if (t) {
strtok(line, "\"");
@@ -261,6 +272,7 @@ read_config(const char *fn)
static void
init(void)
{
+ enum _alpm_errno_t alpm_err;
if (mysql_library_init(0, NULL, NULL))
mysql_die("could not initialize MySQL library: %s\n");
if (!(c = mysql_init(NULL)))
@@ -269,24 +281,20 @@ init(void)
mysql_db, 0, mysql_socket, 0))
mysql_die("failed to initiate MySQL connection to %s: %s\n", mysql_host);
- if (alpm_initialize())
- alpm_die("failed to initialize ALPM: %s\n");
- if (alpm_option_set_root("/"))
- alpm_die("failed to set ALPM root: %s\n");
- if (alpm_option_set_dbpath(ALPM_DBPATH))
- alpm_die("failed to set ALPM database path: %s\n");
+ if ((handle = alpm_initialize("/", ALPM_DBPATH, &alpm_err)) == NULL)
+ die("failed to initialize ALPM: %s\n", alpm_strerror(alpm_err));
}
static void
cleanup(void)
{
- if (mysql_host) free(mysql_host);
- if (mysql_socket) free(mysql_socket);
- if (mysql_user) free(mysql_user);
- if (mysql_passwd) free(mysql_passwd);
- if (mysql_db) free(mysql_db);
+ free(mysql_host);
+ free(mysql_socket);
+ free(mysql_user);
+ free(mysql_passwd);
+ free(mysql_db);
- alpm_release();
+ alpm_release(handle);
mysql_close(c);
mysql_library_end();
}
diff --git a/support/schema/aur-schema.sql b/support/schema/aur-schema.sql
index 88d074e3..6c8feca8 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),
@@ -190,8 +191,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,
diff --git a/web/html/account.php b/web/html/account.php
index 387fd938..d94d7119 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/html/css/arch.css b/web/html/css/arch.css
index eec02eec..1e588f12 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 ffc5f008..0d513d37 100644
--- a/web/html/index.php
+++ b/web/html/index.php
@@ -25,7 +25,7 @@ $dbh = db_connect();
<?php
echo __(
- 'Welcome to the AUR! Please read the %hAUR User Guidelines%h and %hAUR TU Guidelines%h for more information.',
+ 'Welcome to the AUR! Please read the %sAUR User Guidelines%s and %sAUR TU Guidelines%s for more information.',
'<a href="http://wiki.archlinux.org/index.php/AUR_User_Guidelines">',
'</a>',
'<a href="http://wiki.archlinux.org/index.php/AUR_Trusted_User_Guidelines">',
@@ -37,7 +37,7 @@ echo __(
<?php
echo __(
- 'Contributed PKGBUILDs %hmust%h conform to the %hArch Packaging Standards%h otherwise they will be deleted!',
+ 'Contributed PKGBUILDs %smust%s conform to the %sArch Packaging Standards%s otherwise they will be deleted!',
'<b>', '</b>',
'<a href="http://wiki.archlinux.org/index.php/Arch_Packaging_Standards">',
'</a>'
@@ -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/logout.php b/web/html/logout.php
index 45ab564e..e51eeb92 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/html/passreset.php b/web/html/passreset.php
index 97fbebb0..87be1b27 100644
--- a/web/html/passreset.php
+++ b/web/html/passreset.php
@@ -122,7 +122,7 @@ html_header(__("Password Reset"));
<?php
} else {
?>
- <p><?php echo __('If you have forgotten the e-mail address you used to register, please send a message to the %haur-general%h mailing list.',
+ <p><?php echo __('If you have forgotten the e-mail address you used to register, please send a message to the %saur-general%s mailing list.',
'<a href="http://mailman.archlinux.org/mailman/listinfo/aur-general">',
'</a>'); ?></p>
<form action="" method="post">
diff --git a/web/html/pkgsubmit.php b/web/html/pkgsubmit.php
index 539f0561..75a4b697 100644
--- a/web/html/pkgsubmit.php
+++ b/web/html/pkgsubmit.php
@@ -273,7 +273,7 @@ if ($uid):
$error = __( "Could not create directory %s.", $incoming_pkgdir);
}
} else {
- $error = __( "You are not allowed to overwrite the %h%s%h package.", "<b>", $pkg_name, "</b>");
+ $error = __( "You are not allowed to overwrite the %s%s%s package.", "<b>", $pkg_name, "</b>");
}
if (!$error) {
@@ -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/html/rpc.php b/web/html/rpc.php
index ee7cda3d..415dcb82 100644
--- a/web/html/rpc.php
+++ b/web/html/rpc.php
@@ -18,7 +18,7 @@ else {
// here.
?>
<html><body>
-<p>The methods currently allowed are:</p>
+<h2>Allowed methods</h2>
<ul>
<li><tt>search</tt></li>
<li><tt>info</tt></li>
@@ -29,7 +29,14 @@ else {
<pre>type=<em>methodname</em>&amp;arg=<em>data</em></pre>
<p>Where <em>methodname</em> is the name of an allowed method, and <em>data</em> is the argument to the call.</p>
<p>If you need jsonp type callback specification, you can provide an additional variable <em>callback</em>.</p>
-<p>Example URL: <tt>http://aur-url/rpc.php?type=search&amp;arg=foobar&amp;callback=jsonp1192244621103</tt></p>
+<h2>Examples</h2>
+<dl>
+ <dt><tt>search</tt></dt><dd><tt>http://aur-url/rpc.php?type=search&amp;arg=foobar</tt></li></dd>
+ <dt><tt>info</tt></dt><dd><tt>http://aur-url/rpc.php?type=info&amp;arg=foobar</tt></dd>
+ <dt><tt>multiinfo</tt></dt><dd><tt>http://aur-url/rpc.php?type=multiinfo&amp;arg[]=foo&amp;arg[]=bar</tt></dd>
+ <dt><tt>msearch</tt></dt><dd><tt>http://aur-url/rpc.php?type=msearch&amp;arg=john</tt></li></dd>
+ <dt>Callback</dt><dd><tt>http://aur-url/rpc.php?type=search&amp;arg=foobar&amp;callback=jsonp1192244621103</tt></dd>
+</dl>
</body></html>
<?php
// close if statement
diff --git a/web/lib/acctfuncs.inc.php b/web/lib/acctfuncs.inc.php
index 9bd6e511..512e66ce 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'>&nbsp;</td></tr>\n";
print "<tr>";
@@ -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 )
@@ -233,7 +234,7 @@ function process_account_form($UTYPE,$TYPE,$A,$U="",$T="",$S="",$E="",
if ($result) {
$row = mysql_fetch_array($result);
if ($row[0]) {
- $error = __("The username, %h%s%h, is already in use.",
+ $error = __("The username, %s%s%s, is already in use.",
"<b>", htmlspecialchars($U,ENT_QUOTES), "</b>");
}
}
@@ -251,7 +252,7 @@ function process_account_form($UTYPE,$TYPE,$A,$U="",$T="",$S="",$E="",
if ($result) {
$row = mysql_fetch_array($result);
if ($row[0]) {
- $error = __("The address, %h%s%h, is already in use.",
+ $error = __("The address, %s%s%s, is already in use.",
"<b>", htmlspecialchars($E,ENT_QUOTES), "</b>");
}
}
@@ -273,12 +274,12 @@ function process_account_form($UTYPE,$TYPE,$A,$U="",$T="",$S="",$E="",
"VALUES (1, 0, '" . implode("', '", $escaped) . "')";
$result = db_query($q, $dbh);
if (!$result) {
- print __("Error trying to create account, %h%s%h: %s.",
+ print __("Error trying to create account, %s%s%s: %s.",
"<b>", htmlspecialchars($U,ENT_QUOTES), "</b>", mysql_error($dbh));
} else {
# account created/modified, tell them so.
#
- print __("The account, %h%s%h, has been successfully created.",
+ print __("The account, %s%s%s, has been successfully created.",
"<b>", htmlspecialchars($U,ENT_QUOTES), "</b>");
print "<p>\n";
print __("Click on the Home link above to login.");
@@ -310,10 +311,10 @@ function process_account_form($UTYPE,$TYPE,$A,$U="",$T="",$S="",$E="",
$q.= " WHERE ID = ".intval($UID);
$result = db_query($q, $dbh);
if (!$result) {
- print __("Error trying to modify account, %h%s%h: %s.",
+ print __("Error trying to modify account, %s%s%s: %s.",
"<b>", htmlspecialchars($U,ENT_QUOTES), "</b>", mysql_error($dbh));
} else {
- print __("The account, %h%s%h, has been successfully modified.",
+ print __("The account, %s%s%s, has been successfully modified.",
"<b>", htmlspecialchars($U,ENT_QUOTES), "</b>");
}
}
@@ -415,13 +416,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>";
@@ -466,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'>";
@@ -483,8 +478,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";
@@ -531,16 +526,17 @@ 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;
- 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'>&nbsp;</td>\n";
print " </tr>\n";
@@ -579,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."&amp;SeB=m'>".__("View this user's packages")."</a></td>\n";
print " </tr>\n";
@@ -598,21 +601,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
@@ -643,8 +645,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.
@@ -710,11 +715,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 = '"
. db_escape_string($user). "'";
@@ -739,11 +743,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) {
@@ -784,12 +786,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) {
@@ -804,9 +805,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;
@@ -816,9 +816,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) {
@@ -832,13 +831,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);
diff --git a/web/lib/aur.inc.php b/web/lib/aur.inc.php
index 6bc36ac5..ed0920f9 100644
--- a/web/lib/aur.inc.php
+++ b/web/lib/aur.inc.php
@@ -272,63 +272,6 @@ function db_query($query="", $db_handle="") {
return $result;
}
-# set up the visitor's language
-#
-function set_lang($dbh=NULL) {
- global $LANG;
- global $SUPPORTED_LANGS;
- global $PERSISTENT_COOKIE_TIMEOUT;
- global $streamer, $l10n;
-
- $update_cookie = 0;
- if (isset($_REQUEST['setlang'])) {
- # visitor is requesting a language change
- #
- $LANG = $_REQUEST['setlang'];
- $update_cookie = 1;
-
- } elseif (isset($_COOKIE['AURLANG'])) {
- # If a cookie is set, use that
- #
- $LANG = $_COOKIE['AURLANG'];
-
- } elseif (isset($_COOKIE["AURSID"])) {
- # No language but a session; use default lang preference
- #
- if(!$dbh) {
- $dbh = db_connect();
- }
- $q = "SELECT LangPreference FROM Users, Sessions ";
- $q.= "WHERE Users.ID = Sessions.UsersID ";
- $q.= "AND Sessions.SessionID = '";
- $q.= db_escape_string($_COOKIE["AURSID"])."'";
- $result = db_query($q, $dbh);
-
- if ($result) {
- $row = mysql_fetch_array($result);
- $LANG = $row[0];
- }
- $update_cookie = 1;
- }
-
- # Set $LANG to default if nothing is valid.
- if (!array_key_exists($LANG, $SUPPORTED_LANGS)) {
- $LANG = DEFAULT_LANG;
- }
-
- if ($update_cookie) {
- $cookie_time = time() + $PERSISTENT_COOKIE_TIMEOUT;
- setcookie("AURLANG", $LANG, $cookie_time, "/");
- }
-
- $streamer = new FileReader('../locale/' . $LANG .
- '/LC_MESSAGES/aur.mo');
- $l10n = new gettext_reader($streamer, true);
-
- return;
-}
-
-
# common header
#
function html_header($title="") {
diff --git a/web/lib/aurjson.class.php b/web/lib/aurjson.class.php
index 6c7725c0..234a3c43 100644
--- a/web/lib/aurjson.class.php
+++ b/web/lib/aurjson.class.php
@@ -18,11 +18,14 @@ class AurJSON {
'search', 'info', 'multiinfo', 'msearch'
);
private static $fields = array(
- 'Packages.ID', 'Name', 'Version', 'CategoryID',
- 'Description', 'URL', 'License',
- 'NumVotes', '(OutOfDateTS IS NOT NULL) AS OutOfDate',
+ 'Packages.ID', 'Name', 'Version', 'CategoryID', 'Description', 'URL',
+ 'License', 'NumVotes', 'OutOfDateTS AS OutOfDate',
'SubmittedTS AS FirstSubmitted', 'ModifiedTS AS LastModified'
);
+ private static $numeric_fields = array(
+ 'ID', 'CategoryID', 'NumVotes', 'OutOfDate', 'FirstSubmitted',
+ 'LastModified'
+ );
/**
* Handles post data, and routes the request.
@@ -127,6 +130,14 @@ class AurJSON {
$name = $row['Name'];
$row['URLPath'] = URL_DIR . substr($name, 0, 2) . "/" . $name . "/" . $name . ".tar.gz";
+ /* Unfortunately, mysql_fetch_assoc() returns all fields as
+ * strings. We need to coerce numeric values into integers to
+ * provide proper data types in the JSON response.
+ */
+ foreach (self::$numeric_fields as $field) {
+ $row[$field] = intval($row[$field]);
+ }
+
if ($type == 'info') {
$search_data = $row;
break;
diff --git a/web/lib/config.inc.php.proto b/web/lib/config.inc.php.proto
index fbade866..d1f1cd18 100644
--- a/web/lib/config.inc.php.proto
+++ b/web/lib/config.inc.php.proto
@@ -33,34 +33,6 @@ define("SQL_DEBUG", 0);
# to '127.0.0.1:11211'.
#define("MEMCACHE_SERVERS", '127.0.0.1:11211');
-# Languages we have translations for
-$SUPPORTED_LANGS = array(
- "ca" => "Català",
- "cs" => "česky",
- "da" => "Dansk",
- "de" => "Deutsch",
- "en" => "English",
- "el" => "Ελληνικά",
- "es" => "Español",
- "fi" => "Finnish",
- "fr" => "Français",
- "he" => "עברית",
- "hr" => "Hrvatski",
- "hu" => "Magyar",
- "it" => "Italiano",
- "nb_NO" => "Norsk",
- "nl" => "Dutch",
- "pl" => "Polski",
- "pt" => "Português",
- "pt_BR" => "Português (Brasil)",
- "ro" => "Română",
- "ru" => "Русский",
- "sr" => "Srpski",
- "tr" => "Türkçe",
- "uk" => "Українська",
- "zh_CN" => "简体中文"
-);
-
# Session limit per user
$MAX_SESSIONS_PER_USER = 8;
diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php
index 88b18b88..558cf3fd 100644
--- a/web/lib/pkgfuncs.inc.php
+++ b/web/lib/pkgfuncs.inc.php
@@ -708,6 +708,44 @@ function pkg_delete ($atype, $ids, $mergepkgid, $dbh=NULL) {
}
if ($mergepkgid) {
+ $mergepkgname = pkgname_from_id($mergepkgid, $dbh);
+ }
+
+ # Send email notifications
+ foreach ($ids as $pkgid) {
+ $q = 'SELECT CommentNotify.*, Users.Email ';
+ $q.= 'FROM CommentNotify, Users ';
+ $q.= 'WHERE Users.ID = CommentNotify.UserID ';
+ $q.= 'AND CommentNotify.UserID != ' . uid_from_sid($_COOKIE['AURSID']) . ' ';
+ $q.= 'AND CommentNotify.PkgID = ' . $pkgid;
+ $result = db_query($q, $dbh);
+ $bcc = array();
+
+ while ($row = mysql_fetch_assoc($result)) {
+ array_push($bcc, $row['Email']);
+ }
+ if (!empty($bcc)) {
+ $pkgname = pkgname_from_id($pkgid);
+
+ # TODO: native language emails for users, based on their prefs
+ # Simply making these strings translatable won't work, users would be
+ # getting emails in the language that the user who posted the comment was in
+ $body = "";
+ if ($mergepkgid) {
+ $body .= username_from_sid($_COOKIE['AURSID']) . " merged \"".$pkgname."\" into \"$mergepkgname\".\n\n";
+ $body .= "You will no longer receive notifications about this package, please go to https://aur.archlinux.org/packages.php?ID=".$mergepkgid." and click the Notify button if you wish to recieve them again.";
+ } else {
+ $body .= username_from_sid($_COOKIE['AURSID']) . " deleted \"".$pkgname."\".\n\n";
+ $body .= "You will no longer receive notifications about this package.";
+ }
+ $body = wordwrap($body, 70);
+ $bcc = implode(', ', $bcc);
+ $headers = "Bcc: $bcc\nReply-to: nobody@archlinux.org\nFrom: aur-notify@archlinux.org\nX-Mailer: AUR\n";
+ @mail(' ', "AUR Package deleted: " . $pkgname, $body, $headers);
+ }
+ }
+
+ if ($mergepkgid) {
/* Merge comments */
$q = "UPDATE PackageComments ";
$q.= "SET PackageID = " . intval($mergepkgid) . " ";
diff --git a/web/lib/translator.inc.php b/web/lib/translator.inc.php
index 44c87bda..0bcfb9c0 100644
--- a/web/lib/translator.inc.php
+++ b/web/lib/translator.inc.php
@@ -5,12 +5,11 @@ set_include_path(get_include_path() . PATH_SEPARATOR . '../lib' . PATH_SEPARATOR
# usage:
# use the __() function for returning translated strings of
-# text. The string can contain escape codes %h for HTML
-# and %s for regular text.
+# text. The string can contain escape codes "%s".
#
# examples:
# print __("%s has %s apples.", "Bill", "5");
-# print __("This is a %hmajor%h problem!", "<b>", "</b>");
+# print __("This is a %smajor%s problem!", "<b>", "</b>");
include_once('config.inc.php');
include_once('gettext.php');
@@ -18,6 +17,34 @@ include_once('streams.php');
global $streamer, $l10n;
+# Languages we have translations for
+$SUPPORTED_LANGS = array(
+ "ca" => "Català",
+ "cs" => "česky",
+ "da" => "Dansk",
+ "de" => "Deutsch",
+ "en" => "English",
+ "el" => "Ελληνικά",
+ "es" => "Español",
+ "fi" => "Finnish",
+ "fr" => "Français",
+ "he" => "עברית",
+ "hr" => "Hrvatski",
+ "hu" => "Magyar",
+ "it" => "Italiano",
+ "nb_NO" => "Norsk",
+ "nl" => "Dutch",
+ "pl" => "Polski",
+ "pt" => "Português",
+ "pt_BR" => "Português (Brasil)",
+ "ro" => "Română",
+ "ru" => "Русский",
+ "sr" => "Srpski",
+ "tr" => "Türkçe",
+ "uk" => "Українська",
+ "zh_CN" => "简体中文"
+);
+
function __() {
global $LANG;
global $l10n;
@@ -26,25 +53,73 @@ function __() {
$args = func_get_args();
# First argument is always string to be translated
- $tag = $args[0];
+ $tag = array_shift($args);
# Translate using gettext_reader initialized before.
$translated = $l10n->translate($tag);
$translated = htmlspecialchars($translated, ENT_QUOTES);
- $num_args = sizeof($args);
-
# Subsequent arguments are strings to be formatted
- #
- # TODO: make this more robust.
- # '%%' should translate to a literal '%'
+ if (count($args) > 0) {
+ $translated = vsprintf($translated, $args);
+ }
+
+ return $translated;
+}
+
+# set up the visitor's language
+#
+function set_lang($dbh=NULL) {
+ global $LANG;
+ global $SUPPORTED_LANGS;
+ global $PERSISTENT_COOKIE_TIMEOUT;
+ global $streamer, $l10n;
+
+ $update_cookie = 0;
+ if (isset($_REQUEST['setlang'])) {
+ # visitor is requesting a language change
+ #
+ $LANG = $_REQUEST['setlang'];
+ $update_cookie = 1;
- if ( $num_args > 1 ) {
- for ($i = 1; $i < $num_args; $i++) {
- $translated = preg_replace("/\%[sh]/", $args[$i], $translated, 1);
+ } elseif (isset($_COOKIE['AURLANG'])) {
+ # If a cookie is set, use that
+ #
+ $LANG = $_COOKIE['AURLANG'];
+
+ } elseif (isset($_COOKIE["AURSID"])) {
+ # No language but a session; use default lang preference
+ #
+ if(!$dbh) {
+ $dbh = db_connect();
+ }
+ $q = "SELECT LangPreference FROM Users, Sessions ";
+ $q.= "WHERE Users.ID = Sessions.UsersID ";
+ $q.= "AND Sessions.SessionID = '";
+ $q.= mysql_real_escape_string($_COOKIE["AURSID"])."'";
+ $result = db_query($q, $dbh);
+
+ if ($result) {
+ $row = mysql_fetch_array($result);
+ $LANG = $row[0];
}
+ $update_cookie = 1;
}
- return $translated;
+ # Set $LANG to default if nothing is valid.
+ if (!array_key_exists($LANG, $SUPPORTED_LANGS)) {
+ $LANG = DEFAULT_LANG;
+ }
+
+ if ($update_cookie) {
+ $cookie_time = time() + $PERSISTENT_COOKIE_TIMEOUT;
+ setcookie("AURLANG", $LANG, $cookie_time, "/");
+ }
+
+ $streamer = new FileReader('../locale/' . $LANG .
+ '/LC_MESSAGES/aur.mo');
+ $l10n = new gettext_reader($streamer, true);
+
+ return;
}
diff --git a/web/template/pkg_search_results.php b/web/template/pkg_search_results.php
index e576e6e3..8ef352b0 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'>&nbsp;</th>
+ <th class='header'>&nbsp;</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 9d6c40d0..9b0d8e23 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 7d6c305d..c48f6038 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 75d9414e..0966a4c2 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 ?>&amp;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>