File size: 4.16Kb
<?php
include "cfg.php";
include "unzip.lib.php";
////////////////////FILE SIZE////////////////////////
$total = 0;
$bid = $_GET['book_id'];
$bidt = "$bid.zip";
$total = $total + filesize($bidt);
/////////////////////////////////////////////////////
$p = $_GET['p'];
$filename = $_GET['book_id'].'.zip';
if (@function_exists('gzinflate')) {
$import_handle = new SimpleUnzip(); // zip-...
$import_handle->ReadFile($filename);
if ($import_handle->Count() == 0) { // ...
die(" !");
} elseif ($import_handle->GetError(0) != 0) {
die(" .");
} else {
$unzipped_text = $import_handle->GetData(0); // . .
}
$import_handle = ''; // . ...
} else {
die(" !"); // gzinflate
}
header("Content-type: text/html;charset=utf-8");
$ret = '<html><head><title>WAPrus.Org-BOOKS</title><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body bgcolor="#ffffff" link="#D82021" vlink="#D82021" alink="#FF0000"><font face="Arial" size="2"><img src="librar.gif" alt="librar" border=0><br/>';if(!isset($_GET['chars']) || empty($_GET['chars'])){
$ret .= '<form action="zip_read.php" method="get">
<select name="chars" value="1" title="Выбор">
<option value="1">500</option><option value="2">800</option>
<option value="3">1000</option><option value="4">1600</option>
<option value="5">2100</option><option value="6">8000</option></select><br/>
<input type="hidden" name="book_id" value="'.$_GET['book_id'].'"/>
<input type="submit" value="Выбор"></form><br/>
<img src="line.gif" alt="---" border=0><br/>';
} else {
if (file_exists($filename)) // ...
{
if(!isset($_GET['p']))$p=1; else $p = $_GET['p'];
if($_GET['chars']==1) $five=500;
elseif($_GET['chars']==2) $five=800;
elseif($_GET['chars']==3) $five=1000;
elseif($_GET['chars']==4) $five=1600;
elseif($_GET['chars']==5) $five=2100;
elseif($_GET['chars']==6) $five=8000;
else $five=500; // - , 500
$unzipped_text = htmlspecialchars($unzipped_text);
$unzipped_text = str_replace("\n","<br/>",$unzipped_text);
$size=strlen($unzipped_text);
$obsum = $p * $five;
$nasum = $obsum - $five;
$end='0';
if(!isset($_GET['go']))
{
for($i=$nasum; $i<$obsum; $i++)
{
if(!isset($unzipped_text[$i])) $end='1'; else $ret .=$unzipped_text[$i];
}
$ret .= "<br/>\n";
if($p>=1) $ret .= '<a href="zip_read.php?book_id='.$_GET['book_id'].'&p='.($p-1)."&chars=".$_GET['chars']."\"><<</a> | "; else {$ret .= ' << ';}
if($p==0) $ret .= '|<a href="zip_read.php?book_id='.$_GET['book_id'].'&p='.($p+1)."&chars=".$_GET['chars']."\">>></a>"; else {$ret .= '';}
if($p>=1) $ret .= '<a href="zip_read.php?book_id='.$_GET['book_id'].'&p='.($p+1)."&chars=".$_GET['chars']."\">>></a>"; else {$ret .= '>>';}
////////////////////////////
//$ret .= ' |>> '; else {$ret .= '<a href="zip_read.php?book_id='.$_GET['book_id'].'&p='.($p-1)."&chars=".$_GET['chars']."\"></a> | ";}
//$ret .= '<<'; else {$ret .= '<a href="zip_read.php?book_id='.$_GET['book_id'].'&p='.($p+1)."&chars=".$_GET['chars']."\"></a>";}
////////////////////////////
$ret .= '<br/><a href="zip_read.php?go=1&chars='.$_GET['chars'].'&book_id='.$_GET['book_id']."\"></a>\n";
$ret .= '<br/><a href="zip_read.php?book_id='.$_GET['book_id']."&chars=".$_GET['chars']."\"> </a>\n";
if($allow_download==1) $ret .= "<br/><b>[+]</b> <a href=\"./".$_GET['book_id'].".zip\">Скачать ZIP</a> ($total bytes)\n";
$ret .= "<br/><img src=\"./line.gif\" alt=\"---\" border=0><br/><a href=\"index.php\"></a>\n";
$ret .= "<br/><a href=\"$main_url\">WAPrus.Org</a>\n";
}
else $ret .='
1 '.(ceil(strlen($unzipped_text)/$five)).'<br/><input name="code" format="*N" maxlength="10" title="code"/>
<anchor title="go"><go href="zip_read.php" method="get">
<postfield name="p" value="$(code)"/>
<postfield name="book_id" value="'.$_GET['book_id'].'"/>
<postfield name="chars" value="'.$_GET['chars'].'"/>
</go></anchor>';
}
}
$ret .= "\n</font></body></html>";
if(@function_exists('iconv')){ // iconv, utf-8
echo iconv('WINDOWS-1251','UTF-8',$ret);
}else{// , &xxxx;
include "utf.php";
echo utf($ret);// ...
}
?>