From ce40207c47b198b54d30597aa50cec7003c41548 Mon Sep 17 00:00:00 2001 From: Daniel Winzen Date: Sun, 13 Nov 2016 08:10:04 +0100 Subject: [PATCH] Make pagination configurable + bugfix --- common_config.php | 1 + onions.php | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/common_config.php b/common_config.php index 649c728..0cadbb9 100644 --- a/common_config.php +++ b/common_config.php @@ -31,6 +31,7 @@ define('USERAGENT', 'Daniels Online-Test http://tt3j2x4k5ycaa5zt.onion/test.php' define('LANG', 'en'); // Default language define('PROMOTEPRICE', 0.025); // Price to promote a site for PROMOTETIME long define('PROMOTETIME', 864000); // Time (in seconds) to promote a site payed with PROMOTEPRICE - 864000 equals 10 days +define('PER_PAGE', 50); // Sites listed per page define('VERSION', '1'); // Script version define('DBVERSION', 1); // Database layout version //Categories - new links will always be put into the first one, leave it to Unsorted diff --git a/onions.php b/onions.php index 330332f..468e84f 100644 --- a/onions.php +++ b/onions.php @@ -137,7 +137,7 @@ function send_html(){ } if($category==$cat){ echo "
  • $name ($num[0])
  • "; - $pages=ceil($num[0]/100); + $pages=ceil($num[0]/PER_PAGE); }else{ echo "
  • $name ($num[0])
  • "; } @@ -159,7 +159,7 @@ function send_html(){ $num=$stmt->fetch(PDO::FETCH_NUM); if($category==$cat){ echo "
  • $name ($num[0])
  • "; - $pages=ceil($num[0]/100); + $pages=ceil($num[0]/PER_PAGE); }else{ echo "
  • $name ($num[0])
  • "; } @@ -227,20 +227,20 @@ function send_html(){ --$tmp; } if($category-count($categories)===1){ - $query.=' ORDER BY id DESC LIMIT 100'; + $query.=' ORDER BY id DESC LIMIT ' . PER_PAGE; }else{ $query.=' ORDER BY address'; if($_REQUEST['pg']>0){ - $offset=100*($_REQUEST['pg']-1); - $query.=" LIMIT 100 OFFSET $offset"; + $offset=PER_PAGE*($_REQUEST['pg']-1); + $query.=' LIMIT ' . PER_PAGE . " OFFSET $offset"; } } $stmt=$db->query('SELECT address, lasttest, lastup, timeadded, description, locked, special FROM ' . PREFIX . "onions WHERE $query;"); echo get_table($stmt, $numrows, true); }else{//show normal categories if($_REQUEST['pg']>0){ - $offset=100*($_REQUEST['pg']-1); - $offsetquery=" LIMIT 100 OFFSET $offset"; + $offset=PER_PAGE*($_REQUEST['pg']-1); + $offsetquery=' LIMIT ' . PER_PAGE . " OFFSET $offset"; }else{ $offsetquery=''; } @@ -319,7 +319,7 @@ function get_table(PDOStatement $stmt, &$numrows=0, $promoted=false){ function print_phishing_table(){ global $I, $db; echo ""; - $stmt=$db->query('SELECT address, original, lasttest, lastup FROM ' . PREFIX . 'onions, ' . PREFIX . 'phishing WHERE ' . PREFIX . "onions.id=onion_id AND address!='' ORDER BY onions.address AND timediff<604800;"); + $stmt=$db->query('SELECT address, original, lasttest, lastup FROM ' . PREFIX . 'onions, ' . PREFIX . 'phishing WHERE ' . PREFIX . "onions.id=onion_id AND address!='' AND timediff<604800 ORDER BY address;"); while($link=$stmt->fetch(PDO::FETCH_ASSOC)){ if($link['lastup']===$link['lasttest']){ $class='up';
    $I[link]$I[cloneof]$I[lastup]