Просмотр файла modules/book/index.php

Размер файла: 7.39Kb
<?php
##############################
##	     WAP-ENGINE 	    ##
##############################
##						    ##
## Автор : CHUMA			##
## e-mail : [email protected]		##
## WAP : http://wapeng.info ##
## ICQ : 111-75-74			##
##                        	##
##############################
##  ВЫ НЕ ИМЕЕТЕ ПРАВО      ##
##  ИЗМЕНЯТЬ КОД СКРИПТА    ##
##  ДЛЯ ДАЛЬНЕЙШЕГО         ##
##  РАСПРОСТРАНЕНИЯ         ##
##############################
Error_Reporting(E_ALL & ~E_NOTICE);
Error_Reporting (ERROR | WARNING);

session_name("SESID");
session_start();

include "../../config.php"; # Подключаем настройки сайта. (config.php)
include "../../themes/$themes.php"; # Вставляем скин сайта.
include "../../templates/tr_to_win.php";
include "../../templates/win_to_tr.php";

$file1 = stripslashes($_GET[file]);
$file1 = htmlspecialchars($file1);
$file1 = str_replace('script','',$file1);
$file1 = str_replace('/','',$file1);
$kat = stripslashes($_GET[kat]);
$kat = htmlspecialchars($kat);
$kat = str_replace('.','',$kat);
$kat = str_replace('/','',$kat);

