Чат на коленке

This commit is contained in:
lopar 2018-03-02 01:21:53 +02:00
parent 9a209d6ebd
commit 68ca45299a
3 changed files with 37 additions and 808 deletions

37
chat.php Normal file
View File

@ -0,0 +1,37 @@
<?php
/**
* Copyright (c) 2018.
* Author: Igor Barkov <lopar.4ever@gmail.com>
* Project name: Battles-Game
*/
session_start();
if ($_SESSION['uid'] == null) {
header("Location: index.php");
}
include_once "config.php";
include_once "functions.php";
$chat = db::c()->query('SELECT * FROM `chat` ORDER BY `id` DESC LIMIT 50');
while ($message = $chat->fetch_assoc()) {
echo $message['msgdate'].": " . $message['msg'];
}
$msg = filter_input(INPUT_POST, $_POST['msg']);
$uid = filter_input(INPUT_SESSION, $_SESSION['uid']);
if ($msg) db::c()->query('INSERT INTO `chat` (`cid`, `uid`, `msg`) VALUES (?i, ?i, "?s")', 1, $uid, $msg);
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="css/main.css">
</head>
<body>
<form action="chat.php" method="post">
<input name="msg" size="100" placeholder="Введите сообщение...">
<input type="submit">
</form>
</body>

View File

