top.window.location='index.php'";
die();
}
include_once 'config.php';
include_once 'functions.php';
db::c()->query('UPDATE `online` SET `real_time` = ?i WHERE `id` = ?i', time(), $u->i()['id']);
//function tolink($buf) /*Штука, убивающая чужие ссылки*/
//{
// $x = explode(" ", $buf);
// $newbuf = '';
// for ($j = 0; $j < count($x); $j++) {
// if (preg_match("/(http:\\/\\/)?([a-z_0-9-.]+\\.oldcombats+\\.org(([ \"'>\r\n\t])|(\\/([^ \"'>\r\n\t]*)?)))/", $x[$j], $ok)) {
// $newbuf .= str_replace($ok[2], "[Внутреняя ссылка]", str_replace("http://", "", $x[$j])) . " ";
// } else {
// $newbuf .= $x[$j] . " ";
// }
// }
// return $newbuf;
//}
if (isset($_GET['online']) && $_GET['online'] != null) {
if ($_GET['room'] && (int)$_GET['room'] < 500) {
$user['room'] = (int)$_GET['room'];
}
if ($u->i()['caveleader'] > 0) {
$data = mysql_query('
SELECT
`align`,
`u`.`id`,
`klan`,
`level`,
`login`,
`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` = "' . $u->i()['room'] . '" AND
`u`.`caveleader` = "' . $u->i()['caveleader'] . '"
ORDER BY
`u`.`login`
');
$ttl = "" . $rooms[$user['room']] . " (" . mysql_num_rows($data) . ")";
$ch1 = '_active';
$ch2 = '_passive';
$ch3 = '_passive';
$ch4 = '_passive';
$ch5 = '_passive';
} elseif ($user['room'] == 760) {
$forest = mysql_fetch_array(mysql_query('SELECT `id`, `room`, `time`, `user`, `data` FROM `forest` WHERE `user` = "' . $user['id'] . '" LIMIT 1'));
$sp = mysql_query('SELECT `id`, `room`, `user` FROM `forest` WHERE `room` = "' . $forest['room'] . '"');
while ($pl = mysql_fetch_array($sp)) {
$uss .= ', ';
$uss .= $pl['user'];
}
if ($uss != '') {
$uss = ltrim($uss, ', ');
}
$data = mysql_query('
SELECT
`align`,
`u`.`id`,
`klan`,
`action`,
`level`,
`login`,
`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
`u`.`id` IN (' . $uss . ')
ORDER BY
`u`.`login`
');
$ttl = "" . $var_map[$forest['room']] . " (" . mysql_num_rows($data) . ")";
$ch1 = '_active';
$ch2 = '_passive';
$ch3 = '_passive';
$ch4 = '_passive';
$ch5 = '_passive';
} else {
$data = mysql_query('
SELECT
`align`,
`u`.`id`,
`klan`,
`action`,
`level`,
`login`,
`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`
');
$ttl = "" . $rooms[$user['room']] . " (" . mysql_num_rows($data) . ")";
$ch1 = '_active';
$ch2 = '_passive';
$ch3 = '_passive';
$ch4 = '_passive';
$ch5 = '_passive';
}
?>
= $rooms[$user['room']], ' (', mysql_num_rows($data) ?>)
if ($user['first'] != 99) { ?>
} ?>
if (!$_GET['rms']) { ?>
|
if (!empty($user['klan'])) { ?>
|
} ?>
} ?>
if (!$_GET['room']) {
if (!isset($_GET['chview']) || $_GET['chview'] == 1) {
echo '';
} else {
echo '';
}
}
?>
echo '
' . $ttl . '
'; ?>
top.location.href='index.php';");
}
$cha = file("tmp/chat.txt");
header('Content-Type: text/html; charset=utf-8');
echo "";
mysql_query("UPDATE `online` SET `date` = " . time() . " WHERE `id` = {$user['id']} LIMIT 1");
die();
} else {
if (strpos($_GET['text'], "private") !== FALSE && $user['level'] < 1) {
preg_match_all("/\[(.*)\]/U", $_GET['text'], $matches);
for ($ii = 0; $ii < count($matches[1]); $ii++) {
$dde = mysql_fetch_array(mysql_query("SELECT `id` FROM `users` WHERE (`deal` = 1 OR (`align`>1 AND `align`<2)) AND `login` = '" . trim($matches[1][$ii]) . "' LIMIT 1 ;"));
if (!$dde['id']) {
exit();
}
}
}
if (@trim($_GET['text']) != null) {
$rr = mysql_fetch_array(mysql_query("SELECT `id` FROM `effects` WHERE `type` = 2 AND `owner` = {$user['id']};"));
# Ограничения на ввод символов в чат!
if (!isset($rr['id'])) {
$_GET['text'] = substr($_GET['text'], 0, 1024); // Ограничние на символы в чате!
$_GET['text'] = str_replace('<', '<', $_GET['text']);
$_GET['text'] = str_replace(']:[', '] : [', $_GET['text']);
$_GET['text'] = str_replace('>', '>', $_GET['text']);
$_GET['text'] = preg_replace('/private \[klan-([a-zA-Z]*)\]/', '', $_GET['text']);
if ($user['klan'] == '') {
$_GET['text'] = str_replace('private [klan]', '', $_GET['text']);
$_GET['text'] = str_replace('private [klan]', 'private [klan-' . $user['klan'] . ']', $_GET['text']);
} else {
$_GET['text'] = str_replace('private [klan]', 'private [klan-' . $user['klan'] . ']', $_GET['text']);
$_GET['text'] = preg_replace('/private \[klan-([1-9])\]/', 'private [klan-' . $user['klan'] . ']', $_GET['text']);
$pos = strpos($_GET['text'], "[klan-{$user['klan']}") + strlen($user['klan']) + 7;
}
if ($_GET['chtype'] == 6 && stristr($_GET['text'], 'private') === FALSE) {
$_GET['text'] = 'private [help] ' . $_GET['text'];
} elseif ($_GET['chtype'] == 8 && stristr($_GET['text'], 'private') === FALSE) {
$_GET['text'] = 'private [trade] ' . $_GET['text'];
} elseif ($_GET['chtype'] == 3 && $user['klan'] != '') {
$_GET['text'] = 'private [klan-' . $user['klan'] . '] ' . $_GET['text'];
} elseif ($_GET['chtype'] == 4 && (((int)$user['align'] == 1) || $user['admin'] == 1)) {
$_GET['text'] = 'private [pal] ' . $_GET['text'];
}
if ((int)$user['align'] != 1 && $user['admin'] != 1) {
$_GET['text'] = str_replace('private [pal]', '', $_GET['text']);
}
if (strstr($_GET['text'], "/g_nologin") && (in_array($user['align'], $var_security['g_nologin']['align']) || in_array($user['id'], $var_security['g_nologin']['id']))) {
$temp = str_replace('/g_nologin', '', $_GET['text']);
AddChatSystem('' . $temp . '');
$action = 1;
unset($temp);
}
if (strstr($_GET['text'], "/g_login") && (in_array($user['align'], $var_security['g_login']['align']) || in_array($user['id'], $var_security['g_login']['id']))) {
$temp = str_replace('/g_login', '', $_GET['text']);
AddChatSystem('[' . $user['login'] . '] ' . $temp . '');
$action = 1;
unset($temp);
}
#Надо запомнить и дать паладинам возможность затыкать из чата.
/*
if(strstr($_GET['text'], "/afk")) {
$action = 1;
$tmp = str_replace('/afk', '', $_GET['text']);
mysql_query("UPDATE `users` SET `action` = 'afk<>:<>{$tmp}' WHERE `id` = '{$user['id']}' LIMIT 1");
}
*/
unset($tmp);
# Упростил тот Адъ и Израиль до одной нормальной строчки, которая вырежет все ссылки.
if (!preg_match(GAMEDOMAIN, $_GET['text']) || !preg_match("/imgur.com/", $_GET['text'])) {
$_GET['text'] = preg_replace("@((https?://)?([-\w]+\.[-\w\.]+)+\w(:\d+)?(/([-\w/_\.]*(\?\S+)?)?)*)@", '<РАП/РВС>', $_GET['text']);
}
$smiles = array("/:flowers:/", "/:inv:/", "/:hug:/", "/:horse:/", "/:str:/", "/:susel:/", "/:smile:/", "/:laugh:/", "/:fingal:/", "/:eek:/", "/:smoke:/", "/:hi:/", "/:bye:/", "/:king:/", "/:king2:/", "/:boks2:/", "/:boks:/", "/:gent:/", "/:lady:/", "/:tongue:/", "/:smil:/", "/:rotate:/", "/:ponder:/", "/:bow:/", "/:angel:/", "/:angel2:/", "/:hello:/", "/:dont:/", "/:idea:/", "/:mol:/", "/:super:/", "/:beer:/", "/:drink:/", "/:baby:/", "/:tongue2:/", "/:sword:/", "/:agree:/", "/:loveya:/", "/:kiss:/", "/:kiss2:/", "/:kiss3:/", "/:kiss4:/", "/:rose:/", "/:love:/", "/:love2:/", "/:confused:/", "/:yes:/", "/:no:/", "/:shuffle:/", "/:nono:/", "/:maniac:/", "/:privet:/", "/:ok:/", "/:ninja:/", "/:pif:/", "/:smash:/", "/:alien:/", "/:pirate:/", "/:gun:/", "/:trup:/", "/:mdr:/", "/:sneeze:/", "/:mad:/", "/:friday:/", "/:cry:/", "/:grust:/", "/:rupor:/", "/:fie:/", "/:nnn:/", "/:row:/", "/:red:/", "/:lick:/", "/:help:/", "/:wink:/", "/:jeer:/", "/:tease:/", "/:kruger:/", "/:girl:/", "/:Knight1:/", "/:rev:/", "/:smile100:/", "/:smile118:/", "/:smile149:/", "/:smile166:/", "/:smile237:/", "/:smile245:/", "/:smile28:/", "/:smile289:/", "/:smile314:/", "/:smile36:/", "/:smile39:/", "/:smile44:/", "/:smile70:/", "/:smile87:/", "/:smile434:/", "/:vamp:/");
$smiles2 = array("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "");
preg_match_all("/\[(.*)\]/U", $_GET['text'], $matches);
for ($i = 0; $i < count($matches[1]); $i++) {
$prs = mysql_fetch_array(mysql_query('SELECT `id`, `auto_text`, `login` FROM `users` WHERE `login` = "' . mysql_real_escape_string($matches[1][$i]) . '" LIMIT 1'));
if (isset($prs['id']) && $prs['auto_text'] == 1 && $user['login'] != $prs['login']) {
$txt = mysql_fetch_array(mysql_query('SELECT `text` FROM `auto_text` WHERE `owner` = "' . $prs['id'] . '" LIMIT 1'));
$_GET['text'] = 'private [' . $user['login'] . '] Атоответчик (' . $prs['login'] . '): ' . $txt['text'];
}
#$_GET['text'] = 'private ['.$user['login'].'] '.trim($matches[1][$i]);
}
$prs = mysql_fetch_array(mysql_query('SELECT `id`, `auto_text`, `login` FROM `users` WHERE `login` = "' . mysql_real_escape_string($math[2]) . '" LIMIT 1'));
if (isset($prs['id']) && $prs['auto_text'] == 1 && $user['login'] != $prs['login']) {
$txt = mysql_fetch_array(mysql_query('SELECT `text` FROM `auto_text` WHERE `owner` = "' . $prs['id'] . '" LIMIT 1'));
$_GET['text'] = 'private [' . $user['login'] . '] Атоответчик (' . $prs['login'] . '): ' . $txt['text'];
#addchp('Автоответчик ('.$prs['login'].'): '.$txt['text'], '{[]}'.$user['login'].'{[]}');
}
$_GET['text'] = preg_replace($smiles, $smiles2, $_GET['text'], 3);
$_GET['text'] = tolink($_GET['text']);
if ($user['invis'] == 1) {
$tme = mysql_fetch_row(mysql_query("SELECT `time` FROM `effects` WHERE `owner` = '$user[id]' AND `type` = '1022'"));
$user['login'] = 'невидимка ' . substr($tme[0], strlen($tme[0]) - 4) . '';
}
# Понять бы какого чёрта условия два… Инс.
if ($action != 1) {
$file = 'tmp/chat.txt';
if (filesize("tmp/chat.txt") > 100 * 1024) {
$line = "\r\n:[" . time() . "]:[{$user['login']}]:[" . ($_GET['text']) . "]:[" . $user['room'] . "]\r\n";
// Пишем содержимое в файл,
// используя флаг FILE_APPEND flag для дописывания содержимого в конец файла
// и флаг LOCK_EX для предотвращения записи данного файла кем-нибудь другим в данное время
// а то заебали устаревшие функции использовать. Инс.
file_put_contents($file, $line, FILE_APPEND | LOCK_EX);
echo "1";
} else {
$line = ":[" . time() . "]:[{$user['login']}]:[" . ($_GET['text']) . "]:[" . $user['room'] . "]\r\n";
file_put_contents($file, $line, FILE_APPEND | LOCK_EX);
echo "2";
}
}
}
die ("");
}
}