add auto mobile version

This commit is contained in:
Andrey Kuvshinov
2020-05-22 15:32:05 +03:00
parent 2dee8b96b6
commit a9349269ed
5 changed files with 99 additions and 8 deletions

View File

@@ -177,7 +177,7 @@ function bookmark_set($hash, $page){
function promo_kuri($hash, $page = 0, $promo = true){
function promo_kuri($hash, $page = 0, $promo = true, $device = null){
# test url http://klan.dv/promo/bac343b41b357fdc8243373a429caa62 (742.pdf source)
@@ -194,10 +194,11 @@ function promo_kuri($hash, $page = 0, $promo = true){
if ($page == 0){ //  не читал ли ранее
$page = 1; //если нет страницы то первая
if ($bookmark !== false and $bookmark > 1){
return promo_kuri($hash, $bookmark, $promo);
return promo_kuri($hash, $bookmark, $prom, $device);
}
}
//устанавливаем закладку
bookmark_set($hash, $page);
@@ -222,6 +223,20 @@ function promo_kuri($hash, $page = 0, $promo = true){
$count = $price['pages'];
}
if ($device == null){
$detect = new Mobile_Detect;
if ( $detect->isMobile() ) {
$device = 'mobile';
}
else
$device = 'desktop';
}
//мобильная версия
if ($device == 'mobile')
return readtext_kuri($hash, $page);
$pdfile = $data['pdfpgurl'];
$fullpdf = $data['pdfurl'];
@@ -277,7 +292,7 @@ function promo_kuri($hash, $page = 0, $promo = true){
}
function textpdf_kuri($hash, $page = 1){
function readtext_kuri($hash, $page = 1){
$price = api_pricehash($hash);
@@ -285,7 +300,24 @@ function textpdf_kuri($hash, $page = 1){
return 'page not found';
}
$count = $price['pages'];
$baseurl = '/readtext/'.$hash.'/';
$endurl = "$baseurl$count";
if ($count > $page){
$nextpage = $page + 1;
$nexturl = $baseurl.$nextpage;
}
if ($page > 1) {
$prevpage = $page - 1;
$prevurl = $baseurl.$prevpage;
}
$title = $price['pricename'];
$newcurr = strtotime($price['BeginDate']);
$content = apipage_kuri($price['price_id'], $page);