summaryrefslogtreecommitdiffstats
path: root/web/lib/pkgfuncs.inc.php
diff options
context:
space:
mode:
authorLukas Fleischer <archlinux@cryptocrack.de>2011-06-22 15:26:21 +0200
committerLukas Fleischer <archlinux@cryptocrack.de>2011-06-22 15:42:38 +0200
commit0e9f8c0ff5a315814de3223e5987812fa3a81447 (patch)
tree78a7a2de967ccec958a34dcd9e541d42a2a6d5a0 /web/lib/pkgfuncs.inc.php
parent5853097561cddd1a2405ac9d9b9659ca8772cc5e (diff)
downloadaur-0e9f8c0ff5a315814de3223e5987812fa3a81447.tar.gz
aur-0e9f8c0ff5a315814de3223e5987812fa3a81447.tar.xz
Do not redirect on single search results
The use of header() to redirect after previous output was a design flaw. Our only luck here was PHP's "output_buffering" config variable defaulting to 4096, which kind of hid the bug for a long time. Fixes FS#24580. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'web/lib/pkgfuncs.inc.php')
-rw-r--r--web/lib/pkgfuncs.inc.php51
1 files changed, 22 insertions, 29 deletions
diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php
index 7d46541b..46768f2b 100644
--- a/web/lib/pkgfuncs.inc.php
+++ b/web/lib/pkgfuncs.inc.php
@@ -533,42 +533,35 @@ function pkg_search_page($SID="") {
$last = $_GET['PP'] + $_GET['O'];
}
+ # calculation of pagination links
+ $per_page = ($_GET['PP'] > 0) ? $_GET['PP'] : 50;
+ $current = ceil($first / $per_page);
+ $pages = ceil($total / $per_page);
+ $templ_pages = array();
- if ($total > 1 || $total == 0) {
- # calculation of pagination links
- $per_page = ($_GET['PP'] > 0) ? $_GET['PP'] : 50;
- $current = ceil($first / $per_page);
- $pages = ceil($total / $per_page);
- $templ_pages = array();
-
- if ($current > 1) {
- $templ_pages[__('First')] = 0;
- $templ_pages[__('Previous')] = ($current - 2) * $per_page;
- }
-
- if ($current - 5 > 1)
- $templ_pages["..."] = false;
+ if ($current > 1) {
+ $templ_pages[__('First')] = 0;
+ $templ_pages[__('Previous')] = ($current - 2) * $per_page;
+ }
- for ($i = max($current - 5, 1); $i <= min($pages, $current + 5); $i++) {
- $templ_pages[$i] = ($i - 1) * $per_page;
- }
+ if ($current - 5 > 1)
+ $templ_pages["..."] = false;
- if ($current + 5 < $pages)
- $templ_pages["... "] = false;
+ for ($i = max($current - 5, 1); $i <= min($pages, $current + 5); $i++) {
+ $templ_pages[$i] = ($i - 1) * $per_page;
+ }
- if ($current < $pages) {
- $templ_pages[__('Next')] = $current * $per_page;
- $templ_pages[__('Last')] = ($pages - 1) * $per_page;
- }
+ if ($current + 5 < $pages)
+ $templ_pages["... "] = false;
- include('pkg_search_form.php');
- include('pkg_search_results.php');
- }
- else {
- $pkgdetails = mysql_fetch_assoc($result);
- header("Location: packages.php?ID={$pkgdetails['ID']}");
+ if ($current < $pages) {
+ $templ_pages[__('Next')] = $current * $per_page;
+ $templ_pages[__('Last')] = ($pages - 1) * $per_page;
}
+ include('pkg_search_form.php');
+ include('pkg_search_results.php');
+
return;
}