query('UPDATE `online` SET `real_time` = ?i WHERE `id` = ?i', time(), $u->i()['id']);
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 = db::c()->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`
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 = db::c()->query('SELECT `id`, `room`, `time`, `user`, `data` FROM `forest` WHERE `user` = "' . $user['id'] . '" LIMIT 1')->fetch_assoc();
$sp = db::c()->query('SELECT `id`, `room`, `user` FROM `forest` WHERE `room` = "' . $forest['room'] . '"');
while ($pl = $sp->fetch_assoc()) {
$uss .= ', ';
$uss .= $pl['user'];
}
if ($uss != '') {
$uss = ltrim($uss, ', ');
}
$data = db::c()->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`
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 = db::c()->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`
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';
}
Template::header(sprintf('%s (%s)', $rooms[$user->room], mysql_num_rows($data)));
?>
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 "";
db::c()->query("UPDATE `online` SET `date` = " . time() . " WHERE `id` = {$user['id']} LIMIT 1");
exit;
} 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 = db::c()->query("SELECT `id` FROM `users` WHERE ((`align`>1 AND `align`<2)) AND `login` = '" . trim($matches[1][$ii]) . "' LIMIT 1 ;")->fetch_assoc();
if (!$dde['id']) {
exit();
}
}
}
if (@trim($_GET['text']) != null) {
$rr = db::c()->query("SELECT `id` FROM `effects` WHERE `type` = 2 AND `owner` = {$user['id']};")->fetch_assoc();
# Ограничения на ввод символов в чат!
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 (empty($user->clan)) {
$_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']);
}
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 = ["/:susel:/", "/:ponder:/"];
$smiles2 = ["", ""];
preg_match_all("/\[(.*)\]/U", $_GET['text'], $matches);
$_GET['text'] = preg_replace($smiles, $smiles2, $_GET['text'], 3);
$_GET['text'] = tolink($_GET['text']);
if ($user['invis'] == 1) {
$tme = db::c()->query("SELECT `time` FROM `effects` WHERE `owner` = '$user[id]' AND `type` = '1022'")->fetch_assoc();
$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 ("");
}
}