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

View File

@@ -12,14 +12,14 @@
</script> </script>
<p id="downloadtitle"> <p id="downloadtitle">
<?if ($promo):?> <?if ($promo == 'pr'):?>
<a href="https://argumenti.ru/robomail/486?utm_source=argumenti.ru&utm_medium=subscript&utm_campaign=promo">Получайте «Газету на @email»</a> <a href="https://argumenti.ru/robomail/486?utm_source=argumenti.ru&utm_medium=subscript&utm_campaign=promo">Получайте «Газету на @email»</a>
<?else:?> <?else:?>
<?if ($filedown):?> <?if ($filedown):?>
<a href="<?=$fullpdf?>"><?=$downtitle?></a><span id="downarrow"></span> <a href="<?=$fullpdf?>"><?=$downtitle?></a><span id="downarrow"></span>
<?endif?> <?endif?>
<span id="downarrow">Приятного чтения ↓</span>
<?endif?> <?endif?>
<span id="downarrow">&nbsp;/ <a href="<?=$htmlurl?>">html-версия</a></span>
</p> </p>
<div id="stuff-bar"> <div id="stuff-bar">

View File

@@ -30,8 +30,14 @@
<?else:?> <?else:?>
<p>Данная страница недоступна в мобильной версии</p> <p>Данная страница недоступна в мобильной версии</p>
<p>Перейдите на <a href="<?=$nexturl?>">следующую страницу</a></p> <p>Перейдите на <a href="<?=$nexturl?>">следующую страницу</a></p>
<p>Или <a href="<?=$full_ver_url?>">откройте pdf-версиию</a></p>
<?endif?> <?endif?>
</div> </div>
<?include ('blocks/pgtextnav.phtml')?> <?include ('blocks/pgtextnav.phtml')?>
<div class="header-div">
<a href="<?=$full_ver_url?>">Полная версия газеты</a>
</div>

View File

@@ -5,7 +5,7 @@
<script src="/pub/scripts/pdf.min.js"></script> <script src="/pub/scripts/pdf.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mobile-detect/1.4.4/mobile-detect.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/mobile-detect/1.4.4/mobile-detect.min.js"></script>
<script src="/pub/scripts/klanviewer.js?ver=34"></script> <script src="/pub/scripts/klanviewer.js?ver=34"></script>
<link rel="stylesheet" type="text/css" href="/pub/css/an.css?ver=204"> <link rel="stylesheet" type="text/css" href="/pub/css/an.css?ver=206">
<link rel="icon" type="image/ico" href="https://argumenti.ru/favicon.ico"> <link rel="icon" type="image/ico" href="https://argumenti.ru/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/pub/fontawesome/css/all.css"> <link rel="stylesheet" href="/pub/fontawesome/css/all.css">