[aur-dev] [PATCH 1/4] index.php: Fix undefined variable notice
Spotted when browsing the package details page while being logged out. Reported-by: canyonknight <canyonknight@gmail.com> Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- web/html/index.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/web/html/index.php b/web/html/index.php index 70698a4..2d80a94 100644 --- a/web/html/index.php +++ b/web/html/index.php @@ -42,7 +42,10 @@ if (isset($tokens[1]) && '/' . $tokens[1] == get_pkg_route()) { break; } - $_POST['token'] = $_COOKIE['AURSID']; + if (isset($_COOKIE['AURSID'])) { + $_POST['token'] = $_COOKIE['AURSID']; + } + $_POST['IDs'] = array(pkgid_from_name($tokens[2]) => '1'); } } -- 1.7.12
Use the global keyword to import "$AUR_LOCATION" in add_package_comment(). Regression introduced in d3de6679010a1d140794305e747f1af0e7f21834. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- web/lib/pkgfuncs.inc.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php index b2daf0e..0b3a6cb 100644 --- a/web/lib/pkgfuncs.inc.php +++ b/web/lib/pkgfuncs.inc.php @@ -212,6 +212,8 @@ function package_comments($pkgid, $dbh=NULL) { # Add a comment to a package page and send out appropriate notifications # TODO: Move notification logic to separate function where it belongs function add_package_comment($pkgid, $uid, $comment, $dbh=NULL) { + global $AUR_LOCATION; + if(!$dbh) { $dbh = db_connect(); } -- 1.7.12
Setting GET parameters manually is bad style and causes some strange side effects when using virtual URLs and mkurl(). Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- web/html/index.php | 7 +++++-- web/html/packages.php | 25 ++++++++++++++----------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/web/html/index.php b/web/html/index.php index 2d80a94..5c56868 100644 --- a/web/html/index.php +++ b/web/html/index.php @@ -9,8 +9,11 @@ $tokens = explode('/', $path); if (isset($tokens[1]) && '/' . $tokens[1] == get_pkg_route()) { if (isset($tokens[2])) { - unset($_GET['ID']); - $_GET['N'] = $tokens[2]; + /* TODO: Create a proper data structure to pass variables from + * the routing framework to the individual pages instead of + * initializing arbitrary variables here. */ + $pkgname = $tokens[2]; + $pkgid = pkgid_from_name($pkgname); if (isset($tokens[3])) { if ($tokens[3] == 'voters') { diff --git a/web/html/packages.php b/web/html/packages.php index ec76e41..44f7671 100644 --- a/web/html/packages.php +++ b/web/html/packages.php @@ -7,11 +7,22 @@ set_lang(); # this sets up the visitor's language include_once('pkgfuncs.inc.php'); # package specific functions check_sid(); # see if they're still logged in +# Retrieve package ID and name, unless initialized by the routing framework +if (!isset($pkgid) || !isset($pkgname)) { + if (isset($_GET['ID'])) { + $pkgid = intval($_GET['ID']); + $pkgname = pkgname_from_id($_GET['ID']); + } else if (isset($_GET['N'])) { + $pkgid = pkgid_from_name($_GET['N']); + $pkgname = $_GET['N']; + } else { + unset($pkgid, $pkgname); + } +} + # Set the title to the current query if required -if (isset($_GET['ID']) && ($pkgname = pkgname_from_id($_GET['ID']))) { +if (isset($pkgname)) { $title = $pkgname; -} else if (isset($_GET['N'])) { - $title = $pkgname = $_GET['N']; } else if (!empty($_GET['K'])) { $title = __("Search Criteria") . ": " . $_GET['K']; } else { @@ -90,14 +101,6 @@ html_header($title); <?php endif; ?> <?php -if (isset($_GET['ID'])) { - $pkgid = intval($_GET['ID']); -} else if (isset($_GET['N'])) { - $pkgid = pkgid_from_name($_GET['N']); -} else { - unset($pkgid); -} - if (isset($pkgid)) { include('pkg_search_form.php'); if ($pkgid) { -- 1.7.12
Avoid adding "?comments=all" more than once if the "Latest Comments" link is clicked multiple times. Reported-by: canyonknight <canyonknight@gmail.com> Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- web/template/pkg_comments.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/template/pkg_comments.php b/web/template/pkg_comments.php index d0bd4f8..b0aada2 100644 --- a/web/template/pkg_comments.php +++ b/web/template/pkg_comments.php @@ -5,7 +5,7 @@ $pkgname = $row['Name']; ?> <div id="news"> <h3> - <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> + <a href="<?php echo htmlentities(get_pkg_uri($pkgname), ENT_QUOTES) . '?' . mkurl('comments=all') ?>" title="<?php echo __('View all %s comments' , $count) ?>"><?php echo __('Latest Comments') ?></a> <span class="arrow"></span> </h3> @@ -38,7 +38,7 @@ $pkgname = $row['Name']; <?php if ($count > 10 && !isset($_GET['comments'])): ?> <div id="news"> <h3> - <a href="<?php echo $_SERVER['REQUEST_URI'] ?>&comments=all" title="<?php echo __('View all %s comments', $count) ?>"><?php echo __('All comments', $count) ?></a> + <a href="<?php echo htmlentities(get_pkg_uri($pkgname), ENT_QUOTES) . '?' . mkurl('comments=all') ?>" title="<?php echo __('View all %s comments', $count) ?>"><?php echo __('All comments', $count) ?></a> </h3> </div> <?php endif; ?> -- 1.7.12
participants (1)
-
Lukas Fleischer