add readbook

This commit is contained in:
Andrey Kuvshinov
2020-05-24 17:10:45 +03:00
parent 02b7d3f8fa
commit d91466c5d9
4 changed files with 37 additions and 17 deletions

View File

@@ -5,7 +5,7 @@ function api_pricehash($hash){
$pricesql = " $pricesql = "
SELECT SELECT
`price_id`, `pricename`, `BeginDate`, `category_id`, `pages` `price_id`, `pricename`, `BeginDate`, `category_id`, `pages`, `pdf`, `html`
FROM FROM
`price` `price`
WHERE WHERE

View File

@@ -12,10 +12,13 @@ if (isset($_SERVER['HTTP_HOST']))
else else
define('SITEPATH', dirname(__FILE__)); define('SITEPATH', dirname(__FILE__));
if (SITE == 'http://klan.argumenti.ru/') if (SITE == 'http://klan.argumenti.ru/'){
define('PDFSOURCE', '/vhosts/an/httpdocs/pub/files/pdf/pdf/'); define('PDFSOURCE', '/vhosts/an/httpdocs/pub/files/pdf/pdf/');
else define('HTMLSOURCE', '/vhosts/an/httpdocs/pub/files/html/');
define('PDFSOURCE', SITEPATH.'pub/source/'); }
else {
define('PDFSOURCE', SITEPATH.'pub/source/');
}
define('PDFPATH', '/pub/files/pdf/'); define('PDFPATH', '/pub/files/pdf/');
define('PGPATH', '/pub/files/pages/'); define('PGPATH', '/pub/files/pages/');

View File

@@ -40,6 +40,7 @@ function endparagraf($html, $pos){
function convert2html($xfile){ function convert2html($xfile){
if (!file_exists($xfile)){ if (!file_exists($xfile)){
echo 'file not found';
return ''; return '';
} }
@@ -48,8 +49,10 @@ function convert2html($xfile){
$result = str_replace('</body>', '', $xhtml); $result = str_replace('</body>', '', $xhtml);
$result = str_replace('</html>', '', $xhtml); $result = str_replace('</html>', '', $xhtml);
//$start_style =(strpos('<style>', $result))
if ($pos = strpos('<body', $result)){ if ($pos = strpos('<body', $result)){
$result = substr($result, $pos+1); $result = substr($result, $pos-1);
} }
return $result; return $result;

View File

@@ -225,6 +225,11 @@ function read_kuri($hash, $page = 0, $promo = false, $version = null){
} }
if ($price['html'] = '.html'){
return readbook_kuri($hash, $page = 1);
}
if ($version == null){ if ($version == null){
$detect = new Mobile_Detect; $detect = new Mobile_Detect;
@@ -312,11 +317,6 @@ function readtext_kuri($hash, $page = 1, $promo = 'no'){
$baseurl = '/readtext/'.$hash.'/'; $baseurl = '/readtext/'.$hash.'/';
$endurl = "$baseurl$count"; $endurl = "$baseurl$count";
$title = $price['pricename']; $title = $price['pricename'];
$newcurr = strtotime($price['BeginDate']); $newcurr = strtotime($price['BeginDate']);
$full_ver_url = SITE."read/$hash/$page/$promo/pdf"; $full_ver_url = SITE."read/$hash/$page/$promo/pdf";
@@ -389,20 +389,35 @@ function initpageurls($page, $count, $baseurl){
function epub_kuri($page = 1){ function readbook_kuri($hash, $page = 1){
require (APPPATH.'functions/xhtmltransform.php'); require (APPPATH.'functions/xhtmltransform.php');
$dir = APPPATH.'pub/ops/';
$price = api_pricehash($hash);
if (!isset($price['price_id'])){
return 'page not found';
}
$file = HTMLSOURCE.$price['price_id'].'.'.$price['html'];
$limit = 4000; $limit = 4000;
$count = 20; $count = 20;
$htmlfile = APPPATH.'pub/html/furer.html';
$html = convert2html($dir.'toc.xhtml'); $html = convert2html($htmlfile);
$html .= convert2html($dir.'chapter-1.xhtml'); $razmer = strlen($html);
$count = $razmer / $limit;
// $html .= convert2html($dir.'chapter-1.xhtml');
$pagehtml = pagehtml($html, $page, $limit); $pagehtml = pagehtml($html, $page, $limit);
$baseurl = SITE.'/epub/'; $baseurl = SITE.'/readbook/'.$hash.'/';
$endurl = $baseurl.$count; $endurl = $baseurl.$count;
$nextpage = $page + 1; $nextpage = $page + 1;
@@ -411,8 +426,7 @@ function epub_kuri($page = 1){
$prevpage = $page - 1; $prevpage = $page - 1;
$prevurl = $baseurl.$prevpage; $prevurl = $baseurl.$prevpage;
$title = 'Млечин - Тайна фюрера'; $title = $price['pricename'];
$tempcontent = VIEWPATH.'epub.phtml'; //подшаблон $tempcontent = VIEWPATH.'epub.phtml'; //подшаблон
include VIEWPATH.'layout.phtml'; //центральный шаблон include VIEWPATH.'layout.phtml'; //центральный шаблон