View file admin/downloads.php

File size: 8.11Kb
<?php
##############################
##	     WAP-ENGINE 	    ##
##############################
##						    ##
## Автор : CHUMA			##
## e-mail : [email protected]		##
## WAP : http://wapeng.info ##
## ICQ : 13-14-11			##
##                        	##
##############################
##  ВЫ НЕ ИМЕЕТЕ ПРАВО      ##
##  ИЗМЕНЯТЬ КОД СКРИПТА    ##
##  ДЛЯ ДАЛЬНЕЙШЕГО         ##
##  РАСПРОСТРАНЕНИЯ         ##
##############################
Error_Reporting(E_ALL & ~E_NOTICE);
Error_Reporting (ERROR | WARNING);

extract($HTTP_GET_VARS);
extract($HTTP_POST_VARS);
extract($HTTP_COOKIE_VARS);
extract($HTTP_SERVER_VARS);
extract($HTTP_SESSION_VARS);

session_name("SESID");
session_start();

function tr_to_win($str)
{
$str=strtr($str,array("__"=>" ","_"=>"","a"=>"а","b"=>"б","v"=>"в","g"=>"г","d"=>"д","e"=>"е","yo"=>"ё","zh"=>"ж","z"=>"з","i"=>"и","j"=>"й","k"=>"к","l"=>"л","m"=>"м","n"=>"н","o"=>"о","p"=>"п","r"=>"р","s"=>"с","t"=>"т","u"=>"у","f"=>"ф","h"=>"х","c"=>"ц","ch"=>"ч","sh"=>"ш","sch"=>"щ","q"=>"ъ","x"=>"ы","%"=>"ь","ye"=>"э","yu"=>"ю","ya"=>"я",
"A"=>"А","B"=>"Б","V"=>"В","G"=>"Г","D"=>"Д","E"=>"Е","YO"=>"Ё","ZH"=>"Ж","Z"=>"З","I"=>"И","J"=>"Й","K"=>"К","L"=>"Л","M"=>"М","N"=>"Н","O"=>"О","P"=>"П","R"=>"Р","S"=>"С","T"=>"Т","U"=>"У","F"=>"Ф","H"=>"Х","C"=>"Ц","CH"=>"Ч","SH"=>"Ш","SCH"=>"Щ","Q"=>"Ъ","X"=>"Ы","YE"=>"Э","YU"=>"Ю","YA"=>"Я"));
 return $str;
}

function win_to_tr($str)
{
$str=strtr($str,array(" "=>"__","а"=>"a","б"=>"b","в"=>"v","г"=>"g","д"=>"d","е"=>"e","ё"=>"yo","ж"=>"zh","з"=>"z","и"=>"i","й"=>"j","к"=>"k","л"=>"l","м"=>"m","н"=>"n","о"=>"o","п"=>"p","р"=>"r","с"=>"s","т"=>"t","у"=>"u","ф"=>"f","х"=>"h","ц"=>"c","ч"=>"ch","ш"=>"sh","щ"=>"sch","ъ"=>"q","ы"=>"x","ь"=>"%","э"=>"ye","ю"=>"yu","я"=>"ya",
"А"=>"A","Б"=>"B","В"=>"V","Г"=>"G","Д"=>"D","Е"=>"E","Ё"=>"YO","Ж"=>"ZH","З"=>"Z","И"=>"I","Й"=>"J","К"=>"K","Л"=>"L","М"=>"M","Н"=>"N","О"=>"O","П"=>"P","Р"=>"R","С"=>"S","Т"=>"T","У"=>"U","Ф"=>"F","Х"=>"H","Ц"=>"C","Ч"=>"CH","Ш"=>"SH","Щ"=>"SCH","Ъ"=>"Q","Ы"=>"X","Э"=>"YE","Ю"=>"YU","Я"=>"YA"));
 return $str;
}


include ("../config.php"); //Подключаем настройки сайта. (config.php)

if ($_GET[act]=="zag")
{

 if ($_SESSION['login']==$nickadmina && md5($_SESSION['pass'])==$passadmina)
  {
$katalog = win_to_tr($_POST[wkat]);
$opis = $_POST[op];
if(!empty($opis))
{
$fp = fopen("../modules/down/$katalog/op/".basename($HTTP_POST_FILES[userfile][name]).".txt", "w");
fputs($fp, $opis);
fclose($fp);
}

$uploaddir = "../modules/down/$katalog/";
$uploadfile = $uploaddir . basename($HTTP_POST_FILES['userfile']['name']);
$flag = move_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'], $uploadfile);
if($flag)
{
 header ("location: downloads.php?set=addzag");
}
else
{
 header ("location: downloads.php?set=notaddzag");
}
  } 
   else
  {
   include ("../themes/$themes.php"); //Вставляем скин сайта.
   echo'Неправильный ввод.<br><a href=index.php>Назад</a>';
   include ("../templates/foot.php"); //Вставляем низ сайта. (templates/foot.php)
  }

}


