summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-10-21 22:15:55 +0200
committerLukas Fleischer <archlinux@cryptocrack.de>2011-11-02 21:21:23 +0100
commite571a694d6e15891b591c28dd40cd464740a7126 (patch)
tree22f52edb32653ba24ddf9ca5d1230b53a1968d4f
parentfe90b4bc3e6b2a2a352236359577b3d46728aed6 (diff)
downloadaur-e571a694d6e15891b591c28dd40cd464740a7126.tar.gz
aur-e571a694d6e15891b591c28dd40cd464740a7126.tar.xz
Add a new AUR_LOCATION setting
This should be set to something like 'http://localhost' for development or 'https://aur.archlinux.org' in production. It ensures all links in the site stay in the development site and there is no sudden jump from development to production environments. Signed-off-by: Dan McGee <dan@archlinux.org> Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
-rw-r--r--web/html/passreset.php2
-rw-r--r--web/lib/aur.inc.php1
-rw-r--r--web/lib/config.inc.php.proto3
-rw-r--r--web/lib/pkgfuncs.inc.php6
-rw-r--r--web/template/header.php2
-rw-r--r--web/template/login_form.php2
-rw-r--r--web/template/pkg_comment_form.php4
7 files changed, 14 insertions, 6 deletions
diff --git a/web/html/passreset.php b/web/html/passreset.php
index 87be1b27..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";
diff --git a/web/lib/aur.inc.php b/web/lib/aur.inc.php
index ed0920f9..c662b80f 100644
--- a/web/lib/aur.inc.php
+++ b/web/lib/aur.inc.php
@@ -281,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/config.inc.php.proto b/web/lib/config.inc.php.proto
index d1f1cd18..1f196514 100644
--- a/web/lib/config.inc.php.proto
+++ b/web/lib/config.inc.php.proto
@@ -49,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 558cf3fd..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);
diff --git a/web/template/header.php b/web/template/header.php
index 8313bb36..73486b4d 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);