<?php
header("Cache-Control: no-cache");
header("Content-type:text/vnd.wap.wml");
$ref=rand(10000,1000000);
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\">Can not connect to MySQL</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\">error select the database...</p>
</card>
</wml>");
$result = @mysql_query ("Select * from users where id='".$id."'");
if (mysql_affected_rows() == 0) {
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.dtd\">\n";
echo "<wml>\n";
echo "<card id=\"error\" title=\"Ошибка\" ontimer=\"index.php?ref=$ref\"><timer value=\"15\"/>\n";
echo "<p align=\"center\">\n";
echo "User was not found\n";
echo "</p>\n";
echo "</card>\n";
echo "</wml>\n";
mysql_close($link);
exit;
}
$row = mysql_fetch_array ($result);
if ($ps !== $row["pass"]){
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.dtd\">\n";
echo "<wml>\n";
echo "<card id=\"error\" title=\"Ошибка\" ontimer=\"index.php?ref=$ref\"><timer value=\"10\"/>\n";
echo "<p align=\"center\">\n";
echo "Your login failed\n";
echo "</p>\n";
echo "</card>\n";
echo "</wml>\n";
mysql_close($link);
exit;
}
if(isset($go)) {
@$to = str_replace(chr("13"), " ", $to);
@$to = str_replace(chr("10"), " ", $to);
@$to = str_replace("\\n", " ", $to);
@$to = str_replace(" ", " ", $to);
@$to=substr($to,0,100);
@$to = str_replace(" ", " ", $to);
@$to=ereg_replace(" +"," ",$to);
@$to = trim(" $to ");
if (!eregi("^[a-z0-9\._-]+@[a-z0-9\._-]+\.[a-z]{2,4}\$", $to))$err="Неверный формат e-mail адреса";
@$subject = str_replace(chr("13"), " ", $subject);
@$subject = str_replace(chr("10"), " ", $subject);
@$subject = str_replace("\\n", " ", $subject);
@$subject = str_replace(" ", " ", $subject);
@$subject = str_replace(" ", " ", $subject);
@$subject=ereg_replace(" +"," ",$subject);
@$subject = trim(" $subject ");
@$subject = str_replace("", "", $subject);
@$subject = str_replace("", "", $subject);
@$subject = str_replace("", "", $subject);
@$subject = str_replace("", "", $subject);
@$subject = str_replace("", "", $subject);
@$subject = str_replace("", "", $subject);
@$subject= str_replace("\\", "", $subject);
@$mail = str_replace(chr("13"), " ", $mail);
@$mail = str_replace(chr("10"), " ", $mail);
@$mail = str_replace("\\n", " ", $mail);
@$mail = str_replace(" ", " ", $mail);
@$mail = str_replace(" ", " ", $mail);
@$mail=ereg_replace(" +"," ",$mail);
@$mail = trim(" $mail ");
@$mail = str_replace("", "", $mail);
@$mail = str_replace("", "", $mail);
@$mail = str_replace("", "", $mail);
@$mail = str_replace("", "", $mail);
@$mail = str_replace("", "", $mail);
@$mail = str_replace("", "", $mail);
@$mail= str_replace("\\", "", $mail);
@$body = str_replace(chr("13"), " ", $body);
@$body = str_replace(chr("10"), " ", $body);
@$body = str_replace("\\n", " ", $body);
@$body = str_replace(" ", " ", $body);
@$body = str_replace(" ", " ", $body);
@$body=ereg_replace(" +"," ",$body);
@$body = trim(" $body ");
@$body = str_replace("", "", $body);
@$body = str_replace("", "", $body);
@$body = str_replace("", "", $body);
@$body = str_replace("", "", $body);
@$body = str_replace("", "", $body);
@$body = str_replace("", "", $body);
@$body= str_replace("\\", "", $body);
if(@$body==="")$err="Не заполнено поле ввода \"Письмо\"";
if(!isset($err)){
function utf_to_win($str){
$str=strtr($str,array("Р°"=>"а","Р±"=>"б","РІ"=>"в","Рі"=>"г","Рґ"=>"д","Рµ"=>"е","С‘"=>"ё","Р¶"=>"ж","Р·"=>"з","Рё"=>"и","Р№"=>"й","Рє"=>"к","Р»"=>"л","Рј"=>"м","РЅ"=>"н","Рѕ"=>"о","Рї"=>"п","СЂ"=>"р","СЃ"=>"с","С‚"=>"т","Сѓ"=>"у","С„"=>"ф","С…"=>"х","С†"=>"ц","С‡"=>"ч","С€"=>"ш","С‰"=>"щ","СЉ"=>"ъ","С‹"=>"ы","СЊ"=>"ь","СЌ"=>"э","СЋ"=>"ю","СЏ"=>"я",
"Рђ"=>"А","Р‘"=>"Б","Р’"=>"В","Р“"=>"Г","Р”"=>"Д","Р•"=>"Е","РЃ"=>"Ё","Р–"=>"Ж","Р—"=>"З","Р?"=>"И","Р™"=>"Й","Рљ"=>"К","Р›"=>"Л","Рњ"=>"М","Рќ"=>"Н","Рћ"=>"О","Рџ"=>"П","Р "=>"Р","РЎ"=>"С","Рў"=>"Т","РЈ"=>"У","Р¤"=>"Ф","РҐ"=>"Х","Р¦"=>"Ц","Р§"=>"Ч","РЁ"=>"Ш","Р©"=>"Щ","РЄ"=>"Ъ","Р«"=>"Ы","Р¬"=>"Ь","Р"=>"Э","Р®"=>"Ю","РЇ"=>"Я"));
return $str;
}
$subject = utf_to_win($subject);
$subject=substr($subject,0,100);
$body = utf_to_win($body);
$body=substr($body,0,1000);
$mail = utf_to_win($mail);
$mail=substr($mail,0,100);
$now= date("j-m-Y");
$body = "Вам письмо от: $mail \n $body \n $now \n Это письмо послано через почтовый сервис wap-сайта http://wap.bodr.net";
$subject = convert_cyr_string($subject, 'w','k');
$body = convert_cyr_string($body, 'w','k');
$mail = convert_cyr_string($mail, 'w','k');
$adds = "From: bodr@mail \n";
$adds .= "X-sender: < bodr@mail >\n";
$adds .= "Content-Type: text/plain; charset=koi8-r\n";
//if (strtolower($to)!="olyaklukva@bk.ru")
mail($to,$subject,$body,$adds);
//else echo "error";
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.dtd\">\n";
echo "<wml>\n";
echo "<head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>\n";
if($rm=="enter"){
echo "<card id=\"ok\" title=\"ok\" ontimer=\"enter.php?id=$id&ps=$ps&r=$ref\"><timer value=\"10\"/>\n";
} else {
echo "<card id=\"ok\" title=\"ok\" ontimer=\"chat.php?id=$id&ps=$ps&rm=$rm&r=$ref\"><timer value=\"10\"/>\n";
}
echo "<do type=\"prev\" label=\"Назад\"><prev/></do>\n";
echo "<p align=\"center\">\n";
echo "<b>Ваше письмо для $to успешно отправлено</b>\n";
echo "</p>\n";
echo "</card>\n";
echo "</wml>\n";
exit;
}
}
$yourmail=$row["mail"];
if(strstr($yourmail,"<a href=\""))
{
$t = strpos($yourmail,"\">");
$yourmail = substr($yourmail,0,$t);
$e=strlen($yourmail);
$yourmail = substr($yourmail,51,$e);
}
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.dtd\">\n";
echo "<wml>\n";
echo "<head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>\n";
echo "<card id=\"send\" title=\"Send\">\n";
echo "<do type=\"prev\" label=\"Назад\"><prev/></do>\n";
echo "<p>\n";
if(isset($err))echo "$err<br/>\n";
$adr=$to;
echo "РљРѕРјСѓ:<br/>\n";
echo "<input name=\"to$ref\" maxlength=\"100\" value=\"$adr\" title=\"to\"/><br/>\n";
echo "Тема:<br/>\n";
echo "<input name=\"subject$ref\" maxlength=\"100\" title=\"subject\"/><br/>\n";
echo "РџРёСЃСЊРјРѕ:<br/>\n";
echo "<input name=\"body$ref\" title=\"body\"/><br/>\n";
echo "Ваш e-mail:<br/>\n";
echo "<input name=\"mail$ref\" maxlength=\"100\" value=\"$yourmail\" title=\"body\"/><br/>\n";
echo "<anchor title=\"Sign\">Отправить<go href=\"mail.php?id=$id&ps=$ps&rm=$rm&go=send\" method=\"post\">\n";
echo "<postfield name=\"to\" value=\"$(to$ref)\"/>\n";
echo "<postfield name=\"subject\" value=\"$(subject$ref)\"/>\n";
echo "<postfield name=\"body\" value=\"$(body$ref)\"/>\n";
echo "<postfield name=\"mail\" value=\"$(mail$ref)\"/>\n";
echo "</go></anchor><br/>\n";
echo "*********<br/>\n";
if($rm=="enter"){
echo "<a href=\"enter.php?id=$id&ps=$ps&r=$ref\">На улицу</a>\n";
} else {
echo "<a href=\"chat.php?id=$id&ps=$ps&rm=$rm&r=$ref\">В чат</a>\n";
}
echo "</p>\n";
echo "</card>\n";
echo "</wml>\n";
mysql_close($link);
?>