Размер файла: 6.16Kb
<?
Error_Reporting(E_ALL & ~E_NOTICE); /////////////// игнорируем ошибки
header ("Content-type:text/vnd.wap.wml; charset=utf-8");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-cache, must-relative");
list($msec,$sec)=explode(chr(32),microtime());
$HeadTime=$sec+$msec;
require("conf.inc.php");
$ref=rand(10000,1000000);
$link=@mysql_pconnect ($DB_HOST, $DB_USER, $DB_PASS)
or die ("<wml>
<card id=\"error\" title=\"Ошибка\">
<do type=\"prev\" label=\"Back\"><prev/></do><p align=\"center\">Can not connect to db...</p>
</card>
</wml>");
@mysql_select_db($DB_NAME) or die ("<wml>
<card id=\"error\" title=\"Ошибка\">
<do type=\"prev\" label=\"Back\"><prev/></do><p align=\"center\">error in selecting of the database...</p>
</card>
</wml>");
$result = @mysql_query ("Select * from users where cid='".$cid."' AND 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?cid=$cid&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);
} else {
$row = mysql_fetch_array ($result);
if ($pass !== $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?cid=$cid&ref=$ref\"><timer value=\"15\"/>\n";
echo "<p align=\"center\">\n";
echo "Your login failed\n";
echo "</p>\n";
echo "</card>\n";
echo "</wml>\n";
mysql_close ($link);
} else {
$id = UrlEncode($id);
$login=$row['login'];
$smile=$row['smile'];
$max = $row["num_msgs"];
$time=date ("H:i");
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=\"history\" title=\"Р В Р’ВсторРСвЂР РЋР РЏ\">\n";
echo "<do type=\"options\" name=\"refresh\" label=\"РћР±РЅРѕРІРСвЂР ЎвЂљРЎРЉ\"><go href=\"room.php?id=$id&pass=$pass&room=$room&cid=$cid&ref=$ref\"/></do>\n";
echo "<p mode=\"wrap\">\n";
echo "<a href=\"#add\">Сказать</a><br/>\n";
echo "<a href=\"room.php?id=$id&pass=$pass&room=$room&cid=$cid&ref=$ref\">Обновить</a>\n";
$res = @mysql_query ("Select * from room where cid='".$cid."' AND room='".$room."' AND ((`pr_to` = '-' AND `pr_from` = '-') OR (`pr_from` = '".$id."' OR `pr_to` = '".$id."')) order by id desc limit 60");
$kol = mysql_affected_rows();
@$total=$kol-1;
if (!isset($num)) $num=0;
$mread = $num;
for ($i = 1; $i<=$num; $i++) $data = mysql_fetch_array ($res);
$i = $num;
while (($mread < $num+$max)&&($i<=$total)){
$data = mysql_fetch_array ($res);
$dblogin=$data['login'];
$dbid=$data['dbid'];
$dbmsg=$data['msg'];
$dbtime=$data['time'];
$pr_from=$data['pr_from'];
$pr_to=$data['pr_to'];
++$i;
if($smile==0)
{
$dbmsgearch = array (
"'<[\/\!]*?[^<>]*?>'si");
$replace = array (
"*вырезанo*");
$dbmsg = preg_replace ($dbmsgearch, $replace, $dbmsg);
$dbmsg=preg_replace("/\[!\[/","<",$dbmsg);
$dbmsg=preg_replace("/\]!\]/",">",$dbmsg);
}
if(($pr_from=="-")&&($pr_to=="-")) {
echo "<br/><b><a href=\"user.php?id=$id&pass=$pass&room=$room&dbid=$dbid&cid=$cid&ref=$ref\">$dblogin</a></b> [$dbtime]<br/>$dbmsg";++$mread;
} else {
echo "<br/><b><a href=\"user.php?id=$id&pass=$pass&room=$room&dbid=$dbid&cid=$cid&ref=$ref\">$dblogin</a>[!]</b> [$dbtime]<br/>$dbmsg";++$mread;
}
}
mysql_close ($link);
$total=$kol+($mread-$i);
$page_next = $num + $max-1;
$page_prev = $num - $max+1;
if ($num + $max < $total) {
echo "<br/><a href=\"history.php?id=$id&pass=$pass&room=$room&num=$page_next&cid=$cid&ref=$ref\">След. $max</a>";
}
if ($num >= $max) {
echo "<br/><a href=\"history.php?id=$id&pass=$pass&room=$room&num=$page_prev&cid=$cid&ref=$ref\">Пред. $max</a>\n";
}
echo "<br/><a href=\"enter.php?id=$id&pass=$pass&room=$room&cid=$cid&ref=$ref\">Прихожая</a><br/>\n";
list($msec,$sec)=explode(chr(32),microtime());
echo "[".round(($sec+$msec)-$HeadTime,4)."]";
echo "</p>\n";
echo "</card>\n";
echo "<card id=\"add\" title=\"НапРСвЂР ЎРѓР В°РЎвЂљРЎРЉ\">\n";
echo "<p mode=\"wrap\">\n";
echo "<input name=\"msg$ref\" maxlength=\"200\" title=\"Текст\"/><br/>\n";
echo "<anchor title=\"send\">Сказать<go href=\"room.php?id=$id&pass=$pass&room=$room&cid=$cid&ref=$ref\" method=\"post\">\n";
echo "<postfield name=\"msg\" value=\"$(msg$ref)\"/>\n";
echo "<postfield name=\"private\" value=\"-.-\"/>\n";
echo "</go></anchor>\n";
echo "<br/>\n";
echo "<a href=\"room.php?id=$id&pass=$pass&room=$room&cid=$cid&ref=$ref\">В чат</a>\n";
echo "</p>\n";
echo "</card>\n";
echo "</wml>\n";
}
}
?>