add bookmark

This commit is contained in:
Andrey Kuvshinov
2020-05-15 21:02:24 +03:00
parent 90d0e08e06
commit 112df0f957

View File

@@ -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);