File size: 6.88Kb
<?
/////////// Powered by Giga!!! /////////
/////////// http://gwap.net.ru /////////
/////////// [email protected] /////////
Error_Reporting(E_ALL & ~E_NOTICE);
include 'fig.php';
$head ="<?xml version=\"1.0\" encoding=\"utf-8\"?>
<!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.0//EN\" \"http://www.wapforum.org/DTD/xhtml-mobile10.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"ru\">
<head>
<title>$title</title>
<meta http-equiv=\"Content-Type\" content=\"application/vnd.wap.xhtml+xml; charset=UTF-8\" />
<meta http-equiv=\"Pragma\" content=\"no-cache\" />
<link rel=\"stylesheet\" href=\"./style.css\" type=\"text/css\" />
</head>
<body>";
$end ='</body></html>';
if (!$act)
{
echo $head;
echo "<div class=\"l\">";
echo "<div class=\"top\"><b>$topot</b></div>";
echo '<div class="c">';
$basesd="sd.txt";
$num_sep =20;
$preview="$basesd";
$preview = file($preview);
$count = count($preview);
if ($count>$num_sep) nav_page(ceil($count/$num_sep),(isset($HTTP_GET_VARS['page']) ? $HTTP_GET_VARS['page']: 1),"index.php?page=");
$num_page=1;
if (isset($HTTP_GET_VARS['page'])) {
if (($HTTP_GET_VARS['page']>0) and ($HTTP_GET_VARS['page']<=ceil($count/$num_sep))) $num_page=$HTTP_GET_VARS['page'];
}
for ( $i=($num_page-1)*$num_sep; $i<=(($num_page*$num_sep<$count) ? $num_page*$num_sep-1: $count-1); $i++)
{
$nomer =$i+1;
$oss = file("$basesd");
$selectsd = explode("|", $oss[$i]);
echo "<a href=\"index.php?act=sd&sd=sd$nomer\">";
echo "$selectsd[1]</a><br />$selectsd[2]<br />";
$sdir = opendir ("text/sd$nomer/");
$file_array = array();
while ($file = readdir ($sdir))
{
if(substr($file,0,1) != '.' and $file != "..")
{
$file_array[] = $file;
}
}
$file_count = count ($file_array);
echo "всего: $file_count<br />";
closedir ($sdir);
}
if ($count>$num_sep) nav_page(ceil($count/$num_sep),(isset($HTTP_GET_VARS['page']) ? $HTTP_GET_VARS['page']: 1),"index.php?page=");
echo "<br />разделов: $count<br />";
echo "</div>";
echo "<div class=\"top\"><a href=\"http://$home\">$home</a></div>";
echo "</div>";
echo $end;
}
if($act=="sd")
{
echo $head;
echo "<div class=\"l\">";
echo "<div class=\"top\"><b>$topot</b></div>";
$conf["items_per_page"] = $sdlist;
if (!isset($page)) {$page = 0;}
$total = 0;
if(!($dp = opendir("text/$sd"))) die ("Ошибка открытия папки ./");
$file_array = array();
while ($file = readdir ($dp))
{
if(substr($file,0,1) != '.' and $file != "..")
{
$file_array[] = $file;
}
}
$file_count = count ($file_array);
sort ($file_array);
if ($file_count == 0)
{
echo 'В разделе пока нет файлов, зайдите позже.<br />';
}
if ($file_count > 0)
{
$first_record = $page * $conf["items_per_page"];
$last_record = $first_record + $conf["items_per_page"];
while (list($fileIndexValue, $file_name) = each ($file_array))
{
if (($fileIndexValue >= $first_record) AND ($fileIndexValue < $last_record))
{
$datafiles = "text/$sd/$file_name";
$dataname = file("$datafiles");
$filename = trim($dataname[0]);
$fileopis = trim($dataname[1]);
$fileopis = "<br />$fileopis";
$file_name = str_replace('.txt','',$file_name);
echo "<a href=\"index.php?act=view&d=$sd&f=$file_name\">$filename</a>$fileopis<br/>";
}
}
if (($file_count > 0) AND ($page != 0))
{
$prev_page = $page -1;
echo "<br /><a href=\"".$_SERVER["PHP_SELF"]."?act=sd&sd=sd1&page=$prev_page\">назад</a><br/>";
}
if (($file_count > 0) AND ($last_record < $file_count))
{
$next_page = $page + 1;
echo "<br/><a href=\"".$_SERVER["PHP_SELF"]."?act=sd&sd=sd1&page=$next_page\">далее</a><br/>";
}
echo "<br />Всего $file_count ";
}
closedir($dp);
echo '<br /><a href="./">к разделам</a><br />';
echo "<div class=\"top\"><a href=\"http://$home\">$home</a></div>";
echo "</div>";
echo $end;
}
if ($act=="view")
{
echo $head;
echo "<div class=\"top\"><b>$topot</b></div>";
$text= "text/$d/$f.txt";
$text = file($text);
echo '<div class="c">';
function nav_page($count, $num_page, $url)
{
$page_nav = 3;
$begin_loop=1;
$end_loop=$count;
echo " Страница $num_page из $count<br />";
if ($num_page>$count or $num_page<1) $num_page=1;
if ($num_page>$page_nav) {
echo " <a href=\"$url".($page_nav*(floor($num_page/$page_nav)-($num_page%$page_nav==0 ? 1: 0)))."\">".($page_nav*(floor($num_page/$page_nav)-1-($num_page%$page_nav==0 ? 1: 0))+1)."-".($page_nav*(floor($num_page/$page_nav)-($num_page%$page_nav==0 ? 1: 0)))."</a> ...";
$begin_loop=$page_nav*(floor($num_page/$page_nav)-($num_page%$page_nav==0 ? 1: 0))+1;
}
if ($count>$page_nav*(floor($num_page/$page_nav)-($num_page%$page_nav==0 ? 1: 0)+1)) { $end_loop=$page_nav*ceil($num_page/$page_nav); }
for ($i = $begin_loop; $i <= $end_loop; $i++) {
if ($i==$num_page) echo " <b>$i</b>";
else echo " <a href=\"$url$i\">$i</a>";
}
if ($count>$page_nav*(floor($num_page/$page_nav)-($num_page%$page_nav==0 ? 1: 0)+1)) {
echo " ... <a href=\"$url".($page_nav*ceil($num_page/$page_nav)+1)."\">".($page_nav*ceil($num_page/$page_nav)+1);
if ($page_nav*ceil($num_page/$page_nav)+1<$count) {
echo "-".($count<=$page_nav*(ceil($num_page/$page_nav)+1) ? $count: $page_nav*(ceil($num_page/$page_nav)+1));
}
echo "</a><hr />";
}}
$count = count($text);
if ($count>$num_sep) nav_page(ceil($count/$num_sep),(isset($HTTP_GET_VARS['page']) ? $HTTP_GET_VARS['page']: 1),"index.php?act=view&d=$d&f=$f&page=");
$num_page=1;
if (isset($HTTP_GET_VARS['page'])) {
if (($HTTP_GET_VARS['page']>0) and ($HTTP_GET_VARS['page']<=ceil($count/$num_sep))) $num_page=$HTTP_GET_VARS['page'];
}
for ( $i=($num_page-1)*$num_sep; $i<=(($num_page*$num_sep<$count) ? $num_page*$num_sep-1: $count-1); $i++) {
echo "$text[$i]<br />";
}
echo '<div class="c">';
if ($count>$num_sep) nav_page(ceil($count/$num_sep),(isset($HTTP_GET_VARS['page']) ? $HTTP_GET_VARS['page']: 1),"index.php?act=view&d=$d&f=$f&page=");
echo "<form action=\"index.php\" metod=\"post\">
<input type=\"hidden\" name=\"act\" value=\"view\" />
<input type=\"hidden\" name=\"d\" value=\"$d\" />
<input type=\"hidden\" name=\"f\" value=\"$f\" />
<input type=\"text\" size=\"3\" name=\"page\" value=\"\" />
<input value=\"GO\" name=\"do\" type=\"submit\" /></form>";
echo '</div>';
echo "<div class=\"c\"><a href=\"./\">библиотека</a></div>";
echo "<div class=\"top\"><a href=\"http://$home\">$home</a></div>";
echo "</div>";
echo '
</body>
</html>';
}
?>