<?
require_once ('../system/func.php');
if(isset($_POST['text'])){
$text = $_POST['text'];
$ban = mysql_query('SELECT * FROM `ban` WHERE `id_user` = "'.$myID.'" AND `last` > "'.time().'" ORDER BY `id` DESC LIMIT 1');
$ban = mysql_fetch_array($ban);
if(strlen($text) < 3 or strlen($text) > 500)$err = 'Длина сообщения должна быть в пределах 3 - 500 символов';
if($ban)$err = "На вас наложен бан осталось ".tl($ban['last']-time());
$ban_ip = mysql_query('SELECT * FROM `ban` WHERE `ip` = "'.$user['ip'].'" AND `last` > "'.time().'" ORDER BY `id` DESC LIMIT 1');
$ban_ip = mysql_fetch_array($ban_ip);
if($ban_ip)$err = "Ваш IP совпадает с нарушителем!<br>Осталось: ".tl($ban_ip['last']-time());
$chat_limit = mysql_query('SELECT * FROM `chat` WHERE `id_user` = "'.$myID.'" AND `time` > "'.(time()-15).'" ORDER BY `id` DESC LIMIT 1');
$chat_limit = mysql_fetch_array($chat_limit);
if($chat_limit)$err = 'Писать можно только раз в 15 сек';
if(!$err){
mysql_query("INSERT INTO `chat` SET `id_user` = '$user[id]', `time` = '".time()."', `text` = '".text($text)."'");
}else{
echo $err;
}
}else{
echo "Введите сообщение";
}
?>