<?

$t_lim=time()-60;



$q = mysql_query("SELECT COUNT(*) FROM `$mysql[pref]chat` WHERE `id_r` = '$id_r' AND `time` > '$t_lim';");
$t_shut=time()-60-mysql_num_rows($q)*3;




$q = mysql_query("SELECT COUNT(*) FROM `$mysql[pref]chat` WHERE `id_r` = '$id_r' AND `shut` = '1' AND `time` > '$t_shut';");
if (mysql_result($q, 0)==0)
{
$file_um=file(BASEDIR."SYSTEM/data/chat/shut.txt");
$anek=$file_um[(rand(0, count($file_um)-1))];
$anek=stripcslashes(htmlspecialchars(trim($anek)));
mysql_query("INSERT INTO `$mysql[pref]chat` (id_r, nick, time, msg, shut)
values('$id_r', 'Шутник', '$time', '$anek', '1');");
}
?>
