summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
Diffstat (limited to 'web')
-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
17 files changed, 224 insertions, 183 deletions
diff --git a/web/html/account.php b/web/html/account.php
index 387fd93..d94d711 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 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 ffc5f00..0d513d3 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 45ab564..e51eeb9 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 97fbebb..87be1b2 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 539f056..75a4b69 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 ee7cda3..415dcb8 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 9bd6e51..512e66c 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 6bc36ac..ed0920f 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 6c7725c..234a3c4 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 fbade86..d1f1cd1 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 88b18b8..558cf3f 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 44c87bd..0bcfb9c 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 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'>&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 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 ?>&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>