if ($_GET[file])
 {
  $file = explode(".","$file1");
  $filewin = tr_to_win($file[0]);
  echo "<p align=\"center\">$filewin</p>";
  
$text = implode("<br/>", file("$kat/$file1"));
$string_array = explode(" ", $text);  

$count = count($string_array);
$slov = 50;
if(!empty($_POST['slov']))
 {
  $post_slov = "$_POST[slov]";
  $slov = "$post_slov";
 }
if(!empty($_GET[slov]))
 {
  $slov = "$_GET[slov]";
 }
if($slov > 9999)
 {
  $slov = "9999";
 }
$stranic = ceil($count/$slov);

if(empty($_GET["page"]))
 {
  $page_get = 1;
 }
  else
 {
  $page_get = "$_GET[page]";
  $page_get = trim($page_get);
  $page_get = stripslashes($page_get);
  $page_get = htmlspecialchars($page_get);
  $page_get = intval($page_get);
  $page_get = "$page_get";
 }
 
$do = $slov * ($page_get - 1);
$end = $slov * $page_get;

$page_nazad = $page_get - 1;
$page_dalee = $page_get + 1;

echo "<p class=\"b\">";
if ($page_get < 0 | $page_get > $stranic | !eregi("([0-9])", "$page_get"))
 {
  echo "Данной страницы несуществует!";
 }
for ($i = $do; $i < $end; $i++)
 {
  if (!empty($string_array[$i]))
   {
    echo "$string_array[$i] ";
   }
 }
echo "</p>";

echo "<p align=\"center\" class=\"d\">";
if($page_get > 1)
 {
  echo "<a href=\"index.php?page=$page_nazad&amp;file=$file1&amp;kat=$kat&amp;view=2&amp;slov=$slov\">Назад</a>";
 }
echo "|";
if($stranic > $page_get)
 {
  echo "<a href=\"index.php?page=$page_dalee&amp;file=$file1&amp;kat=$kat&amp;view=2&amp;slov=$slov\">Дальше</a>";
 } 
echo "<br/>Страница:$page_get<br/>"; 
echo "Всего страниц:$stranic<br/>";
if($page_get > 1)
 {
  echo "<a href=\"index.php?page=1&amp;file=$file1&amp;kat=$kat&amp;view=2&amp;slov=$slov\">В начало</a>";
 }
echo "|";
if($stranic > $page_get)
 {
  echo "<a href=\"index.php?page=$stranic&amp;file=$file1&amp;kat=$kat&amp;view=2&amp;slov=$slov\">В конец</a><br/>";
 }
echo "</p>";

echo "<form action=\"index.php\" method=\"get\">";
echo "<p align=\"center\" style=\"border:2px solid #000000;\">";
echo "На страницу<br/>
      <input type=\"text\" name=\"page\" size=\"3\" maxlength=\"3\" value=\"\" /><br/>
      <input type=\"hidden\" name=\"file\" value=\"$file1\" />
      <input type=\"hidden\" name=\"kat\" value=\"$kat\" />
      <input type=\"hidden\" name=\"view\" value=\"2\" />
      <input type=\"hidden\" name=\"slov\" value=\"$slov\" />
      <input type=\"submit\" value=\"Перейти\" />";
echo "</p>";
echo "</form>";

if($page_get == 1)
 {
  echo "<form action=\"index.php?file=$file1&amp;kat=$kat&amp;view=2\" method=\"post\">";
  echo "<p align=\"center\" style=\"border:2px solid #000000;\">";
  echo "Слов на страницу<br/>
       <input type=\"text\" name=\"slov\" size=\"3\" maxlength=\"4\" value=\"\" /><br/>
       <input type=\"submit\" value=\"OK\" />";
  echo "</p>";
  echo "</form>";
 }

  $katwin = tr_to_win($kat);
  echo "<p><a href=\"index.php?kat=$kat&amp;view=1\">В $katwin</a></p>";
 }  
 
 if ($_GET[view] == 1)
 { 
   $katwin = tr_to_win($kat);
   echo "<p align=\"center\">$katwin</p>";
   echo "<p class=\"b\" align=\"center\">Сортировка книг<br/>
         <a href=\"index.php?sort=alfa&amp;kat=$kat&amp;view=1\">По алфавиту</a><br/>
         <a href=\"index.php?sort=data&amp;kat=$kat&amp;view=1\">По дате добавления книги</a>
         </p>";
   echo "<p  align=\"center\">Список книг</p>";
         
   $dir = opendir ("$kat");
   while ( $file = readdir ($dir))
    {
     if ($file != "." && $file != ".." && $file != ".htaccess" && $file != "index.php")
      {
        if($_GET[sort] == "alfa" || empty($_GET[sort]))
         {
          $file = tr_to_win($file);
          $files[] = "$file"; 
         }
          elseif($_GET[sort] == "data")
         {
          $files[] = "".date ("YmdHis", filemtime("$kat/$file"))."||$file"; 
         }  
      }
    }
    
   if($_GET[sort] == "alfa" || empty($_GET[sort]))
    {
     sort($files);
    }
   if($_GET[sort] == "data")
    {
     rsort($files);
    }
    
   $count_files = count($files);
   $knig = 15;
   $stranic = ceil($count_files/$knig);

   if(empty($_GET["page"]))
    {
     $page_get = 1;
    }
     else
    {
     $page_get = "$_GET[page]";
     $page_get = trim($page_get);
     $page_get = stripslashes($page_get);
     $page_get = htmlspecialchars($page_get);
	 $page_get = intval($page_get);
     $page_get = "$page_get";
    }
 
   $do = $knig * ($page_get - 1);
   $end = $knig * $page_get;

   $page_nazad = $page_get - 1;
   $page_dalee = $page_get + 1;
   
   for($i = $do; $i < $end; $i++)
    {
     $file = "$files[$i]";
     if(!empty($file))
      {
       if($_GET[sort] == "data")
        {
         $file = explode("||","$file");
         $file = $file[1];
        }
       if($_GET[sort] == "alfa" || empty($_GET[sort]))
        {
         $file = win_to_tr($file);
        }
       $fil = explode(".","$file");
       $filewin = tr_to_win($fil[0]);
       echo "<p class=\"b\"><a href=\"index.php?file=$file&amp;kat=$kat&amp;view=2\">$filewin</a></p>";
      }
    }
   
   if($count_files > $knig)
   { 
   echo "<p align=\"center\" class=\"d\">";
   if($page_get > 1)
    {
     echo "<a href=\"index.php?page=$page_nazad&amp;kat=$kat&amp;view=1&amp;sort=$_GET[sort]\">Назад</a>";
    }
   echo "|";
   if($stranic > $page_get)
    {
     echo "<a href=\"index.php?page=$page_dalee&amp;kat=$kat&amp;view=1&amp;sort=$_GET[sort]\">Дальше</a>";
    } 
   echo "</p>";
   }
    
   echo "<p>В категории $count_files книг</p>";
   echo "<p><a href=\"./\">К категориям</a><br/><br/></p>";
 }
 
 if(empty($_GET[view]))
 {
  echo "<p align=\"center\">Библиотека</p>";
  echo "<p>Категории</p>";
   $dir = opendir (".");
   while ( $file = readdir ($dir))
    {
     if (( $file != ".") && ($file != "..") && ($file != ".htaccess") && ($file != "index.php"))
      {
       $filewin = tr_to_win($file);
       echo "<p class=\"b\"><a href=\"index.php?kat=$file&amp;view=1\">$filewin</a></p>";
      }
    }
 }



include ("../../templates/foot.php");
?>