Просмотр файла files/adm/file_imp.php

Размер файла: 6Kb
<?php
Defined('ADMIN_S_S') or die ('Доступ запрещен!!!');
if ($_POST[fname] == "")
{
	// Запуск  генератора
 $fp = fopen ("files/namekat.txt", "r");
 $buffer = fread($fp, filesize("files/namekat.txt"));
 fclose ($fp);
 $count = explode("|", $buffer);
 echo "<form name='red' enctype='multipart/form-data' action='' method='post'>";
 echo 'Выберите раздел для загрузки.<br />';
 echo '<select size="1" name="el">';
 $i=0;
 while ($count[$i] != "")
 {
 echo "<option value='$count[$i]'>$count[$i]</option>";
 $i++;
 };
 echo '</select><br />';
 ?>
 <input name="data" type="hidden" value="<?php echo date("d.m.Y");?>">
 Имя файла. (На русском языке)<br />
 <input name="fname" type="text" value=""><br />
 Описание:<br />
 <textarea name="fopis" rows=8 cols=40></textarea><br />
 <!--//Форма для загрузки файла//-->
 Файл:(сюда вписывать прямую ссылку на файл. Расширение только .php)<br />
  <input name="url" type="text" value="http://">
 <input name="inc" type="hidden" value="file_imp.php">
 <?php
 echo '<input type="submit" value="Добавить">';
 echo '</form>';
 // Закрытие генератора
?>


<?php
}
else
{
if ($_POST[fname] != "" and $_POST[fopis] != "" and $_POST[url] != "")
{


              $basename1 = basename($_POST['url'],".zip");
              $basename2 = basename($_POST['url']);
        if ("$basename1.zip" == $basename2)
       {
              if(copy($_POST[url],"files/file/$basename2"))
              {
                 echo'Файл загружен на сервер<br>';

              }else
              {
                 echo'Ошибка! Файл не загружен<br>';
              };


         $file_s = $_POST[fname];
         $file_s=strtr($file_s,"абвгдеёзийклмнопрстуфхъыэ_",
         "abvgdeeziyklmnoprstufh'iei");
         $file_s=strtr($file_s,"АБВГДЕЁЗИЙКЛМНОПРСТУФХЪЫЭ_",
         "ABVGDEEZIYKLMNOPRSTUFH'IEI");
         $file_s=strtr($file_s,
         array(
         "ж"=>"zh", "ц"=>"ts", "ч"=>"ch", "ш"=>"sh",
         "щ"=>"shch","ь"=>"", "ю"=>"yu", "я"=>"ya",
         "Ж"=>"ZH", "Ц"=>"TS", "Ч"=>"CH", "Ш"=>"SH",
         "Щ"=>"SHCH","Ь"=>"", "Ю"=>"YU", "Я"=>"YA",
         "ї"=>"i", "Ї"=>"Yi", "є"=>"ie", "Є"=>"Ye"
         ));
         $file_s = str_replace(" ","_",$file_s);
         $file_s = str_replace("\\","_",$file_s);
         $file_s = str_replace("\"","_",$file_s);
         $file_s = str_replace("'","_",$file_s);
         $file_s = str_replace(".","_",$file_s);
         $file_s = str_replace("-","_",$file_s);
         $file_s = str_replace("/","_",$file_s);
         $file_s = str_replace("#","_",$file_s);
         $file_s = str_replace("=","_",$file_s);
         $file_s = str_replace(">","_",$file_s);
         $file_s = str_replace("<","_",$file_s);
         $file_s = str_replace("|","_",$file_s);
            $file_put = $file_s;

         $_POST[fopis] = str_replace("\\\\","\\",$_POST[fopis]);
         $_POST[fopis] = str_replace("\"","\"",$_POST[fopis]);
         $_POST[fopis] = str_replace("\\'","'",$_POST[fopis]);
         $_POST[fopis] = str_replace("/","_",$_POST[fopis]);
         $_POST[fopis] = str_replace("#","_",$_POST[fopis]);
         $_POST[fopis] = str_replace("=","_",$_POST[fopis]);
         $_POST[fopis] = str_replace(">","_",$_POST[fopis]);
         $_POST[fopis] = str_replace("<","_",$_POST[fopis]);
         $_POST[fopis] = str_replace("|","_",$_POST[fopis]);

       $fp = fopen ("files/fop/$file_put", "w+");
       fwrite ($fp, "<?php \r\n");
       fwrite ($fp, "Defined('INDEX_S_S') or die ('Доступ запрещен!!!');\r\n");
       //запись данных
       fwrite ($fp, "\$fname = '$_POST[fname]';\r\n");
       fwrite ($fp, "\$fopis = '$_POST[fopis]';\r\n");
       fwrite ($fp, "\$fput = 'files/file/$basename2';\r\n");
       fwrite ($fp, "\$autor = 'Администратор';\r\n");
       fwrite ($fp, "\$data = '$_POST[data]';\r\n");
       fwrite ($fp, "\r\n?>");
       fclose ($fp);
        echo 'Файл создан. Работа с каталогом...<br />';

        $file_s = $_POST[el];
        $file_s=strtr($file_s,"абвгдеёзийклмнопрстуфхъыэ_",
        "abvgdeeziyklmnoprstufh'iei");
        $file_s=strtr($file_s,"АБВГДЕЁЗИЙКЛМНОПРСТУФХЪЫЭ_",
        "ABVGDEEZIYKLMNOPRSTUFH'IEI");
        $file_s=strtr($file_s,
        array(
        "ж"=>"zh", "ц"=>"ts", "ч"=>"ch", "ш"=>"sh",
        "щ"=>"shch","ь"=>"", "ю"=>"yu", "я"=>"ya",
        "Ж"=>"ZH", "Ц"=>"TS", "Ч"=>"CH", "Ш"=>"SH",
        "Щ"=>"SHCH","Ь"=>"", "Ю"=>"YU", "Я"=>"YA",
        "ї"=>"i", "Ї"=>"Yi", "є"=>"ie", "Є"=>"Ye"
        ));
         $file_s = str_replace(" ","_",$file_s);
         $file_s = str_replace("\\","_",$file_s);
         $file_s = str_replace("\"","_",$file_s);
         $file_s = str_replace("'","_",$file_s);
         $file_s = str_replace(".","_",$file_s);
         $file_s = str_replace("-","_",$file_s);
         $file_s = str_replace("/","_",$file_s);
         $file_s = str_replace("#","_",$file_s);
         $file_s = str_replace("=","_",$file_s);
         $file_s = str_replace(">","_",$file_s);
         $file_s = str_replace("<","_",$file_s);
         $file_s = str_replace("|","_",$file_s);
           $mdh = $file_s ;
         $fp = fopen ("files/rasd/$mdh", "a+");
         if (filesize("files/rasd/$mdh") == 0)
         fwrite ($fp, "$_POST[fname]");
         else
         fwrite ($fp,"|$_POST[fname]");
         fclose ($fp);
         echo 'Каталог отредактирован. Работа с базой...<br />';
         $fp = fopen ("files/count.txt", "w+");
         fwrite ($fp,$file_put);
         fclose ($fp);
         $fp = fopen ("files/count2.txt", "r");
         $count = fread ($fp, filesize("files/count2.txt"));
         fclose ($fp);
         $count++;
         $fp = fopen ("files/count2.txt", "w");
         fwrite ($fp,$count);
         fclose ($fp);
         echo 'База отредактирована успешно. Работа завершена успешно.<br />
         <a href="/admin.php?int=files/adm/ind.php">Далее</a>';
      }
      else
      {
      	echo 'Вы грузите не zip архив!';
      };


}
else
{
echo 'Все поля должны быть заполнены.';
};

};
?>