summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--web/html/index.php10
-rw-r--r--web/html/pkgsubmit.php2
-rw-r--r--web/html/voters.php2
-rw-r--r--web/lib/pkgfuncs.inc.php7
-rw-r--r--web/lib/routing.inc.php18
-rw-r--r--web/template/actions_form.php2
-rw-r--r--web/template/pkg_comments.php4
-rw-r--r--web/template/pkg_details.php6
-rw-r--r--web/template/pkg_search_results.php2
-rw-r--r--web/template/stats/updates_table.php2
10 files changed, 40 insertions, 15 deletions
diff --git a/web/html/index.php b/web/html/index.php
index b0f346d..de38178 100644
--- a/web/html/index.php
+++ b/web/html/index.php
@@ -5,8 +5,16 @@ include_once("config.inc.php");
include_once("routing.inc.php");
$path = rtrim($_SERVER['PATH_INFO'], '/');
+$tokens = explode('/', $path);
-if (get_route($path) !== NULL) {
+if (isset($tokens[1]) &&'/' . $tokens[1] == get_pkg_route()) {
+ if (isset($tokens[2])) {
+ unset($_GET['ID']);
+ $_GET['N'] = $tokens[2];
+ }
+
+ include get_route('/' . $tokens[1]);
+} elseif (get_route($path) !== NULL) {
include get_route($path);
} else {
switch ($path) {
diff --git a/web/html/pkgsubmit.php b/web/html/pkgsubmit.php
index 8c93b0c..b918e8b 100644
--- a/web/html/pkgsubmit.php
+++ b/web/html/pkgsubmit.php
@@ -400,7 +400,7 @@ if ($uid):
# Entire package creation process is atomic
end_atomic_commit($dbh);
- header('Location: ' . get_uri('/packages/') . '?ID=' . $packageID);
+ header('Location: ' . get_pkg_uri($pkg_name));
}
chdir($cwd);
diff --git a/web/html/voters.php b/web/html/voters.php
index 378e605..3ba5248 100644
--- a/web/html/voters.php
+++ b/web/html/voters.php
@@ -15,7 +15,7 @@ if ($atype == 'Trusted User' || $atype== 'Developer'):
?>
<div class="box">
- <h2>Votes for <a href="<?php echo get_uri('/packages/'); ?>?ID=<?php echo $pkgid ?>"><?php echo pkgname_from_id($pkgid) ?></a></h2>
+ <h2>Votes for <a href="<?php echo get_pkg_uri(pkgname_from_id($pkgid)); ?>"><?php echo pkgname_from_id($pkgid) ?></a></h2>
<div class="boxbody">
<?php
diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php
index bdf8976..0610617 100644
--- a/web/lib/pkgfuncs.inc.php
+++ b/web/lib/pkgfuncs.inc.php
@@ -238,8 +238,7 @@ function add_package_comment($pkgid, $uid, $comment, $dbh=NULL) {
# 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 ' . $AUR_LOCATION . '/' . get_uri('/packages/') . '?ID='
- . $pkgid . "\n"
+ 'from ' . $AUR_LOCATION . '/' . get_pkg_uri($row['Name']) . "\n"
. username_from_sid($_COOKIE['AURSID'], $dbh) . " wrote:\n\n"
. $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.";
@@ -744,7 +743,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:\n" . $AUR_LOCATION . "/" . get_uri('/packages/') . "?ID=" . $row['ID'] . "\n\n[1] - " . $AUR_LOCATION . "/" . get_uri('/accounts/') . "?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 . "/" . get_pkg_uri($row['Name']) . "\n\n[1] - " . $AUR_LOCATION . "/" . get_uri('/accounts/') . "?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);
@@ -813,7 +812,7 @@ function pkg_delete ($atype, $ids, $mergepkgid, $dbh=NULL) {
$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/" . get_uri('/packages/') . "?ID=".$mergepkgid." and click the Notify button if you wish to recieve them again.";
+ $body .= "You will no longer receive notifications about this package, please go to https://aur.archlinux.org/" . get_pkg_uri($mergepkgname) . " 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.";
diff --git a/web/lib/routing.inc.php b/web/lib/routing.inc.php
index 0d940a2..e8a2deb 100644
--- a/web/lib/routing.inc.php
+++ b/web/lib/routing.inc.php
@@ -17,6 +17,8 @@ $ROUTES = array(
'/addvote' => 'addvote.php',
);
+$PKG_PATH = '/packages';
+
function get_route($path) {
global $ROUTES;
@@ -37,3 +39,19 @@ function get_uri($path) {
return get_route($path);
}
}
+
+function get_pkg_route() {
+ global $PKG_PATH;
+ return $PKG_PATH;
+}
+
+function get_pkg_uri($pkgname) {
+ global $USE_VIRTUAL_URLS;
+ global $PKG_PATH;
+
+ if ($USE_VIRTUAL_URLS) {
+ return $PKG_PATH . '/' . urlencode($pkgname) . '/';
+ } else {
+ return get_route($PKG_PATH) . '?N=' . urlencode($pkgname);
+ }
+}
diff --git a/web/template/actions_form.php b/web/template/actions_form.php
index 9cd5024..045022d 100644
--- a/web/template/actions_form.php
+++ b/web/template/actions_form.php
@@ -1,5 +1,5 @@
<div class="box">
- <form action="<?php echo get_uri('/packages/'); ?>?ID=<?php echo $row['ID'] ?>" method="post">
+ <form action="<?php echo htmlspecialchars(get_pkg_uri($row['Name']), ENT_QUOTES); ?>" method="post">
<fieldset>
<input type="hidden" name="IDs[<?php echo $row['ID'] ?>]" value="1" />
<input type="hidden" name="ID" value="<?php echo $row['ID'] ?>" />
diff --git a/web/template/pkg_comments.php b/web/template/pkg_comments.php
index 5b5f610..40b2fd1 100644
--- a/web/template/pkg_comments.php
+++ b/web/template/pkg_comments.php
@@ -4,7 +4,7 @@ $count = package_comments_count($_GET['ID']);
?>
<div id="news">
<h3>
- <a href="<?php echo htmlentities($_SERVER['REQUEST_URI'], ENT_QUOTES) ?>&amp;comments=all" title="<?php echo __('View all %s comments' , $count) ?>"><?php echo __('Latest Comments') ?></a>
+ <a href="<?php echo htmlentities($_SERVER['REQUEST_URI'], ENT_QUOTES) ?>?comments=all" title="<?php echo __('View all %s comments' , $count) ?>"><?php echo __('Latest Comments') ?></a>
<span class="arrow"></span>
</h3>
@@ -14,7 +14,7 @@ $count = package_comments_count($_GET['ID']);
endif; ?>
<h4>
<?php if (canDeleteCommentArray($row, $atype, $uid)): ?>
- <form method="post" action="<?php echo get_uri('/packages/'); ?>?ID=<?php echo $row['ID'] ?>">
+ <form method="post" action="<?php echo htmlspecialchars(get_pkg_uri($row['Name']), ENT_QUOTES); ?>">
<fieldset style="display:inline;">
<input type="hidden" name="action" value="do_DeleteComment" />
<input type="hidden" name="comment_id" value="<?php echo $row['ID'] ?>" />
diff --git a/web/template/pkg_details.php b/web/template/pkg_details.php
index 4cb8602..b4b52d5 100644
--- a/web/template/pkg_details.php
+++ b/web/template/pkg_details.php
@@ -57,7 +57,7 @@ if ($SID && ($uid == $row["MaintainerUID"] ||
($atype == "Developer" || $atype == "Trusted User"))):
?>
<td>
- <form method="post" action="<?php echo get_uri('/packages/'); ?>?ID=<?php echo $pkgid ?>">
+ <form method="post" action="<?php echo htmlspecialchars(get_pkg_uri($row['Name']), ENT_QUOTES); ?>">
<div>
<input type="hidden" name="action" value="do_ChangeCategory" />
<?php if ($SID): ?>
@@ -139,7 +139,7 @@ if ($atype == "Developer" || $atype == "Trusted User"):
# darr: (DepName, DepCondition, PackageID), where ID is NULL if it didn't exist
if (!is_null($darr[2])):
?>
- <li><a href="<?php echo get_uri('/packages/'); ?>?ID=<?php echo $darr[2]?>" title="<?php echo __('View packages details for').' '.$darr[0].$darr[1]?>"><?php echo $darr[0].$darr[1]?></a></li>
+ <li><a href="<?php echo htmlspecialchars(get_pkg_uri($darr[0]), ENT_QUOTES); ?>" title="<?php echo __('View packages details for').' '.$darr[0].$darr[1]?>"><?php echo $darr[0].$darr[1]?></a></li>
<?php else: ?>
<li><a href="http://www.archlinux.org/packages/?q=<?php echo urlencode($darr[0])?>" title="<?php echo __('View packages details for').' '.$darr[0].$darr[1] ?>"><?php echo $darr[0].$darr[1] ?></a></li>
<?php endif; ?>
@@ -155,7 +155,7 @@ if ($atype == "Developer" || $atype == "Trusted User"):
# darr: (PackageName, PackageID)
while (list($k, $darr) = each($requiredby)):
?>
- <li><a href="<?php echo get_uri('/packages/'); ?>?ID=<?php echo $darr[1] ?>" title="<?php echo __('View packages details for').' '.$darr[0]?>"><?php echo $darr[0] ?></a></li>
+ <li><a href="<?php echo htmlspecialchars(get_pkg_uri($darr[0]), ENT_QUOTES); ?>" title="<?php echo __('View packages details for').' '.$darr[0]?>"><?php echo $darr[0] ?></a></li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
diff --git a/web/template/pkg_search_results.php b/web/template/pkg_search_results.php
index 440698b..11db7a1 100644
--- a/web/template/pkg_search_results.php
+++ b/web/template/pkg_search_results.php
@@ -52,7 +52,7 @@ if (!$result): ?>
<td><input type="checkbox" name="IDs[<?php echo $row["ID"] ?>]" value="1" /></td>
<?php endif; ?>
<td><?php echo htmlspecialchars($row["Category"]) ?></td>
- <td><a href="<?php echo get_uri('/packages/'); ?>?ID=<?php echo $row["ID"] ?>"><?php echo htmlspecialchars($row["Name"]) . ' ' . htmlspecialchars($row["Version"]) ?></a></td>
+ <td><a href="<?php echo htmlspecialchars(get_pkg_uri($row["Name"]), ENT_QUOTES); ?>"><?php echo htmlspecialchars($row["Name"]) . ' ' . htmlspecialchars($row["Version"]) ?></a></td>
<td><?php echo $row["NumVotes"] ?></td>
<?php if ($SID): ?>
<td>
diff --git a/web/template/stats/updates_table.php b/web/template/stats/updates_table.php
index 835d956..6e43e22 100644
--- a/web/template/stats/updates_table.php
+++ b/web/template/stats/updates_table.php
@@ -6,7 +6,7 @@
<?php foreach ($newest_packages->getIterator() as $row): ?>
<tr>
<td>
- <a href="<?php echo get_uri('/packages/'); ?>?ID=<?php print intval($row["ID"]); ?>"><?php print htmlspecialchars($row["Name"]) . ' ' . htmlspecialchars($row["Version"]); ?></a>
+ <a href="<?php echo get_pkg_uri($row["Name"]); ?>"><?php print htmlspecialchars($row["Name"]) . ' ' . htmlspecialchars($row["Version"]); ?></a>
</td>
<td>
<span><?php print gmdate("Y-m-d H:i", intval($row["ModifiedTS"])); ?></span>