Files
anpdf/app/functions/xhtmltransform.php

60 lines
1021 B
PHP
Raw Permalink Normal View History

2020-05-23 23:22:21 +03:00
<?php
function pagehtml($html, $page, $limit){
if ($page == 1){
$start = $limit;
$rstart = 0;
}
else {
$prevpage = $page - 1;
$start = $prevpage * $limit;
$r_start = endparagraf($html, $start);
}
$endpos = $page * $limit;
$r_end = endparagraf($html, $endpos);
$len = $r_end - $r_start;
return substr($html, $r_start, $len);
}
function endparagraf($html, $pos){
$end = strpos($html, '</p>', $pos);
if ($end)
return $end;
else
return false;
}
//удаляем xtml
function convert2html($xfile){
if (!file_exists($xfile)){
2020-05-24 17:10:45 +03:00
echo 'file not found';
2020-05-23 23:22:21 +03:00
return '';
}
$xhtml = file_get_contents($xfile);
$result = str_replace('</body>', '', $xhtml);
$result = str_replace('</html>', '', $xhtml);
2020-05-24 17:10:45 +03:00
//$start_style =(strpos('<style>', $result))
2020-05-23 23:22:21 +03:00
if ($pos = strpos('<body', $result)){
2020-05-24 17:10:45 +03:00
$result = substr($result, $pos-1);
2020-05-23 23:22:21 +03:00
}
return $result;
}