if ($_GET[act]=="setkat")
{

 if ($_SESSION['login']==$nickadmina && md5($_SESSION['pass'])==$passadmina)
  {
$katalog = win_to_tr($_POST[wkat]);
$flag = mkdir("../modules/down/$katalog", 0777);
        chmod("../modules/down/$katalog", 0777);
$flag1 = mkdir("../modules/down/$katalog/op", 0777);
        chmod("../modules/down/$katalog/op", 0777);         
if($flag)
{
 header ("location: downloads.php?set=addkat");
}
else
{
 header ("location: downloads.php?set=notaddkat");
}
  } 
   else
  {
   include ("../themes/$themes.php"); //Вставляем скин сайта.
   echo'Неправильный ввод.<br><a href=index.php>Назад</a>';
   include ("../templates/foot.php"); //Вставляем низ сайта. (templates/foot.php)
  }

}

if ($_GET[act]=="deletekat")
{

 if ($_SESSION['login']==$nickadmina && md5($_SESSION['pass'])==$passadmina)
  {

function full_del_dir ($directory)
{
$dir = opendir($directory);
while(($file = readdir($dir)))
{
if ( is_file ($directory."/".$file))
{
unlink ($directory."/".$file);
}
else if ( is_dir ($directory."/".$file) &&
($file != ".") && ($file != ".."))
{
full_del_dir ($directory."/".$file); 
}
}
closedir ($dir);
rmdir ($directory);
}

$katalog = win_to_tr($_POST[wkat]);
full_del_dir ("../modules/down/$katalog");
header ("location: downloads.php?set=delkat");
  } 
   else
  {
   include ("../themes/$themes.php"); //Вставляем скин сайта.
   echo'Неправильный ввод.<br><a href=index.php>Назад</a>';
   include ("../templates/foot.php"); //Вставляем низ сайта. (templates/foot.php)
  }

}

if ($_GET[act]=="")
{
include ("../themes/$themes.php"); //Вставляем скин сайта.

if ($_SESSION['login']==$nickadmina && md5($_SESSION['pass'])==$passadmina)
  {
echo'<center>Загруз-центр</center>';
if ($_GET[set]=="addkat")
{
echo"<center>Категория добавлена</center>";
}
if ($_GET[set]=="notaddkat")
{
echo"<center>Категория не добавлена.<br / >Возможно категория с таким именем уже существует.</center>";
}
if ($_GET[set]=="delkat")
{
echo"<center>Категория удалена.</center>";
}
if ($_GET[set]=="addzag")
{
echo"<center>Файл загружен</center>";
}
if ($_GET[set]=="notaddzag")
{
echo"<center>Файл не добавлен.<br / >Возможно файл с таким именем уже существует.</center>";
}
echo"<form method=\"post\" action=\"downloads.php?act=setkat\">
     <div class=b><center>Создание категории</center>
     Название:<br />
     <input name=\"wkat\" maxlength=\"50\" value=\"\" /><br />";
echo"<input value=\"Создать\" name=\"do\" type=\"submit\"/></div></form>";

echo"<form method=\"post\" action=\"downloads.php?act=deletekat\">
     <div class=b><center>Удаление категории</center>
     Категория:<br />
          <select name='wkat' class='textbox'>";

 $dir = opendir ("../modules/down"); 
   while ($file = readdir ($dir)) 
 {
    if (( $file != ".") && ($file != "..") && ($file != ".htaccess") && ($file != "index.php") && ($file != "tr_win.php") && ($file != "kom.php") && ($file != "adminkom.php"))
    { $file= str_replace(".php","",$file);
      $filewin = tr_to_win($file);
      echo "<option>$filewin</option>";
    }}
 echo "</select><br />";
closedir ($dir);
echo"<input value=\"Удалить\" name=\"do\" type=\"submit\"/></div></form>";

echo"<form enctype=\"multipart/form-data\" method=\"post\" action=\"downloads.php?act=zag\">
     <div class=b><center>Загрузка файла</center>
     Категория:<br />
     <select name='wkat' class='textbox'>";

 $dir = opendir ("../modules/down"); 
   while ($file = readdir ($dir)) 
 {
    if (( $file != ".") && ($file != "..") && ($file != ".htaccess") && ($file != "index.php") && ($file != "tr_win.php") && ($file != "kom.php") && ($file != "adminkom.php"))
    { $file= str_replace(".php","",$file);
      $filewin = tr_to_win($file);
      echo "<option>$filewin</option>";
    }}
 echo "</select><br />";
closedir ($dir);

#echo"Ссылка на файл<br />
#     <input name=\"wlink\" maxlength=\"50\" value=\"http://\" /><br />";
echo"Загрузить с диска<br />
     <input type=\"file\" name=\"userfile\" /><br />";
echo"Описание<br />
     <input type=\"text\" name=\"op\" />";
echo"<br/><input value=\"Загрузить\" name=\"do\" type=\"submit\"/></div></form>";
print"<a href=\"main.php\">В админку</a>";
  }
   else
  {
    echo'Неправильный ввод.<br> <a href=index.php>Назад</a>';
  }

include ("../templates/foot.php"); //Вставляем низ сайта. (templates/foot.php)  
}
?>