<?
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");
$ref=rand(100000000,1000000);
require("conf.inc.php");
global $REMOTE_ADDR;
global $HTTP_USER_AGENT;
$id=@mysql_escape_string($id);
$pass=@mysql_escape_string($pass);
$login=@mysql_escape_string($login);
$link=mysql_pconnect ($DB_HOST, $DB_USER, $DB_PASS);
mysql_select_db($DB_NAME);
if(empty($id)) {
$find_user=mysql_query("Select * from users where cid='".$cid."' AND login='".$login."' and pass='".$pass."'") or die("Querry error");
} else {
$find_user=mysql_query("Select * from users where cid='".$cid."' AND id='".$id."' and pass='".$pass."'") or die("Querry error");
}
if(mysql_affected_rows()==0)
{
echo <<<END
<?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="search" title="Поиск">
<p align="center">
Логин или пароль неверны, проверьте ваш ввод.
</p>
</card>
</wml>
END;
return 0;
}
else
{
$row=mysql_fetch_array($find_user);
$login=$row['login'];
$id=$row['id'];
if (($row["browser"]!==$HTTP_USER_AGENT) or ($row["ip"]!==$REMOTE_ADDR))
{
mysql_query("update users set browser='$HTTP_USER_AGENT', ip='$REMOTE_ADDR' where cid='".$cid."' AND id='$id';");
}
//Проверка, не забанен ли ip+browser:
mysql_query ("Select * from bannedib WHERE cid='".$cid."' AND (ip = '".$REMOTE_ADDR."')and(browser = '".$HTTP_USER_AGENT."')");
if(mysql_affected_rows()!=0)
{
echo <<<END
<?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="error" title="Забанен">
<p align="center">
Вы забанены по связке ip+browser!
</p>
</card>
</wml>
END;
exit;
}
//online
$q_count = @mysql_query("SELECT count(*) FROM users WHERE cid='".$cid."' AND ltime>'".intval(time()-300)."'");
$count = @mysql_fetch_array($q_count);
//end online
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 title=\"online(".$count['count(*)'].")\">\n";
echo "<p align=\"left\">\n";
$q = @mysql_query("select `var`,`val1` from setts where cid='".$cid."' AND mod='room' order by val3;");
while($droom = @mysql_fetch_array($q)) {
$q_online = @mysql_query("SELECT `login` FROM users WHERE cid='".$cid."' AND ltime>'".intval(time()-300)."' AND lroom='".$droom['var']."' order by ltime desc;");
echo '<a href="room.php?id='.$id.'&pass='.$pass.'&room='.$droom['var'].'&cid='.$cid.'&ref='.$ref.'">'.$droom['val1'].':</a><br/>';
while($donline = @mysql_fetch_array($q_online)) { echo $donline['login'].", "; }
echo '<br/>';
}
$pr_count = @mysql_query("SELECT count(*) FROM users WHERE cid='".$cid."' AND ltime>'".intval(time()-300)."' AND lroom='';");
$pdc = @mysql_fetch_array($pr_count);
echo "<a href=\"enter.php?id=$id&pass=$pass&cid=$cid&ref=$ref\">Прихожая</a>(".$pdc['count(*)'].")<br/>";
}
?>
</p>
</card>
</wml>