View file trans/index.php

File size: 4.32Kb
<!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("а"=>"&#x430;","б"=>"&#x431;","в"=>"&#x432;","г"=>"&#x433;","д"=>"&#x434;","е"=>"&#x435;","ё"=>"&#x451;","ж"=>"&#x436;","з"=>"&#x437;","и"=>"&#x438;","й"=>"&#x439;","к"=>"&#x43A;","л"=>"&#x43B;","м"=>"&#x43C;","н"=>"&#x43D;","о"=>"&#x43E;","п"=>"&#x43F;","р"=>"&#x440;","с"=>"&#x441;","т"=>"&#x442;","у"=>"&#x443;","ф"=>"&#x444;","х"=>"&#x445;","ц"=>"&#x446;","ч"=>"&#x447;","ш"=>"&#x448;","щ"=>"&#x449;","ъ"=>"&#x44A;","ы"=>"&#x44B;","ь"=>"&#x44C;","э"=>"&#x44D;","ю"=>"&#x44E;","я"=>"&#x44F;",
"А"=>"&#x410;","Б"=>"&#x411;","В"=>"&#x412;","Г"=>"&#x413;","Д"=>"&#x414;","Е"=>"&#x415;","Ё"=>"&#x401;","Ж"=>"&#x416;","З"=>"&#x417;","И"=>"&#x418;","Й"=>"&#x419;","К"=>"&#x41A;","Л"=>"&#x41B;","М"=>"&#x41C;","Н"=>"&#x41D;","О"=>"&#x41E;","П"=>"&#x41F;","Р"=>"&#x420;","С"=>"&#x421;","Т"=>"&#x422;","У"=>"&#x423;","Ф"=>"&#x424;","Х"=>"&#x425;","Ц"=>"&#x426;","Ч"=>"&#x427;","Ш"=>"&#x428;","Щ"=>"&#x429;","Ъ"=>"&#x42A;","Ы"=>"&#x42B;","Ь"=>"&#x42C;","Э"=>"&#x42D;","Ю"=>"&#x42E;","Я"=>"&#x42F;"));
 return $str;
}
$a1=win2uni($a);
$a2=str_replace("&","&amp;",$a1);
$file=fopen("file/$name","w"); fputs($file, $a1); fclose($file); }
 
else { //перевод из юникода в win-1251
function uni2win($str){
$str=strtr($str,array("&#x430;"=>"а","&#x431;"=>"б","&#x432;"=>"в","&#x433;"=>"г","&#x434;"=>"д","&#x435;"=>"е","&#x451;"=>"ё","&#x436;"=>"ж","&#x437;"=>"з","&#x438;"=>"и","&#x439;"=>"й","&#x43A;"=>"к","&#x43B;"=>"л","&#x43C;"=>"м","&#x43D;"=>"н","&#x43E;"=>"о","&#x43F;"=>"п","&#x440;"=>"р","&#x441;"=>"с","&#x442;"=>"т","&#x443;"=>"у","&#x444;"=>"ф","&#x445;"=>"х","&#x446;"=>"ц","&#x447;"=>"ч","&#x448;"=>"ш","&#x449;"=>"щ","&#x44A;"=>"ъ","&#x44B;"=>"ы","&#x44C;"=>"ь","&#x44D;"=>"э","&#x44E;"=>"ю","&#x44F;"=>"я",
"&#x410;"=>"А","&#x411;"=>"Б","&#x412;"=>"В","&#x413;"=>"Г","&#x414;"=>"Д","&#x415;"=>"Е","&#x401;"=>"Ё","&#x416;"=>"Ж","&#x417;"=>"З","&#x418;"=>"И","&#x419;"=>"Й","&#x41A;"=>"К","&#x41B;"=>"Л","&#x41C;"=>"М","&#x41D;"=>"Н","&#x41E;"=>"О","&#x41F;"=>"П","&#x420;"=>"Р","&#x421;"=>"С","&#x422;"=>"Т","&#x423;"=>"У","&#x424;"=>"Ф","&#x425;"=>"Х","&#x426;"=>"Ц","&#x427;"=>"Ч","&#x428;"=>"Ш","&#x429;"=>"Щ","&#x42A;"=>"Ъ","&#x42B;"=>"Ы","&#x42C;"=>"Ь","&#x42D;"=>"Э","&#x42E;"=>"Ю","&#x42F;"=>"Я"));
 return $str;
}
$a1=uni2win($a);
$a2=str_replace("&amp;","&",$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 &amp; maslanin
  </div>  </body>  </html>