summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
Diffstat (limited to 'web')
-rw-r--r--web/README26
-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.php4
-rw-r--r--web/html/pkgsubmit.php4
-rw-r--r--web/html/rpc.php11
-rw-r--r--web/html/tu.php5
-rw-r--r--web/lib/acctfuncs.inc.php81
-rw-r--r--web/lib/aur.inc.php58
-rw-r--r--web/lib/aurjson.class.php30
-rw-r--r--web/lib/config.inc.php.proto31
-rw-r--r--web/lib/pkgfuncs.inc.php44
-rw-r--r--web/lib/translator.inc.php101
-rw-r--r--web/template/header.php2
-rw-r--r--web/template/login_form.php2
-rw-r--r--web/template/pkg_comment_form.php4
-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
22 files changed, 263 insertions, 208 deletions
diff --git a/web/README b/web/README
index 37a224ec..266f39e4 100644
--- a/web/README
+++ b/web/README
@@ -1,7 +1,7 @@
Setup on Arch Linux:
====================
-1) Install Apache, MySQL, PHP, and git
- # pacman -Syu apache mysql php git
+1) Install Apache, MySQL, PHP, git and php-pear
+ # pacman -Syu apache mysql php git php-pear
2) Set a local 'hostname' of 'aur'
- Edit /etc/hosts and append 'aur' to loopback address
@@ -16,11 +16,13 @@ Setup on Arch Linux:
Include conf/extra/php5_module.conf
- Also append the following snippet to enable the aur
- Virtual Host (Replace MYUSER with your username).
+ Virtual Host in /etc/httpd/conf/extra/httpd-vhosts.conf.
+ Comment out the example vhosts and replace MYUSER with your username.
+ (You could put aur in /srv/http/aur and then create a symlink in ~ )
<VirtualHost aur:80>
Servername aur
- DocumentRoot /home/MYUSER/aur/web/html
+ DocumentRoot /home/MYUSER/aur/web/html
ErrorLog /var/log/httpd/aur-error.log
CustomLog /var/log/httpd/aur-access.log combined
<Directory /home/MYUSER/aur/web/html>
@@ -31,6 +33,10 @@ Setup on Arch Linux:
</Directory>
</VirtualHost>
+ - In httpd.conf, uncomment this line:
+
+ Include conf/extra/httpd-vhosts.conf
+
4) Clone the AUR project (using the MYUSER from above)
$ cd
$ git clone git://projects.archlinux.org/aur.git
@@ -56,21 +62,17 @@ Setup on Arch Linux:
- Install the Archive_Tar PEAR package:
# pear install Archive_Tar
- - Put PEAR in your php include_path in php.ini:
-
- include_path = ".:/usr/share/pear"
-
- PEAR's path may vary depending on your set up.
-
6) Configure MySQL
- Start the MySQL service. Example:
# /etc/rc.d/mysqld start
+ - Create database
+ # mysqladmin -p create AUR
+
- Connect to the mysql client
- # mysql -uroot
+ # mysql -uroot -p AUR
- Issue the following commands to the mysql client
- mysql> CREATE DATABASE AUR;
mysql> GRANT ALL PRIVILEGES ON AUR.* to aur@localhost
> identified by 'aur';
mysql> FLUSH PRIVILEGES;
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..82be3ef4 100644
--- a/web/html/passreset.php
+++ b/web/html/passreset.php
@@ -67,7 +67,7 @@ if (isset($_GET['resetkey'], $_POST['email'], $_POST['password'], $_POST['confir
'your password follow the link below, otherwise ignore '.
'this message and nothing will happen.').
"\n\n".
- 'https://aur.archlinux.org/passreset.php?'.
+ "{$AUR_LOCATION}/passreset.php?".
"resetkey={$resetkey}";
$body = wordwrap($body, 70);
$headers = "To: {$email}\nReply-to: nobody@archlinux.org\nFrom:aur-notify@archlinux.org\nX-Mailer: PHP\nX-MimeOLE: Produced By AUR";
@@ -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/html/tu.php b/web/html/tu.php
index 6e202c80..6e043538 100644
--- a/web/html/tu.php
+++ b/web/html/tu.php
@@ -5,7 +5,10 @@ set_include_path(get_include_path() . PATH_SEPARATOR . '../lib');
include_once("aur.inc.php");
set_lang();
check_sid();
-html_header();
+
+$title = __("Trusted User");
+
+html_header($title);
# Default votes per page
$pp = 10;
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..c662b80f 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="") {
@@ -338,6 +281,7 @@ function html_header($title="") {
global $LANG;
global $SUPPORTED_LANGS;
global $DISABLE_HTTP_LOGIN;
+ global $AUR_LOCATION;
if (!$DISABLE_HTTP_LOGIN || (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'])) {
$login = try_login();
diff --git a/web/lib/aurjson.class.php b/web/lib/aurjson.class.php
index 6c7725c0..c1b079a4 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.
@@ -100,7 +103,7 @@ class AurJSON {
private function json_error($msg) {
// set content type header to app/json
header('content-type: application/json');
- return $this->json_results('error', $msg);
+ return $this->json_results('error', 0, $msg);
}
/**
@@ -109,8 +112,8 @@ class AurJSON {
* @param $data The result data to return
* @return mixed A json formatted result response.
**/
- private function json_results($type, $data) {
- return json_encode( array('type' => $type, 'results' => $data) );
+ private function json_results($type, $count, $data) {
+ return json_encode( array('type' => $type, 'resultcount' => $count, 'results' => $data) );
}
private function process_query($type, $where_condition) {
@@ -121,12 +124,21 @@ class AurJSON {
"WHERE ${where_condition}";
$result = db_query($query, $this->dbh);
- if ( $result && (mysql_num_rows($result) > 0) ) {
+ $resultcount = mysql_num_rows($result);
+ if ( $result && $resultcount > 0 ) {
$search_data = array();
while ( $row = mysql_fetch_assoc($result) ) {
$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;
@@ -137,10 +149,10 @@ class AurJSON {
}
mysql_free_result($result);
- return $this->json_results($type, $search_data);
+ return $this->json_results($type, $resultcount, $search_data);
}
else {
- return $this->json_error('No results found');
+ return $this->json_results($type, 0, array());
}
}
diff --git a/web/lib/config.inc.php.proto b/web/lib/config.inc.php.proto
index fbade866..1f196514 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;
@@ -77,3 +49,6 @@ $MAX_FILESIZE_UNCOMPRESSED = 1024 * 1024 * 8;
# Allow HTTPs logins only
$DISABLE_HTTP_LOGIN = true;
+
+# Web URL used in email links and absolute redirects, no trailing slash
+$AUR_LOCATION = "http://localhost";
diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php
index 88b18b88..42040191 100644
--- a/web/lib/pkgfuncs.inc.php
+++ b/web/lib/pkgfuncs.inc.php
@@ -301,6 +301,8 @@ function pkgname_is_blacklisted($name, $dbh=NULL) {
# display package details
#
function package_details($id=0, $SID="", $dbh=NULL) {
+ global $AUR_LOCATION;
+
if(!$dbh) {
$dbh = db_connect();
}
@@ -618,6 +620,8 @@ function sanitize_ids($ids) {
* @return string Translated success or error messages
*/
function pkg_flag ($atype, $ids, $action=true, $dbh=NULL) {
+ global $AUR_LOCATION;
+
if (!$atype) {
if ($action) {
return __("You must be logged in before you can flag packages.");
@@ -664,7 +668,7 @@ function pkg_flag ($atype, $ids, $action=true, $dbh=NULL) {
if (mysql_num_rows($result)) {
while ($row = mysql_fetch_assoc($result)) {
# construct email
- $body = "Your package " . $row['Name'] . " has been flagged out of date by " . $f_name . " [1]. You may view your package at:\nhttps://aur.archlinux.org/packages.php?ID=" . $row['ID'] . "\n\n[1] - https://aur.archlinux.org/account.php?Action=AccountInfo&ID=" . $f_uid;
+ $body = "Your package " . $row['Name'] . " has been flagged out of date by " . $f_name . " [1]. You may view your package at:\n" . $AUR_LOCATION . "/packages.php?ID=" . $row['ID'] . "\n\n[1] - " . $AUR_LOCATION . "/account.php?Action=AccountInfo&ID=" . $f_uid;
$body = wordwrap($body, 70);
$headers = "Reply-to: nobody@archlinux.org\nFrom:aur-notify@archlinux.org\nX-Mailer: PHP\nX-MimeOLE: Produced By AUR\n";
@mail($row['Email'], "AUR Out-of-date Notification for ".$row['Name'], $body, $headers);
@@ -708,6 +712,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/header.php b/web/template/header.php
index 8749dae6..91ee8065 100644
--- a/web/template/header.php
+++ b/web/template/header.php
@@ -23,7 +23,7 @@
<li id="anb-forums"><a href="https://bbs.archlinux.org/" title="Community forums">Forums</a></li>
<li id="anb-wiki"><a href="https://wiki.archlinux.org/" title="Community documentation">Wiki</a></li>
<li id="anb-bugs"><a href="https://bugs.archlinux.org/" title="Report and track bugs">Bugs</a></li>
- <li id="anb-aur"><a href="https://aur.archlinux.org/" title="Arch Linux User Repository">AUR</a></li>
+ <li id="anb-aur"><a href="/" title="Arch Linux User Repository">AUR</a></li>
<li id="anb-download"><a href="http://www.archlinux.org/download/" title="Get Arch Linux">Download</a></li>
</ul>
</div>
diff --git a/web/template/login_form.php b/web/template/login_form.php
index c27e9ba3..21bdaa72 100644
--- a/web/template/login_form.php
+++ b/web/template/login_form.php
@@ -32,7 +32,7 @@ else {
?>
<span class='error'>
<?php printf(__("HTTP login is disabled. Please %sswitch to HTTPs%s if you want to login."),
- '<a href="https://aur.archlinux.org' . htmlspecialchars($_SERVER['REQUEST_URI'], ENT_QUOTES) . '">', '</a>'); ?>
+ '<a href="' . $AUR_LOCATION . htmlspecialchars($_SERVER['REQUEST_URI'], ENT_QUOTES) . '">', '</a>'); ?>
</span>
<?php } ?>
</div>
diff --git a/web/template/pkg_comment_form.php b/web/template/pkg_comment_form.php
index d3b602cd..a2bbf714 100644
--- a/web/template/pkg_comment_form.php
+++ b/web/template/pkg_comment_form.php
@@ -35,9 +35,9 @@ if (isset($_REQUEST['comment'])) {
# 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 =
- 'from https://aur.archlinux.org/packages.php?ID='
+ 'from ' . $AUR_LOCATION . '/packages.php?ID='
. $_REQUEST['ID'] . "\n"
- . username_from_sid($_COOKIE['AURSID']) . " wrote:\n\n"
+ . username_from_sid($_COOKIE['AURSID'], $dbh) . " wrote:\n\n"
. $_POST['comment']
. "\n\n---\nIf you no longer wish to receive notifications about this package, please go the the above package page and click the UnNotify button.";
$body = wordwrap($body, 70);
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>