<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" " http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1251">
<title>TRANSFER v3.0</title>
</head>
<body text="lime" link="red" bgcolor="black">
<div align='center'>
<?
@$dir = opendir("/file/"); //проверка на наличие папки file
if(!$dir) { $ss=@mkdir("file"); $ss=@chmod($ss,0777);} //права папки 777
//счетчик
@$name=str_replace("../","",$name);
$count=@file('count.txt');
if(!$count){
$fp=fopen('count.txt','w');
fwrite($fp,1);
fclose($fp);
echo('Спасибо! Вы наш первый посетитель!<br>');
}else{
$count[0]++;
$fp=fopen('count.txt','w');
fwrite($fp,$count[0]);
fclose($fp);
echo('Счетчик: '); echo $count[0]; echo('<br>');
//конец счетчика
}
if((!$name) || (empty($name)))
{ echo "<h2>Введете имя файла!!!</h2>"; }
else {
echo '<h1>Последним был создан файл:</h1><h2> ';
echo $name;
echo '</h2>';
if ($sel=='a') { //перевод из win-1251 в юникод
function win2uni($str){
$str=strtr($str,array("а"=>"а","б"=>"б","в"=>"в","г"=>"г","д"=>"д","е"=>"е","ё"=>"ё","ж"=>"ж","з"=>"з","и"=>"и","й"=>"й","к"=>"к","л"=>"л","м"=>"м","н"=>"н","о"=>"о","п"=>"п","р"=>"р","с"=>"с","т"=>"т","у"=>"у","ф"=>"ф","х"=>"х","ц"=>"ц","ч"=>"ч","ш"=>"ш","щ"=>"щ","ъ"=>"ъ","ы"=>"ы","ь"=>"ь","э"=>"э","ю"=>"ю","я"=>"я",
"А"=>"А","Б"=>"Б","В"=>"В","Г"=>"Г","Д"=>"Д","Е"=>"Е","Ё"=>"Ё","Ж"=>"Ж","З"=>"З","И"=>"И","Й"=>"Й","К"=>"К","Л"=>"Л","М"=>"М","Н"=>"Н","О"=>"О","П"=>"П","Р"=>"Р","С"=>"С","Т"=>"Т","У"=>"У","Ф"=>"Ф","Х"=>"Х","Ц"=>"Ц","Ч"=>"Ч","Ш"=>"Ш","Щ"=>"Щ","Ъ"=>"Ъ","Ы"=>"Ы","Ь"=>"Ь","Э"=>"Э","Ю"=>"Ю","Я"=>"Я"));
return $str;
}
$a1=win2uni($a);
$a2=str_replace("&","&",$a1);
$file=fopen("file/$name","w"); fputs($file, $a1); fclose($file); }
else { //перевод из юникода в win-1251
function uni2win($str){
$str=strtr($str,array("а"=>"а","б"=>"б","в"=>"в","г"=>"г","д"=>"д","е"=>"е","ё"=>"ё","ж"=>"ж","з"=>"з","и"=>"и","й"=>"й","к"=>"к","л"=>"л","м"=>"м","н"=>"н","о"=>"о","п"=>"п","р"=>"р","с"=>"с","т"=>"т","у"=>"у","ф"=>"ф","х"=>"х","ц"=>"ц","ч"=>"ч","ш"=>"ш","щ"=>"щ","ъ"=>"ъ","ы"=>"ы","ь"=>"ь","э"=>"э","ю"=>"ю","я"=>"я",
"А"=>"А","Б"=>"Б","В"=>"В","Г"=>"Г","Д"=>"Д","Е"=>"Е","Ё"=>"Ё","Ж"=>"Ж","З"=>"З","И"=>"И","Й"=>"Й","К"=>"К","Л"=>"Л","М"=>"М","Н"=>"Н","О"=>"О","П"=>"П","Р"=>"Р","С"=>"С","Т"=>"Т","У"=>"У","Ф"=>"Ф","Х"=>"Х","Ц"=>"Ц","Ч"=>"Ч","Ш"=>"Ш","Щ"=>"Щ","Ъ"=>"Ъ","Ы"=>"Ы","Ь"=>"Ь","Э"=>"Э","Ю"=>"Ю","Я"=>"Я"));
return $str;
}
$a1=uni2win($a);
$a2=str_replace("&","&",$a1);
$file=fopen("file/$name","w"); fputs($file, $a1); fclose($file); }}
?>
<form action='index.php' method='post'>
file name:<br>
<input type='text' maxlength='20' name='name'>
<br>code:<br>
<textarea wrap='virtual' cols='50' rows='20' name='a'>
<?
//вывод в форме
if((!$name) || (empty($name)))
{echo '';} else {
if($p=='1' && $sel=='a') { echo $a; }
if($p=='2' && $sel=='a') { echo $a2; }
if($p=='1' && $sel=='b') { echo $a2; }
if($p=='2' && $sel=='b') { echo $a; }}
?>
</textarea><br>Вид перевода:<br>
<select name='sel'>
<option selected value='a'>кириллица в UTF-8
<option value='b'>UTF-8 в кириллицу</select><br>Вывод в форме:<br>
<select name='p'>
<option value='1'>исходник
<option selected value='2'>результат</select>
<br><input type='reset' value='очистить'><br>
<input type='submit' value='generate'>
</form>
<form action='look.php' method='post'>
<input type='submit' value='Папка для файлов'>
</form>
<br> ® 254th & maslanin
</div> </body> </html>