Файл: gamele.ru/ch.php
Строк: 392
<?php
session_start();
//error_reporting(0);
require_once ($_SERVER["DOCUMENT_ROOT"]."/func/connect.php");
require_once ($_SERVER["DOCUMENT_ROOT"]."/func/sql_func.php");
db_open();
if(isset($_GET['ch_mode'])){
switch(intval($_GET['ch_mode'])){
case 0: $_SESSION['chat']['mode']=0;break;
case 1: $_SESSION['chat']['mode']=1;break;
case 2: $_SESSION['chat']['mode']=2;break;
case 3: $_SESSION['chat']['mode']=3;break;
default: $_SESSION['chat']['mode']=0;break;
}
}
switch($_SESSION['chat']['mode']){
case 0: $ch_mode=0; break; //Системный
case 1: $ch_mode=1; break; //Торговый
case 2: $ch_mode=2; break;
case 3: $ch_mode=3; break; //Системный
default: $ch_mode=0; break;
}
if($_GET['a']=="ign"){
if($_GET['u']!=$_SESSION['user']['login']){
switch($_GET['s']){
case'0':
unset($_SESSION['ignor'][$_GET['u']]);
break;
case'1':
$_SESSION['ignor'][$_GET['u']]=1;
break;
}
}
}
$player=player();
function is_rvs($m){
global $player;
$m = strtolower(trim($m));
$m = str_replace("/","",$m);
$a = explode(" ",$m);
foreach($a as $m)
{
$m = " ".$m." ";
if ((substr_count($m,"http:")
or substr_count($m,".com ")
or substr_count($m,".ru ")
or substr_count($m,".org ")
or substr_count($m,".net ")
or substr_count($m,".su "))
and !substr_count($m,"gamele.ru")
and !substr_count($m,"radikal.ru")
and !substr_count($m,"vk.com")
and !substr_count($m,"userapi.com")
and !substr_count($m,"youtube.com")
and !substr_count($m,"gmail.com")
and !substr_count($m,"mail.ru")
and !substr_count($m,"inbox.ru")
and !substr_count($m,"list.ru")
and !substr_count($m,"bk.ru")
and !substr_count($m,"uppix.net")
and !substr_count($m,"dropbox.com")
and $player['clan_id']!='watchers'
and $player['clan_id']!='admin'
) return true;
}
return false;
}
function is_rkp($m){
global $player;
$m = strtolower(trim($m));
if ((substr_count($m,"escilon")
or substr_count($m,"chaosroad")
or substr_count($m,"neverlands")
or substr_count($m,"ereality")
or substr_count($m,"lastworlds")
or substr_count($m,"windland")
or substr_count($m,"W i n d L a n d")
or substr_count($m,"legendbattles")
or substr_count($m,"lifeiswar")
or substr_count($m,"legendworld")
or substr_count($m,"neolands")
or substr_count($m,"dwar"))
and !substr_count($m,"gamele.ru")
and $player['clan_id']!='watchers'
and $player['clan_id']!='admin'
) return true;
return false;
}
//End Functions
include("includes/database/BotsGroup.php");
list($player['x'],$player['y']) = explode("_",$player['pos']);
$nature_bots = mysql_fetch_assoc(mysql_query("SELECT * FROM `nature_bots` WHERE `x`='".$player['x']."' AND `y`='".$player['y']."'"));
if($player['lastbots']<time() and $player['fight']=='0' and ($player['battle'] == '0' or $player['battle'] == '') and $player['wait']<time() and $player['hp']>='1' and $player['loc']=='28' and !empty($nature_bots['group'])){
NatureBotAttack($BotGroup[$nature_bots['group']][0],$BotGroup[$nature_bots['group']][2]);
}
if(!preg_match("/{$HTTP_HOST}/",getenv ('HTTP_REFERER' )) or $player['pcid']!=md5($player['id'].$player['pass'].$player['Autch_time'].getIP().$_SERVER['HTTP_USER_AGENT'].$player['block'])){
if($player['block']!=''){
exit("<script>top.location = 'index.php?act=logout';</script>");
}else{
exit("<script>top.frames['main_top'].location = '/main.php?useaction=error-page';</script>");
}
}
if(isset($_GET['lo'])){
header("Location: /core2/ch.php");
}
if (isset($_POST['text']) and !empty($player['id'])){
save_hp();
if($player['sleep']<time()){
$msg = ltrim($_POST['text']);
if($player['clan_id']!='none'){
$msg = preg_replace("/^%clan%/","%<clan>",$msg);
}
if($player['pair_id']!='none'){
$msg = preg_replace("/^%pair%/","%<pair>",$msg);
}
preg_match("/^((?:%?<[^>]{2,20}>s?)+)(.*?)$/", $msg, $arr);
if ($arr){
if ($arr[2]){
$message = htmlspecialchars(strip_tags($arr[2], ''));
$to = $arr[1];
}else{
$message = '';
}
}else{
$message = htmlspecialchars(strip_tags($msg, ''));
}
if(preg_match("/%<clan>/i",$arr[1])){
$chtime='clchattime';
$clan_id = $player['clan_id'];
}elseif(preg_match("/%<pair>/i",$arr[1])){
$chtime='pchattime';
$pair_id = $player['pair_id'];
$clan_id = $player['clan_id'];
}elseif(preg_match("/%</i",$arr[1])){
$chtime='prchattime';
}else{
$chtime='yochattime';
}
$messangetobot = $message;
$messangetobot = "<font color=000000> Персонаж <b>".$player['login']."</b> проронил следующее сообщение: <b>".preg_replace("/'/","´",$messangetobot)."</b></font> <BR>'+'');";
if(is_rkp($message)){
$molch = array("Эта игра не вкусная, я у ней уже был... (РКП)","И что нам там делать? Тут интересней! (РКП)");
mysql_query("INSERT INTO `chat` (`time`,`login`,`msg`) VALUES ('".time()."','sys','".addslashes("top.frames['chmain'].add_msg('<font class=chattime> ".date("H:i:s")." </font> <font color=000000><b><font color=#CC0000>Внимание!</font></b></font> На персонажа <b>".$player['login']."</b> наложено заклятие молчания сроком на <b>10</b> мин. (<b>Дружинник</b>)</font><BR>'+'');")."');");
mysql_query("INSERT INTO `chat` (`time`,`login`,`msg`) VALUES ('".time()."','sys','".addslashes("top.frames['chmain'].add_msg ('<font class=chattime> ".date("H:i:s")." </font> <SPL><SPAN>Дружинник</SPAN><SPL><".$player['login']."> <SPL> <font color=000000> ".$molch[rand(0,(count($molch)-1))]."</font> <BR>'+'');")."');");
mysql_query("INSERT INTO `chat` (`time`,`login`,`inv`,`dlya`,`clan_id`,`pair_id`,`msg`) VALUES ('".time()."','Дружинник','0','%<pair> ','chaos','watchers','".addslashes($messangetobot)."');");
mysql_query("UPDATE `user` SET `sleep`='".(time()+10*60)."' WHERE `login`='".$player['login']."' LIMIT 1;");
$molch_next = 1;
}elseif(is_rvs($message)){
$molch = array("Я этот сайт пробывал, он не вкусный ;) (РВС)","А я то думал какой еше сайт мне взломать?) (РВС)");
mysql_query("INSERT INTO `chat` (`time`,`login`,`msg`) VALUES ('".time()."','sys','".addslashes("top.frames['chmain'].add_msg('<font class=chattime> ".date("H:i:s")." </font> <font color=000000><b><font color=#CC0000>Внимание!</font></b></font> На персонажа <b>".$player['login']."</b> наложено заклятие молчания сроком на <b>5</b> мин. (<b>Дружинник</b>)</font><BR>'+'');")."');");
mysql_query("INSERT INTO `chat` (`time`,`login`,`msg`) VALUES ('".time()."','sys','".addslashes("top.frames['chmain'].add_msg ('<font class=chattime> ".date("H:i:s")." </font> <SPL><SPAN>Дружинник</SPAN><SPL><".$player['login']."> <SPL> <font color=000000> ".$molch[rand(0,(count($molch)-1))]."</font> <BR>'+'');")."');");
mysql_query("INSERT INTO `chat` (`time`,`login`,`inv`,`dlya`,`clan_id`,`pair_id`,`msg`) VALUES ('".time()."','Дружинник','0','%<pair> ','chaos','watchers','".addslashes($messangetobot)."');");
mysql_query("UPDATE `user` SET `sleep`='".(time()+5*60)."' WHERE `login`='".$player['login']."' LIMIT 1;");
$molch_next = 1;
}
//Парсим Лнки
if(preg_match("/gamele.ru/",$message) or preg_match("/vk.com/",$message) or preg_match("/radikal.ru/",$message) or preg_match("/userapi.com/",$message) or preg_match("/youtube.com/",$message) or preg_match("/gmail.com/",$message) or preg_match("/dropbox.com/",$message) or preg_match("/mail.ru/",$message) or preg_match("/inbox.ru/",$message) or preg_match("/list.ru/",$message) or preg_match("/bk.ru/",$message) or preg_match("/uppix.net/",$message)){
$pattern = array("'[w+]+://[A-z0-9.?+-/_=&%#:;]+[w/=]+'si","'([^/])(www.[A-z0-9.?+-/_=&%#:;]+[w/=]+)'si","'[w]+[w-.]+@[w-.]+.[w]+'si");
$replacement = array('<a href="$0" target="_blank"><font color=#3564A5>$0</font></a>','$1<a href="http://$2" target="_blank"><font color=#3564A5>$2</font></a>','<a href="mailto:$0"><font color=#3564A5>$0</font></a>');
$message = preg_replace($pattern,$replacement,$message);
}
//Работаем далее
if(!empty($message) and empty($molch_next)){
if($_POST['pactiondo']==1){
$message = "<i><b>".$message."</b></i>";
}
if($player['invisible']>time() and $chtime == 'yochattime'){
$users = $to?'<SPL><b>невидимка</b><SPL>'.preg_replace("<SPL>","",$to).'<SPL>':'<b>невидимка</b>:';
}else{
$users = $to?'<SPL><SPAN>'.$player['login'].'</SPAN><SPL>'.preg_replace("<SPL>","",$to).'<SPL>':'<SPAN>'.$player['login'].'</SPAN>:';
}
$message = preg_replace("/'/","´",$message);
$message = preg_replace("/&#162;/","¢",$message);
$message = preg_replace("/&#8734;/","∞",$message);
$message = "<font color=".$player['chcolor']."> ".preg_replace("/'/","´",$message)."</font> <BR>'+'');";
mysql_query("INSERT INTO `chat` (`time`,`login`,`inv`,`dlya`,`clan_id`,`pair_id`,`loc`,`pos`,`msg`,`mode`) VALUES
(".time().", '".$player['login']."', '".(($player['invisible']<time())?'0':'1')."', '".$to."', '".($clan_id?$clan_id:'none')."', '".($pair_id?$pair_id:'none')."','".$player['loc']."', '".$player['pos']."', '".addslashes($message)."','".$ch_mode."');");
echo "<script>top.clr_input();top.frames['chmain'].add_msg".($ch_mode==0?'':($ch_mode==1?'_trade':($ch_mode==3?'_system':'')))."('<font class=".$chtime."> ".date("H:i:s")." </font> ".$users." ".$message."</script>";
if($to == '<Дружинник> ' or $to == '%<Дружинник> '){
include("includes/database/NewChatBot.php");
if($to != '%<Дружинник> '){
if($response != ''){
$response = "<font color=000000> ".$response."</font> <BR>'+'');";
mysql_query("INSERT INTO `chat` (`time`,`login`,`inv`,`dlya`,`clan_id`,`pair_id`,`loc`,`pos`,`msg`) VALUES ('".time()."','Дружинник','0','<".$player['login']."> ','none','none','".$player['loc']."','".$player['pos']."','".$response."');");
mysql_query("INSERT INTO `chat` (`time`,`login`,`inv`,`dlya`,`clan_id`,`pair_id`,`loc`,`pos`,`msg`) VALUES
(".time().", 'Дружинник', '0', '<".$player['login']."> ', 'none', 'none','".$player['loc']."', '".$player['pos']."', '".addslashes($response)."');");
echo"<script>top.frames['chmain'].add_msg".($ch_mode==0?'':($ch_mode==1?'_trade':($ch_mode==3?'_system':'')))." ('<font class=yochattime> ".date("H:i:s")." </font> <SPL><SPAN>Дружинник</SPAN><SPL><".$player['login']."> <SPL> ".$response."ntop.set_lmid(8);n</script>";
}
}elseif($to == '%<Дружинник> '){
if($response != ''){
echo"<script>top.frames['chmain'].add_msg".($ch_mode==0?'':($ch_mode==1?'_trade':($ch_mode==3?'_system':'')))." ('<font class=prchattime> ".date("H:i:s")." </font> <SPL><SPAN>Дружинник</SPAN><SPL>%<".$player['login']."> <SPL> ".$response."</script>";
}
}
}
echo'</script>';
}
}else{
echo "<script>ntop.clr_input();n</script>";
}
}
if(isset($_GET['show']) and !empty($player['id'])){
if ($_SESSION['user']['on_time'] <= time()){
$_SESSION['user']['on_time'] = time()+200;
mysql_query("UPDATE `user` SET `last`='".time()."' WHERE `id`='".$player['id']."' LIMIT 1;");
}
if($_SESSION['user']['wait'] == 1 and $player['fight'] > 0){
if($player['side'] == 1){
$side = 2;
}else{
$side = 1;
}
$en = mysql_num_rows(mysql_query("SELECT `user`.`id`, `user`.`side`, `user`.`battle`, `user`.`hp`, `fight`.`eid` FROM `user` LEFT JOIN `fight` ON `user`.`id` = `fight`.`eid` WHERE (((`user`.`battle`)='".$player['battle']."') AND ((`user`.`side`)='".$side."') AND ((`user`.`hp`)>'0') AND ((`fight`.`eid`) Is Null)) LIMIT 1;"));
if($en>0){
echo "<script> top.frames['main_top'].location='main.php';</script>";
}
}
/*
$result = mysql_query("SELECT * FROM `chat` WHERE (
(`login` != '".$player['login']."' and `chat`.`dlya` LIKE '%%<".$player['login'].">%' and `id` > '".$_SESSION['user']['lastch']."') or
(`login` != '".$player['login']."' and `clan_id` = '".$player['clan_id']."' and `id`>'".$_SESSION['user']['lastch']."') or
(`login` != '".$player['login']."' and (`pair_id` = '".$player['clan_id']."' or `clan_id` = '".$player['clan_id']."') and `id` > '".$_SESSION['user']['lastch']."') or
(`login` != '".$player['login']."' and `chat`.`dlya` LIKE '%".$player['login']."%' and `id` > '".$_SESSION['user']['lastch']."') or
(`login` != '".$player['login']."' and (`chat`.`dlya` not LIKE '%%<%>%' or `dlya`='') and `id` > '".$_SESSION['user']['lastch']."')) or
((`login`='sys' or `login`='mass') and `id` > '".$_SESSION['user']['lastch']."') or
((`login`='sys' or `login`='mass') and `id` > '".$_SESSION['user']['lastch']."');");
*/
$result = mysql_query("SELECT * FROM `chat` WHERE `id` > '".$_SESSION['user']['lastch']."' AND `login` != '".$player['login']."'");
echo "<script>";
while ($row = mysql_fetch_assoc($result)){
$msg = $row['msg'];
$dlya = $row['dlya'];
$ot = $row['login'];
$time = $p.date("H:i:s",$row['time']);
$_SESSION['user']['lastch'] = $row['id'];
if (array_key_exists($row['login'], $_SESSION['ignor'])){
continue;
}
if(($fyo!=2 and $fyo!=1) and $ot=='mass' and (preg_match("/<".$_SESSION['user']['login'].">/i", $dlya, $regs) or $dlya=='')){
echo "top.frames['chmain'].add_msg".($row['mode']==0?'':($row['mode']==1?'_trade':($row['mode']==3?'_system':'')))."('".$msg."<BR>'+'');";
}else if($ot == 'sys' and (preg_match("/<".$player['login'].">/i", $dlya, $regs)or $dlya == '')){
echo $msg;
}else{
if($fyo==2){
$msg='';
}else if($fyo==1){
if(preg_match("/%<clan>/i", $dlya, $regs) and $player['clan_id']==$row['clan_id']){
$ctimecolor="clchattime";
}elseif(preg_match("/%<pair>/i", $dlya, $regs) and ($player['clan_id']==$row['pair_id'] or $player['clan_id']==$row['clan_id'])){
$ctimecolor="pchattime";
}elseif(preg_match("/%<".$player['login'].">/i", $dlya, $regs) and !preg_match("/%<clan>/i", $dlya, $regs) and !preg_match("/%<pair>/i", $dlya, $regs)){
$ctimecolor="prchattime";
}elseif(preg_match("/<".$player['login'].">/i", $dlya, $regs) and !preg_match("/%<clan>/i", $dlya, $regs) and !preg_match("/%<pair>/i", $dlya, $regs)){
$ctimecolor="yochattime";
}else{
$msg='';
}
}else if($fyo==0){
if(preg_match("/%<clan>/i", $dlya, $regs) and $player['clan_id']==$row['clan_id']){
$ctimecolor="clchattime";
}elseif(preg_match("/%<pair>/i", $dlya, $regs) and ($player['clan_id']==$row['pair_id'] or $player['clan_id']==$row['clan_id'])){
$ctimecolor="pchattime";
}elseif(preg_match("/%<".$player['login'].">/i", $dlya, $regs) and !preg_match("/%<clan>/i", $dlya, $regs) and !preg_match("/%<pair>/i", $dlya, $regs)){
$ctimecolor="prchattime";
}elseif(preg_match("/<".$player['login'].">/i", $dlya, $regs) and !preg_match("/%<clan>/i", $dlya, $regs) and !preg_match("/%<pair>/i", $dlya, $regs)){
$ctimecolor="yochattime";
}elseif(!preg_match("/%</i", $dlya, $regs) and !preg_match("/%<clan>/i", $dlya, $regs) and !preg_match("/%<pair>/i", $dlya, $regs)){
$ctimecolor="chattime";
}else{
$msg='';
}
}
if ($msg != '' and $ot!='sys'){
$ShowMsg = 1;
if($row['inv']=='1' and ($ctimecolor == 'chattime' or $ctimecolor == 'yochattime')){
$ot_1 = ((accesses($player['id'],'pvu'))?'<i>'.$ot.'</i>':'');
$users = $dlya?'<SPL>'.((accesses($player['id'],'pvu'))?'<s><i><SPAN>'.$ot.'</SPAN></i></s>':'невидимка').'<SPL>'.$dlya.'<SPL>':((accesses($player['id'],'pvu'))?'<s><i><SPAN>'.$ot.'</SPAN></i></s>':'невидимка:');
}else{
$users = $dlya?'<SPL><SPAN>'.$ot.'</SPAN><SPL>'.$dlya.'<SPL>':'<SPAN>'.$ot.'</SPAN>:';
}
if($ot == 'Дружинник' and $dlya == '<'.$player['login'].'> '){
$ShowMsg = 0;
}
if($ShowMsg == 1){
echo "ntop.frames['chmain'].add_msg".($row['mode']==0?'':($row['mode']==1?'_trade':($row['mode']==3?'_system':'')))." ('<font class=".$ctimecolor."> ".$time." </font> ".$users." ".$msg;
}
}
}
}
echo "ntop.set_lmid(8);n</script>";
mysql_free_result($result);
}