From 36ee5561035af335bc3c900ded7aa89066421226 Mon Sep 17 00:00:00 2001
From: Loui Chang
Date: Tue, 24 Jun 2008 02:53:16 -0400
Subject: Move code out of index.php
Move database queries to functions and html to templates.
Signed-off-by: Loui Chang
---
web/lib/stats.inc | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 72 insertions(+)
create mode 100644 web/lib/stats.inc
(limited to 'web/lib')
diff --git a/web/lib/stats.inc b/web/lib/stats.inc
new file mode 100644
index 0000000..e659210
--- /dev/null
+++ b/web/lib/stats.inc
@@ -0,0 +1,72 @@
+= $targstamp OR Packages.ModifiedTS >= $targstamp)";
+ $result = db_query($q, $dbh);
+ $row = mysql_fetch_row($result);
+ $update_count = $row[0];
+
+ include('stats/general_stats_table.php');
+}
+
--
cgit v1.2.3-70-g09d2
From 2feee92a75d4fe7042be52d1eef4e6e466af4967 Mon Sep 17 00:00:00 2001
From: Andrea Scarpino
Date: Tue, 8 Jul 2008 18:56:42 +0200
Subject: Remember user between sessions.
Signed-off-by: Loui Chang
---
web/lang/en/index_po.inc | 2 ++
web/lang/it/index_po.inc | 2 ++
web/lib/acctfuncs.inc | 7 ++++++-
web/template/login_form.php | 1 +
4 files changed, 11 insertions(+), 1 deletion(-)
(limited to 'web/lib')
diff --git a/web/lang/en/index_po.inc b/web/lang/en/index_po.inc
index bdeb87f..eb626eb 100644
--- a/web/lang/en/index_po.inc
+++ b/web/lang/en/index_po.inc
@@ -25,6 +25,8 @@ $_t["en"]["Password:"] = "Password:";
$_t["en"]["Username:"] = "Username:";
+$_t["en"]["Remember me"] = "Remember me";
+
$_t["en"]["Welcome to the AUR! If you're a newcomer, you may want to read the %hGuidelines%h."] = "Welcome to the AUR! If you're a newcomer, you may want to read the %hGuidelines%h.";
$_t["en"]["This is where the intro text will go."] = "This is where the intro text will go.";
diff --git a/web/lang/it/index_po.inc b/web/lang/it/index_po.inc
index f1e54eb..12b6e56 100644
--- a/web/lang/it/index_po.inc
+++ b/web/lang/it/index_po.inc
@@ -19,6 +19,8 @@ $_t["it"]["Password:"] = "Password:";
$_t["it"]["Username:"] = "Nome utente:";
+$_t["it"]["Remember me"] = "Ricordami" ;
+
$_t["it"]["Welcome to the AUR! If you're a newcomer, you may want to read the %hGuidelines%h."] = "Benvenuto in AUR! Se sei un nuovo utente, dovresti leggere le %hGuidelines%h.";
$_t["it"]["This is where the intro text will go."] = "Qui ci andrà il testo di introduzione.";
diff --git a/web/lib/acctfuncs.inc b/web/lib/acctfuncs.inc
index bbd6b74..73db270 100644
--- a/web/lib/acctfuncs.inc
+++ b/web/lib/acctfuncs.inc
@@ -644,7 +644,12 @@ function try_login() {
if ($logged_in) {
# set our SID cookie
- setcookie("AURSID", $new_sid, 0, "/");
+ if ($_POST['remember_me'] == "on")
+ # Set cookies for 30 days.
+ $cookie_time = time() + (60 * 60 * 24 * 30);
+ else
+ $cookie_time = 0;
+ setcookie("AURSID", $new_sid, $cookie_time, "/");
# header("Location: /index.php");
header("Location: " . $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']);
$login_error = "";
diff --git a/web/template/login_form.php b/web/template/login_form.php
index b2ed066..4bfc579 100644
--- a/web/template/login_form.php
+++ b/web/template/login_form.php
@@ -16,6 +16,7 @@
} ?>" />
+
" />
--
cgit v1.2.3-70-g09d2
From 1deb924674d1a42fc9b127a18bdc012c84ec6f93 Mon Sep 17 00:00:00 2001
From: Loui Chang
Date: Wed, 9 Jul 2008 00:30:05 -0400
Subject: Make JSON search return more information.
Signed-off-by: Loui Chang
---
web/lib/aurjson.class.php | 34 ++++++++++++++++++++--------------
1 file changed, 20 insertions(+), 14 deletions(-)
(limited to 'web/lib')
diff --git a/web/lib/aurjson.class.php b/web/lib/aurjson.class.php
index 953f5ab..6ff9b0f 100644
--- a/web/lib/aurjson.class.php
+++ b/web/lib/aurjson.class.php
@@ -22,6 +22,8 @@ if (!extension_loaded('json'))
class AurJSON {
private $dbh = false;
private $exposed_methods = array('search','info');
+ private $fields = array('ID','Name','Version','Description',
+ 'URL','URLPath','License','NumVotes','OutOfDate');
/**
* Handles post data, and routes the request.
@@ -42,7 +44,9 @@ class AurJSON {
// do the routing
if ( in_array($http_data['type'], $this->exposed_methods) ) {
// ugh. this works. I hate you php.
- $json = call_user_func_array(array(&$this,$http_data['type']),$http_data['arg']);
+ $json = call_user_func_array(array(&$this,$http_data['type']),
+ $http_data['arg']);
+
// allow rpc callback for XDomainAjax
if ( isset($http_data['callback']) ) {
return $http_data['callback'] . "({$json})";
@@ -87,22 +91,22 @@ class AurJSON {
}
$keyword_string = mysql_real_escape_string($keyword_string, $this->dbh);
- $query = sprintf(
- "SELECT Name,ID FROM Packages WHERE ( Name LIKE '%%%s%%' OR Description LIKE '%%%s%%' ) AND DummyPkg=0",
- $keyword_string, $keyword_string );
+
+ $query = "SELECT " . implode(',', $this->fields) .
+ " FROM Packages WHERE DummyPkg=0 AND ";
+ $query .= sprintf("( Name LIKE '%%%s%%' OR Description LIKE '%%%s%%' )",
+ $keyword_string, $keyword_string);
$result = db_query($query, $this->dbh);
if ( $result && (mysql_num_rows($result) > 0) ) {
$search_data = array();
while ( $row = mysql_fetch_assoc($result) ) {
- $elem = array(
- 'Name' => $row['Name'],
- 'ID' => $row['ID'] );
- array_push($search_data,$elem);
- }
+ array_push($search_data, $row);
+ }
+
mysql_free_result($result);
- return $this->json_results('search',$search_data);
+ return $this->json_results('search', $search_data);
}
else {
return $this->json_error('No results found');
@@ -115,7 +119,8 @@ class AurJSON {
* @return mixed Returns an array of value data containing the package data
**/
private function info($pqdata) {
- $base_query = "SELECT ID,Name,Version,Description,URL,URLPath,License,NumVotes,OutOfDate FROM Packages WHERE DummyPkg=0 AND ";
+ $base_query = "SELECT " . implode(',', $this->fields) .
+ " FROM Packages WHERE DummyPkg=0 AND ";
if ( is_numeric($pqdata) ) {
// just using sprintf to coerce the pqd to an int
@@ -127,7 +132,8 @@ class AurJSON {
if(get_magic_quotes_gpc()) {
$pqdata = stripslashes($pqdata);
}
- $query_stub = sprintf("Name=\"%s\"",mysql_real_escape_string($pqdata));
+ $query_stub = sprintf("Name=\"%s\"",
+ mysql_real_escape_string($pqdata));
}
$result = db_query($base_query.$query_stub, $this->dbh);
@@ -135,11 +141,11 @@ class AurJSON {
if ( $result && (mysql_num_rows($result) > 0) ) {
$row = mysql_fetch_assoc($result);
mysql_free_result($result);
- return $this->json_results('info',$row);
+ return $this->json_results('info', $row);
}
else {
return $this->json_error('No result found');
}
}
}
-?>
+
--
cgit v1.2.3-70-g09d2
From 1a1a6eb36e17315f08eee0e44a83fe4bdf0887f5 Mon Sep 17 00:00:00 2001
From: Loui Chang
Date: Wed, 9 Jul 2008 14:38:08 -0400
Subject: Add a new DEFAULT_LANG constant.
DEFAULT_LANG will essentially be used to specify what language
strings are initially written in.
This will eliminate the need for English translation arrays in
AUR and make adding or changing the English strings a lot easier.
DEFAULT_LANG may be required for strings to display properly.
Also change the output when a translation isn't found.
Eliminate the which can cause validation errors depending
on where the string is placed.
Signed-off-by: Loui Chang
---
web/lib/aur.inc | 8 +++-----
web/lib/config.inc.proto | 11 ++++++++---
web/lib/translator.inc | 9 ++++++---
3 files changed, 17 insertions(+), 11 deletions(-)
(limited to 'web/lib')
diff --git a/web/lib/aur.inc b/web/lib/aur.inc
index 81ffde2..ade5b82 100644
--- a/web/lib/aur.inc
+++ b/web/lib/aur.inc
@@ -311,12 +311,11 @@ function set_lang() {
$LANG = $row[0];
}
$update_cookie = 1;
- } else {
- $LANG = "en";
}
+ # Set $LANG to default if nothing is valid.
if (!array_key_exists($LANG, $SUPPORTED_LANGS)) {
- $LANG = "en"; # default to English
+ $LANG = DEFAULT_LANG;
}
if ($update_cookie) {
@@ -336,7 +335,7 @@ function html_header($title="") {
global $SUPPORTED_LANGS;
$login = try_login();
- $login_error = $login['error'];
+ $login_error = $login['error'];
$title = htmlspecialchars($title, ENT_QUOTES);
@@ -410,4 +409,3 @@ function uid_from_username($username="")
return $row[0];
}
-?>
diff --git a/web/lib/config.inc.proto b/web/lib/config.inc.proto
index 7a0a155..505fa7c 100644
--- a/web/lib/config.inc.proto
+++ b/web/lib/config.inc.proto
@@ -16,9 +16,12 @@ define( "USERNAME_MAX_LEN", 16 );
define( "PASSWD_MIN_LEN", 4 );
define( "PASSWD_MAX_LEN", 128 );
-$LOGIN_TIMEOUT = 7200; # number of idle seconds before timeout
+# Language that messages are initially written in.
+# This should never change.
+define("DEFAULT_LANG", "en");
-$SUPPORTED_LANGS = array( # what languages we have translations for
+# Languages we have translations for
+$SUPPORTED_LANGS = array(
"en" => "English",
"pl" => "Polski",
"it" => "Italiano",
@@ -30,4 +33,6 @@ $SUPPORTED_LANGS = array( # what languages we have translations for
"fr" => "Français"
);
-?>
+# Idle seconds before timeout
+$LOGIN_TIMEOUT = 7200;
+
diff --git a/web/lib/translator.inc b/web/lib/translator.inc
index 41ece89..f16bd11 100644
--- a/web/lib/translator.inc
+++ b/web/lib/translator.inc
@@ -37,12 +37,16 @@ function __() {
# First argument is always string to be translated
$tag = $args[0];
- $translated = $_t[$LANG][$tag];
+ if (empty($LANG) || $LANG == DEFAULT_LANG)
+ $translated = $tag;
+ else
+ $translated = $_t[$LANG][$tag];
+
if (empty($translated)) {
# if it's a supported language, but there isn't a translation,
# alert the visitor to the missing translation.
#
- $translated = "_${tag}_";
+ $translated = "_${tag}_";
}
# This condition is to reorganise the arguments in case of
@@ -63,4 +67,3 @@ function __() {
return $translated;
}
-?>
--
cgit v1.2.3-70-g09d2
From 2c6bae2e63c69f87599e5ef081eeba0a8d08bf00 Mon Sep 17 00:00:00 2001
From: Loui Chang
Date: Wed, 23 Jul 2008 10:36:41 -0400
Subject: Convert special chars in translations to html entities.
This closes
FS#10809 - bug in french translation of AUR web interface
Signed-off-by: Loui Chang
---
web/lib/translator.inc | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
(limited to 'web/lib')
diff --git a/web/lib/translator.inc b/web/lib/translator.inc
index f16bd11..fb9ed63 100644
--- a/web/lib/translator.inc
+++ b/web/lib/translator.inc
@@ -25,7 +25,6 @@
include_once("common_po.inc");
-
function __() {
global $_t;
global $LANG;
@@ -49,6 +48,8 @@ function __() {
$translated = "_${tag}_";
}
+ $translated = htmlspecialchars($translated, ENT_QUOTES);
+
# This condition is to reorganise the arguments in case of
# deprecated usage. __("string", array("string","string"))
if (!empty($args[1]) && is_array($args[1])) {
@@ -64,6 +65,7 @@ function __() {
$translated = preg_replace("/\%[sh]/", $args[$i], $translated, 1);
}
}
+
return $translated;
}
--
cgit v1.2.3-70-g09d2
From 1d416d6891d2945af6bfcc67ebfeb89e83195c60 Mon Sep 17 00:00:00 2001
From: Loui Chang
Date: Tue, 19 Aug 2008 15:35:58 -0400
Subject: Add Turkish to SUPPORTED_LANGS in config.inc.proto.
Signed-off-by: Loui Chang
---
web/lib/config.inc.proto | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
(limited to 'web/lib')
diff --git a/web/lib/config.inc.proto b/web/lib/config.inc.proto
index 505fa7c..7248b93 100644
--- a/web/lib/config.inc.proto
+++ b/web/lib/config.inc.proto
@@ -22,15 +22,16 @@ define("DEFAULT_LANG", "en");
# Languages we have translations for
$SUPPORTED_LANGS = array(
+ "ca" => "Català",
+ "de" => "Deutsch",
"en" => "English",
- "pl" => "Polski",
+ "es" => "Español",
+ "fr" => "Français",
"it" => "Italiano",
- "ca" => "Català",
+ "pl" => "Polski",
"pt" => "Português",
- "es" => "Español",
- "de" => "Deutsch",
"ru" => "Русский",
- "fr" => "Français"
+ "tr" => "Türkçe"
);
# Idle seconds before timeout
--
cgit v1.2.3-70-g09d2
From 52fb8550a21aeac6a6c75700c78be36de8983e15 Mon Sep 17 00:00:00 2001
From: Andrea Scarpino
Date: Tue, 26 Aug 2008 17:49:26 +0200
Subject: doesn't show disown package when already disowned
Signed-off-by: Callan Barrett
---
web/lib/pkgfuncs.inc | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
(limited to 'web/lib')
diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc
index 77b0ab1..484e5a6 100644
--- a/web/lib/pkgfuncs.inc
+++ b/web/lib/pkgfuncs.inc
@@ -512,14 +512,12 @@ function package_details($id=0, $SID="") {
if ($row["MaintainerUID"] == 0) {
echo "\n";
- }
-
- if ($row["MaintainerUID"] == uid_from_sid($SID) ||
- account_from_sid($SID) == "Trusted User" ||
- account_from_sid($SID) == "Developer") {
+ } else if ($row["MaintainerUID"] == uid_from_sid($SID) ||
+ account_from_sid($SID) == "Trusted User" ||
+ account_from_sid($SID) == "Developer") {
echo "\n";
- }
+ }
if (account_from_sid($SID) == "Trusted User" ||
account_from_sid($SID) == "Developer") {
--
cgit v1.2.3-70-g09d2
From 5c3f01909301f641f57b2ffe8b59609de6be2256 Mon Sep 17 00:00:00 2001
From: Loui Chang
Date: Fri, 12 Sep 2008 20:19:42 -0400
Subject: Use system rm in rm_rf function.
PHP can't properly handle symlinks which causes problems when
self-referencing symlinks appear.
This closes FS#11187.
Signed-off-by: Loui Chang
---
web/lib/aur.inc | 15 +++------------
1 file changed, 3 insertions(+), 12 deletions(-)
(limited to 'web/lib')
diff --git a/web/lib/aur.inc b/web/lib/aur.inc
index ade5b82..a126bb9 100644
--- a/web/lib/aur.inc
+++ b/web/lib/aur.inc
@@ -374,19 +374,10 @@ function can_submit_pkg($name="", $sid="") {
# recursive delete directory
#
function rm_rf($dirname="") {
- $d = dir($dirname);
- while ($f = $d->read()) {
- if ($f != "." && $f != "..") {
- if (is_dir($dirname."/".$f)) {
- rm_rf($dirname."/".$f);
- }
- if (is_file($dirname."/".$f) || is_link($dirname."/".$f)) {
- unlink($dirname."/".$f);
- }
- }
+ if ($dirname != "") {
+ exec('rm -rf ' . escapeshellcmd($dirname));
}
- $d->close();
- rmdir($dirname);
+
return;
}
--
cgit v1.2.3-70-g09d2
From df39cded09cb2a1ed9ee2f11207b28ccbb24fd51 Mon Sep 17 00:00:00 2001
From: Callan Barrett
Date: Mon, 29 Sep 2008 00:07:33 +0800
Subject: Sort required by list in package details page.
This closes FS#11420.
Signed-off-by: Callan Barrett
Signed-off-by: Loui Chang
---
web/lib/pkgfuncs.inc | 1 +
1 file changed, 1 insertion(+)
(limited to 'web/lib')
diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc
index 484e5a6..5ba56da 100644
--- a/web/lib/pkgfuncs.inc
+++ b/web/lib/pkgfuncs.inc
@@ -128,6 +128,7 @@ function package_required($pkgid=0) {
$q.= "WHERE PackageDepends.PackageID = Packages.ID ";
$q.= "AND PackageDepends.DepPkgID = ";
$q.= mysql_real_escape_string($pkgid);
+ $q.= " ORDER BY Name";
$result = db_query($q, $dbh);
if (!$result) {return array();}
while ($row = mysql_fetch_row($result)) {
--
cgit v1.2.3-70-g09d2
From c7bfd9528473da0886afd328f0fa68e26c97ca3d Mon Sep 17 00:00:00 2001
From: Loui Chang
Date: Thu, 18 Sep 2008 22:16:40 -0400
Subject: Take formatting out of version number in web/lib/version.inc
Signed-off-by: Loui Chang
Signed-off-by: Callan Barrett
---
web/lib/version.inc | 2 +-
web/template/footer.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
(limited to 'web/lib')
diff --git a/web/lib/version.inc b/web/lib/version.inc
index dcc2f3c..9ef059f 100644
--- a/web/lib/version.inc
+++ b/web/lib/version.inc
@@ -1,3 +1,3 @@
v1.5.2" );
+define( "AUR_VERSION", "v1.5.2" );
diff --git a/web/template/footer.php b/web/template/footer.php
index 9d85c7d..fe8f89c 100644
--- a/web/template/footer.php
+++ b/web/template/footer.php
@@ -3,7 +3,7 @@
$ver
\n";
+ print "
$ver
\n";
}
?>
--
cgit v1.2.3-70-g09d2
From 78ace0914eb6a8c6cc39306ab586ab741aa25187 Mon Sep 17 00:00:00 2001
From: Loui Chang
Date: Sun, 5 Oct 2008 20:24:57 -0400
Subject: Show developer-TUs their total community packages.
This closes:
FS#11561 - Devs in AUR can't see their packages in Community
Thanks to Hugo Doria for the original patch.
Signed-off-by: Loui Chang
Signed-off-by: Callan Barrett
---
web/lib/stats.inc | 2 +-
web/template/stats/user_table.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
(limited to 'web/lib')
diff --git a/web/lib/stats.inc b/web/lib/stats.inc
index e659210..6fbc033 100644
--- a/web/lib/stats.inc
+++ b/web/lib/stats.inc
@@ -29,7 +29,7 @@ function user_table($user, $dbh)
# If the user is a TU calculate the number of the packages
$atype = account_from_sid($_COOKIE["AURSID"]);
- if ($atype == 'Trusted User') {
+ if (($atype == 'Trusted User') || ($atype == 'Developer')) {
$result = db_query(sprintf($base_q, 'community'), $dbh);
$row = mysql_fetch_row($result);
$maintainer_community_count = $row[0];
diff --git a/web/template/stats/user_table.php b/web/template/stats/user_table.php
index b844662..ec71999 100644
--- a/web/template/stats/user_table.php
+++ b/web/template/stats/user_table.php
@@ -13,7 +13,7 @@
-
+
--
cgit v1.2.3-70-g09d2
From 8f5882e68deec6a8780653ae537aea7aa02283c3 Mon Sep 17 00:00:00 2001
From: Callan Barrett
Date: Sun, 5 Oct 2008 01:46:31 +0800
Subject: Convert package flagging to a function
Signed-off-by: Callan Barrett
Signed-off-by: Loui Chang
---
web/html/packages.php | 101 +++-----------------------------------------------
web/lib/pkgfuncs.inc | 74 +++++++++++++++++++++++++++++++++++-
2 files changed, 79 insertions(+), 96 deletions(-)
(limited to 'web/lib')
diff --git a/web/html/packages.php b/web/html/packages.php
index 4cfe9c4..317583f 100644
--- a/web/html/packages.php
+++ b/web/html/packages.php
@@ -37,106 +37,17 @@ if (isset($_COOKIE["AURSID"])) {
# grab the list of Package IDs to be operated on
#
isset($_POST["IDs"]) ? $ids = $_POST["IDs"] : $ids = array();
-#isset($_REQUEST["All_IDs"]) ?
-# $all_ids = explode(":", $_REQUEST["All_IDs"]) :
-# $all_ids = array();
-
# determine what button the visitor clicked
#
if ($_POST['action'] == "do_Flag" || isset($_POST['do_Flag'])) {
- if (!$atype) {
- print __("You must be logged in before you can flag packages.");
- print " \n";
-
- } else {
-
- if (!empty($ids)) {
- $dbh = db_connect();
-
- # Flag the packages in $ids array
- #
- $first = 1;
- while (list($pid, $v) = each($ids)) {
- if ($first) {
- $first = 0;
- $flag = $pid;
- } else {
- $flag .= ", ".$pid;
- }
- }
- $q = "UPDATE Packages SET OutOfDate = 1 ";
- $q.= "WHERE ID IN (" . $flag . ")";
- db_query($q, $dbh);
-
- print "
\n";
- print __("The selected packages have been flagged out-of-date.");
- print "
\n";
-
- # notification by tardo.
- $f_name = username_from_sid($_COOKIE['AURSID']);
- $f_email = email_from_sid($_COOKIE['AURSID']);
- $f_uid = uid_from_sid($_COOKIE['AURSID']);
- $q = "SELECT Packages.Name, Users.Email, Packages.ID ";
- $q.= "FROM Packages, Users ";
- $q.= "WHERE Packages.ID IN (" . $flag .") ";
- $q.= "AND Users.ID = Packages.MaintainerUID ";
- $q.= "AND Users.ID != " . $f_uid;
- $result = db_query($q, $dbh);
- 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 . ". You may view your package at:\nhttp://aur.archlinux.org/packages.php?do_Details=1&ID=" . $row['ID'];
- $body = wordwrap($body, 70);
- $headers = "To: ".$row['Email']."\nReply-to: nobody@archlinux.org\nFrom:aur-notify@archlinux.org\nX-Mailer: PHP\nX-MimeOLE: Produced By AUR\n";
- @mail(' ', "AUR Out-of-date Notification for ".$row['Name'], $body, $headers);
- }
- }
-
- } else {
- print "
\n";
- print __("You did not select any packages to flag.");
- print "