<?
Error_Reporting(E_ALL & ~E_NOTICE);
if ($login!="") {
$currHour=date("H",time());
$currDate=date("dS F, Y", time());
$currTime=date("$currHour:i:s", time());
if ($met==bz) {
$yv=$obr ;
if ($mess!="") {
$login = htmlspecialchars(stripslashes($login));
$mess = htmlspecialchars(stripslashes($mess));
$k="";
if ($tr!=5) {
$conv1 = array(":)",":(",":E",":smok1",":smok2",":smok3",":monyment",":cvetok",":jazik",
":grin",":fack",":plach",":viking",";)",":P",":chajnik",":pozdravlenie",":ryki",
":pivo1",":best",":cool",":wc",":bye",":nika",":kiss1",":encore",":kiss2",":drun",
":love",":beer",":luv",":syper",":gost",":dont",":lamer",":roza",":gitara",":mogila");
$conv2 =array("<img src=\"sm/s1.gif\" alt=\":)\"/>",
"<img src=\"sm/s2.gif\" alt=\":(\"/>",
"<img src=\"sm/s3.gif\" alt=\":E\"/>",
"<img src=\"sm/s4.gif\" alt=\"kyrit\"/>",
"<img src=\"sm/s5.gif\" alt=\"kyrit\"/>",
"<img src=\"sm/s6.gif\" alt=\"kyrit\"/>",
"<img src=\"sm/s7.gif\" alt=\"monyment\"/>",
"<img src=\"sm/s8.gif\" alt=\"cvetok\"/>",
"<img src=\"sm/s9.gif\" alt=\"jazik\"/>",
"<img src=\"sm/s10.gif\" alt=\"grin\"/>",
"<img src=\"sm/s11.gif\" alt=\"fack\"/>",
"<img src=\"sm/s12.gif\" alt=\"plach\"/>",
"<img src=\"sm/s13.gif\" alt=\"viking\"/>",
"<img src=\"sm/s14.gif\" alt=\";)\"/>",
"<img src=\"sm/s15.gif\" alt=\":P\"/>",
"<img src=\"sm/s16.gif\" alt=\"chajnik\"/>",
"<img src=\"sm/s17.gif\" alt=\"pozdravlenie\"/>",
"<img src=\"sm/s18.gif\" alt=\"ryki\"/>",
"<img src=\"sm/s19.gif\" alt=\"pivo1\"/>",
"<img src=\"sm/s20.gif\" alt=\"best\"/>",
"<img src=\"sm/s21.gif\" alt=\"cool\"/>",
"<img src=\"sm/s22.gif\" alt=\"wc\"/>",
"<img src=\"sm/s23.gif\" alt=\"bye\"/>",
"<img src=\"sm/s24.gif\" alt=\"nika\"/>",
"<img src=\"sm/s25.gif\" alt=\"kiss\"/>",
"<img src=\"sm/s26.gif\" alt=\"encore\"/>",
"<img src=\"sm/s27.gif\" alt=\"kiss\"/>",
"<img src=\"sm/s28.gif\" alt=\"drun\"/>",
"<img src=\"sm/s29.gif\" alt=\"love\"/>",
"<img src=\"sm/s30.gif\" alt=\"beer\"/>",
"<img src=\"sm/s31.gif\" alt=\"love\"/>",
"<img src=\"sm/s32.gif\" alt=\"syper\"/>",
"<img src=\"sm/s33.gif\" alt=\"gost\"/>",
"<img src=\"sm/s34.gif\" alt=\"dont\"/>",
"<img src=\"sm/s35.gif\" alt=\"lamer\"/>",
"<img src=\"sm/s36.gif\" alt=\"roza\"/>",
"<img src=\"sm/s37.gif\" alt=\"gitara\"/>",
"<img src=\"sm/s38.gif\" alt=\"mogila\"/>");
$me=$mess;
$mess=str_replace($conv1,$conv2,$me); };
if ($tr==5) {
$trans1= array("E","F","CH","SH","IU","IA","A","B","V","G","D","ZH","Z","I","K","L","M","N","O","R","S","T","U","H","C","Y","ch","sh","iu","ia","a","b","v","g","d","e","zh","z","i","k","l","m","n","o","p","r","s","t","u","f","h","c","'","y","J","j","P"
);
$trans2= array("Е","Ф","Ч","Ш","Ю","Я","А","Б","В","Г","Д","Ж","З","И","К","Л","M","Н","О","Р","С","Т","У","Х","Ц","Ы","ч","ш","ю","я","а","б","в","г","д","е","ж","з","и","к","л","м","н","о","п","р","с","т","у","ф","х","ц","ь","ы","Й","й","П"
);
$mess=str_replace($trans1,$trans2,$mess);
};
$text = "
<b>
<a href=\"napis.php?login=\$login&obr=$obr2\">$login</a>
</b> ($currTime): <br/>
$yv $mess
<br/>______<br/>"; /////////////////формат записи в файл нового сообщения
$af = @implode("",@file("af.txt"));
$af = trim($af);
if ($mess!=$af) {
$counterarray = file("counter.dat");
$id = $counterarray[0]+1;
$fp = @fopen("counter.dat","wb");
@fputs($fp,$id);
@fclose($fp);
$nomer = "$id";
if($id>50) { $delfile = $id - 50;
unlink ("rek/$delfile.txt"); }; /////////////////// удаление старых файлов, на сервере сохраняется 50 последних сообщений (при желании можно изменить)
$fp=fopen("rek/$id.txt","w");
fputs($fp,"$text \r\n"); ////////////////// создание нового файла с сообщением с именем номера этого файла
fclose($fp);
$fp=fopen("af.txt","w");
fputs($fp,"$mess \r\n");
fclose($fp);
}; }; }
header("Content-type:text/vnd.wap.wml;charset=UTF-8");
print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://www.wapforum.org/DTD/wml_1.1.xml\">
<wml>
<card id=\"tes\" title=\"Наш чат\" ontimer=\"guest.php?login=$login&new=$id&met=b\" >
<timer value=\"600\"/> <p>
<do type=\"accept\" name=\"newp\" label=\"Сказать\"><go href=\"napis.php?login=$login&obr=&mess=\"/></do>
<do type=\"accept\" name=\"newp2\" label=\"Обновить\"><go href=\"guest.php?login=$login&new=$id&met=b\"/></do>
"; ////////// значение timer можно изменить на другое желаемое значение для автообновления в децесекундах
$id = @implode("",@file("counter.dat"));
if ($nomber == 0) $nomber = "$id" ;
print "<br/> $currTime <br/>========<br/>"; ////////////////// вывод на печать даты и времени
$var = 6; ////////////// число сообщений на странице (чило сообщений = var + 1 !!!)
$i = 0;
while($i <= $var)
{
$text = @implode("",@file("rek/$nomber.txt"));
$nomber = $nomber-1;
print "$text"; $i=$i+1;
};
print "<br/>
<a href=\"napis.php?login=$login&mess=&obr=\">Сказать</a><br/>
<a href=\"guest.php?nomber=$nomber&login=$login&met=b\">Далее</a><br/>
<a href=\"dwap.php?dwap=smile&login=$login&new=$id\">Справка по смайлам</a><br/>
<a href=\"index.wml\">На главную</a>
</p> </card></wml>"; }
//////////////////////////////вывод на страницу ссылок на главную, написать и следующие сообщения.
else {print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.dtd\">
<wml>
<card id=\"tes\" title=\"Наш чат\"><p>
Вернитесь назад и введите логин!<br/>
<a href=\"index.wml\">На главную</a><br/>
</p>
</card>
</wml>";}
?>