<?php
$q=mysql(DBName,"SELECT `l3` FROM `$table` WHERE `domain` = '$domain' AND `site` = '$site' AND `status` < 2 AND `l1` = $razdel AND `l2` = $topic AND `l3` != 0 ORDER BY `time` DESC LIMIT 0, 1");
$f=mysql_fetch_array($q);
$max_l3=$f['l3'];
$q=mysql(DBName,"SELECT `l3`, `login` FROM `$table` WHERE `domain` = '$domain' AND `site` = '$site' AND `l1` = $razdel AND `l2` = $topic AND `l3` = $message");
$s=mysql_num_rows($q)+0;
if ($s<1)
$sysmsg='<b>Cообщение не существует (уже удалено).</b><br/>';
else
{
$f=mysql_fetch_array($q);
$flogin=$f['login'];
$l3=$f['l3'];
if (($status<1)&&(($flogin!=$login)||($l3==1)||($l3!=$max_l3)))
{
$sysmsg='<b>Недостаточно прав... ['.$flogin.":".$l3.":".$max_l3.']</b><br/>';
include($rootpath."messages.php");
}
@mysql(DBName,"DELETE FROM `$table` WHERE `domain` = '$domain' AND `site` = '$site' AND `l1` = '$razdel' AND `l2` = '$topic' AND `l3` = '$message'");
$sysmsg='<b>Сообщение удалено.</b><br/>';
}
include($rootpath_forum."messages.php");
exit();
?>