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

Размер файла: 5.94Kb
<?
Defined('ADMIN_S_S') or die ('Доступ запрещен!!!');
 if ($_POST[pokas] < 1 )
 {
 $fp = fopen ("files/namekat.txt", "r");
 $buffer = fread($fp, filesize("files/namekat.txt"));
 fclose ($fp);
 $count = explode("|", $buffer);
 echo "<form name='red' 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="inc" type="hidden" value="red_file.php">
 <input name="pokas" type="hidden" value="1">
 <?php
 echo '<input type="submit" value="Дальше">';
 echo '</form>';
 }
 elseif ($_POST[pokas] < 2)
 {
  $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", "r");
  $buffer = fread($fp, filesize("files/rasd/$mdh"));
  fclose ($fp);
  $count = explode("|", $buffer);
  echo "<form name='red' action='' method='post'>";
  echo 'Выберите файл.<br />';
  echo '<select size="1" name="fname">';
  $i=0;
  while ($count[$i] != "")
  {
  echo "<option value='$count[$i]'>$count[$i]</option>";
  $i++;
  };
  echo '</select><br />';
  ?>
  <input name="inc" type="hidden" value="red_file.php">
  <input name="pokas" type="hidden" value="2">
  <?php
  echo '<input type="submit" value="Дальше">';
  echo '</form>';
 }
 elseif ($_POST[pokas] < 3)
 {
         $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);
         $_SESSION['file_s'] = $file_s;
         if (!is_file("files/fop/$_SESSION[file_s]"))
         {
         echo 'Файл не обнаружен'; exit;
         }
         else
         {?>
         <form name="" action="" method="post">
          Файл обнаружен.<br />
          <input name="pokas" type="hidden" value="3">
          <input name="inc" type="hidden" value="red_file.php">
          <input type="submit" value="Далее">
         </form>
         <?php
         };
 }
 elseif ($_POST[pokas] < 4)
 {
         include_once("files/fop/$_SESSION[file_s]");?>
         <form name="" action="" method="post">
         Имя файла:<br />
         <input name="fname" type="text" value="<?php echo $fname ?>"><br />
         Описание файла:<br />
         <textarea name="fopis" rows=8 cols=40><?php echo $fopis ?></textarea> <br />
         Путь к файлу:(Для профессионалов)<br />
         <textarea name="fput" rows=2 cols=30><?php echo $fput?></textarea> <br />
         Автор файла:<br />
         <input name="autor" type="text" value="<?php echo $autor?>"><br />
         <input name="data" type="hidden" value="<?php echo $data?>">
         <input name="pokas" type="hidden" value="4">
         <input type="submit" value="Cохранить изменения.">
         <input name="inc" type="hidden" value="red_file.php">
         </form>
 <?php
 }
 elseif ($_POST[pokas] < 5)
 {

         $_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/$_SESSION[file_s]", "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 = '$_POST[fput]';\r\n");
 fwrite ($fp, "\$autor = 'Администратор';\r\n");
 fwrite ($fp, "\$data = '$_POST[data]';\r\n");
 fwrite ($fp, "\r\n?>");
 fclose ($fp);
 echo 'Успешно. <a href="/admin.php?int=files/adm/ind.php">Далее</a>';
 };
?>