View file files/adm/red_kat.php

File size: 4.52Kb
<?php
Defined('ADMIN_S_S') or die ('Доступ запрещен!!!');

if (filesize('files/namekat.txt') != 0)
{
 if (!isset($_POST[el]) and !isset($_POST[elred]) and !isset($_POS[elopis]))
 {
 // Запуск  генератора
 $fp = fopen ("files/namekat.txt", "r");
 $buffer = fread($fp, filesize("files/namekat.txt"));
 fclose ($fp);
 $count = explode("|", $buffer);
 echo "<form name='red' action='$_SERVER[self]' 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 />';
 ?>

 Новое имя раздела:<br />
 <input name="elred" type="text" value=""><br />
 Описание редактируемого раздела:<br />
 <textarea name="fopis" rows=5 cols=20></textarea><br />
 <input name="inc" type="hidden" value="red_kat.php">
 <?php
 echo '<input type="submit" value="Редактировать">';
 echo '</form>';
 // Закрытие генератора
 }
 else
 {
                   if (($_POST[el]) and ($_POST[elred]) and ($_POST[elopis]))
    {
      // редактирование
  $data = fopen ("files/namekat.txt", "r");
 $dan = fread($data, filesize("files/namekat.txt"));
  fclose ($data);
 $dan = str_replace($_POST[el],$_POST[elred],$dan) ;
  $data = fopen ("files/namekat.txt", "w");
 fwrite ($data, $dan);
  fclose ($data);
                // конец

          $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;
unlink("files/count/$mdh.txt");

          $file_s = $_POST[elred];
 $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;

         $_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]);

  $data = fopen ("files/count/$mdh.txt", "w+");
  fwrite ($data, $_POST[fopis]);
  fclose ($data);
  echo 'Успешно. <a href="/admin.php?int=files/adm/ind.php">Далее</a>';
       }
       else
       {
       	 echo 'Все параметры нужно заполнить!';
       };


      // конец редактирования

 };
}
else
{
echo 'Разделы не созданы!';
};














?>