new logic pdf loaded
This commit is contained in:
@@ -10,12 +10,20 @@ if (isset($_SERVER['HTTP_HOST']))
|
|||||||
if (isset($_SERVER['HTTP_HOST']))
|
if (isset($_SERVER['HTTP_HOST']))
|
||||||
define('SITEPATH', $_SERVER['DOCUMENT_ROOT'].'/');
|
define('SITEPATH', $_SERVER['DOCUMENT_ROOT'].'/');
|
||||||
else
|
else
|
||||||
define('SITEPATH', dirname(__FILE__));
|
define('SITEPATH', dirname(__FILE__));
|
||||||
|
|
||||||
|
if (SITE == 'http://klan.argumenti.ru/')
|
||||||
|
define('PDFSOURCE', '/vhosts/an/httpdocs/pub/files/pdf/pdf/');
|
||||||
|
else
|
||||||
|
define('PDFSOURCE', SITEPATH.'pub/files/source/');
|
||||||
|
|
||||||
|
|
||||||
|
define('PDFPATH', '/pub/files/pdf/');
|
||||||
|
define('PGPATH', '/pub/files/pages/');
|
||||||
|
define('PDFDIR', SITEPATH.PDFPATH);
|
||||||
|
define('PGDIR', SITEPATH.PGPATH);
|
||||||
|
|
||||||
|
|
||||||
define('PDFDIR', '/vhosts/anpdf/app/pub/files/pdf/');
|
|
||||||
define('PGDIR', '/vhosts/anpdf/app/pub/files/pages/');
|
|
||||||
define('PDFURL', 'pub/files/pdf/');
|
|
||||||
define('PGURL', 'pub/files/pages/');
|
|
||||||
|
|
||||||
define('APPPATH', SITEPATH);
|
define('APPPATH', SITEPATH);
|
||||||
define('VIEWPATH', SITEPATH.'views/');
|
define('VIEWPATH', SITEPATH.'views/');
|
||||||
|
|||||||
@@ -4,16 +4,19 @@ function anpromo_kuri($page = 1, $scale = 1){
|
|||||||
|
|
||||||
// $pdfile = 'https://argumenti.ru/templinks/md5files/f9598f88e667146d50d106eeedbd74c1.pdf';
|
// $pdfile = 'https://argumenti.ru/templinks/md5files/f9598f88e667146d50d106eeedbd74c1.pdf';
|
||||||
$namefile = 'promo.pdf';
|
$namefile = 'promo.pdf';
|
||||||
|
|
||||||
$title = 'Номер 12(706)';
|
$title = 'Номер 12(706)';
|
||||||
$baseurl = '/';
|
|
||||||
$newcurr = strtotime('2006-05-12');
|
$newcurr = strtotime('2006-05-12');
|
||||||
|
|
||||||
$file = SITEPATH.'pub/files/pdf/promo.pdf';
|
$file = SITEPATH.'pub/files/source/742.pdf';
|
||||||
$data = pdfs_init($file);
|
$data = pdfs_init($file, $page);
|
||||||
|
|
||||||
$pdfile = $data['pdfpgurl'];
|
$pdfile = $data['pdfpgurl'];
|
||||||
|
|
||||||
$fullpdf = $data['pdfurl'];
|
$fullpdf = $data['pdfurl'];
|
||||||
|
|
||||||
|
$baseurl = "/anpromo/";
|
||||||
|
$pagenum = 1;
|
||||||
$nextpage = $page + 1;
|
$nextpage = $page + 1;
|
||||||
$filedown = True;
|
$filedown = True;
|
||||||
|
|
||||||
@@ -30,8 +33,7 @@ function anpromo_kuri($page = 1, $scale = 1){
|
|||||||
}
|
}
|
||||||
|
|
||||||
$downtitle = 'Если по какой-то причине у вас не загрузилась страница ниже, то нажмите сюда, чтобы скачать pdf';
|
$downtitle = 'Если по какой-то причине у вас не загрузилась страница ниже, то нажмите сюда, чтобы скачать pdf';
|
||||||
$baseurl = "/anpromo/";
|
|
||||||
$pagenum = 1;
|
|
||||||
|
|
||||||
$tempcontent = VIEWPATH.'anpdf2.phtml'; //подшаблон
|
$tempcontent = VIEWPATH.'anpdf2.phtml'; //подшаблон
|
||||||
include VIEWPATH.'layout.phtml'; //центральный шаблон
|
include VIEWPATH.'layout.phtml'; //центральный шаблон
|
||||||
@@ -44,6 +46,8 @@ function anpromo_kuri($page = 1, $scale = 1){
|
|||||||
|
|
||||||
function read_kuri($hash, $page = 1, $scale = 1, $promo = false){
|
function read_kuri($hash, $page = 1, $scale = 1, $promo = false){
|
||||||
|
|
||||||
|
return promo_kuri($hash, $page, false);
|
||||||
|
|
||||||
$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");
|
||||||
|
|
||||||
if (!isset($price['price_id'])){
|
if (!isset($price['price_id'])){
|
||||||
@@ -52,11 +56,14 @@ function read_kuri($hash, $page = 1, $scale = 1, $promo = false){
|
|||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$file = SITEPATH.'pub/files/source/742.pdf';
|
||||||
|
|
||||||
$namefile = $hash.'.pdf';
|
$namefile = $hash.'.pdf';
|
||||||
$basepg = PGDIR.$hash.'/'.$hash.'-';
|
$basepg = PGDIR.$hash.'/'.$hash.'-';
|
||||||
$pgfile = $basepg.$page.'.pdf';
|
$pgfile = $basepg.$page.'.pdf';
|
||||||
$cachefile = PDFDIR.$namefile;
|
$cachefile = PDFDIR.$namefile;
|
||||||
$newcurr = strtotime($price['BeginDate']);
|
$newcurr = strtotime($price['BeginDate']);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (file_exists($cachefile)){
|
if (file_exists($cachefile)){
|
||||||
@@ -126,9 +133,9 @@ function text_kuri(){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
function promo_kuri($hash, $page = 1, $scale = 2, $promo = false){
|
function promo_kuri($hash, $page = 1, $promo = true){
|
||||||
|
|
||||||
return read_kuri($hash, $page, $scale, true);
|
# test url http://klan.dv/promo/bac343b41b357fdc8243373a429caa62 (742.pdf source)
|
||||||
|
|
||||||
$price = db_get("SELECT `price_id`, `pricename` FROM `price` WHERE `pricehash` = '$hash' LIMIT 1");
|
$price = db_get("SELECT `price_id`, `pricename` FROM `price` WHERE `pricehash` = '$hash' LIMIT 1");
|
||||||
|
|
||||||
@@ -138,31 +145,56 @@ function promo_kuri($hash, $page = 1, $scale = 2, $promo = false){
|
|||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = $price['price_id'];
|
$file = PDFSOURCE."${price['price_id']}.pdf";
|
||||||
$pdfile = "/file/$hash";
|
$data = pdfs_init($file, $page);
|
||||||
$maxpage = 32;
|
|
||||||
|
|
||||||
if ($page > 1)
|
|
||||||
$title = $price['pricename']."- $page";
|
|
||||||
else
|
|
||||||
$title = $price['pricename'];
|
|
||||||
|
|
||||||
if (!$promo)
|
|
||||||
$filedown = False;
|
|
||||||
|
|
||||||
$baseurl = "/promo/$hash/";
|
$pdfile = $data['pdfpgurl'];
|
||||||
|
$fullpdf = $data['pdfurl'];
|
||||||
if ($page < $maxpage){
|
$count = $data['count'];
|
||||||
$nextpage = $page + 1;
|
$pagenum = 1;
|
||||||
$nexturl = "$baseurl$nextpage";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($page > 1) {
|
|
||||||
$prevpage = $page - 1;
|
if ($promo){
|
||||||
$prevurl = "$baseurl$prevpage";
|
$filedown = True;
|
||||||
}
|
$baseurl = "/promo/$hash/";
|
||||||
|
}
|
||||||
include ('anpdf2.phtml');
|
else {
|
||||||
|
$filedown = True;
|
||||||
|
$baseurl = "/read/$hash/";
|
||||||
|
}
|
||||||
|
|
||||||
|
$endurl = "$baseurl$count";
|
||||||
|
|
||||||
|
if ($count > $page){
|
||||||
|
$nextpage = $page + 1;
|
||||||
|
$nexturl = "$baseurl$nextpage";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$nexturl = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($page > 1) {
|
||||||
|
//$title = $price['pricename']." / $page стр.";
|
||||||
|
$title = $price['pricename'];
|
||||||
|
$prevpage = $page - 1;
|
||||||
|
$prevurl = "$baseurl$prevpage";
|
||||||
|
if (!$promo){
|
||||||
|
$downtitle = 'Если по какой-то причине у вас не загрузилась страница ниже, то нажмите сюда, чтобы скачать pdf';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$title = $price['pricename'];
|
||||||
|
$downtitle = 'Если по какой-то причине у вас не загрузилось издание ниже, то нажмите сюда, чтобы скачать pdf';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$tempcontent = VIEWPATH.'anpdf2.phtml'; //подшаблон
|
||||||
|
include VIEWPATH.'layout.phtml'; //центральный шаблон
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
function pdfs_filename($pdf){
|
|
||||||
|
function pdfs_basename($pdf){
|
||||||
return basename($source, ".pdf");
|
return basename($source, ".pdf");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -13,15 +14,18 @@ function pdfs_count($pdf){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function pdfs_hash($pdf){
|
||||||
|
$basefile = basename($pdf, ".pdf");
|
||||||
|
return md5($basefile);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function pdfs_cachefile($pdf){
|
function pdfs_cachefile($pdf){
|
||||||
|
|
||||||
$basefile = basename($pdf);
|
$name = pdfs_hash($pdf).'.pdf';
|
||||||
$cachefile = PDFDIR.$basefile;
|
$cachefile = PDFDIR.$name;
|
||||||
$cacheurl = PDFURL.$basefile;
|
$cacheurl = PDFPATH.$name;
|
||||||
|
|
||||||
if (!file_exists($cachefile)) {
|
if (!file_exists($cachefile)) {
|
||||||
if (copy($pdf, $cachefile))
|
if (copy($pdf, $cachefile))
|
||||||
return $cacheurl;
|
return $cacheurl;
|
||||||
@@ -46,7 +50,7 @@ function pdfs_init($source, $page = 1){
|
|||||||
$result['pdfurl'] = pdfs_cachefile($source); //полный файл на скачку
|
$result['pdfurl'] = pdfs_cachefile($source); //полный файл на скачку
|
||||||
|
|
||||||
|
|
||||||
$name = basename($source, ".pdf");
|
$name = pdfs_hash($source);
|
||||||
$cachedir = PGDIR.$name.'/';
|
$cachedir = PGDIR.$name.'/';
|
||||||
$cachefile = $name.'-'.$page.'.pdf';
|
$cachefile = $name.'-'.$page.'.pdf';
|
||||||
$fullcachefile = $cachedir.$cachefile;
|
$fullcachefile = $cachedir.$cachefile;
|
||||||
@@ -56,13 +60,13 @@ function pdfs_init($source, $page = 1){
|
|||||||
if (!is_dir($cachedir))
|
if (!is_dir($cachedir))
|
||||||
mkdir($cachedir);
|
mkdir($cachedir);
|
||||||
|
|
||||||
$cmd = "pdftk $source cat 1 output $fullcachefile";
|
$cmd = "pdftk $source cat $page output $fullcachefile";
|
||||||
shell_exec($cmd);
|
shell_exec($cmd);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_exists($fullcachefile))
|
if (file_exists($fullcachefile))
|
||||||
$result['pdfpgurl'] = PGURL.$name.'/'.$cachefile;
|
$result['pdfpgurl'] = PGPATH.$name.'/'.$cachefile;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script>
|
<script>
|
||||||
var pdfDoc = null,
|
var pdfDoc = null,
|
||||||
pageNum = <?=$pagenum?>,
|
pageNum = <?=$pagenum?>,
|
||||||
scale = <?=$scale?>,
|
scale = 1,
|
||||||
url = '<?=$pdfile?>',
|
url = '<?=$pdfile?>',
|
||||||
pageRendering = false,
|
pageRendering = false,
|
||||||
pageNumPending = null,
|
pageNumPending = null,
|
||||||
@@ -11,10 +11,10 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<p id="downloadtitle">
|
<p id="downloadtitle">
|
||||||
<?if ($filedown):?>
|
<?if ($promo):?>
|
||||||
<a href="<?=$fullpdf?>"><?=$downtitle?></a><span id="downarrow">↑</span>
|
|
||||||
<?else:?>
|
|
||||||
<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:?>
|
||||||
|
<a href="<?=$fullpdf?>"><?=$downtitle?></a><span id="downarrow">↑</span>
|
||||||
<?endif?>
|
<?endif?>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
@@ -33,6 +33,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="pagenav">
|
<div id="pagenav">
|
||||||
|
|
||||||
<?if (isset($prevurl)):?>
|
<?if (isset($prevurl)):?>
|
||||||
<div class="firstpage">
|
<div class="firstpage">
|
||||||
<a href="<?=$baseurl?>">
|
<a href="<?=$baseurl?>">
|
||||||
@@ -41,10 +42,17 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="navpage"><a href="<?=$prevurl?>"><i class="fas fa-chevron-circle-left"></i></a></div>
|
<div class="navpage"><a href="<?=$prevurl?>"><i class="fas fa-chevron-circle-left"></i></a></div>
|
||||||
<?endif?>
|
<?endif?>
|
||||||
|
|
||||||
<div id="currpage"><?=$page?></div>
|
<div id="currpage"><?=$page?></div>
|
||||||
|
|
||||||
<?if (isset($nexturl)):?>
|
<?if (isset($nexturl)):?>
|
||||||
<div class="navpage"><a href="<?=$nexturl?>"><i class="fas fa-chevron-circle-right"></i></a></div>
|
<div class="navpage"><a href="<?=$nexturl?>"><i class="fas fa-chevron-circle-right"></i></a></div>
|
||||||
|
<?if (isset($endurl)):?>
|
||||||
|
<div class="navpage"><a href="<?=$endurl?>"><i class="fas fa-angle-double-right"></i></a></div>
|
||||||
|
<?endif?>
|
||||||
<?endif?>
|
<?endif?>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -72,7 +80,7 @@
|
|||||||
<div id="currpage"><?=$page?></div>
|
<div id="currpage"><?=$page?></div>
|
||||||
<?if (isset($nexturl)):?>
|
<?if (isset($nexturl)):?>
|
||||||
<div class="navpage"><a href="<?=$nexturl?>"><i class="fas fa-chevron-circle-right"></i></a></div>
|
<div class="navpage"><a href="<?=$nexturl?>"><i class="fas fa-chevron-circle-right"></i></a></div>
|
||||||
<?endif?>
|
<?endif?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user