Файл: chat/inc/room.php
Строк: 85
<?
if (isset($_POST['msg']) && isset($user))
{
$msg=$_POST['msg'];
if (isset($_POST['translit']) && $_POST['translit']==1)
{
$msg=translit($msg);
}
$mat=antimat($msg);
if ($mat)
{
$err='В тексте сообщения обнаружен мат: '.$mat;
}
if (strlen2($msg)>512)
{
$err='Сообщение слишком длинное!';
}
else if (strlen2($msg)<2)
{
$err='Короткое сообщение!';
}
else if (mysql_result(mysql_query("SELECT COUNT(*) FROM `chat_post` WHERE `id_user` = '".$user['id']."' AND `msg` = '".mysql_escape_string($msg)."' AND `time` > '".($time-300)."' LIMIT 1"),0)!=0)
{
$err='Ваше сообщение повторяет предыдущее!';
}
else if(!isset($err))
{
if(isset($_POST['privat']))
{
$priv=abs(intval($_POST['privat']));
}else{
$priv=0;
}
mysql_query("INSERT INTO `chat_post` (`id_user`, `time`, `msg`, `room`, `privat`) values('".$user['id']."', '".$time."', '".my_esc($msg)."', '".$room['id']."', '".$priv."')");
mysql_query("UPDATE `user` SET `balls` = '".($user['balls']+1)."' WHERE `id` = '".$user['id']."' LIMIT 1");
msg('Сообщение успешно добавлено');
}
}
if ($room['umnik']=='1')
{
include 'inc/umnik.php';
}
if ($room['shutnik']=='1')
{
include 'inc/shutnik.php';
}
auter();
err();
echo "<a href='/chat/room/".$room['id']."/".rand(1000,9999)."/'>";
echo "<div class='u_menu'><img src='/s-klub/img/obnov.png'> <b>Обновить</b></div>";
echo "</a>";
if (isset($user))
{
echo "<form method='post' name='message' action='/chat/room/$room[id]/".rand(1000,9999)."/'>";
echo "<table style='width:100%' cellspacing='1' cellpadding='1'><tr>";
echo "<td class='forum_tema'>";
if (($user['dop']==1) && is_file(H.'s-klub/js/altername_post_form.php'))
{
include_once H.'s-klub/js/altername_post_form.php';
}else{
echo "<img src='/s-klub/img/post-add.png'> <b>Сообщение:</b><br />";
bb_panel();
echo "<textarea name='msg'></textarea><br />";
}
echo "</td></tr>";
if ($user['set_translit']==1)
{
echo "<tr><td class='forum_tema'>";
echo "<label><input type='checkbox' name='translit' value='1' /> Транслит</label><br />";
echo "</td></tr>";
}
echo "<tr><td class='forum_tema'>";
echo "<input type='submit' value='Отправить' />";
echo "</td></tr></table>";
echo "</form>";
}
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `chat_post` WHERE `room` = '$room[id]' AND (`privat`='0'".(isset($user)?" OR `privat` = '$user[id]'":null).")"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
if ($k_post==0)
{
echo "<table style='width:100%' cellspacing='1' cellpadding='1'><tr>";
echo "<td class='err'>";
echo "Нет сообщений!";
echo "</td>";
echo "</tr></table>";
}
$q=mysql_query("SELECT * FROM `chat_post` WHERE `room` = '".$room['id']."' AND (`privat`='0'".(isset($user)?" OR `privat` = '".$user['id']."'":null).") ORDER BY id DESC LIMIT $start, $set[p_str]");
while ($post=mysql_fetch_assoc($q))
{
if ($post['umnik_st']==0 && $post['shutnik']==0)
{
$ank=get_user($post['id_user']);
}
echo "<table style='width:100%' cellspacing='1' cellpadding='1'><tr>";
echo "<td class='icon14'>";
if ($post['umnik_st']==0 && $post['shutnik']==0)
{
avatar_mini($ank['id']);
}else{
if (($post['shutnik']==1) || ($post['umnik_st']!=0))
{
echo "<img src='/s-klub/images/bot.png' alt='Бот' />";
}
}
echo "</td>";
echo "<td class='p_t'>";
if ($post['umnik_st']==0 && $post['shutnik']==0)
{
echo "".status($ank['id'])." ";
echo "<a href='/chat/room/".$room['id']."/".rand(1000,9999)."/".$ank['id']."/'><b>";
echo GradientText("$ank[nick]", "$ank[ncolor]", "$ank[ncolor2]");
echo "</b></a>";
echo " ".online($ank['id'])." ";
if ($post['privat']==$user['id'])
{
echo "<img src='/s-klub/images/privatno.png' title='Приватно' /> ";
}
echo "<br />";
echo "<img src='/s-klub/img/time.png'> <b>".vremja($post['time'])."</b><br />";
}
else if ($post['umnik_st']!=0)
{
echo "<img src='/s-klub/img/umnik.png'> <b>".$set['chat_umnik']."</b><br />";
echo "<img src='/s-klub/img/time.png'> <b>".vremja($post['time'])."</b><br />";
}
else if ($post['shutnik']==1)
{
echo "<img src='/s-klub/img/shutnik.png'> <b>".$set['chat_shutnik']."</b><br />";
echo "<img src='/s-klub/img/time.png'> <b>".vremja($post['time'])."</b><br />";
}
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td class='forum' colspan='2'><b>";
echo output_text($post['msg'])."";
echo "</b></td>";
echo "</tr></table>";
}
if ($k_page>1)
{
str("/chat/room/".$room['id']."/".rand(1000,9999)."/?",$k_page,$page);
}
?>