From 925ef570cf830f8ebc30da1689b073897d47d809 Mon Sep 17 00:00:00 2001 From: Andrey Kuvshinov Date: Tue, 28 Apr 2020 22:24:58 +0300 Subject: [PATCH] add automaxpages --- app/routes/anpdf.php | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/app/routes/anpdf.php b/app/routes/anpdf.php index 62a4c44..1788ac1 100644 --- a/app/routes/anpdf.php +++ b/app/routes/anpdf.php @@ -41,7 +41,8 @@ function read_kuri($hash, $page = 1, $scale = 1.5, $promo = false){ } $namefile = $hash.'.pdf'; - $pgfile = PGDIR.$hash.'/'.$hash.'-'.$page.'.pdf'; + $basepg = PGDIR.$hash.'/'.$hash.'-'; + $pgfile = $basepg.$page.'.pdf'; $cachefile = PDFDIR.$namefile; if (file_exists($cachefile)){ @@ -56,16 +57,7 @@ function read_kuri($hash, $page = 1, $scale = 1.5, $promo = false){ $pdfile = '/pages/'.$hash.'/'.$hash.'-'.$page.'.pdf'; $pagenum = 1; } - elseif (file_exists($cachefile)){ - $pdfile = '/pdf/'.$namefile; - $pagenum = $page; - } - else { - $pdfile = $fullpdf; - $pagenum = $page; - } - - + if ($page > 1 or $promo){ $fullpdf = $pdfile; $downtitle = 'Если по какой-то причине у вас не загрузилась страница ниже, то нажмите сюда, чтобы скачать pdf'; @@ -78,7 +70,6 @@ function read_kuri($hash, $page = 1, $scale = 1.5, $promo = false){ $id = $price['price_id']; - $maxpage = 24; $title = $price['pricename']; if ($promo){ @@ -90,9 +81,9 @@ function read_kuri($hash, $page = 1, $scale = 1.5, $promo = false){ $baseurl = "/read/$hash/"; } - if ($page < $maxpage){ - $nextpage = $page + 1; - $nexturl = "$baseurl$nextpage"; + $nextpage = $page + 1; + if (file_exists($basepg.$nextpage.'.pdf')){ + $nexturl = "$baseurl$nextpage"; } if ($page > 1) { @@ -103,7 +94,6 @@ function read_kuri($hash, $page = 1, $scale = 1.5, $promo = false){ $tempcontent = VIEWPATH.'anpdf2.phtml'; //подшаблон include VIEWPATH.'layout.phtml'; //центральный шаблон - } function text_kuri(){