<?
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="del_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);
$_SESSION[rasd] = $mdh;
$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="del_file.php">
<input name="pokas" type="hidden" value="2">
<?php
echo '<input type="submit" value="Дальше">';
echo '</form>';
}
elseif ($_POST[pokas] < 3)
{ $_SESSION[file_ss] = $_POST[fname];
$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="del_file.php">
<input type="submit" value="Далее">
</form>
<?php
};
}
elseif ($_POST[pokas] < 4)
{
// редакт раздела
// редактирование
$data = fopen ("files/rasd/$_SESSION[rasd]", "r");
$dan = fread($data, filesize("files/rasd/$_SESSION[rasd]"));
fclose ($data);
if (!eregi("(\|)($_SESSION[file_ss])",$dan))
{
if (!eregi("($_SESSION[file_ss])(\|)",$dan))
$dan = str_replace("$_SESSION[file_ss]","",$dan);
else
$dan = str_replace("$_SESSION[file_ss]|","",$dan);
}
else
{
$dan = str_replace("|$_SESSION[file_ss]","",$dan);
};
$data = fopen ("files/rasd/$_SESSION[rasd]", "w");
fwrite ($data, $dan);
fclose ($data);
// конец
// редакт счетчика
$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);
include('files/adm/viget_red.php');
//конец
//редакт файлов
include("files/fop/$_SESSION[file_s]");
unlink($fput);
unlink("files/fop/$_SESSION[file_s]");
//конец
echo 'Успешно. <a href="/admin.php?int=files/adm/ind.php">Далее</a>';
};
?>