correct bookmark

This commit is contained in:
Andrey Kuvshinov
2020-05-15 21:29:36 +03:00
parent 112df0f957
commit ef83a38925

View File

@@ -150,7 +150,19 @@ function bookmark_get($hash){
function bookmark_set($hash, $page){ function bookmark_set($hash, $page){
$bookcook = 'book_'.$hash; $bookcook = 'book_'.$hash;
$_COOKIE[$bookcook] = $page;
if ($page == 1){ // не устанавливать на первую страницу
if (isset($_COOKIE[$bookcook])){
unset($_COOKIE[$bookcook]);
setcookie($bookcook, null, -1, '/', $_SERVER['HTTP_HOST']);
}
return true;
}
$timeout = time()+(60*60*24*30*2); // хранить 2 месяца
setcookie ($bookcook , $page, $timeout, '/', $_SERVER['HTTP_HOST']);
return true; return true;
@@ -158,7 +170,7 @@ function bookmark_set($hash, $page){
function promo_kuri($hash, $page = 1, $promo = true){ function promo_kuri($hash, $page = 0, $promo = true){
# test url http://klan.dv/promo/bac343b41b357fdc8243373a429caa62 (742.pdf source) # test url http://klan.dv/promo/bac343b41b357fdc8243373a429caa62 (742.pdf source)
@@ -170,19 +182,18 @@ function promo_kuri($hash, $page = 1, $promo = true){
return False; return False;
} }
if ($page == 1){ if ($page == 0){ //  не читал ли ранее
$bookmark = bookmark_get($hash); $bookmark = bookmark_get($hash);
$page = 1; //если нет страницы то первая
if ($bookmark !== false and $bookmark > 1){ if ($bookmark !== false and $bookmark > 1){
header("HTTP/1.1 301 Moved Permanently"); header("HTTP/1.1 301 Moved Permanently");
header('Location: '.SITE.'read/'.$hash.'/'.$page.'/'.$promo); header('Location: '.SITE.'read/'.$hash.'/'.$page.'/'.$promo);
exit(); exit();
} }
}
else {
bookmark_set($hash, $page);
} }
//устанавливаем закладку
bookmark_set($hash, $page);
$file = PDFSOURCE."${price['price_id']}.pdf"; $file = PDFSOURCE."${price['price_id']}.pdf";