<?php
Defined('ADMIN_S_S') or die ('Доступ запрещен!!!');
if (!isset($_POST[nkat]) and !isset($_POST[okat]))
{
?>
<form name="" action="" method="post">
Имя раздела: <input name="nkat" type="text" value=""><br>
Описание раздела: <textarea name="okat" rows=5 cols=20></textarea>
<input name="inc" type="hidden" value="add_kat.php">
<input type="submit" value="Добавить">
</form>
<?php
}
else
{
if ($_POST[nkat] != "" and $_POST[okat] != "")
{
// создание русских названий.
$_POST[nkat] = str_replace('|','',$_POST[nkat]);
if (filesize('files/namekat.txt') == 0)
{
$data = fopen ("files/namekat.txt", "a+");
fwrite ($data, $_POST[nkat]);
fclose ($data);
}
else
{
$fp = fopen ("files/namekat.txt", "a");
fwrite($fp,"|$_POST[nkat]");
fclose ($fp);
};
// конец
// создание не русских имен
$file_s = $_POST[nkat];
$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);
$mdh = $file_s ;
$data = fopen ("files/count/$mdh.txt", "w+");
fwrite ($data, $_POST[okat]);
fclose ($data);
$fp = fopen ("files/rasd/$mdh", "w+");
fclose ($fp);
echo 'Успешно. <a href="/admin.php?int=files/adm/ind.php">Далее</a>';
}
else
{
echo 'Оба поля должны быть заполнены!';
};
};
?>