Files
anpdf/app/routes/anpdf.php
Andrey Kuvshinov 42af8d196d add save zoom
2020-05-13 01:15:18 +03:00

237 lines
5.7 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
function anpromo_kuri($page = 1, $scale = 1){
// $pdfile = 'https://argumenti.ru/templinks/md5files/f9598f88e667146d50d106eeedbd74c1.pdf';
$namefile = 'promo.pdf';
$title = 'Номер 12(706)';
$newcurr = strtotime('2006-05-12');
$file = SITEPATH.'pub/files/source/742.pdf';
$data = pdfs_init($file, $page);
$pdfile = SITE.$data['pdfpgurl'];
$fullpdf = $data['pdfurl'];
$baseurl = "/anpromo/";
$pagenum = 1;
$nextpage = $page + 1;
$filedown = True;
if ($data['count'] > $nextpage){
$nexturl = "$baseurl$nextpage";
}
else {
$nexturl = '';
}
if ($page > 1) {
$prevpage = $page - 1;
$prevurl = "$baseurl$prevpage";
}
$downtitle = 'Если по какой-то причине у вас не загрузилась страница ниже, то нажмите сюда, чтобы скачать pdf';
$tempcontent = VIEWPATH.'anpdf2.phtml'; //подшаблон
include VIEWPATH.'layout.phtml'; //центральный шаблон
}
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");
if (!isset($price['price_id'])){
header("HTTP/1.0 404 Not Found");
echo "file not found";
return False;
}
$file = SITEPATH.'pub/files/source/742.pdf';
$namefile = $hash.'.pdf';
$basepg = PGDIR.$hash.'/'.$hash.'-';
$pgfile = $basepg.$page.'.pdf';
$cachefile = PDFDIR.$namefile;
$newcurr = strtotime($price['BeginDate']);
if (file_exists($cachefile)){
$fullpdf = '/pdf/'.$namefile;
}
else {
$fullpdf = '/file/'.$hash;
}
if (file_exists($pgfile)){
$pdfile = '/pages/'.$hash.'/'.$hash.'-'.$page.'.pdf';
$pagenum = 1;
}
if ($page > 1 or $promo){
$fullpdf = $pdfile;
$downtitle = 'Если по какой-то причине у вас не загрузилась страница ниже, то нажмите сюда, чтобы скачать pdf';
}
else {
$downtitle = 'Если по какой-то причине у вас не загрузилось издание ниже, то нажмите сюда, чтобы скачать pdf';
}
$id = $price['price_id'];
$title = $price['pricename'];
if ($promo){
$filedown = True;
$baseurl = "/promo/$hash/";
}
else {
$filedown = True;
$baseurl = "/read/$hash/";
}
$nextpage = $page + 1;
if (file_exists($basepg.$nextpage.'.pdf')){
$nexturl = "$baseurl$nextpage";
}
if ($page > 1) {
$prevpage = $page - 1;
$prevurl = "$baseurl$prevpage";
}
$tempcontent = VIEWPATH.'anpdf2.phtml'; //подшаблон
include VIEWPATH.'layout.phtml'; //центральный шаблон
}
function text_kuri(){
$id = 659286;
$news = file_get_contents(API.'id/'.$id);
print_r($news);
$tempcontent = VIEWPATH.'anpdf.phtml';
include VIEWPATH.'layout.phtml';
//view( 'views/antext.phtml',['news'=> $news] );
}
function promo_kuri($hash, $page = 1, $promo = 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");
if (!isset($price['price_id'])){
header("HTTP/1.0 404 Not Found");
echo "file not found";
return False;
}
$file = PDFSOURCE."${price['price_id']}.pdf";
$data = pdfs_init($file, $page);
$pdfile = $data['pdfpgurl'];
$fullpdf = $data['pdfurl'];
$count = $data['count'];
$pagenum = 1;
$newcurr = strtotime($price['BeginDate']);
if ($promo){
$filedown = True;
$baseurl = "/promo/$hash/";
}
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'; //центральный шаблон
}
function pdfscan_kuri(){
$pdfsql = "SELECT price_id, pricehash FROM price WHERE category_id = 1";
$path = '~/vhosts/anpdf/pub/files/pages/';
echo exec('whoami');
$pdfs = dbl_get($pdfsql);
foreach($pdfs as $pdf){
$pagedir = $path.$pdf['pricehash'];
if(!is_dir($pagedir)) {
mkdir($pagedir);
$cmd = 'docker run --name pdftk -it --rm \
--user $(id -u):$(id -g) \
-v "$PDFDIR:/workdir/pdf" \
-v "$OUTDIR:/workdir/pages" \
-w "/workdir" \
masterforweb/pdftk pdftk "pdf/$file" burst output "pages/${name}/${name}-%1d.pdf';
}
}
}