📄 pt.php
字号:
<?php## pt.php (c) 2006 Michael Thompson lMaker@michaelthompson.org# for the latest info visit http://michaelthompson.org/doc/## This program is free software; you can redistribute it and/or# modify it under the terms of the GNU General Public License# as published by the Free Software Foundation; either version 2# of the License, or (at your option) any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program; if not, write to the Free Software# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.#if( isset($book) ) { $base=$_SERVER["PHP_SELF"]; @include(".pt-config"); if( !isset($skip) ) $skip = 0; if( !isset($shelf) ) $shelf="."; if( !isset($chapterMarker) ) $chapterMarker="c"; if( !isset($extBook) ) $extBook=".txt"; if( !isset($extIndex) ) $extIndex=".lis"; if( !isset($chapter) ) $chapter=0; if( !isset($page) ) $page=0; if( !isset($lpp) ) $lpp=24; if( !isset($noprevSymbol) ) $noprevSymbol="_x_"; if( !isset($prevSymbol) ) $prevSymbol="<="; if( !isset($nextSymbol) ) $nextSymbol="=>"; if( !isset($firstSymbol) ) $firstSymbol="1"; if( !isset($lastSymbol) ) $lastSymbol="N"; setcookie("bookMark-$book","$chapter|$page", time()+3600*24*180,"/","." . $_SERVER["HTTP_HOST"]); if( isset($x) ) { $dex = "$shelf/$book$extIndex"; if( is_file($dex) && ($fh=@fopen($dex,"r")) ) { # return list of chapters $buff = ""; $n = 0; while( !feof($fh) ) { $line=trim(fgets($fh)); if( strlen($line)<1 ) continue; if( strlen($title)<1 ) { $title = $line; continue; } if( strlen($author)<1 ) { $author = $line; continue; } if( $n==$chapter ) { $line = "$prefixCurrentChapter$line$suffixCurrentChapter"; } $buff .= <<<END$prefixChapter<a href="#" onClick="fillPage('$base','$book','$n','0','chaps');">$line</a>$suffixChapterEND; $n++; } fclose($fh); $fh = null; $buff = "$title|$author|" . $buff; echo substr("$buff",$skip); } } elseif( isset($y) ) { $pLnk = "$noprevSymbol"; $next_page = $page + 1; $prev_chapter = $next_chapter = $chapter; if( $page=="last" ) { $tex = "$shelf/$book$chapterMarker$chapter$extBook"; if( ($fh=@fopen($tex,"r")) ) { $n = 0; while( !feof($fh) ) { fgets($fh); $n++; } $page = ceil($n/$lpp); fclose($fh); } $next_page = 0; $next_chapter = $chapter + 1; } if( ($prev_page=$page-1)<0 ) { $prev_page = "last"; $prev_chapter = $chapter - 1; } $tex = "$shelf/$book$chapterMarker$next_chapter$extBook"; if( !is_file($tex) ) { $next_chapter = $chapter; $next_page = "last"; } $prev_div = (($prev_chapter==$chapter)?"navbar":"chaps"); $next_div = (($next_chapter==$chapter)?"navbar":"chaps"); if( $prev_chapter>=0 ) $pLnk = <<<END<a href="#" onClick="fillPage('$base','$book','$prev_chapter','$prev_page','$prev_div');">$prevSymbol</a>END; $nLnk=<<<END<a href="#" onClick="fillPage('$base','$book','$next_chapter','$next_page','$next_div');">$nextSymbol</a>END; $fLnk=<<<END<a href="#" onClick="fillPage('$base','$book','$chapter','0','navbar');">$firstSymbol</a>END; $lLnk=<<<END<a href="#" onClick="fillPage('$base','$book','$chapter','last','navbar');">$lastSymbol</a>END; $buff = str_replace("_PLNK_","$pLnk",$navBar); $buff = str_replace("_NLNK_","$nLnk",$buff); $buff = str_replace("_1LNK_","$fLnk",$buff); $buff = str_replace("_LLNK_","$lLnk",$buff); echo substr("$buff",$skip); } else { $thePage = ""; $lines = 0; $uchap = $chapter; do { $tex = "$shelf/$book$chapterMarker$uchap$extBook"; if( !is_file($tex) || !($fh=@fopen($tex,"r")) ) break; if( $uchap!=$chapter ) { $thePage="__NEXT__"; break; } # skip ahead to my page? $onPage=0; if( $page>0 || $page=="last" ) { $n=0; $ar = array(); while( !feof($fh) ) { $ar[]= $prefixLine . trim(fgets($fh)) . $suffixLine; if( count($ar)>$lpp ) array_shift($ar); $n++; if( $n>=$lpp ) { $n = 0; $onPage++; if( $page==$onPage ) break; } } $lastPage = implode($ar); if( $page=="last" ) break; } $n=0; while( !feof($fh) ) { $buff = trim(fgets($fh)); $lines += strlen($buff); $thePage .= $prefixLine . $buff . $suffixLine; $n++; if( $n>=$lpp ) break; } $uchap++; } while( $lines==0 ); if( $fh ) fclose($fh); if( strlen($thePage)<1 ) $thePage = $lastPage; if( $thePage!="__NEXT__" ) $thePage = $prefixPage . $thePage . $suffixPage; $buff = $thePage; echo substr("$buff",$skip); }}?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -