View file wps_1.0/zagruzka/index.php

File size: 16.42Kb
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>sumbian  + java</title>
<LINK REL=STYLESHEET TYPE="text/css" HREF="../styles_z.css">
</head>

<body>
<?php

Error_Reporting(E_ALL & ~E_NOTICE);
Error_Reporting (ERROR | WARNING);


include ("../config.php");
include ("../tr_to_win.php");

function dir_kol($kat_kol)
 {  
  $dir_kol = opendir("$kat_kol"); 
 
  while($files_kol = readdir($dir_kol))
   { 
    if(is_file($kat_kol."/".$files_kol) && $files_kol != "Thumbs.db")
     { 
      $kol++;
     }
      elseif(is_dir($kat_kol."/".$files_kol) && $files_kol != "." && $files_kol != ".."  && $files_kol != "op")
     {
      $es = dir_kol($kat_kol."/".$files_kol);
      $kol = $kol + $es;
     }
   } 
  closedir($dir_kol);
  
  if(empty($kol))
   {
    $kol = 0;
   }
    else
   {
    $kol = $kol;
   }

  return"$kol";
 }

function dir_kol_new($kat_kol_new)
 {  
  $dir_kol_new = opendir("$kat_kol_new"); 
 
  while($files_kol_new = readdir($dir_kol_new))
   { 
    if(is_file($kat_kol_new."/".$files_kol_new) && $files_kol_new != "Thumbs.db")
     { 
      $datanew = date ("YmdHis", filemtime("$kat_kol_new/$files_kol_new")) + 5000000;
      $datenow = date ("YmdHis");
      if($datanew > $datenow)
       {
        $kol_new++;
       } 
     }
      elseif(is_dir($kat_kol_new."/".$files_kol_new) && $files_kol_new != "." && $files_kol_new != ".."  && $files_kol_new != "op")
     {
      $es_new = dir_kol_new($kat_kol_new."/".$files_kol_new);
      $kol_new = $kol_new + $es_new;
     }
   } 
  closedir($dir_kol_new);
  
  if(empty($kol_new))
   {
    $kol_new = 0;
   }
    else
   {
    $kol_new = $kol_new;
   }
  return"$kol_new";
 }

function dir_list ($kat)
 {
  include ("../../config.php");
  if(empty($kat))
   {
    $dir = ".";
   }
    else
   {
    $dir = stripslashes($kat);
   }
  if(ereg("^\.[-a-zA-Z0-9_\/\'\,\(\)!\@\=]*$", $kat))
   {
    $dir_kat = opendir ("$dir");
    $dir_file = opendir ("$dir");
    
     if($dir != ".")
      {
       $dir_exp = explode("/", "$dir");
       $dir_exp_count = count($dir_exp);
       
       echo"<p align=\"center\"><a href=\"index.php\">Загрузки</a>";
       
       for($i=1; $i < $dir_exp_count; $i++)
        {
         $dir_plus = "$dir_plus/$dir_exp[$i]";
         
         $file_win = "$dir_exp[$i]";
          
         if(ereg("(--[-a-zA-Z0-9_\'\,\(\)!\@]*--)", $dir_exp[$i], $replasement))
          {
           $zamena11 = str_replace("--", "", "$replasement[1]");
           $zamena = tr_to_win($zamena11);
           $file_win = str_replace("$replasement[1]", "$zamena", "$dir_exp[$i]");
          }
          
         $dir_use = str_replace("__", " ", "$file_win");
         $dir_use = ereg_replace("^[0-9]{0,2}[-]", "", $dir_use);
         
         if(".$dir_plus" == "$dir" && $_GET['view']==1)
          {
           echo" | <a href=\"index.php?kat=.$dir_plus\">$dir_use</a>";
          }
         elseif(".$dir_plus" == "$dir")
          {
           echo" | $dir_use";
          }
           else
          {
           echo" | <a href=\"index.php?kat=.$dir_plus\">$dir_use</a>";
          }
        }
       echo"</p>";
      }
       else
      {
       echo"<p align=\"center\">Загрузки</p>";
      }
     
     if($_GET['view']==1)
      {
       if(ereg("^[-a-zA-Z0-9_\'\, \(\)!\@]*$", $_GET['kategor']))
        {
         if(ereg("^\.\/[-a-zA-Z0-9_\/\.\'\, \(\)!\@\=]*\.[a-z0-9]{3}$", "$_GET[dir_kat]"))
          {
           if(ereg("^[0-9]{14}$", "$_GET[date]"))
            {
             ereg_replace("../", "", $_GET['dir_kat']);
             ereg("\/([-a-zA-Z0-9_\.\'\, \(\)!\@\=]*\.[a-z0-9]{3})$", "$_GET[dir_kat]", $file_name);
             $file_win = "$file_name[1]";
             if(ereg("(--[-a-zA-Z0-9_\'\, \(\)!\@]*--)", $file_name[1], $replasement))
              {
               $zamena = str_replace("--", "", "$replasement[1]");
               $zamena = tr_to_win($zamena);
               $file_win = str_replace("$replasement[1]", "$zamena", "$file_name[1]");
              }
             $file_use = str_replace("__", " ", "$file_win");
             $sizef = stat(stripslashes($_GET['dir_kat']));
             $kb = 1000;
             $size_file = round($sizef[7] / $kb, 2);
             $date_zag = date ("d/m/Y H:i:s", filemtime(stripslashes($_GET['dir_kat'])));
             $datanew = $_GET['date'] + 5000000;
             $datenow = date ("YmdHis");
             ereg("\/([-a-zA-Z0-9_\.\'\, \(\)!\@\=]*\.[a-z0-9]{1,4})$", $_GET['dir_kat'], $fil);
             
             echo "<p class=\"b\">";
             if($datanew > $datenow)
                {
                 echo "<font color=\"red\">Новый файл</font><br/>";
                }
             echo "Имя: $file_use<br/>";
             echo "Файл загружен: $date_zag<br/>";
             echo "Размер: $size_file Кбайт<br/>";
             if(!ereg("\.jar$", $_GET['dir_kat']))
              {
               echo "<a href=\"$home/servis/".stripslashes($_GET['dir_kat'])."\">Скачать</a><br/>";
              }
             if(ereg("\.jar$", $_GET['dir_kat']))
              {
               $jad = str_replace(".jar", ".jad", "$_GET[dir_kat]");
               echo "<a href=\"$home/servis/".stripslashes($_GET['dir_kat'])."\">Скачать JAR</a><br/>";
               if(file_exists("$jad"))
                {
                 echo "<a href=\"$home/servis/$jad\">Скачать JAD</a><br/>";
                }
              }
			 
			 ereg("^([-a-zA-Z0-9_\'\,\. \(\)!\@]*)\.[a-z]{0,4}$", $fil[1], $replasement_fil);
			 
             if (file_exists("$dir/op/$replasement_fil[1].txt"))
              {
               echo "<br/>Описание: ";
               include ("$dir/op/$replasement_fil[1].txt");
               echo "<br/>";
              }
              
             if (file_exists("$dir/op/$replasement_fil[1].gif"))
              {
               echo "<br/>Скриншот: ";
               echo "<br/><img src=\"img.php?img=$_GET[kat]/op/$replasement_fil[1].gif&amp;wid=100&amp;prev=1\" alt=\"\">";
               echo "<br/>";
              }
             if (file_exists("$dir/op/$replasement_fil[1].jpg"))
              {
               echo "<br/>Скриншот: ";
               echo "<br/><img src=\"img.php?img=$_GET[kat]/op/$replasement_fil[1].jpg&amp;wid=100&amp;prev=1\" alt=\"\">";
               echo "<br/>";
              }
             if (file_exists("$dir/op/$replasement_fil[1].png"))
              {
               echo "<br/>Скриншот: ";
               echo "<br/><img src=\"img.php?img=$_GET[kat]/op/$replasement_fil[1].png&amp;wid=100&amp;prev=1\" alt=\"\">";
               echo "<br/>";
              }
                
             if(ereg("\.gif$|\.jpg$|\.jpeg$|\.jpe$|\.png$", $_GET['dir_kat']))
              {
               echo "<br/>Просмотр: ";
               echo "<br/><img src=\"img.php?img=$_GET[dir_kat]\" alt=\"prew\" />";
               echo "<br/>Скачать для вашего экрана:";
               echo "<br/>
                     <a href=\"img.php?img=$_GET[dir_kat]&amp;hei=80\">101x80</a>|<a href=\"img.php?img=$_GET[dir_kat]&amp;hei=90\">128x90</a><br/>
                     <a href=\"img.php?img=$_GET[dir_kat]&amp;wid=128\">128x128</a>|<a href=\"img.php?img=$_GET[dir_kat]&amp;wid=128\">128x160</a><br/>
                     <a href=\"img.php?img=$_GET[dir_kat]&amp;wid=132\">132x176</a>|<a href=\"img.php?img=$_GET[dir_kat]&amp;hei=144\">176x144</a><br/>
                     <a href=\"img.php?img=$_GET[dir_kat]&amp;wid=176\">176x208</a>|<a href=\"img.php?img=$_GET[dir_kat]&amp;wid=176\">176x220</a><br/>
                     <a href=\"img.php?img=$_GET[dir_kat]&amp;wid=208\">208x208</a>|<a href=\"img.php?img=$_GET[dir_kat]&amp;wid=240\">240x266</a><br/>
                     <a href=\"img.php?img=$_GET[dir_kat]&amp;wid=240\">240x240</a>|<a href=\"img.php?img=$_GET[dir_kat]&amp;wid=240\">240x320</a><br/>
                     <br/>";
                     
               echo "<form action=\"img.php?img=$_GET[dir_kat]\" method=\"post\">";
               echo "Уникальный размер:<br/>
                     Ширина: <input type=\"text\" name=\"wid\" size=\"3\" maxlength=\"3\" value=\"\" /><br/>
                     Высота: <input type=\"text\" name=\"hei\" size=\"3\" maxlength=\"3\" value=\"\" /><br/>
                     <input type=\"submit\" value=\"Скачать\" />";
               echo "</form>";
              }
             
             
             echo "</p>";
             }
              else
             {
              echo "<p class=\"b\">Неправильный формат даты</p>";
             }
          }
           else
          {
           echo "<p class=\"b\">Неправильный формат директоии</p>";
          }
        }
         else
        {
         echo "<p class=\"b\">Неправильный формат категории</p>";
        }
      }
       else
      {
     while ($file = readdir($dir_kat))
      {
       if(is_dir("$dir/$file") && $file != "." && $file != ".." && $file != "op")
        {
         $files[] = "$file";
        }
      }
     $file_co = count($files);
     sort($files);
     for ($i=0; $i < $file_co; $i++)
      {
       if(is_dir("$dir/$files[$i]") && $files[$i] != "." && $files[$i] != ".." && $files[$i] != "op")
        {  
         $file_win = "$files[$i]"; 
         if(ereg("(--[-a-zA-Z0-9_\'\,\(\)!\@]*--)", $files[$i], $replasement))
          {
           $zamena1 = str_replace("--", "", "$replasement[1]");
           $zamena = tr_to_win($zamena1);
           $file_win = str_replace("$replasement[1]", "$zamena", "$files[$i]");
          }
         $file_use = str_replace("__", " ", "$file_win");
         $file_use = ereg_replace("^[0-9]{1,2}[-]", "", $file_use); 
         
         echo "<p class=\"b\">";
         echo "<img src=\"../../images/dir.gif\" alt=\"\" /> <a href=\"index.php?kat=$dir/$files[$i]\">$file_use</a>[".dir_kol("$dir/$files[$i]")."";
         if(($kolvo = dir_kol_new("$dir/$files[$i]")) > 0)
          {
           echo "/<font color=\"red\">$kolvo</font>";
          }
         echo "]";
         echo "</p>";
         $a++;
        }
      }
      
     if(!empty($a))
      {
       echo "<p><br/></p>"; 
      }

     while ($file1 = readdir($dir_file))
      {
       if(is_file("$dir/$file1") && $file1 != "Thumbs.db" && $file1 != ".htaccess" && $file1 != "index.php" && $file1 != "kol.php" && $file1 != "img.php" && $file1 != "adminkom.php" && $file1 != "kom.php")
        {
         $file_array[] = "".date ("YmdHis", filemtime("$dir/$file1"))."||$file1";
        }
      }
     rsort($file_array);
     $count_files = count($file_array);
     
     $kol_files = 10;
     $stranic = ceil($count_files/$kol_files);

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

     $page_nazad = $page_get - 1;
     $page_dalee = $page_get + 1;
     
     for($i = $do; $i < $end; $i++)
      {
       if(!empty($file_array[$i]) && !ereg("\.jad$", $file_array[$i]))
        {       
         $file_win_arr = explode("||", $file_array[$i]); 
         ereg("^([-a-zA-Z0-9_\.\'\, !\(\)\@\=]*)\.[a-z0-9]{3}$", $file_win_arr['1'], $repl);
         $file_win = "$repl[1]";
         if(ereg("(--[-a-zA-Z0-9_\.\'\, \(\)!\@]*--)", $repl[1], $replasement))
          {
           $zamena = str_replace("--", "", "$replasement[1]");
           $zamena = tr_to_win($zamena);
           $file_win = str_replace("$replasement[1]", "$zamena", "$repl[1]");
          }
         $file_use = str_replace("__", " ", "$file_win");
         
		 ereg("^([-a-zA-Z0-9_\'\,\. \(\)!\@]*)\.[a-z]{0,4}$", $file_win_arr[1], $replasement_fil_win_arr);
		 
         echo "<p class=\"b\">";
         if(file_exists("$dir/op/$replasement_fil_win_arr[1].jpg"))
          {
           echo "<img src=\"img.php?img=$dir/op/$replasement_fil_win_arr[1].jpg&amp;prev=1\" alt=\"prev\" /><br/>";
          }
         elseif(file_exists("$dir/op/$replasement_fil_win_arr[1].gif"))
          {
           echo "<img src=\"img.php?img=$dir/op/$replasement_fil_win_arr[1].gif&amp;prev=1\" alt=\"prev\" /><br/>";
          }
         elseif(file_exists("$dir/op/$replasement_fil_win_arr[1].png"))
          {
           echo "<img src=\"img.php?img=$dir/op/$replasement_fil_win_arr[1].png&amp;prev=1\" alt=\"prev\" /><br/>";
          }
         if(ereg("\.zip$", $file_win_arr[1]))
          {
           echo "<img src=\"../../images/zip.gif\" alt=\"\" /> ";
          }
         elseif(ereg("\.rar$|\.jar$", $file_win_arr[1]))
          {
           echo "<img src=\"../../images/rar.gif\" alt=\"\" /> ";
          }
         elseif(ereg("\.mp3$|\.mid$|\.mmf$|\.wav$|\.ogg$|\.amr$", $file_win_arr[1]))
          {
           echo "<img src=\"../../images/melody.gif\" alt=\"\" /> ";
          }
         elseif(ereg("\.txt$", $file_win_arr[1]))
          {
           echo "<img src=\"../../images/txt.gif\" alt=\"\" /> ";
          }
         elseif(ereg("\.exe$|\.sis$", $file_win_arr[1]))
          {
           echo "<img src=\"../../images/exe.gif\" alt=\"\" /> ";
          }
         elseif(ereg("\.avi$|\.3gp$", $file_win_arr[1]))
          {
           echo "<img src=\"../../images/avi.gif\" alt=\"\" /> ";
          }
         elseif(ereg("\.gif$|\.jpg$|\.jpeg$|\.jpe$|\.png$", $file_win_arr[1]))
          {
           echo "<img src=\"img.php?img=$dir/$file_win_arr[1]&amp;prev=1\" alt=\"prev\" /><br/><img src=\"../../images/img.gif\" alt=\"\" /> ";
          }
         else
          {
           echo "<img src=\"../../images/file.gif\" alt=\"\" /> ";
          }
         $datanew = $file_win_arr[0] + 5000000;
         $datenow = date ("YmdHis");
         $sizef = stat("$dir/$file_win_arr[1]");
         $kb = 1000;
         $size_file = round($sizef[7] / $kb, 2);
         if($datanew > $datenow)
          {
           echo "<font color=\"red\">[NEW]</font> ";
          }
         echo "<a href=\"index.php?kat=$dir&amp;dir_kat=$dir/$file_win_arr[1]&amp;kategor=$zamena11&amp;date=$file_win_arr[0]&amp;view=1\">$file_use</a>($size_file Кб)";
         echo "</p>";
        }
      }
     
     if($count_files > $kol_files)
      { 
       echo "<p align=\"center\" class=\"d\">";
       if($page_get > 1)
        {
         echo "<a href=\"index.php?page=$page_nazad&amp;kat=$kat\">Назад</a>";
        }
       echo "|";
       if($stranic > $page_get)
        {
         echo "<a href=\"index.php?page=$page_dalee&amp;kat=$kat\">Дальше</a>";
        }
       echo "<br/>Страница:$page_get<br/>"; 
       echo "Всего страниц:$stranic<br/>"; 
       if($page_get > 1)
        {
         echo "<a href=\"index.php?page=1&amp;kat=$kat\">В начало</a>";
        }
       echo "|";
       if($stranic > $page_get)
        {
         echo "<a href=\"index.php?page=$stranic&amp;kat=$kat\">В конец</a><br/>";
        }
       echo "<br/>";
       
       echo "<form action=\"index.php\" method=\"get\">";

       echo "На страницу<br/>
             <input type=\"text\" name=\"page\" size=\"3\" maxlength=\"3\" value=\"\" /><br/>
             <input type=\"hidden\" name=\"kat\" value=\"$kat\" />
             <input type=\"submit\" value=\"Перейти\" />";
       echo "</form>";
       echo "</p>";
      }
     
     echo "<p class=\"d\">";
     if(!empty($a))
      {
       echo "Категорий: $a<br/>";
      }
     if($count_files > 0)
      {
       echo "Файлов: $count_files";
      }
     echo "</p>";
      }     
   }
    else
   {
    echo "<p class=\"b\">Неправильный формат каталога</p>";
   }
  closedir ($dir_kat);
  closedir ($dir_file);
 }

  if(empty($_GET['kat']))
   {
    $dir = ".";
   }
    else
   {
    $dir = $_GET['kat'];
   }
  if(ereg("^\.[-a-zA-Z0-9_\/\'\,!\@\=]*$", $dir))
   {
    dir_list ($dir); 
   }
    else
   {
    echo "<p class=\"b\">Неправильный формат каталога.</p>";
   }

?>
</body>
</html>