Размер файла: 3.64Kb
<?php
/*********************************************************************/
#---------------------------KokirCMS Соц сети-------------------------#
#---------------------Kiriyan и kokir Сайт kiriyan.org----------------#
#-------------------------------2012 г.-------------------------------#
#------------------Связь ICQ 455002004. [email protected]#
#----------------------------Пример ewwap.ru--------------------------#
/*********************************************************************/
require('../inc/core.php');
if(empty($_GET['id']) || !ctype_digit($_GET['id']))
header("Location: index.php");
$id = $_GET['id'];
$room = mysql_fetch_array(mysql_query("SELECT * FROM `chat_rooms` WHERE `id` = $id;"));
if(!$room)
header("Location: index.php");
$title = $room['caption'];
require('../inc/head.php');
mysql_query("INSERT INTO `chat_online` VALUES('" . $user['id'] . "', '" . $id . "', '" . $time . "');");
if(isset($_POST['say']))
{
$text = escstr($_POST['text']);
if(mysql_num_rows(mysql_query("SELECT `id` FROM `chat` WHERE `room` = $id AND `date` > " . ($time - $antiFlood) . ";")))
echo '<div class="error">Антифлуд</div>';
else if(mysql_num_rows(mysql_query("SELECT `id` FROM `chat` WHERE `room` = $id AND `text` = '" . $text . "';")))
echo '<div class="error">Антиспам</div>';
else
{
mysql_query("INSERT INTO `chat` VALUES(0, '" . $id . "', '" . $user['id'] . "', '" . $text . "', '" . $time . "');");
header("Location: ?id={$id}");
}
}
$tValue = '';
if(!empty($_GET['u']) && ctype_digit($_GET['u']))
{
$u = mysql_fetch_array(mysql_query("SELECT `login` FROM `users` WHERE `id` = " . $_GET['u'] . ";"));
if($u)
$tValue = $u['login'] . ', ';
}
echo '<div class="caption"><a href="index.php">Чат</a> » ' . $room['caption'] . '</div>';
echo '<div class="menu">';
echo '<form action="" method="post">';
echo '<label>Текст:<br/><textarea name="text">' . $tValue . '</textarea></label><br/>';
echo '<input type="submit" name="say" value="Сказать"/>';
echo '</form>';
echo '</div>';
$total = mysql_num_rows(mysql_query("SELECT * FROM `chat` WHERE `room` = $id;"));
if($total)
{
$query = mysql_query("SELECT * FROM `chat` WHERE `room` = $id ORDER BY `date` DESC LIMIT $page, $chms;");
if($total > $chms)
echo '<div class="nav">' . pagination('?id=' . $id . '&', $total) . '</div>';
while($post = mysql_fetch_array($query))
{
echo '<div class="post">';
echo userInfo($post['author'], TRUE, '<small>' . fTime($post['date']) . '</small>', ($user['id'] != $post['author'] ? '<a href="?id=' . $id . '&u=' . $post['author'] . '">[o]</a>' : ''));
echo tags($post['text']);
if($user['rights'] >= 1)
{
echo '<div class="sub">';
echo '<a href="manage.php?mode=delete&id=' . $post['id'] . '">Удалить</a>';
echo '</div>';
}
echo '</div>';
}
if($total > $chms)
echo '<div class="nav">' . pagination('?id=' . $id . '&', $total) . '</div>';
if($user['rights'] >= 1 && $total > 1)
echo '<div class="menu adm"><a href="manage.php?id=' . $id . '">Очистка</a></div>';
echo '<div class="caption">Всего: ' . $total . '</div>';
}
else
echo '<div class="menu big-block">Сообщений нету. Будь первым!</div>';
$totalOnline = mysql_num_rows(mysql_query("SELECT * FROM `chat_online` WHERE `room` = $id;"));
echo '<div class="c-menu">Сейчас в комнате <a href="online.php?id=' . $id . '">' . $totalOnline . ' человек</a></div>';
require('../inc/end.php');
?>