Просмотр файла chat_servis/letters/send.php

Размер файла: 6.22Kb
<?
Error_Reporting(E_ALL & ~E_NOTICE);          /////////////// игнорируем ошибки

if(empty($to)) $error=$error."&#x41D;&#x435;&#x442; &#x43B;&#x43E;&#x433;&#x438;&#x43D;&#x430;!<br/>";
if(empty($subject)) $error=$error."&#x41D;&#x435;&#x442; &#x442;&#x435;&#x43C;&#x44B;!<br/>";
if(empty($letter)) $error=$error."&#x41D;&#x435;&#x442; &#x441;&#x43E;&#x43E;&#x431;&#x449;&#x435;&#x43D;&#x438;&#x44F;!<br/>";
header ("Content-type:text/vnd.wap.wml; charset=utf-8");

list($msec,$sec)=explode(chr(32),microtime()); 
$HeadTime=$sec+$msec;									

$rand=rand(10000,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">
				&#x41B;&#x43E;&#x433;&#x438;&#x43D; &#x438;&#x43B;&#x438; &#x43F;&#x430;&#x440;&#x43E;&#x43B;&#x44C; &#x43D;&#x435;&#x432;&#x435;&#x440;&#x43D;&#x44B;, &#x43F;&#x440;&#x43E;&#x432;&#x435;&#x440;&#x44C;&#x442;&#x435; &#x432;&#x430;&#x448; &#x432;&#x432;&#x43E;&#x434;.
			</p>
		</card>
	</wml>
END;
return 0;
}
else
{
$row=mysql_fetch_array($find_user);
$login=$row['login'];
$id=$row['id'];
$admin=$row['admin'];
$status=$row['status'];
$posts=$row['posts'];

  			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">
								&#x412;&#x44B; &#x437;&#x430;&#x431;&#x430;&#x43D;&#x435;&#x43D;&#x44B; &#x43F;&#x43E; &#x441;&#x432;&#x44F;&#x437;&#x43A;&#x435; ip+browser!
							</p>
						</card>
					</wml>
END;
				exit;
				}

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=\"&#x41E;&#x442;&#x43F;&#x440;&#x430;&#x432;&#x438;&#x442;&#x44C;\" ontimer=\"../enter.php?id=$id&amp;pass=$pass&amp;cid=$cid&amp;ref=$rand\"><timer value=\"20\"/>\n";
echo "<p align=\"center\">\n";
if($row['fsize'] == "small") { $fsize1 = "<small>"; $fsize2 = "</small>"; }
elseif($row['fsize'] == "big") { $fsize1 = "<big>"; $fsize2 = "</big>"; }
else { $fsize1 = ""; $fsize2 = ""; }

$q_to=@mysql_query("select * from users where cid='".$cid."' AND login='$to'");
$to_data=@mysql_fetch_array($q_to);
if(!empty($error)) { print $error;} else {
		if($to==$to_data['login']) {
		mysql_query("insert into letters values(0,'$login','$to','$subject','$letter','".time()."',1,'$cid');");
		print "<b>&#x412;&#x430;&#x448;&#x435; &#x43F;&#x438;&#x441;&#x44C;&#x43C;&#x43E; &#x43E;&#x442;&#x43F;&#x440;&#x430;&#x432;&#x43B;&#x435;&#x43D;&#x43E;!</b><br/>"; } else {
		print "&#x43E;&#x448;&#x438;&#x431;&#x43A;&#x430; &#x43F;&#x440;&#x438; &#x43E;&#x442;&#x43F;&#x430;&#x432;&#x43A;&#x435; &#x43F;&#x438;&#x441;&#x44C;&#x43C;&#x430;!";
		}
}

}
?>
</p>
</card>
</wml>
<?
mysql_close($link);
?>