@ -1,160 +0,0 @@
<?
class Filter {
public $sm = array("laugh"=>1,"fingal"=>1,"eek"=>1,"smoke"=>1,"hi"=>1,"bye"=>1,"king"=>1,"king2"=>1,"boks2"=>1,"boks"=>1,"gent"=>1,"lady"=>1,"tongue"=>1,"smil"=>1,"rotate"=>1,"ponder"=>1,"bow"=>1,"angel"=>1,"angel2"=>1,"hello"=>1,"dont"=>1,"idea"=>1,"mol"=>1,"super"=>1,"beer"=>1,"drink"=>1,"baby"=>1,"tongue2"=>1,"sword"=>1,"agree"=>1,"loveya"=>1,"kiss"=>1,"kiss2"=>1,"kiss3"=>1,"kiss4"=>1,"rose"=>1,"love"=>1,"love2"=>1,"confused"=>1,"yes"=>1,"no"=>1,"shuffle"=>1,"nono"=>1,"maniac"=>1,"privet"=>1,"ok"=>1,"ninja"=>1,"pif"=>1,"smash"=>1,"alien"=>1,"pirate"=>1,"gun"=>1,"trup"=>1,"mdr"=>1,"sneeze"=>1,"mad"=>1,"friday"=>1,"cry"=>1,"grust"=>1,"rupor"=>1,"fie"=>1,"nnn"=>1,"row"=>1,"red"=>1,"lick"=>1,"help"=>1,"wink"=>1,"jeer"=>1,"tease"=>1,"nunu"=>1,"inv"=>1,"duel"=>1,"susel"=>1,"nun"=>1,"kruger"=>1,"flowers"=>1,"horse"=>1,"hug"=>1,"str"=>1,"alch"=>1,"pal"=>1,"mag"=>1,"sniper"=>1,"vamp"=>1,"doc"=>1,"doc2"=>1,"sharp"=>1,"naem"=>1,"naem2"=>1,"naem3"=>1,"invis"=>1,"chtoza"=>1,"beggar"=>1,"sorry"=>1,"sorry2"=>1,"creator"=>1,"grace"=>1,"dustman"=>1,"carreat"=>1,"lordhaos"=>1,"ura"=>1,"elix"=>1,"dedmoroz"=>1,"snegur"=>1,"showng"=>1,"superng"=>1,"podz"=>1,"sten"=>1,"devil"=>1,"cat"=>1,"owl"=>1,"lightfly"=>1,"snowfight"=>1,"rocket"=>1,"ball"=>1,"smile"=>1,"fuck"=>1);
public $abuse = array("лох"=>1,"мудак"=>2);
public function e($t) {
mysql_query('INSERT INTO `chat` (`text`, `city`, `to`, `type`, `new`, `time`) VALUES ("#'.date('d.m.Y').' %'.date('H:i:s').': <b>'.mysql_real_escape_string($t).'</b>", "capitalcity", "The Kite Runner", "6", "1", "-1")');
}
public function setOnline($online, $uid, $afk) {
$add = 0;
if(time()-$online >= 1) {
if(time()-$online < 60) {
$add += time()-$online;
} else {
$add += 60;
}
}
$afk = 0;
if($add > 0) {
$on = mysql_fetch_array(mysql_query('SELECT * FROM `online` WHERE `id` = "'.$uid.'" LIMIT 1'));
if(isset($on['id'])) {
$mt = 0;
$lst = time();
mysql_query('UPDATE `online` SET `date` = "'.$lst.'" WHERE `id` = "'.$on['id'].'" LIMIT 1');
}
}
}
public function mystr($string) {
$str = strtolower($string);
if(strtolower('S') != 's') {
$ru = 'АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЫЭЮЯЬЪ';
$ru2 = 'абвгдеёжзийклмнопрстуфхцчшщъьыэюяьъ';
$en = 'QWERTYUIOPASDFGHJKLZXCVBNM';
$en2 = 'qwertyuiopasdfghjklzxcvbnm';
$i = 0;
while($i < 33) {
if(isset($ru[$i])) {
$str = strtr($str, $ru[$i], $ru2[$i]);
}
if(isset($en[$i])) {
$str = strtr($str, $en[$i], $en2[$i]);
}
$i++;
}
}
return $str;
}
public function reverse_i($str) {
$newstr = $str;
return $newstr;
}
public function spamFiltr($txt) {
$nospam = 0;
$txt = str_replace('&gt;', '', $txt);
$txt = str_replace('&lt;', '', $txt);
$txt = str_replace('&quot;', '', $txt);
$txt = $this->mystr($txt);
$i = 0;
$j = 0;
while($i <= count($this->sm)) {
if(isset($this->sm[$i])) {
$txt = preg_replace('/:'.$this->sm[$i].':/', "", $txt);
}
$i++;
}
$spam = file_get_contents('spambase.txt',"r");
$testEN = preg_replace('/[^a-z]*/i', '', $txt);
$testEN2 = $txt;
$testEN2 = str_replace('Р°','a',$testEN2);
$testEN2 = str_replace('Р±','b',$testEN2);
$testEN2 = str_replace('СЃ','c',$testEN2);
$testEN2 = str_replace('РІ','b',$testEN2);
$testEN2 = str_replace('Рµ','e',$testEN2);
$testEN2 = str_replace('С','t',$testEN2);
$testEN2 = str_replace('Рѕ','o',$testEN2);
$testEN2 = str_replace('СЂ','p',$testEN2);
$testEN2 = str_replace('Рј','m',$testEN2);
$testEN2 = str_replace('РЅ','h',$testEN2);
$testEN2 = str_replace('Сѓ','y',$testEN2);
$testEN2 = str_replace('Рє','k',$testEN2);
$testEN2 = str_replace('Рё','u',$testEN2);
$testEN2 = str_replace('С…','x',$testEN2);
$testEN2 = str_replace('()','o',$testEN2);
$testEN2 = str_replace('0','o',$testEN2);
$testEN2 = preg_replace('/[^a-z]*/i', '', $testEN2);
$testRU = preg_replace('/[^Р°-СЏ]*/i', '', $txt);
$testRU2 = $txt;
$testRU2 = str_replace('a','Р°',$testRU2);
$testRU2 = str_replace('b','Р±',$testRU2);
$testRU2 = str_replace('c','СЃ',$testRU2);
$testRU2 = str_replace('b','РІ',$testRU2);
$testRU2 = str_replace('e','Рµ',$testRU2);
$testRU2 = str_replace('t','С',$testRU2);
$testRU2 = str_replace('o','Рѕ',$testRU2);
$testRU2 = str_replace('p','СЂ',$testRU2);
$testRU2 = str_replace('m','Рј',$testRU2);
$testRU2 = str_replace('h','РЅ',$testRU2);
$testRU2 = str_replace('y','Сѓ',$testRU2);
$testRU2 = str_replace('k','Рє',$testRU2);
$testRU2 = str_replace('x','С…',$testRU2);
$testRU2 = str_replace('u','Рё',$testRU2);
$testRU2 = str_replace('()','Рѕ',$testRU2);
$testRU2 = str_replace('0','Рѕ',$testRU2);
$testRU2 = preg_replace('/[^Р°-СЏ]*/i', '', $testRU2);
$i = 0; $spe = explode('|',$spam);
while($i <= count($spe)) {
if(isset($spe[$i]) && $spe[$i] != '' && $spe[$i] != 'capitalcity.old-dark.ru') {
if(preg_match("/".($spe[$i])."/i", ($testEN))) {
$nospam .= '%'.$spe[$i];
} elseif(preg_match("/".($spe[$i])."/i", ($testRU))) {
$nospam .= '%'.$spe[$i];
} elseif(preg_match("/".($spe[$i])."/i", ($testEN2))) {
$nospam .= '%'.$spe[$i];
} elseif(preg_match("/".($spe[$i])."/i", ($testRU2))) {
$nospam .= '%'.$spe[$i];
}
}
$i++;
}
return $nospam;
}
public function getSmiles($txt, $lg) {
$i = 0; $j = 0;
$txt = ' '.$txt; $h = explode(':', $txt);
while($i <= count($this->sm)) {
if(isset($h[$i])) {
if(isset($this->sm[$h[$i]])) {
if($j < 6) {
$clk = 'onclick=\"top.addSm(\''.$h[$i].'\');\" style=\"cursor: pointer;\"';
$h[$i] = '*not_dbl_ponts*<img '.$clk.' src=\"//img.capitalcity.old-dark.ru/i/smile/'.$h[$i].'.gif\" .>*not_dbl_ponts*';
$j++;
}
}
}
$i++;
}
$txt = implode($h, ':');
$txt = str_replace(':*not_dbl_ponts*', '', $txt);
$txt = str_replace('*not_dbl_ponts*:', '', $txt);
$txt = str_replace('*not_dbl_ponts*', '', $txt);
$txt = trim($txt,' ');
return $txt;
}
public function __clone() {
trigger_error('Дублирование не допускается.', E_USER_ERROR);
}
}
$filter = new Filter();
?>

