<?

if(isset($_GET['del']) && intval($_GET['del'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_mail` WHERE `id` = '".intval($_GET['del'])."' AND `type` = 'spam' LIMIT 1"),0)!=0)
{
$_SESSION['msg'] = 'Сообщение успешно удалено';
mysql_query("DELETE FROM `kolhoz_mail` WHERE `id` = '".intval($_GET['del'])."'");
header("Location:/spamlist");
}

echo "<div class='event'><h1>Спам</h1></div>";
echo "<div class='content'>";
echo "<div class='block'>";
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_mail` WHERE `type` = 'spam'"),0);
if ($k_post==0)
{
echo "Список пуст...";
}
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
$q=mysql_query("SELECT * FROM `kolhoz_mail` WHERE `type` = 'spam' ORDER by `id` DESC LIMIT $start, $set[p_str]");

echo "<ul>";
if($page==1)$i=1;else$i=($page-1)*$set['p_str']+1;
while($post=mysql_fetch_array($q))
{
$ank=mysql_fetch_array(mysql_query("SELECT `id` FROM `kolhoz_user` WHERE `id` = '$post[id_kont]'"));
$us=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '$post[id_user]'"));
$anku=$ank;
echo "<li class='pb'><div><img width='16' height='16' src='images/icons/".($post['type']=='to'?"".($post['read']==0?"mail_new.png":"mail_income.png")."":"mail_outcome.png")."' alt='o'><span>";
if($post['id_kont']!=0)echo on_k($ank['id']);
echo " ".($post['id_kont']==0?"Почтовый Сервис":"<a class='' href='user/$ank[id]'>".nc($ank['id'])."</a>")."</span> <span class='minor small'>(<span>".vremja($post['time'])."</span>)</span></div><div class='title'>".hsc($post['msg'])."</div>";
echo"<span class='minor'>Пометил : </span>";
echo on_k($us['id']);
echo" <a class='' href='user/$us[id]'>".(nc($us['id']))."</a><br/>";
echo "<img width='16' height='16' src='images/icons/arrow.png' alt='o'> <a href='/user-$ank[id]/bans/'>забанить </a><img width='16' height='16' src='images/icons/delete.png' alt=''> <a href='/spamlist/del-$post[id]/'>удалить письмо</a></li>";
}
echo "</ul>";
if ($k_page>1)new_str("spamlist/",$k_page,$page); // Вывод страниц
echo "<img width='16' height='16' src='images/icons/delete.png' alt='*'> <a href='/spamlist/dell_all'>Очистить всё</a></div>";
include_once 'inc/foot.php';
?>