57 lines
940 B
PHP
57 lines
940 B
PHP
<?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)){
|
|
return '';
|
|
}
|
|
|
|
$xhtml = file_get_contents($xfile);
|
|
|
|
$result = str_replace('</body>', '', $xhtml);
|
|
$result = str_replace('</html>', '', $xhtml);
|
|
|
|
if ($pos = strpos('<body', $result)){
|
|
$result = substr($result, $pos+1);
|
|
}
|
|
|
|
return $result;
|
|
|
|
} |