Файл: chat.php
Строк: 423
<?php
include ('core/core.php');
include ('core/ava_users.php');
if (!$u['id']) {
header("Location: reg.php?err=1");
exit;
}
$location = 'В чате';
switch (@$_GET['act']) {
//~~~~~~~~~~~~~~~~~~Создание комнаты~~~~~~~~~~~~~~~~~~~~~~~~//
case 'add_room':
$flood = mysql_query("SELECT `time` FROM `chat_room` WHERE `user` = '" . $u['id'] . "' AND `time` > '" . (time() - $system['chat_add']) . "'");
if (mysql_num_rows($flood)) {
require('head.php');
error('<b>Ошибка</b>!</br> Можно добавлять комнаты только раз в ' . $system['chat_add'] . ' сек.');
header("Refresh: 3; URL=chat.php");
require('foot.php');
exit;
}
if ($u['admin'] == 1 || $u['admin'] == 2 || $u['admin'] == 4) {
if (isset($_POST['submit']) and $_POST['name']) {
$type = num($_POST['type']);
$bes = num($_POST['bes']);
$admin = num($_POST['admin']);
$name = check(substr($_POST['name'], 0, 100));
$descr = check(substr($_POST['descr'], 0, 200));
if (empty($name)) {
require('head.php');
;
error(' Ошибка, так делать нельзя !');
$error = '1';
require('foot.php');
exit;
}
if (empty($error)) {
mysql_query("INSERT INTO `chat_room` SET
`name` = '$name',
`descr` = '$descr',
`user` = '" . $u['id'] . "',
`time` = '" . time() . "',
`ord` = '0',
`bes` = '$bes',
`admin` = '$admin',
`type` = '$type'
");
$id = mysql_insert_id();
if ($u['sex'] == 'm') {
$action[0] = 'Создал';
} else {
$action[0] = 'Создала';
}
$text = $action[0] . ' комнату в <a href = "chat.php?">чате</a>.';
mysql_query("INSERT INTO `admin_jurnal` SET
`user` = '" . $u['id'] . "',
`text` = '$text',
`time` = '" . time() . "',
`news` = '0',
`forum` = '0',
`diary` = '0',
`chat` = '1',
`blog` = '0',
`foto` = '0',
`ban` = '0',
`edit` = '0',
`new` = '1'
");
header('location: chat.php');
}
} else {
$title = $title . ' :: Чат';
require('head.php');
echo '<div class="title"><center><a href = "chat.php">Чат</a> :: <a href = "chat.php?act=add_room">Добавить комнату</a></center></div>';
echo '<div class="div">';
echo '<form action=chat.php?act=add_room method=post>
Название: 100 символов <br/><textarea cols="20" rows="1" name="name"style="width: 30%;height: 20px;"></textarea>
</div><div class="div">
Описание: 200 символов <br/><textarea cols="20" rows="3" name="descr"></textarea><br/>
<input name="type" type="checkbox" value="1"/> Викторина<br/>
<input name="bes" type="checkbox" value="1"/> Беспредел<br/>
<input name="admin" type="checkbox" value="1"/> Доступ только администраторам и модераторам<br/>
<input type=submit name="submit" value=Создать class=submit white/ ></form>';
echo '</div>';
echo '<div class="title">';
echo '<img src="style/page/back.png" alt="Back"> <a href = "?sid=back" onclick="history.back()">Назад</a>';
echo '</div>';
require('foot.php');
}
}
break;
//~~~~~~~~~~~~~~~~~~~~~~~Редактирование комнаты~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
case 'edit_room':
$flood = mysql_query("SELECT `etime` FROM `chat_room` WHERE `edit` = '" . $u['id'] . "' AND `etime` > '" . (time() - $system['chat_edit']) . "'");
if (mysql_num_rows($flood)) {
require('head.php');
error('<b>Ошибка</b>!</br> Можно редактировать комнаты только раз в ' . $system['chat_add'] . ' сек.');
header("Refresh: 3; URL=chat.php");
require('foot.php');
exit;
}
if ($u['admin'] == 1 || $u['admin'] == 2 || $u['admin'] == 4) {
if (isset($_GET['id'])) {
$id = num($_GET['id']);
$req = mysql_query("SELECT * FROM `chat_room` WHERE `id` = '$id' LIMIT 1");
if (mysql_num_rows($req)) {
$room = mysql_fetch_assoc($req);
}
}
if ($room) {
if (isset($_POST['submit']) and $_POST['name']) {
$type = num($_POST['type']);
$bes = num($_POST['bes']);
$admin = num($_POST['admin']);
$name = check(substr($_POST['name'], 0, 100));
$descr = check(substr($_POST['descr'], 0, 200));
if (empty($name)) {
require('head.php');
;
error(' Ошибка , так делать нельзя !');
$error = '1';
require('foot.php');
exit;
}
if (empty($error)) {
mysql_query("UPDATE `chat_room` SET
`name` = '$name',
`descr` = '$descr',
`edit` = '" . $u['id'] . "',
`etime` = '" . time() . "',
`ord` = '0',
`type` = '$type',
`admin` = '$admin',
`bes` = '$bes'
WHERE `id` = '$id'
");
if ($u['sex'] == 'm') {
$action[0] = 'Отредактировал';
} else {
$action[0] = 'Отредактировала';
}
$text = $action[0] . ' комнату в <a href = "/chat.php">чате</a>.';
mysql_query("INSERT INTO `admin_jurnal` SET
`user` = '" . $u['id'] . "',
`text` = '$text',
`time` = '" . time() . "',
`news` = '0',
`forum` = '0',
`diary` = '0',
`chat` = '1',
`blog` = '0',
`foto` = '0',
`ban` = '0',
`edit` = '0',
`new` = '1'
");
require('head.php');
$name = $room['name'];
echo '<div class="title">';
echo '<img src="ico/chat.png" alt="!"/> <a href = "chat.php">Чат</a> <a href = "chat.php?act=room&id=' . $id . '">' . $name . '</a> Комната сохранина';
echo '</div>';
ok(' Комната сохранина !');
}
} else {
$title = $title . ' :: Чат';
require('head.php');
$name = $room['name'];
$descr = checkout($room['descr']);
$type = $room['type'];
$bes = $room['bes'];
$admin = $room['admin'];
echo '<div class="title"><center>';
echo '<a href = "chat.php">Чат</a> :: <a href = "chat.php?act=room&id=' . $id . '">' . $name . '</a>';
echo '</center></div>';
echo '<div class="div">';
echo '<form action="chat.php?act=edit_room&id=' . $id . '" method="post">';
echo 'Название: <br/><textarea cols="20" rows="1" name="name"style="width: 30%;height: 20px;">' . $name . '</textarea><br/>';
echo '</div><div class="div">';
echo 'Описание:<br/><textarea cols="20" rows="3" name="descr">' . $descr . '</textarea><br/>';
echo '<input name="type" type="checkbox" value="1"' . ($room["type"] == 1 ? ' checked' : '') . '/> Викторина<br/>
<input name="bes" type="checkbox" value="1"' . ($room["bes"] == 1 ? ' checked' : '') . '/> Беспредел<br/>
<input name="admin" type="checkbox" value="1"' . ($room["admin"] == 1 ? ' checked' : '') . '/> Доступ только администраторам и модераторам<br/>';
echo '<input type="submit" name="submit" value="Сохранить" class="submit white"/>';
echo '</form>';
}
echo '</div>';
echo '<div class="title">';
echo '<img src="style/page/back.png" alt="Back"> <a href = "?sid=back" onclick="history.back()">Назад</a>';
echo '</div>';
require('foot.php');
} else {
require('head.php');
echo '<div class="title"><center> <a href = "chat.php?">Чат</a> :: <b>Ошибка</b></center></div>';
echo '<div class="div">';
echo '<table><tr><td VALIGN=top><img src="style/error/notice.png" alt="Ошибка" /></td><td VALIGN=top>Такой комнаты нет!</table></div>';
echo '</div>';
echo '<div class="title">';
echo '<img src="style/page/back.png" alt="Back"> <a href = "?sid=back" onclick="history.back()">Назад</a>';
echo '</div>';
require('foot.php');
}
} else {
require('head.php');
echo '<div class="title"><img src="ico/chat.png" alt="!"/> <a href = "chat.php?">Чат</a> <b>Ошибка</b></div>';
error(' Отказано в доступе !');
require('foot.php');
}
break;
//~~~~~~~~~~~~~~~~~Очистка сообщений в чате~~~~~~~~~~~~~~~~~~~~~~~~~//
case 'delete_all':
if ($u['admin'] >= 1) {
if (isset($_GET['id'])) {
$id = num($_GET['id']);
$req = mysql_query("SELECT * FROM `chat_room` WHERE `id` = '$id' LIMIT 1");
if (mysql_num_rows($req)) {
$room = mysql_fetch_assoc($req);
}
}
if ($room) {
if (isset($_POST['submit'])) {
mysql_query("DELETE FROM `chat_messages` WHERE `room` = '" . $room['id'] . "'");
header('location: chat.php?act=room&id=' . $id . '"');
} else {
$title = $title . ' :: Чат';
require('head.php');
$name = $room['name'];
echo '<div class="title"><center>';
echo '<a href = "chat.php">Чат</a> :: <a href = "chat.php?act=room&id=' . $id . '">' . $name . '</a>';
echo '</center></div>';
echo '<div class="div">';
echo 'Вы уверены, что хотите очистить комнату "<a href = "chat.php?act=room&id=' . $id . '">' . $name . '</a>" ?<br/>';
echo '<form action="chat.php?act=delete_all&id=' . $id . '" method="post">';
echo '<input type="submit" name="submit" value="Да, удалить" class="submit white"/>';
echo '</form></div>';
}
echo '</div>';
echo '<div class="title">';
echo '<img src="style/page/back.png" alt="Back"> <a href = "?sid=back" onclick="history.back()">Назад</a>';
echo '</div>';
require('foot.php');
} else {
require('head.php');
echo '<div class="title"><center><a href = "chat.php?">Чат</a> :: <b>Ошибка</b</center></div>';
echo '<div class="div">';
echo '<table><tr><td VALIGN=top><img src="style/error/notice.png" alt="Ошибка" /></td><td VALIGN=top>Такой комнаты нет!</table></div>';
echo '</div>';
echo '<div class="title">';
echo '<img src="style/page/back.png" alt="Back"> <a href = "?sid=back" onclick="history.back()">Назад</a>';
echo '</div>';
require('foot.php');
}
} else {
require('head.php');
echo '<div class="title"><center><a href = "chat.php?">Чат</a> :: <b>Ошибка</b></center></div>';
error(' Отказано в доступе !');
require('foot.php');
}
break;
//~~~~~~~~~~~~~~~~~Удаление комнаты ~~~~~~~~~~~~~~~~~~~~~~~//
case 'delete_room':
$flood = mysql_query("SELECT `time` FROM `chat_deleted` WHERE `user` = '" . $u['id'] . "' AND `time` > '" . (time() - $system['deleted_chat_antiflud']) . "'");
if (mysql_num_rows($flood)) {
require('head.php');
error(' <b>Ошибка</b>!</br> Можно удалять комнату только раз в ' . $system['deleted_forum_antiflud'] . ' сек. ');
header("Refresh: 3; URL=chat.php?");
require('foot.php');
exit;
}
if ($u['admin'] == 1 || $u['admin'] == 2 || $u['admin'] == 4) {
if (isset($_GET['id'])) {
$id = num($_GET['id']);
$req = mysql_query("SELECT * FROM `chat_room` WHERE `id` = '$id' LIMIT 1");
if (mysql_num_rows($req)) {
$room = mysql_fetch_assoc($req);
}
}
if ($room) {
if (isset($_POST['submit'])) {
mysql_query("DELETE FROM `chat_room` WHERE `id` = '" . $room['id'] . "'");
mysql_query("DELETE FROM `chat_messages` WHERE `room` = '" . $room['id'] . "'");
mysql_query("INSERT INTO `chat_deleted` SET
`user` = '" . $u['id'] . "',
`time` = '" . time() . "'
");
if ($u['sex'] == 'm') {
$action[0] = 'Удалил';
} else {
$action[0] = 'Удалила';
}
$text = $action[0] . ' комнату в <a href = "/chat.php">чате</a>.';
mysql_query("INSERT INTO `admin_jurnal` SET
`user` = '" . $u['id'] . "',
`text` = '$text',
`time` = '" . time() . "',
`news` = '0',
`forum` = '0',
`diary` = '0',
`chat` = '1',
`blog` = '0',
`foto` = '0',
`ban` = '0',
`edit` = '0',
`new` = '1'
");
require('head.php');
header('location: chat.php');
} else {
$title = $title . ' :: Чат';
require('head.php');
$name = $room['name'];
echo '<div class="title">';
echo '<a href = "chat.php">Чат</a> :: <a href = "chat.php?act=room&id=' . $id . '">' . $name . '</a>';
echo '</div>';
echo '<div class="div">';
echo 'Вы уверены, что хотите удалить комнату "<a href = "chat.php?act=room&id=' . $id . '">' . $name . '</a>" ?<br/>';
echo '<form action="chat.php?act=delete_room&id=' . $id . '" method="post">';
echo '<input type="submit" name="submit" value="Да, удалить" class="submit white"/>';
echo '</form></div>';
}
echo '</div>';
echo '<div class="title">';
echo '<img src="style/page/back.png" alt="Back"> <a href = "?sid=back" onclick="history.back()">Назад</a>';
echo '</div>';
require('foot.php');
} else {
require('head.php');
echo '<div class="title"><center><a href = "chat.php?">Чат</a> :: Ошибка</center></div>';
echo '<div class="div">';
echo '<table><td VALIGN=top><img src="style/error/notice.png" alt="Ошибка" /></td><td VALIGN=top>Комната не найдена!</table></div>';
echo '</div>';
echo '<div class="title">';
echo '<img src="style/page/back.png" alt="Back"> <a href = "?sid=back" onclick="history.back()">Назад</a>';
echo '</div>';
require('foot.php');
}
} else {
require('head.php');
echo '<div class="title"><center><a href = "chat.php?">Чат</a> :: <b>Ошибка</b></center></div>';
error(' Отказано в доступе !');
require('foot.php');
}
break;
//~~~~~~~~~~~~~~~~~~~~~Просмотр комнаты~~~~~~~~~~~~~~~~~~~~~~~~//
case 'room':
if (isset($_GET['id'])) {
$id = num($_GET['id']);
$req = mysql_query("SELECT * FROM `chat_room` WHERE `id` = '$id' LIMIT 1");
if (mysql_num_rows($req)) {
$room = mysql_fetch_assoc($req);
}
}
if ($room) {
$chat_location = $id;
if ($room['type'] == 1) {
$umnik = mysql_query("SELECT * FROM `chat_messages` WHERE `umnik` > '0' and `room` = '$id' ORDER BY `time` DESC");
$res = mysql_fetch_array($umnik);
if (!$res['id'] or ( $res['umnik'] > 3 and $res['time'] < time() - 30 ) or ( $res['vopros'] == 0 and $res['time'] < time() - 30 )) {
$k_vopr = mysql_result(mysql_query("SELECT COUNT(*) FROM `chat_vopros`"), 0);
$umnik_vopros = mysql_fetch_array(mysql_query("SELECT * FROM `chat_vopros` WHERE `id` = '" . rand(1, $k_vopr) . "' LIMIT 1"));
mysql_query("INSERT INTO `chat_messages` SET
`user` = '0',
`message` = '" . $umnik_vopros['vopros'] . " Ответ: слово из " . strlen($umnik_vopros['otvet']) / 2 . " букв',
`time` = '" . time() . "',
`room` = '$id',
`umnik` = '1',
`vopros` = '" . $umnik_vopros['id'] . "',
`timevopros` = '" . time() . "'
");
}
if (isset($res['id'])) {
if ($res['timevopros'] > 0 and $res['timevopros'] < time() - 60) {
$msg = 'На вопрос никто не дал правильный ответ. Следующий вопрос через 30 секунд!';
mysql_query("INSERT INTO `chat_messages` SET
`user` = '0',
`message` = '$msg',
`time` = '" . time() . "',
`room` = '$id',
`umnik` = '1',
`vopros` = '0',
`timevopros` = '0'
");
}
}
}
if (@$_POST['message']) {
$message = check(substr($_POST['message'], 0, 250));
if (empty($message)) {
require('head.php');
error(' Ошибка , так делать нельзя !');
$error = '1';
require('foot.php');
exit;
}
$flood = mysql_query("SELECT `time` FROM `chat_messages` WHERE `user` = '" . $u['id'] . "' AND `time` > '" . (time() - $system['chat_comm']) . "'");
if (mysql_num_rows($flood)) {
header("Location: chat.php?act=room&id=$id");
exit;
}
$req = mysql_query("SELECT * FROM `chat_messages` WHERE `user` = '" . $u['id'] . "' and `room` = '$id' ORDER BY `time` DESC");
$res = mysql_fetch_array($req);
if ($res['message'] == $message) {
header("location: chat.php?act=room&id=$id");
exit;
}
$priv = num($_POST['priv']);
if (empty($error)) {
mysql_query("INSERT INTO `chat_messages` SET
`user` = '" . $u['id'] . "',
`message` = '$message',
`time` = '" . time() . "',
`priv` = '$priv',
`room` = '$id'
");
mysql_query("UPDATE `users` SET `stat_chat` = `stat_chat`+1 WHERE `id` = '" . $u['id'] . "'");
if ($room['type'] == 1) {
$umnik = mysql_query("SELECT * FROM `chat_messages` WHERE `umnik` > '0' and `room` = '$id' ORDER BY `time` DESC");
$res = mysql_fetch_array($umnik);
if ($res['umnik'] < 4 and $res['timevopros'] > time() - 60 and isset($res['vopros'])) {
$umnik_vopros = mysql_fetch_array(mysql_query("SELECT * FROM `chat_vopros` WHERE `id` = '" . $res['vopros'] . "' LIMIT 1"));
if (strtolower_utf8($message) == $umnik_vopros['otvet']) {
if ($res['umnik'] == 1) {
$add_money = 3;
$pod = 'не используя подсказок';
}
if ($res['umnik'] == 2) {
$add_money = 2;
$pod = 'используя одну подсказку';
}
if ($res['umnik'] == 3) {
$add_money = 1;
$pod = 'используя обе подсказки';
}
mysql_query("UPDATE `users` SET `money` = '" . ($u['money'] + $add_money) . "' WHERE `id` = '" . $u[id] . "' LIMIT 1");
$msg = 'Молодец, ' . login($u['id']) . ', Вы дали верный ответ "' . $umnik_vopros['otvet'] . '" первее всех, ' . $pod . '. ' . login($u['id']) . ' получает ' . $add_money . ' монет. Следующий вопрос через 30 сек.';
mysql_query("INSERT INTO `chat_messages` SET
`user` = '0',
`message` = '$msg',
`time` = '" . time() . "',
`room` = '$id',
`umnik` = '1',
`vopros` = '0'
");
} else {
if ($res['umnik'] == 1) {
$help = iconv_substr($umnik_vopros['otvet'], 0, 1, 'utf-8');
for ($i = 0; $i < strlen($umnik_vopros['otvet']) / 2 - 1; $i++) {
$help.='*';
}
$msg = 'Вопрос: ' . $umnik_vopros['vopros'] . ' Первая подсказка: ' . $help . '.';
}
if ($res['umnik'] == 2) {
$help = iconv_substr($umnik_vopros['otvet'], 0, 2, 'utf-8');
for ($i = 0; $i < strlen($umnik_vopros['otvet']) / 2 - 2; $i++) {
$help.='*';
}
$msg = 'Вопрос: ' . $umnik_vopros['vopros'] . ' Вторая подсказка: ' . $help . '.';
}
if ($res['umnik'] == 3) {
$msg = 'На вопрос никто не дал правильный ответ. Следующий вопрос через 30 секунд!';
mysql_query("INSERT INTO `chat_messages` SET
`user` = '0',
`message` = '$msg',
`time` = '" . time() . "',
`room` = '$id',
`umnik` = '" . ($res['umnik'] + 1) . "',
`vopros` = '0',
`timevopros` = '0'
");
} else {
mysql_query("INSERT INTO `chat_messages` SET
`user` = '0',
`message` = '$msg',
`time` = '" . time() . "',
`room` = '$id',
`umnik` = '" . ($res['umnik'] + 1) . "',
`vopros` = '" . $umnik_vopros['id'] . "',
`timevopros` = '" . $res['timevopros'] . "'
");
}
}
}
}
}
header("Location: chat.php?act=room&id=$id");
}
$name = $room['name'];
$title = $title . ' :: Чат';
require('head.php');
require('core/bb_code.php');
require('core/panel.php');
echo '<div class="title"><center><a href = "chat.php">Чат</a> :: ' . $name . '</center></div>';
if (@$_GET['warning']) {
echo '<div class="div">
Внимание!</font></br>
В этой комнате разрешено всё, кроме нарушения правил сайта .</br>
Модераторы здесь абсолютно бессильны и лишены возможности банить.</br>
Рекомендуем не обижаться на оскорбления и мат, которые Вы можете услышать в этой комнате</br>
Многие приходят в эту комнату просто ради эмоциональной разрядки.</br>
Людям со слабыми нервами и тонкой душевной организацией заходить в "Беспредел" настоятельно не рекомендуется.</br>
<a href = "chat.php?act=room&id=' . $room['id'] . '"><font color="red">Войти</font></a>
<a href = "chat.php">Я передумал(а)</a>
</div>';
require('foot.php');
exit;
}
if ($u['admin'] == 0) {
if ($room['admin'] == 1) {
error('<b>Ошибка!</b>Отказано в доступе .');
require('foot.php');
exit;
}
}
$all = mysql_result(mysql_query("SELECT COUNT(*) FROM `users` WHERE `online` > '" . (time() - 600) . "' AND `chat_location` = '$id'"), 0);
echo '<div class="nav"><a href = "' . $_SERVER['REQUEST_URI'] . '">Обновить</a></div>';
if (isset($_GET['o'])) {
$o = num($_GET['o']);
$req = mysql_query("SELECT `id`,`login` FROM `users` WHERE `id` = '$o' LIMIT 1");
$user = mysql_fetch_assoc(mysql_query("SELECT `login` FROM `users` WHERE `id` = '" . $o . "'"));
if ($user['login'])
$otv = $user['login'] . ', ';
if (mysql_num_rows($req)) {
if ($o != $u['id'])
$user = mysql_fetch_assoc($req);
}
}
$count = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `users` WHERE `online` > '" . (time() - 600) . "' AND `chat_location` = '$id'"), 0);
echo '<div class="div">';
echo '<form action="chat.php?act=room&id=' . $id . '" method="post" name="form">';
echo '<textarea cols="20" rows="1" name="message" style="width: 50%;height: 20px;">';
echo @$otv;
echo '</textarea>';
if (@$user['id'])
echo '<input name="priv" type="checkbox" value="' . $user['id'] . '"> Приватно<br/>';
echo " <input type='submit' title='Нажмите для отправки' name='submit' value='Ok' class='submit white'/> ";
echo "</form></div>";
if (@$_GET['um'])
error(' Ошибка, Система сейчас занята!');
if ($u['admin'] >= 1) {
if (@$_GET['um_ban'])
error(' Ошибка, Систему нельзя банить!');
}
if ($u['admin'] >= 1) {
if (@$_GET['del']) {
$del = intval($_GET['del']);
$message = mysql_num_rows(mysql_query("SELECT `id` FROM `chat_messages` WHERE `id` = '$del' LIMIT 1"));
if ($message) {
mysql_query("DELETE FROM `chat_messages` WHERE `id` = '$del' LIMIT 1");
ok('Сообщение удалено !');
}
}
}
$all = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `chat_messages` WHERE `room` = '$id' and (`priv` = '0' OR `priv` = '" . $u['id'] . "' OR `user` = '" . $u['id'] . "')"), 0);
if ($all > 0) {
$total = num(($all - 1) / 10) + 1;
@$page = num($_GET['page']);
if (empty($page) or $page < 0)
$page = 1;
if ($page > $total)
$page = $total;
$start = $page * 10 - 10;
$result = mysql_query("SELECT * FROM `chat_messages` WHERE `room` = '$id' and (`priv` = '0' OR `priv` = '" . $u['id'] . "' OR `user` = '" . $u['id'] . "') ORDER BY `id` DESC LIMIT $start, 10");
while ($chat = mysql_fetch_assoc($result)) {
echo '<div class="div">';
$user = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '" . $chat["user"] . "'"));
$message = checkout($chat['message']);
if ($chat['user'] != $u['id'])
$otvet = '[<a href = "chat.php?act=room&id=' . $id . '&o=' . $user['id'] . '">Отв</a>]';
else
$otvet = '';
if ($chat['priv'])
$priv = '<font color = "red">[Приватно]</font></a><br/>';
else
$priv = '';
if ($chat['umnik']) {
echo '<img src = "/style/users/woman_off.png"> <a href="id2"><b><font color="#79358c">Система</font></b></a> ';
} else {
if ($user['delete'] == 1) {
echo '' . ico($user['sex'], $user['admin'], $user['online']) . ' <a href = "id' . $user['id'] . '"><del><b><font color="#79358c">' . $user['login'] . '</font></b></del></a>';
} else {
echo '' . ico($user['sex'], $user['admin'], $user['online']) . ' <a href = "id' . $user['id'] . '"><b><font color="#79358c">' . $user['login'] . '</font></b></a>';
}
}
echo '' . medal($user['rating']) . '';
echo '<span style="float:right;color:grey;">(' . vremya($chat['time']) . ')</span>';
echo '<br/>';
echo $priv;
echo '' . smile(links(bb_code($message))) . '';
echo '</br>';
echo '<small>';
if ($chat['umnik']) {
echo '[<a href = "chat.php?act=room&id=' . $id . '&um=1">Отв</a>]';
} else {
echo '' . $otvet . '';
}
if ($u['admin'] == 1 || $u['admin'] == 2 || $u['admin'] == 3 || $u['admin'] == 4 || $u['admin'] == 5) {
echo ' [<a href = "chat.php?act=room&id=' . $id . '&del=' . $chat['id'] . '">удал</a>] ';
if ($chat['umnik']) {
echo '[<a href = "chat.php?act=room&id=' . $id . '&um_ban=1"><font color="red">Бан</font></a>]';
} else {
if ($u['id'] != $user['id']) {
if (ban($user['id'])) {
if ($message['user'] != $u['id'])
echo ' [<a href = "adminka.php?act=delban_users&id=' . $user['id'] . '"><font color="red">Разбанить</font></a>]';
} else {
if ($message['user'] != $u['id'])
echo ' [<a href = "adminka.php?act=ban_users&id=' . $user['id'] . '"><font color="red">Бан</font></a>]';
}
}
}
}
echo '</small>';
echo '</div>';
}
if ($u['admin'] >= 1) {
echo '<div class="title"><img src="style/page/delete.gif" alt="!"/> <a href = "chat.php?act=delete_all&id=' . $room['id'] . '">Очисть комнату</a></div>';
}
echo '</div>';
echo '<div class="title"><a href = "chat.php?act=who&id=' . $id . '">Кто здесь?</a></div>';
navigation($page, $total, 'chat.php?act=room&id=' . $id . '&');
}
require('foot.php');
} else {
require('head.php');
echo '<div class="title"><center> <a href = "chat.php?">Чат</a> :: <b>Ошибка</b></center></div>';
echo '<div class="div">';
echo '<table><tr><td VALIGN=top><img src="style/error/notice.png" alt="Ошибка" /></td><td VALIGN=top>Такой комнаты нет!</table></div>';
echo '</div>';
echo '<div class="title">';
echo '<img src="style/page/back.png" alt="Back"> <a href = "?sid=back" onclick="history.back()">Назад</a>';
echo '</div>';
require('foot.php');
}
break;
//~~~~~~~~~~~~~~~~Кто в комнате~~~~~~~~~~~~~~//
case 'who':
if (isset($_GET['id'])) {
$id = num($_GET['id']);
$req = mysql_query("SELECT * FROM `chat_room` WHERE `id` = '$id' LIMIT 1");
if (mysql_num_rows($req)) {
$room = mysql_fetch_assoc($req);
}
}
if ($room) {
$chat_location = $id;
$name = $room['name'];
$all = mysql_result(mysql_query("SELECT COUNT(*) FROM `users` WHERE `online` > '" . (time() - 600) . "' AND `chat_location` = '$id'"), 0);
$title = $title . ' :: Чат';
require('head.php');
echo '<div class="title"><center><a href = "chat.php?">Чат</a> :: <a href = "chat.php?act=room&id=' . $id . '">' . $name . '</a> :: <b>Кто здесь</b></center></div>';
if ($u['setting_users_list'])
$count = $u['setting_users_list']; else
$count = 10;
if ($all > 0) {
$total = num(($all - 1) / $count) + 1;
@$page = num($_GET['page']);
if (empty($page) or $page < 0)
$page = 1;
if ($page > $total)
$page = $total;
$start = $page * $count - $count;
$result = mysql_query("SELECT * FROM `users` WHERE `online` > '" . (time() - 600) . "' AND `chat_location` = '$id' ORDER BY online DESC LIMIT $start, $count");
while ($user = mysql_fetch_assoc($result)) {
echo '<div class="div">';
echo '<table><tr><td VALIGN=top>';
ava($user['id'], 50);
echo '</td><td VALIGN=top>';
if ($user['delete'] == 1) {
echo '' . ico($user['sex'], $user['admin'], $user['online']) . ' <a href = "/id' . $user['id'] . '"><del><b><font color="#79358c">' . $user['login'] . '</font></b></del></a>';
} else {
echo '' . ico($user['sex'], $user['admin'], $user['online']) . ' <a href = "/id' . $user['id'] . '"><b><font color="#79358c">' . $user['login'] . '</font></b></a>';
}
echo '' . medal($user['rating']) . '';
echo '<br/>';
if ($user['id'] != $u['id']) {
echo '<img src="style/page/go_mail.gif"> <a href = "mail.php?act=write&id=' . $user['id'] . '"><u>Сообщение</u></a><br/>';
}
echo '</table></div>';
}
echo '</div>';
navigation($page, $total, 'users.php?&');
} else {
echo '<div class="div">Пользователей пока нет!</div>';
}
echo '</div>';
echo '<div class="title">';
echo '<img src="style/page/back.png" alt="Back"> <a href = "?sid=back" onclick="history.back()">Назад</a>';
echo '</div>';
require('foot.php');
} else {
header("Location: chat.php");
}
break;
//~~~~~~~~~~~Список комнат~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
default:
$title = $title . ' :: Комнаты';
require('head.php');
echo '<div class="title"><center><a href = "chat.php?"> Чат </a></center></div>';
if ($u['admin'] == 1 || $u['admin'] == 2 || $u['admin'] == 4) {
echo '<div class="title"><img src="style/page/edit.gif" alt="!"/> <a href = "?act=add_room">Добавить комнату</a> / <a href = "?&info=1">Информация</a></div>';
}
$all = mysql_result(mysql_query("SELECT COUNT(*) FROM `chat_room`"), 0);
if ($all > 0) {
$result = mysql_query("SELECT * FROM `chat_room` ORDER BY `ord` DESC");
while ($room = mysql_fetch_assoc($result)) {
echo '<div class="div">';
$count = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `users` WHERE `online` > '" . (time() - 600) . "' AND `chat_location` = '" . $room['id'] . "'"), 0);
$name = $room['name'];
$descr = checkout($room['descr']);
$user = $room['user'];
$etime = $room['etime'];
$edit = $room['edit'];
if ($u['admin'] == 1 || $u['admin'] == 2 || $u['admin'] == 4) {
echo '<span style="float:right;">';
echo '<a href = "chat.php?act=edit_room&id=' . $room['id'] . '"><img src="style/page/edit.gif"></a> <a href = "chat.php?act=delete_room&id=' . $room['id'] . '"><img src="style/page/delete.gif"></a>';
echo '</span>';
}
if ($room['bes'] == 1) {
echo '<a href = "chat.php?act=room&id=' . $room['id'] . '&warning=1"><b>' . $name . '</b></a> (' . $count . ') <font color="red">18+</font><br>';
} else {
echo '<a href = "chat.php?act=room&id=' . $room['id'] . '"><b>' . $name . '</b></a> (' . $count . ' чел.)<br>';
}
echo '<font color="grey">' . $descr . '</font>';
echo '</div>';
if ($u['admin'] == 1 || $u['admin'] == 2 || $u['admin'] == 3 || $u['admin'] == 4 || $u['admin'] == 5) {
if (@$_GET['info']) {
if ($u['sex'] == 'm') {
$action[0] = 'Создал';
} else {
$action[0] = 'Создала';
}
if ($u['sex'] == 'm') {
$who[0] = 'Редактировал';
} else {
$who[0] = 'Редактировала';
}
echo '<div class="title">';
echo '<small>' . $action[0] . ': <a href = "/' . $room['user'] . '">' . login($room['user']) . '</a>
<b>/</b> ' . $who[0] . ': <a href = "/' . $room['edit'] . '">' . login($room['edit']) . '</a> [' . vremya($room['etime']) . '] </small>';
echo '</div>';
}
}
}
} else {
echo '<div class="div">Комнат пока нет!</div>';
}
echo '</div>';
if ($u['admin'] == 1 || $u['admin'] == 2 || $u['admin'] == 4) {
echo '<div class="title"><img src="style/page/edit.gif" alt="!"/> <a href = "?act=add_room">Добавить комнату</a> / <a href = "?&info=1">Информация</a></div>';
}
require('foot.php');
break;
}
?>