<?php
include_once("incs/conf.php");
include_once("incs/fmysql.php");
include_once("incs/fnc.php");
include_once("incs/head.php");

$act=fil($_GET['act']);

head("Спам",$meuser,$auth);
echo "<div class='rowup'>";
include_once("incs/title.php");
echo "Спам</div>";

if($on==1 && $user[level]>=2){

$ban_ok=$user[ban]-$time;
if($ban_ok>0){
echo "Вы забанены по причине:<br>";
echo "<b>$user[ban_prich]</b><br>";
echo "До окончания бана осталось: $ban_ok сек.<br>";
echo "Старайтесь больше не нарушать <a href=\"../rules.php\">правила</a> сайта!<br>";
include_once("incs/down.php");
}

$msg_sp = mysql_num_rows(mysql_query("SELECT id FROM `spam` WHERE `id_otrim` = '$user[id]'"));
if($msg_sp==0)
{
echo "Нет сообщений";
}

if($on==1){
$end=$user[msg_for_page];
}else{
$end=10;}
$skok_pages=ceil($msg_sp/$end);
if(!isset($_GET['page'])){
$page=1;
}else{
$page=intval($_GET['page']);
if($page<1){$page=1;}
if($page>$skok_pages){$page=1;}
}
if($page==1 OR $page<1){
$start=0;
}else{
$start=($page-1)*$end;
}

$spa_msg=mysql_query("SELECT * FROM `spam` WHERE `id_otrim` = '$user[id]' ORDER BY id DESC LIMIT $start,$end");
while ($spam_msg = mysql_fetch_array($spa_msg))
{
mysql_query("UPDATE `spam` SET `read` = '1' WHERE `id_otrim` = '$user[id]'");
$s_msg=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$spam_msg[id_user]'"));
$spam_user_msg=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$spam_msg[id_otprav]'"));
if($num==1){ 
echo "<div class='reki'>"; 
$num=0;
}else{ 
echo "<div class='rek'>"; 
$num=1;}
echo "<a href=\"my.php?id=$s_msg[id]\"><b>$s_msg[nick]</b></a> сообщает о спаме:<br>";
echo "<a href=\"my.php?id=$spam_user_msg[id]\">$spam_user_msg[nick]</a> ($spam_msg[time]) ";
echo "<br>$spam_msg[msg]<br>";
echo "[<a href='admin/ban.php?id=$spam_user_msg[id]'>Бан</a>]</div>";
}

if($skok_pages>1){
for($i=1;$i<=$skok_pages;$i++){
if($i==$page){
echo "<span class=\"str_t\">$i</span>";
}else{
echo "<span class=\"str_l\"><a href='?page=$i'>$i</a></span>";
}}}
}else{
echo "<div class='rowup'>";
include_once("../incs/title2.php");
echo "Админ панель</div>";
echo "Извени, но тебе здесь находитса нельзя!<br>";
}
include_once("incs/down.php");
?>