<?// 10:19 28.10.2012г.
include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/adm_check.php';
include_once '../sys/inc/user.php';
$set['title']='AnTiSpaM';
include_once '../sys/inc/thead.php';
title(); aut(); only_level(1);
################################################################################
if (isset($_GET['oks'])){
$q=mysql_fetch_array(mysql_query("SELECT * FROM `mail_spam` WHERE `id` = '".intval($_GET['ids'])."' LIMIT 1"));
if ($q['read']!=1){
if ($q['id_user']==$user['id']){$err="Spam This Id :D";}  err();
if(!isset($err)){
mysql_query("UPDATE `user` SET `balls`=`balls`+'100' WHERE `id`='$q[sdal]' LIMIT 1"); // Баллы кто сдал спам.
mysql_query("INSERT INTO `mail` (`id_user`, `id_kont`, `msg`, `time`) values('0', '$q[sdal]', 'Created 100 points for you...Thank U :)', '".time()."')");
}
mysql_query("UPDATE `mail_spam` SET `read` = '1', `user_kto` = '$user[id]', `time_sd` = '$time' WHERE `id` = '$q[id]' LIMIT 1");
msg("Thank you for your work. User received 100 Points.");
}
}
################################################################################
if (isset($_GET['del']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `mail_spam` WHERE `id` = '".intval($_GET['del'])."'"),0)){
mysql_query("DELETE FROM `mail_spam` WHERE `id` = '".intval($_GET['del'])."' LIMIT 1");
msg('Spam is deleted');
}
###############################################################################
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `mail_spam`"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
echo "<table class='post'>\n";

if ($k_post==0)echo "<tr><td class='p_t'>No message</td></tr>\n";
$q=mysql_query("SELECT * FROM `mail_spam` ORDER BY id DESC LIMIT $start, $set[p_str]");
while ($post=mysql_fetch_assoc($q)){
$ank=mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = '$post[id_user]' LIMIT 1"));
$ank2=mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = '$post[id_kont]' LIMIT 1"));
$ank3=mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = '$post[sdal]' LIMIT 1"));
$ank4=mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = '$post[user_kto]' LIMIT 1"));
echo "<td class='p_t'>From: <a href='/info.php?id=$ank[id]'>$ank[nick]</a>\n";
echo "To: <a href='/info.php?id=$ank2[id]'>$ank2[nick]</a> (".vremja($post['time']).") <b>User: $ank3[nick]</b>\n";
echo "  </td></tr><tr>\n";
if ($set['set_show_icon']==1)echo "<td class='p_m' colspan='2'>\n"; else echo "<td class='p_m'>\n";
echo output_text($post['msg'])."<br />\n";
if($post['read']==0)echo "<a href='?oks&amp;ids=$post[id]'>PM</a>";
elseif($post['read']==1)echo "<u>PM: <a href='/info.php?id=$ank4[id]'>$ank4[nick]</a> (".vremja($post['time_sd']).")</u>";
echo "  <a href='?del=$post[id]'>Remove</a>\n";
echo "  </td></tr>\n";
}
echo "</table>\n";

if ($k_page>1)str('?',$k_page,$page); // Вывод страниц
include_once '../sys/inc/tfoot.php';
?>