View File

@ -1,648 +0,0 @@
<?php
session_start();
if(!isset($_SESSION['uid'])) { die(json_encode(array('js' => 'top.location="main.php?exit='.mt_rand(0, 50000).'";'))); }
include('config.php');
include('classes/filter_class.php');
$rooms = array (
"0"=>"Секретная Комната",
"1"=>"Комната Новичков",
"2"=>"Комната Новичков 2",
"3"=>"Комната Новичков 3",
"4"=>"Комната Новичков 4",
"5"=>"Зал Воинов ",
"6"=>"Зал Воинов 1",
"7"=>"Зал Воинов 2",
"8"=>"Торговый зал",
"9"=>"Рыцарский зал",
"10"=>"Башня рыцарей-магов",
"11"=>"Колдовской мир",
"12"=>"Этажи духов",
"13"=>"Астральные этажи",
"14"=>"Огненный мир",
"15"=>"Зал Паладинов",
"16"=>"Совет Белого Братства",
"17"=>"Зал Тьмы",
"18"=>"Царство Тьмы",
"19"=>"Будуар",
"20"=>"Центральная площадь",
"21"=>"Страшилкина улица",
"22"=>"Магазин",
"23"=>"Ремонтная мастерская",
"24"=>"Памятник Архангелу",
"25"=>"Комиссионный магазин",
"26"=>"Замковая улица",
"27"=>"Почта",
"28"=>"Регистратура кланов",
"29"=>"Банк",
"30"=>"Регистратура кланов",
"31"=>"Башня смерти",
"32"=>"Готический замок",
"33"=>"Лабиринт хаоса",
"34"=>"Цветочный магазин",
"35"=>"Сувенирный магазин",
"36"=>"Зал Стихий",
"37"=>"Готический замок - приемная",
"38"=>"Готический замок - арсенал",
"39"=>"Готический замок - внутренний двор",
"40"=>"Готический замок - мастерские",
"41"=>"Готический замок - комнаты отдыха",
"42"=>"Лотерея Сталкеров",
"43"=>"Хижина Знахаря",
"44"=>"Новогодняя елка",
"45"=>"Замок Мэра",
"47"=>"Замок (строительство)",
"48"=>"Обитель Хаоса",
"49"=>"Проход к Цитадели Хаоса",
"50"=>"Магазин Берёзка",
"51"=>"Парковая улица",
"52"=>"Квартал Законников",
"53"=>"Библиотека",
"54"=>"Зал Света",
"55"=>"Царство Света",
"56"=>"Царство Стихий",
"57"=>"Зал Клановых Войн",
"101"=>"Противостояние сил",
"200"=> "Турнир",
"401"=> "Врата Ада",
// БС
"501" => "Восточная Крыша",
"502" => "Бойница",
"503" => "Келья 3",
"504" => "Келья 2",
"505" => "Западная Крыша 2",
"506" => "Келья 4",
"507" => "Келья 1",
"508" => "Служебная комната",
"509" => "Зал Отдыха 2",
"510" => "Западная Крыша 1",
"511" => "Выход на Крышу",
"512" => "Зал Статуй 2",
"513" => "Храм",
"514" => "Восточная комната",
"515" => "Зал Отдыха 1",
"516" => "Старый Зал 2",
"517" => "Старый Зал 1",
"518" => "Красный Зал 3",
"519" => "Зал Статуй 1",
"520" => "Зал Статуй 3",
"521" => "Трапезная 3",
"522" => "Зал Ожиданий",
"523" => "Оружейная",
"524" => "Красный Зал-Окна",
"525" => "Красный Зал",
"526" => "Гостинная",
"527" => "Трапезная 1",
"528" => "Внутренний Двор",
"529" => "Внутр.Двор-Вход",
"530" => "Желтый Коридор",
"531" => "Мраморный Зал 1",
"532" => "Красный Зал 2",
"533" => "Библиотека 1",
"534" => "Трапезная 2",
"535" => "Проход Внутр. Двора",
"536" => "Комната с Камином",
"537" => "Библиотека 3",
"538" => "Выход из Мрам.Зала",
"539" => "Красный Зал-Коридор",
"540" => "Лестница в Подвал 1",
"541" => "Южный Внутр. Двор",
"542" => "Трапезная 4",
"543" => "Мраморный Зал 3",
"544" => "Мраморный Зал 2",
"545" => "Картинная Галерея 1",
"546" => "Лестница в Подвал 2",
"547" => "Проход Внутр. Двора 2",
"548" => "Внутр.Двор-Выход",
"549" => "Библиотека 2",
"550" => "Картинная Галерея 3",
"551" => "Картинная Галерея 2",
"552" => "Лестница в Подвал 3",
"553" => "Терасса",
"554" => "Оранжерея",
"555" => "Зал Ораторов",
"556" => "Лестница в Подвал 4",
"557" => "Темная Комната",
"558" => "Винный Погреб",
"559" => "Комната в Подвале",
"560" => "Подвал",
"600" => "Вход в Цитадель Хаоса",
"601" => "Цитадель Хаоса",
"602" => "Городской парк",
"603" => "Арена Ангелов",
620 => "Вход в Рудник",
621 => "Рудник",
660 => "Гостиница, холл",
661 => "Гостиница",
662 => "Памятник Архангелу",
760 => "Тёмный Лес",
// Клановая улица
"650" => "Клановая улица",
"651" => "Клановая улица",
"652" => "Клановый Замок",
//
"1000" => "Вход в рудник",
"1001" => "Рудник",
1051 => "Вход в Лабиринты",
1052 => "Лабиринты",
1053 => "Храмовая лавка",
"2000" => "Подземный проход",
"2001" => "Подземный проход (1)",
"2002" => "Подземный проход (2)",
"2003" => "Подземный проход (3)",
"2004" => "Подземный проход (4)",
"2005" => "Подземный проход (5)",
"2006" => "Подземный проход (6)",
"2007" => "Подземный проход (7)",
"2008" => "Подземный проход (8)",
"2009" => "Подземный проход (9)",
"2010" => "Подземный проход (10)",
"2011" => "Подземный проход (11)",
"2012" => "Подземный проход (12)",
"2013" => "Подземный проход (13)",
"2014" => "Подземный проход (14)",
"2015" => "Подземный проход (15)",
"2016" => "Подземный проход (16)",
"2017" => "Подземный проход (17)",
"2018" => "Подземный проход (18)",
"2019" => "Подземный проход (19)",
"2020" => "Подземный проход (20)",
"2021" => "Подземный проход (21)",
"2022" => "Подземный проход (22)",
"2023" => "Подземный проход (23)",
"2024" => "Подземный проход (24)",
"2025" => "Подземный проход (25)",
"2026" => "Подземный проход (26)",
"2027" => "Подземный проход (27)",
"2028" => "Подземный проход (28)",
"2029" => "Подземный проход (29)",
"2030" => "Подземный проход (30)",
"2031" => "Подземный проход (31)",
"2032" => "Подземный проход (32)",
"2033" => "Подземный проход (33)",
"2034" => "Подземный проход (34)",
"2035" => "Подземный проход (35)",
"2036" => "Подземный проход (36)",
"2037" => "Подземный проход (37)",
"2038" => "Подземный проход (38)",
"2039" => "Подземный проход (39)",
"2040" => "Подземный проход (40)",
"2041" => "Подземный проход (41)",
"2042" => "Подземный проход (42)",
"2043" => "Подземный проход (43)",
"2044" => "Подземный проход (44)",
"2045" => "Подземный проход (45)",
"2046" => "Подземный проход (46)",
"2047" => "Подземный проход (47)",
"2048" => "Подземный проход (48)",
"2049" => "Подземный проход (49)",
"2050" => "Подземный проход (50)",
"2051" => "Подземный проход (51)",
"2052" => "Подземный проход (52)",
"2053" => "Подземный проход (53)",
"2054" => "Подземный проход (54)",
"2055" => "Подземный проход (55)",
"2056" => "Подземный проход (56)",
"2057" => "Подземный проход (57)",
"2100" => "Сектор 2100"
);
$user = mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = "'.mysql_real_escape_string($_SESSION['uid']).'" LIMIT 1'));
$sleep = mysql_fetch_array(mysql_query('SELECT `id`, `time` FROM `effects` WHERE `type` = 2 AND `owner` = "'.$user['id'].'" LIMIT 1'));
if(!isset($user['id'])) { die(json_encode(array('js' => 'top.location="main.php?exit='.mt_rand(0, 50000).'";'))); }
$uroom = $rooms[$user['room']];
$user['city'] = 'capitalcity';
$r = array('rnd' => mt_rand(1, 500000), 'rn' => null, 'list' => null, 'msg' => null, 'key' => null, 'js' => null, 'xu' => 0);
if($user['battle'] > 0) {
$btl = mysql_fetch_array(mysql_query('SELECT `id` FROM `battle` WHERE `id` = "'.$user['battle'].'" AND `win` = 3 LIMIT 1'));
if(!isset($btl['id'])) {
$r['js'] .= 'top.frames["main"].location="fbattle.php";';
}
}
if(isset($_POST['delMsg']) && ($user['align'] = 2.99)) {
if(((int)$_POST['delMsg']) > 0) {
mysql_query('UPDATE `chat` SET `delete` = "'.$user['id'].'" WHERE `id` = "'.mysql_real_escape_string(((int)$_POST['delMsg'])).'" LIMIT 1');
}
}
if(isset($_POST['msg']) && str_replace(' ', '', $_POST['msg']) != '') {
$msg = array();
$_POST['msg'] = str_replace('\x3C', '<', $_POST['msg']);
$_POST['msg'] = str_replace('\x3', '>', $_POST['msg']);
$_POST['msg'] = $_POST['msg'];
$_POST['msg'] = str_replace('\\', '\\\\', $_POST['msg']);
$_POST['msg'] = str_replace('"', '[s1;]', $_POST['msg']);
$_POST['msg'] = str_replace("'", '[s2;]', $_POST['msg']);
$_POST['msg'] = str_replace('<', '[s3;]', $_POST['msg']);
$_POST['msg'] = str_replace('>', '[s4;]', $_POST['msg']);
$_POST['msg'] = str_replace(' ', ' ',$_POST['msg']);
$_POST['msg'] = htmlspecialchars($_POST['msg']);
$_POST['msg'] = str_replace('::', '', $_POST['msg']);
$_POST['msg'] = str_replace('[s1;]', '&quot;', $_POST['msg']);
$_POST['msg'] = str_replace("[s2;]", '&quot;', $_POST['msg']);
$_POST['msg'] = str_replace('[s3;]', '&lt;', $_POST['msg']);
$_POST['msg'] = str_replace('[s4;]', '&gt;', $_POST['msg']);
$lmgs = mysql_fetch_array(mysql_query('SELECT COUNT(`id`) FROM `chat` WHERE `login` = "'.$user['login'].'" AND `time` > '.(time()-2).' LIMIT 2'));
if($lmg[0] > 0) {
$r['js'] .= 'chat.sendMsg(["new", "'.time().'", "6", "", "'.$user['login'].'", "<small>РС РЅРµ можете отправлять так часто сообщения... </small>", "Black", "1", "1", "0"]);';
} else {
$msg['time'] = time(); $msg['spam'] = 0; $msg['type'] = 1; $msg['toChat'] = 0; $msg['color'] = 'Black'; $msg['typeTime'] = 0; $msg['sound'] = 0; $msg['global'] = 0; $msg['molch'] = 0; $msg['login'] = $user['login']; $msg['cancel'] = 0; $msg['delete'] = 0; $msg['to'] = ''; $msg['da'] = 0; $msg['color'] = $user['chatColor'];
if($user['align'] != '3.99') {
$msg['fspam'] = $filter->spamFiltr(str_replace('точка', '.', str_replace('ру', 'ru', $_POST['msg'])));
if($msg['fspam'] != '0') {
$msg['spam'] = 1; $msg['delete'] = 1;
$r['js'] .= 'chat.sendMsg(["new", "'.time().'", "6", "", "'.$user['login'].'", "Рнашем чате запрещается сообщать ссылки на атльтернативные проекты. Повторные попытки могут привести к блокировке персонажа.", "Black", "1", "2", "0", "", "", "", "", "'.date('H:i', time()).'"]);';
}
}
if(preg_match("/private\[(.*?)\]/", $_POST['msg'], $msg['to'])) {
$_POST['msg'] = str_replace('private['.$msg['to'].']', 'private ['.$msg['to'].']', $_POST['msg']); $msg['to'] = '';
} elseif(preg_match("/to\[(.*?)\]/", $_POST['msg'], $msg['to'])) {
$msg['to'] = $msg['to'][1];
$_POST['msg'] = str_replace('to['.$msg['to'].']', 'to ['.$msg['to'].']', $_POST['msg']); $msg['to'] = '';
}
if(preg_match("/private \[(.*?)\]/", $_POST['msg'], $msg['to'])) {
$msg['to'] = trim($msg['to']['1'], ' '); $msg['type'] = 3; $_POST['msg'] = str_replace('private ['.$msg['to'].']', ' ', $_POST['msg']);
} elseif(preg_match("/to \[(.*?)\]/", $_POST['msg'], $msg['to'])) {
$msg['to'] = trim($msg['to']['1'], ' '); $msg['type'] = 2; $_POST['msg'] = str_replace('to ['.$msg['to'].']', ' ', $_POST['msg']);
}
if(preg_match("/Невидимка/", $msg['to'])) {
$msg['to'] = preg_replace("/&lt;b&gt;&lt;i&gt;Невидимка&lt;\/i&gt;&lt;\/b&gt;/", "<b><i>Невидимка</i></b>", $msg['to']);
$msg['to'] = preg_replace("/&lt;small&gt;(.*?)&lt;\/small&gt;/", "<small>$1</small>", $msg['to']);
}
$qix = mysql_fetch_array(mysql_query('SELECT `id` FROM `friends` WHERE `ignor` > 0 AND `user` = "'.mysql_real_escape_string($user['id']).'" AND `user_ignor` = "'.mysql_real_escape_string($msg['to']).'" LIMIT 1'));
if(isset($qix['id'])) {
$r['js'] .= 'chat.sendMsg(["new", "'.time().'", "6", "", "'.$user['login'].'", "<b>Вас добавили РІ РёРіРЅРѕСЂ</b>: РС РЅРµ можете отправлять сообщения персонажу &quot;'.htmlspecialchars($msg['to']).'&quot;.", "Black", "1", "1", "0"]);';
$msg['cancel']++;
} elseif($msg['type'] == 3 && $user['level'] < 0) {
$r['js'] .= 'chat.sendMsg(["new", "'.time().'", "6", "", "'.$user['login'].'", "<small>Отправлять сообщения в <b>приват</b> могут персонажи старше нулевого уровня.</small>", "Black", "1", "1", "0"]);';
$msg['cancel']++;
}
if($msg['type'] == 3 && $msg['to'] == 'klan') {
if($user['klan']== '') {
$r['js'] .= 'chat.sendMsg(["new", "'.time().'", "6", "", "'.$user['login'].'", "<small>РС РЅРµ являетесь частью РѕРґРЅРѕРіРѕ РёР· <b>Кланов</b> Рё РЅРµ можете общаться РїРѕ этому каналу.</small>", "Black", "1", "1", "0"]);';
$msg['cancel']++;
} else {
$msg['to'] = 'k'.$user['klan'];
$msg['da'] = 1;
}
} elseif($msg['type'] == 3 && $msg['to'] == 'paladins') {
if($user['align'] <= 1 || $user['align'] >= 2) {
$r['js'] .= 'chat.sendMsg(["new", "'.time().'", "6", "", "'.$user['login'].'", "<small>РС РЅРµ являетесь частью <b>Ордена Света</b> Рё РЅРµ можете общаться РїРѕ этому каналу.</small>", "Black", "1", "1", "0"]);';
$msg['cancel']++;
} else {
$msg['type'] = -3;
}
}
if(isset($sleep['id'])) {
$msg['molch'] = 1;
}
if($msg['cancel'] == 0) {
if(is_array($msg['to'])) {
$msg['to'] = '';
}
if($msg['type'] == 3 && $msg['da'] > 0) {
$msg['type'] = -3;
}
$nosend = 0;
if($nosend == 0) {
$activ = 1;
mysql_query('INSERT INTO `chat` (`active`, `invis`, `da`, `delete`, `molch`, `new`, `login`, `to`, `city`, `room`, `time`, `type`, `spam`, `text`, `toChat`, `color`, `typeTime`, `sound`, `global`) VALUES (
"'.$activ.'",
"'.$user['invis'].'",
"'.$msg['da'].'",
"'.$msg['delete'].'",
"'.$msg['molch'].'",
"1",
"'.$msg['login'].'",
"'.mysql_real_escape_string($msg['to']).'",
"'.$user['city'].'",
"'.$user['room'].'",
"'.$msg['time'].'",
"'.$msg['type'].'",
"'.$msg['spam'].'",
"'.mysql_real_escape_string($_POST['msg']).'",
"'.$msg['toChat'].'",
"'.$msg['color'].'",
"'.$msg['typeTime'].'",
"'.$msg['sound'].'",
"'.$msg['global'].'")');
}
}
}
}
if($_GET['r1'] != 0) {
$sp = mysql_query('SELECT `align`, `u`.`id`, `klan`, `action`, `level`, `login`, `caveleader`, `u`.`battle` AS `in_battle`, `o`.`date`, `u`.`invis`, (SELECT `id` FROM `effects` WHERE `type` = 2 AND `owner` = `u`.`id` LIMIT 1) AS `slp`, (SELECT `id` FROM `effects` WHERE (`type` = 11 OR `type` = 12 OR `type` = 13 OR `type` = 14) AND `owner` = `u`.`id` LIMIT 1) AS `trv`, `deal` FROM `online` AS `o`, `users` AS `u` WHERE `o`.`id` = `u`.`id` AND (`o`.`date` >= '.(time()-90).' OR `u`.`in_tower` = 1) AND `o`.`room` = "'.$user['room'].'" ORDER by `u`.`login`');
$ar_id = 0; $ar_lvl = 0; $ar_all = 0; $usl = array(); $cw = array(); $usid = array();
while($pl = mysql_fetch_array($sp)) {
$ysee = 1;
if(!isset($usl[$pl['login']])) {
$ysee = 1;
}
if((int)$_GET['r3'] != 1) {
if($user['caveleader'] > 0 && $user['caveleader'] != $pl['caveleader']) {
$ysee = 0;
}
}
if($usid[$pl['login']] == true) {
$ysee = 0;
}
$usl[$pl['login']] = $pl['id'];
if(($pl['date'] > time()-90) && $ysee == 1) {
if(($pl['invis'] != 1)) {
$usid[$pl['login']] = true;
$pl['atack'] = 0;
$pl['molch1'] = (0+$sleep['time']);
if($pl['klan'] != '') {
$cl = mysql_fetch_array(mysql_query('SELECT `id`, `name` FROM `clans` WHERE `id` = "'.$pl['klan'].'" LIMIT 1'));
$pl['klan'] = $cl['name'];
}
if(iconv("utf-8", "utf-8", $pl['login']) != '') {
$pl['login'] = iconv("utf-8", "utf-8", $pl['login']);
}
$r['list'] .= '"'.$r['xu'].'":["'.$pl['id'].'","'.$pl['login'].'","'.$pl['level'].'","'.$pl['align'].'","'.$pl['klan'].'","capitalcity","capitalcity","'.$pl['room'].'","","","'.$pl['block'].'","'.$pl['molch1'].'","'.$pl['battle'].'","0","","'.$pl['sex'].'"],';
$ar_id += $pl['id'];
$ar_lvl += $pl['level'];
$ar_all += $pl['align']+$pl['klan']+$pl['molch1']+$pl['block']+$pl['battle'];
}
$r['xu']++;
}
}
unset($pl, $sp);
$r['list'] = rtrim($r['list'], ',');
$r['list'] = '{'.$r['list'].'}';
}
if(isset($_GET['mid']) && !isset($_POST['mid'])) {
$_POST['mid'] = $_GET['mid'];
}
$r['msg'] = ''; $i = 0; $l = 0;
$sp = mysql_query('SELECT `frv`,`id`,`dn`,`active`,`invis`,`login`,`to`,`city`,`room`,`time`,`type`,`spam`,`text`,`toChat`,`color`,`typeTime`,`sound`,`global`,`delete`,`molch`,`da` FROM `chat` WHERE
(
(
`delete` > 0
AND
`time` > '.(time()-360).'
)
OR
(
`time` > '.(time()-120).'
OR
(
`time` = -1
AND
(
`to` = "'.$user['login'].'"
OR
`type` = 8
)
)
OR
(
`time` < -1
AND
`time` > -'.time().'
AND
(
`to` = "'.$user['login'].'"
OR
`type` = 8
OR
`to` = ""
)
)
)
)
AND
`new` = "1"
AND
(
`id` > '.((int)$_POST['mid']).'
OR
`delete` > 0
OR
`spam` > 0
OR
(
`time` < 0
AND
`time` > -'.time().'
AND
(
`to` = "'.$user['login'].'"
OR
`to` = ""
)
)
)
ORDER BY `id` ASC LIMIT 250');
while($pl = mysql_fetch_array($sp)) {
if($pl['delete'] > 0) {
$r['msg'] .= ', "m'.$i.'":["'.$pl['id'].'", "", "delete", "", "", "", "", "", "", "0", "0", "0", "1", "", ""]';
}
if($pl['type'] == 6 || $pl['type'] == 8) { $pl['city'] = $user['city']; }
$see = 1;
if($pl['type'] == 8 && $user['align'] != 2.99 && (($user['align'] <= 1 || $user['align'] >= 2))) {
$see = 0;
}
if($pl['type'] > 0 && $pl['type'] < 4 && $pl['room'] != 0) {
$pl['room'] = $user['room'];
$pl['city'] = $user['city'];
}
if((($pl['type'] == 3 || $pl['type'] == 4) && ($pl['city'] == $user['city'] || $pl['global'] == 1)) || (($pl['type'] == 5 || $pl['type'] == 6 || ($pl['type'] == 8 && ($user['align'] == 2.99 || ($user['align'] > 1 && $user['align'] < 2)))) && ($pl['city'] == $user['city'] || $pl['global'] == 1)) || ($pl['type'] == 7 && $pl['city'] == $user['city'] && $pl['room'] == $user['room']) || ($pl['type'] == 6 && ($pl['city'] == $user['city'] || $pl['global'] == 1)) || $pl['type'] == 9 || $pl['type'] == 10) {
if($pl['to'] != '' && $pl['login'] != $user['login'] && $pl['to'] != $user['login']) {
$n = 0;
$ex = explode(',', $pl['to']);
$j = 0;
while($j < count($ex)) {
if(trim($ex[$j], ' ') == $user['login']) {
$n++;
}
$j++;
}
if($n == 0) {
$see = 0;
}
unset($n, $j, $ex);
}
}
if($pl['type'] == -3 && ($pl['to'] == 'k'.$user['klan'] || ($pl['to'] == 'paladins' && $user['align'] > 1 && $user['align'] < 2))) {
$pl['type'] = 3;
if($pl['to'] == 'k'.$user['klan']) {
$pl['to'] = 'klan';
}
$see = 1;
} elseif($pl['type'] == -3) {
$see = 0;
}
if($pl['type'] == 6 && $pl['room'] > 0 && $pl['room'] != $user['room'] && $pl['to'] == '') {
$see = 0;
}
if($pl['type'] == 8 && $pl['city'] != $user['city'] && $pl['global'] == 0) {
$see = 0;
}
if($pl['molch'] > 0) {
$see = 0;
}
if(($pl['type'] == 1 || $pl['type'] == 2) && ($pl['room'] != $user['room'] || $pl['city'] != $user['city']) && ($pl['global'] == 0 || $_COOKIE['chatCfg11'] == 0)) {
$see = 0;
}
if($pl['global'] == 1 && $pl['city'] == $user['city'] && $pl['type'] != -3) {
$see = 1;
}
if($pl['city'] != $user['city'] && $pl['global'] == 0) {
$see = 0;
}
if($pl['active'] == 1 && $user['align'] != 2.99 && $pl['login'] != $user['login']) {
if($user['align'] > 1 && $user['align'] < 2) {
} else {
$see = 0;
}
}
if($see == 1 && $pl['delete'] == 0 && $pl['login'] != '') {
$qix = mysql_fetch_array(mysql_query('SELECT `id` FROM `friends` WHERE `ignor` > 0 AND `login_ignor` = "'.mysql_real_escape_string($pl['login']).'" AND `user` = "'.$user['id'].'" ) LIMIT 1'));
if(isset($qix['id'])) {
$see = 0;
}
unset($qix);
}
if($see == 1 && $pl['delete'] == 0) {
if($pl['time'] < 0) {
if($pl['to'] == '') {
$lmsch = mysql_fetch_array(mysql_query('SELECT `id` FROM `chat` ORDER BY `id` DESC LIMIT 1'));
if(isset($lmsch['id'])) {
$lmsch['id']++;
mysql_query('UPDATE `chat` SET `id` = "'.$lmsch['id'].'", `time` = "'.time().'" WHERE `id` = "'.$pl['id'].'" LIMIT 1');
$pl['id'] = $lmsch['id'];
} else {
mysql_query('UPDATE `chat` SET `time` = "'.time().'" WHERE `id` = "'.$pl['id'].'" LIMIT 1');
}
} else {
mysql_query('UPDATE `chat` SET `time` = "'.time().'" WHERE `id` = "'.$pl['id'].'" LIMIT 1');
}
$pl['time'] = time();
}
if($pl['delete'] > 0) {
$r['msg'] .= ', "'.$i.'":{"d":"'.$pl['id'].'"}';
} elseif($pl['spam'] > 0) {
$r['msg'] .= ', "'.$i.'":{"s":"'.$pl['id'].'"}';
} else {
if($pl['type'] != 3) {
if($pl['invis'] == 1) {
if($user['align'] != 2.99) {
$pl['login'] = '<b><i>Невидимка</i></b>';
} else {
$pl['login'] = '<b><i>Невидимка</i></b> <small>('.$pl['login'].')</small>';
}
}
}
$r['msg'] .= ', "m'.$i.'":["'.$pl['id'].'", "'.$pl['time'].'", "'.$pl['type'].'", "'.$pl['login'].'", "'.$pl['to'].'", "'.$pl['text'].'", "'.$pl['color'].'", "'.$pl['toChat'].'", "'.$pl['typeTime'].'", "'.$pl['sound'].'", "'.$pl['global'].'", "'.$pl['molch'].'", "'.$pl['active'].'", "'.date('H:i', $pl['time']).'","'.date('d.m.Y H:i', $pl['time']).'", "'.$pl['frv'].'"]';
}
}
if($l < $pl['id']) {
$l = $pl['id'];
}
$i++;
}
$r['msg'] = '{"ld":"'.(0+$l).'", "id":"'.$i.'"'.$r['msg'].'}';
$r['key'] = md5($uroom.'+'.$ar_id.'+'.$ar_lvl.'+'.$ar_all);
unset($ar_id, $ar_lvl);
if($_COOKIE['chatCfg12'] == 0) {
$_GET['key'] = time();
}
if($r['key'] == $_GET['key']) {
unset($r['rn'], $r['list'], $r['key'], $r['xu']);
} elseif($_GET['r1'] != 0) {
$r['rn'] = $uroom;
$r['list'] = $r['list'];
}
if($r['js'] != NULL) {
$r['js'] = $r['js'];
} else {
unset($r['js']);
}
if($r['msg'] != NULL) {
$r['msg'] = $r['msg'];
} else {
unset($r['msg']);
}
unset($c, $u, $db);
$r = json_encode($r);
echo $r;
unset($r);
?>