<?
Error_Reporting(E_ALL & ~E_NOTICE);
header("Cache-Control: no-cache");
header("Content-Type:text/html; charset=UTF-8");
require("inc.php");
$link = @mysql_pconnect ($MySQL_Hostname, $MySQL_Username, $MySQL_Password)
or die ("<wml><card id=\"error\" title=\"error\">
<do type=\"prev\" label=\"Back\"><prev/></do><p align=\"center\"><small>Can not connect to MySQL</small></p>
</card></wml>");
@mysql_select_db($MySQLDatabasename) or die ("<wml><card id=\"error\" title=\"error\">
<do type=\"prev\" label=\"Back\"><prev/></do><p align=\"center\"><small>error select the database...</small></p>
</card></wml>");
$ref=rand(10000,1000000);
if(!isset($ps))
{
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">";
echo "<html>";
echo "<head>";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>";
echo "<title>Чат Регион-56</title>";
echo "</head>";
echo "<body bgcolor=\"#F7EDCE\" link=\"blue\" vlink=\"blue\" text=\"black\">";
echo "<div align=\"center\">";
if(@$error=="user"){$msg="<font color=\"red\" size=\"5\"><b>Юзер не найден!</b></font><br/><br/>";}
if(@$error=="login"){$msg="<font color=\"red\" size=\"5\"><b>Не верное сочетание Ника и Пароля!</b></font><br/><br/>";}
echo "Введите свой \"чатовский\" ник и пароль.\n";
echo "<b><form method=\"POST\" action=\"foto.php?ref=$ref\" name=\"auth\">\n";
echo "Ник:<br/>\n";
echo "<input type=\"text\" name=\"us\" maxlength=\"15\" size=\"15\"><br/>\n";
echo "Пароль:<br/>\n";
echo "<input type=\"text\" name=\"ps\" maxlength=\"15\" size=\"15\"><br/>\n";
echo "<input type=\"submit\" value=\"Вход\" name=\"enter\"></b>\n";
echo "<br/>---<br/>";
echo "<a href=\"enter.php?id=$id&ps=$ps&ref=$ref\">Прихожая</a><br/>";
echo "</div>";
echo "</BODY>\n";
echo "</HTML>\n";
exit;
}
if(isset($us)){
$us=strtr($us,array("а"=>"Р°","б"=>"Р±","в"=>"РІ","г"=>"Рі","д"=>"Рґ","е"=>"Рµ","ё"=>"С‘","ж"=>"Р¶","з"=>"Р·","и"=>"Рё","й"=>"Р№","к"=>"Рє","л"=>"Р»","м"=>"Рј","н"=>"РЅ","о"=>"Рѕ","п"=>"Рї","р"=>"СЂ","с"=>"СЃ","т"=>"С‚","у"=>"Сѓ","ф"=>"С„","х"=>"С…","ц"=>"С†","ч"=>"С‡","ш"=>"С€","щ"=>"С‰","ъ"=>"СЉ","ы"=>"С‹","ь"=>"СЊ","э"=>"СЌ","ю"=>"СЋ","я"=>"СЏ","А"=>"Рђ","Б"=>"Р‘","В"=>"Р’","Г"=>"Р“","Д"=>"Р”","Е"=>"Р•","Ё"=>"РЃ","Ж"=>"Р–","З"=>"Р—","И"=>"Р","Й"=>"Р™","К"=>"Рљ","Л"=>"Р›","М"=>"Рњ","Н"=>"Рќ","О"=>"Рћ","П"=>"Рџ","Р"=>"Р ","С"=>"РЎ","Т"=>"Рў","У"=>"РЈ","Ф"=>"Р¤","Х"=>"РҐ","Ц"=>"Р¦","Ч"=>"Р§","Ш"=>"РЁ","Щ"=>"Р©","Ъ"=>"РЄ","Ы"=>"Р«","Ь"=>"Р¬","Э"=>"Р","Ю"=>"Р®","Я"=>"РЇ"));
}
if(isset($id)){
$result = @mysql_query ("Select * from users where id='".$id."'");
} else {
if ($us=="") {
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">";
echo "<html>";
echo "<head>";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>";
echo "<title>Ошибка!</title>";
echo "</head>";
echo "<body bgcolor=\"#F7EDCE\" link=\"blue\" vlink=\"blue\" text=\"black\">";
echo "<div align=\"center\">";
echo "<font color=\"red\" size=\"5\"><b>Юзер не найден!</b></font><br/><br/>";
echo "Введите свой \"чатовский\" ник и пароль.\n";
echo "<b><form method=\"POST\" action=\"foto.php?ref=$ref\" name=\"auth\">\n";
echo "Ник:<br/>\n";
echo "<input type=\"text\" name=\"us\" maxlength=\"15\" size=\"15\"><br/>\n";
echo "Пароль:<br/>\n";
echo "<input type=\"text\" name=\"ps\" maxlength=\"15\" size=\"15\"><br/>\n";
echo "<input type=\"submit\" value=\"Вход\" name=\"enter\"></b>\n";
echo "<br/>---<br/>";
echo "<a href=\"enter.php?id=$id&ps=$ps&ref=$ref\">Прихожая</a><br/>";
echo "</div>";
echo "</BODY>\n";
echo "</HTML>\n";
mysql_close ($link);
exit;
}
function rus_to_k($str){
$str = str_replace("Р°","a",$str);
$str = str_replace("Р±","b",$str);
$str = str_replace("РІ","v",$str);
$str = str_replace("Рі","g",$str);
$str = str_replace("Рґ","d",$str);
$str = str_replace("Рµ","e",$str);
$str = str_replace("С‘","e",$str);
$str = str_replace("Р¶","j",$str);
$str = str_replace("Р·","z",$str);
$str = str_replace("Рё","i",$str);
$str = str_replace("Р№","y",$str);
$str = str_replace("Рє","k",$str);
$str = str_replace("Р»","l",$str);
$str = str_replace("Рј","m",$str);
$str = str_replace("РЅ","n",$str);
$str = str_replace("Рѕ","o",$str);
$str = str_replace("Рї","p",$str);
$str = str_replace("СЂ","r",$str);
$str = str_replace("СЃ","s",$str);
$str = str_replace("С‚","t",$str);
$str = str_replace("Сѓ","u",$str);
$str = str_replace("С„","f",$str);
$str = str_replace("С…","h",$str);
$str = str_replace("С‡","c",$str);
$str = str_replace("С†","q",$str);//ч
$str = str_replace("С€","w",$str);
$str = str_replace("С‰",">",$str);//щ
$str = str_replace("СЊ","<",$str);//ъ
$str = str_replace("С‹","x",$str);//ы
$str = str_replace("СЉ",".",$str);//ь
$str = str_replace("СЌ",":",$str);//э
$str = str_replace("СЋ",";",$str);//ю
$str = str_replace("СЏ","}",$str);//я
$str = str_replace("Рђ","a",$str);
$str = str_replace("Р‘","b",$str);
$str = str_replace("Р’","v",$str);
$str = str_replace("Р“","g",$str);
$str = str_replace("Р”","d",$str);
$str = str_replace("Р•","e",$str);
$str = str_replace("РЃ","e",$str);
$str = str_replace("Р–","j",$str);
$str = str_replace("Р—","z",$str);
$str = str_replace("Р?","i",$str);
$str = str_replace("Р™","y",$str);
$str = str_replace("Рљ","k",$str);
$str = str_replace("Р›","l",$str);
$str = str_replace("Рњ","m",$str);
$str = str_replace("Рќ","n",$str);
$str = str_replace("Рћ","o",$str);
$str = str_replace("Рџ","p",$str);
$str = str_replace("Р ","r",$str);
$str = str_replace("РЎ","s",$str);
$str = str_replace("Рў","t",$str);
$str = str_replace("РЈ","u",$str);
$str = str_replace("Р¤","f",$str);
$str = str_replace("РҐ","h",$str);
$str = str_replace("Р§","c",$str);
$str = str_replace("Р¦","q",$str);
$str = str_replace("РЁ","w",$str);
$str = str_replace("Р©",">",$str);
$str = str_replace("Р¬","<",$str);
$str = str_replace("Р«","x",$str);
$str = str_replace("РЄ",".",$str);
$str = str_replace("Р",":",$str);
$str = str_replace("Р®",";",$str);
$str = str_replace("РЇ","}",$str);
return $str;
}
$latuser=strtolower($us);
$ruser = rus_to_k($us);
if($ruser==$us){
$result = mysql_query ("Select * from users where latuser = '".$latuser."'");
} else {
$result = mysql_query ("select * from users where ruser = '".$ruser."'");
}
}
if (mysql_affected_rows() == 0) {
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">";
echo "<html>";
echo "<head>";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>";
echo "<title>Ошибка!</title>";
echo "</head>";
echo "<body bgcolor=\"#F7EDCE\" link=\"blue\" vlink=\"blue\" text=\"black\">";
echo "<div align=\"center\">";
echo "<font color=\"red\" size=\"5\"><b>Юзер не найден!</b></font><br/><br/>";
echo "Введите свой \"чатовский\" ник и пароль.\n";
echo "<b><form method=\"POST\" action=\"foto.php?ref=$ref\" name=\"auth\">\n";
echo "Ник:<br/>\n";
echo "<input type=\"text\" name=\"us\" maxlength=\"15\" size=\"15\"><br/>\n";
echo "Пароль:<br/>\n";
echo "<input type=\"text\" name=\"ps\" maxlength=\"15\" size=\"15\"><br/>\n";
echo "<input type=\"submit\" value=\"Вход\" name=\"enter\"></b>\n";
echo "<br/>---<br/>";
echo "<a href=\"enter.php?id=$id&ps=$ps&ref=$ref\">Прихожая</a><br/>";
echo "</div>";
echo "</BODY>\n";
echo "</HTML>\n";
mysql_close ($link);
exit;
}
$row = mysql_fetch_array ($result);
if ($ps !== $row["pass"]){
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">";
echo "<html>";
echo "<head>";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>";
echo "<title>Ошибка!</title>";
echo "</head>";
echo "<body bgcolor=\"#F7EDCE\" link=\"blue\" vlink=\"blue\" text=\"black\">";
echo "<div align=\"center\">";
echo "<font color=\"red\" size=\"5\"><b>Не верное сочетание Ника и Пароля!</b></font><br/><br/>";
echo "Введите свой \"чатовский\" ник и пароль.\n";
echo "<b><form method=\"POST\" action=\"foto.php?ref=$ref\" name=\"auth\">\n";
echo "Ник:<br/>\n";
echo "<input type=\"text\" name=\"us\" maxlength=\"15\" size=\"15\"><br/>\n";
echo "Пароль:<br/>\n";
echo "<input type=\"text\" name=\"ps\" maxlength=\"15\" size=\"15\"><br/>\n";
echo "<input type=\"submit\" value=\"Вход\" name=\"enter\"></b>\n";
echo "<br/>---<br/>";
echo "<a href=\"enter.php?id=$id&ps=$ps&ref=$ref\">Прихожая</a><br/>";
echo "</div>";
echo "</BODY>\n";
echo "</HTML>\n";
mysql_close ($link);
exit;
}
if(!isset($id))$id=$row["id"];
$us=$row["user"];
if(isset($go)){
if(!isset($file)){
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">";
echo "<html>";
echo "<head>";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>";
echo "<title>Ошибка!</title>";
echo "</head>";
echo "<body bgcolor=\"#F7EDCE\" link=\"blue\" vlink=\"blue\" text=\"black\">";
echo "<div align=\"center\">";
echo "<font color=\"red\" size=\"3\"><b>Вы не указали файл!</b></font>";
echo "<br/>---<br/>";
echo "<a href=\"foto.php?id=$id&ps=$ps&ref=$ref\">← Назад</a>";
echo "</div>";
echo "</BODY>\n";
echo "</HTML>\n";
exit;
}
$size = filesize($file);
$par = GetImageSize($file);
if(($par[2]!==2)&&($par[2]!==1)){
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">";
echo "<html>";
echo "<head>";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>";
echo "<title>Ошибка!</title>";
echo "</head>";
echo "<body bgcolor=\"#F7EDCE\" link=\"blue\" vlink=\"blue\" text=\"black\">";
echo "<div align=\"center\">";
echo "<font color=\"red\" size=\"3\"><b>Указанный вами файл не является Gif-файлом!</b></font>";
echo "<br/>---<br/>";
echo "<a href=\"foto.php?id=$id&ps=$ps&ref=$ref\">← Назад</a>";
echo "</div>";
echo "</BODY>\n";
echo "</HTML>\n";
exit;
}
if($size>100240){
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">";
echo "<html>";
echo "<head>";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>";
echo "<title>Ошибка!</title>";
echo "</head>";
echo "<body bgcolor=\"#F7EDCE\" link=\"blue\" vlink=\"blue\" text=\"black\">";
echo "<div align=\"center\">";
echo "<font color=\"red\" size=\"3\"><b>Слишком большой размер файла!</b></font>";
echo "<br/>---<br/>";
echo "<a href=\"foto.php?id=$id&ps=$ps&ref=$ref\">← НАЗАД</a>";
echo "</div>";
echo "</BODY>\n";
echo "</HTML>\n";
exit;
}
if(($par[0]>174)||($par[1]>174)){
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">";
echo "<html>";
echo "<head>";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>";
echo "<title>Ошибка!</title>";
echo "</head>";
echo "<body bgcolor=\"#F7EDCE\" link=\"blue\" vlink=\"blue\" text=\"black\">";
echo "<div align=\"center\">";
echo "<font color=\"red\" size=\"3\"><b>Неправильное разрешение фотографии!</b></font>";
echo "<br/>---<br/>";
echo "<a href=\"foto.php?id=$id&ps=$ps&ref=$ref\">← НАЗАД</a>";
echo "</div>";
echo "</BODY>\n";
echo "</HTML>\n";
exit;
}
$foto=$id.".gif";
if (file_exists("photos/$foto"))
{
unlink ("photos/$foto");
}
Copy($file, "photos/$foto");
@mysql_query ("Update users set img='".$foto."' where id ='".$id."'");
}
$result = mysql_query ("select * from users where id = '".$id."'");
$row = mysql_fetch_array ($result);
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">";
echo "<html>";
echo "<head>";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>";
echo "<title>Добавить фотку!</title>";
echo "</head>";
echo "<body bgcolor=\"#F7EDCE\" link=\"blue\" vlink=\"blue\" text=\"black\">";
echo "<div align=\"center\">";
$nick=strtr($us,array("Р°"=>"а","Р±"=>"б","РІ"=>"в","Рі"=>"г","Рґ"=>"д","Рµ"=>"е","С‘"=>"ё","Р¶"=>"ж","Р·"=>"з","Рё"=>"и","Р№"=>"й","Рє"=>"к","Р»"=>"л","Рј"=>"м","РЅ"=>"н","Рѕ"=>"о","Рї"=>"п","СЂ"=>"р","СЃ"=>"с","С‚"=>"т","Сѓ"=>"у","С„"=>"ф","С…"=>"х","С†"=>"ц","С‡"=>"ч","С€"=>"ш","С‰"=>"щ","СЉ"=>"ъ","С‹"=>"ы","СЊ"=>"ь","СЌ"=>"э","СЋ"=>"ю","СЏ"=>"я","Рђ"=>"А","Р‘"=>"Б","Р’"=>"В","Р“"=>"Г","Р”"=>"Д","Р•"=>"Е","РЃ"=>"Ё","Р–"=>"Ж","Р—"=>"З","Р?"=>"И","Р™"=>"Й","Рљ"=>"К","Р›"=>"Л","Рњ"=>"М","Рќ"=>"Н","Рћ"=>"О","Рџ"=>"П","Р "=>"Р","РЎ"=>"С","Рў"=>"Т","РЈ"=>"У","Р¤"=>"Ф","РҐ"=>"Х","Р¦"=>"Ц","Р§"=>"Ч","РЁ"=>"Ш","Р©"=>"Щ","РЄ"=>"Ъ","Р«"=>"Ы","Р¬"=>"Ь","Р"=>"Э","Р®"=>"Ю","РЇ"=>"Я"));
echo "Загружаемая фотка обязательно должна быть в формате Gif или Jpg, разрешением не более 174х174 и размером не более 25кб. Если вы хотите заменить свою фотку то просто загрузите новую, а старая автоматически удалится.<br/>\n";
echo "<font color=\"blue\" size=\"5\">$nick</font><br/>\n";
if($row["img"]!="")
{
echo "<img align=\"center\" src=\"fr.php?id=$id\"><br/>\n";
}
echo "<form ENCTYPE=\"multipart/form-data\" action=\"foto.php?id=$id&ps=$ps&ref=$ref\" method=\"post\">\n";
echo "<b>Прикрепить фотку:</b><br/>\n";
echo "<INPUT NAME=\"file\" TYPE=\"file\" SIZE=\"20\"><br/>\n";
echo "<input type=\"submit\" name=\"go\" value=\"Отправить\">\n";
echo "</form>\n";
echo "---<br/><a href=\"enter.php?id=$id&ps=$ps&ref=$ref\">Прихожая</a><br/>";
echo "</BODY>\n";
echo "</HTML>\n";
mysql_close ($link);
?>