From 112df0f9574902ead2eb69f1f591d073cb67208b Mon Sep 17 00:00:00 2001 From: Andrey Kuvshinov Date: Fri, 15 May 2020 21:02:24 +0300 Subject: [PATCH] add bookmark --- app/routes/anpdf.php | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/app/routes/anpdf.php b/app/routes/anpdf.php index 833aac2..f2b94d3 100644 --- a/app/routes/anpdf.php +++ b/app/routes/anpdf.php @@ -133,6 +133,31 @@ function text_kuri(){ +//закладки - пока только куки +function bookmark_get($hash){ + + $bookcook = 'book_'.$hash; + + if (isset($_COOKIE[$bookcook])) + return $_COOKIE[$bookcook]; + else + return false; + +} + + + +function bookmark_set($hash, $page){ + + $bookcook = 'book_'.$hash; + $_COOKIE[$bookcook] = $page; + + return true; + +} + + + function promo_kuri($hash, $page = 1, $promo = true){ # test url http://klan.dv/promo/bac343b41b357fdc8243373a429caa62 (742.pdf source) @@ -145,6 +170,21 @@ function promo_kuri($hash, $page = 1, $promo = true){ return False; } + if ($page == 1){ + $bookmark = bookmark_get($hash); + if ($bookmark !== false and $bookmark > 1){ + header("HTTP/1.1 301 Moved Permanently"); + header('Location: '.SITE.'read/'.$hash.'/'.$page.'/'.$promo); + exit(); + } + + } + else { + bookmark_set($hash, $page); + } + + + $file = PDFSOURCE."${price['price_id']}.pdf"; $data = pdfs_init($file, $page);