Просмотр файла chat/add_p.php

Размер файла: 2.82Kb
<?
include_once "../SYSTEM/include/functions.php";
include_once "../SYSTEM/include/mysql.php";
include_once "../SYSTEM/include/param.php";
include_once "../SYSTEM/include/ban.php";
include_once "../SYSTEM/include/sess.php";
include_once "../SYSTEM/include/ban_2.php";
include_once "../SYSTEM/include/theme.php";
$title='Написать';
$mesto='Пишет в чате';
head();

if (!isset($_GET['id_r']))
{
header ("Location: index.php?".SID."");
exit;
}
if (isset($_GET['page']))
{
$page=$_GET['page'];
}else{$page=1;}
$id_r=intval($_GET['id_r']);


$q = mysql_query("SELECT * FROM `$mysql[pref]chat_room` WHERE `id` = '$id_r';");
if(mysql_num_rows($q) != 0)
{
$room = mysql_fetch_array($q);
}
else
{
header ("Location: index.php?".SID."&");

exit;
}


if (!isset($user))
{
header ("Location: index.php?".SID."&id_r=$id_r");

exit;
}





if (isset($_GET['act']) && $_GET['act']=='add' && isset($_POST['msg']))
{
$msg=$_POST['msg'];
$msg = iconv('utf-8', 'windows-1251', $msg);
$msg=substr($msg, 0, 512);
$msg = iconv('windows-1251', 'utf-8', $msg);
$msg=htmlspecialchars($msg);
$msg=str_replace("\r\n","<br />",$msg);
$msg=str_replace("\r","<br />",$msg);
$msg=str_replace("\n","<br />",$msg);

if (isset($_POST['tr']))
{
$msg=translit($msg);
}

$msg=mysql_escape_string($msg);

$id=$room['id'];
if ($msg=='')
{
header("Location: index.php?".SID."&id_r=$id_r");
exit;
}


$time_q=$time-30;
$q = mysql_query("SELECT COUNT(*) FROM `$mysql[pref]chat` WHERE `id_r` = '$id_r' AND `time` > '$time_q' AND `msg` = '$msg' AND `id_us` = '$user[id]';");
$repeat=mysql_result($q, 0);
if ($repeat==0)
{


if ($room['umnik']==1){@include "bot/umnik.php";}
if ($room['shut']==1){@include "bot/shut.php";}


mysql_query("INSERT INTO `$mysql[pref]chat` (id_r, nick, time, msg, id_us)
values('$id_r', '$user[nickname]', '$time', '$msg', '$user[id]');");
$user['chat_post_k']++;
mysql_query("UPDATE `$mysql[pref]users` SET `chat_post_k` = '$user[chat_post_k]' WHERE `id` = '$user[id]';");


if ($room['umnik']==1){umnik($msg);}

ball_add();
}

header("Location: index.php?".SID."&act=add&id_r=$id_r");

exit;
}



echo "<div class=\"h\">Добавить сообщение</div><hr />\n";

if ($mail_in_new>0)echo "<div class=\"privat\"><img src=\"../SYSTEM/themes/$them/img/mail0.gif\" alt=\"\" /> <a href=\"../mail.php?act=in\">Приват</a> [$mail_in_new]</div><hr />\n";

echo "<br /><form method=\"post\" action=\"add_p.php?act=add&amp;id_r=$id_r\">\n";
echo "Сообщение:<br />\n<textarea name=\"msg\" class=\"form\" rows=\"3\"></textarea><br />\n";
echo "<input type=\"checkbox\" name=\"tr\" value=\"1\" /> Транслит<br />\n";
echo "<input value=\"Добавить\" class=\"form\" type=\"submit\" />\n";
echo "</form>\n";

echo "<br />\n";




echo "<a href=\"index.php?id_r=$id_r\">В чат</a>\n";
echo "<br /><a href=\"../index.php\">На главную</a>\n";

foot();
?>