Файл: chat/topic.php
Строк: 52
<?php
require '../sid.php';
require '../config.php';
$link = connect_db();
list($user, $id, $ps) = check_login($link);
include '../head.php';
$rm = my_int($_GET['rm']);
whorm(0, 'room' . $rm);
$open = mysql_fetch_array(mysql_query("SELECT `open_chat` FROM `setting` WHERE `ids` = '1'"));
if ($open[0] == 0) {
err('Чат закрыт Администратором!');
include '../foot.php';
exit();
}
if ($user['level'] != 2 && $user['level'] != 4 && $user['level'] != 5) {
header('Location: room.php?rm=' . $rm);
die();
}
if (isset($_POST['ok'])) {
$newtop = trim(mysql_real_escape_string(check($_POST['newtop'])));
$ids = mt_rand(100000, 999999);
$who = ($user['sex'] == 1) ? ' сменила ' : ' сменил ';
$cl = ($user['sex'] == 1) ? ' очистила ' : ' очистил ';
if (!empty($newtop)) $tekst = '<a href="/'.$user['id'].'">' . cvetnik($user['id']) . '</a> ' . $who . ' топик на <b>' . $newtop . '</b>!';
else $tekst = '<a href="/'.$user['id'].'">' . cvetnik($user['id']) . '</a> ' . $cl . ' топик!';
mysql_query("UPDATE `rooms` SET `top` = '$newtop' WHERE `id` = '$rm' LIMIT 1");
mysql_query("INSERT INTO `message` SET
`id` = '$ids',
`time` = '" . time() . "',
`who` = '0',
`user` = 'Система',
`msg` = '$tekst',
`room` = '$rm'");
header('Location: room.php?rm='.$rm.'&oktop');
}
$empty = mysql_query("SELECT * FROM `rooms` WHERE `id` = '$rm' LIMIT 1");
$inf = mysql_fetch_assoc($empty);
$ASnum = mysql_num_rows(mysql_query("SELECT * FROM `users` WHERE `room` = 'room$rm' AND `onl` + '200' > '" . time() . "' ORDER BY `onl` DESC"));
echo $div_left . $div_title . $inf['name'] . $div_end . $div_menu . '
<a href="index.php?'.$ref.'">Комнаты | </a>
<a href="room.php?rm='.$rm.'">' . $inf['name'] . '</a> |
<a href="say.php?rm='.$rm.'">Сказать</a> |
<a href="whoroom.php?rm='.$rm.'">Кто здесь(' . $ASnum . ')</a>
' . $div_end;
if (mysql_num_rows($empty) != FALSE) {
echo $div_title . $inf['name'] . $div_end . '
<FORM method="POST" action="topic.php?rm='.$rm.'">
<label>Новый топик:</label><br/>
<input type="text" name="newtop" value="' . $inf['top'] . '"/>
<br/>
<input type="submit" name="ok" value="Сменить"/>
</FORM>' . $div_end;
} else {
err('Такой комнаты не существует!');
}
include '../foot.php';
?>