correct logic promo

This commit is contained in:
Andrey Kuvshinov
2020-05-22 17:03:33 +03:00
parent a9349269ed
commit c15662d09f
4 changed files with 34 additions and 20 deletions

View File

@@ -49,9 +49,9 @@ function anpromo_kuri($page = 1, $scale = 1){
function read_kuri($hash, $page = 0, $scale = 1, $promo = false){
function promo_kuri ($hash, $page = 0, $scale = 1, $promo = 'pr', $version = null){
return promo_kuri($hash, $page, false);
return read_kuri($hash, $page, 'pr', $version);
$price = db_get("SELECT `price_id`, `pricename`, `BeginDate` FROM `price` WHERE `pricehash` = '$hash' LIMIT 1");
@@ -177,10 +177,11 @@ function bookmark_set($hash, $page){
function promo_kuri($hash, $page = 0, $promo = true, $device = null){
function read_kuri($hash, $page = 0, $promo = false, $version = null){
# test url http://klan.dv/promo/bac343b41b357fdc8243373a429caa62 (742.pdf source)
$price = api_pricehash($hash);
if (!isset($price['price_id'])){
@@ -194,7 +195,7 @@ function promo_kuri($hash, $page = 0, $promo = true, $device = null){
if ($page == 0){ //  не читал ли ранее
$page = 1; //если нет страницы то первая
if ($bookmark !== false and $bookmark > 1){
return promo_kuri($hash, $bookmark, $prom, $device);
return read_kuri($hash, $bookmark, $promo, $version);
}
}
@@ -223,19 +224,24 @@ function promo_kuri($hash, $page = 0, $promo = true, $device = null){
$count = $price['pages'];
}
if ($device == null){
if ($version == null){
$detect = new Mobile_Detect;
if ( $detect->isMobile() ) {
$device = 'mobile';
$version = 'html';
}
else
$device = 'desktop';
$version = 'pdf';
}
//мобильная версия
if ($device == 'mobile')
return readtext_kuri($hash, $page);
if ($version == 'html')
return readtext_kuri($hash, $page, $promo);
$pdfile = $data['pdfpgurl'];
@@ -245,12 +251,12 @@ function promo_kuri($hash, $page = 0, $promo = true, $device = null){
$newcurr = strtotime($price['BeginDate']);
$category = $price['category_id'];
if ($promo){
$filedown = True;
if ($promo == 'pr'){
$filedown = false;
$baseurl = "/promo/$hash/";
}
else {
$filedown = True;
$filedown = true;
$baseurl = "/read/$hash/";
}
@@ -282,7 +288,7 @@ function promo_kuri($hash, $page = 0, $promo = true, $device = null){
$downtitle = 'Скачать в pdf формате';
}
$htmlurl = "/readtext/$hash/$page/$promo";
$tempcontent = VIEWPATH.'anpdf3.phtml'; //подшаблон
include VIEWPATH.'layout.phtml'; //центральный шаблон
@@ -292,9 +298,10 @@ function promo_kuri($hash, $page = 0, $promo = true, $device = null){
}
function readtext_kuri($hash, $page = 1){
function readtext_kuri($hash, $page = 1, $promo = 'no'){
$price = api_pricehash($hash);
if (!isset($price['price_id'])){
return 'page not found';
@@ -317,6 +324,7 @@ function readtext_kuri($hash, $page = 1){
$title = $price['pricename'];
$newcurr = strtotime($price['BeginDate']);
$full_ver_url = SITE."read/$hash/$page/$promo/pdf";
$content = apipage_kuri($price['price_id'], $page);