<?php
include '../system/bd.php';
include '../system/cook.php';
include ("../system/gzip.php");
if(isset($_SESSION['auth']) && $_SESSION['auth']==1){
include '../system/head.php';
include '../system/head1.php';
//////////ban//////////

if($user[prava] <= '2'){
header ("Location: ../error.php");}

switch($_GET[mod]){
default:

break;
case 'bandel':
if(empty($_GET[id])){
echo"<img src=\"pic/main/!.png\"> Ошибка не выбран персонаж!";
echo'<div class="ssl">';
	echo '<a class="navi" href="adminka.php">&nbsp <img src="/pic/main/rotate.png" alt="*"/> Вернуться</a></div>';
include '../system/foot.php';
exit;
}

$req = mysql_query("SELECT * FROM `block` where `usr`='".intval($_GET['id'])."'");
$avto=mysql_num_rows($req);
if($avto==0){
echo"<img src=\"pic/main/!.png\"> бан снят";
echo'<div class="block_link">';
	echo '<a href="./mod_3.php?mod=ban"><img src="/img/foot/index.png" alt="*"/> Вернуться</a></div>';
include '../system/foot.php';
exit;}
mysql_query("DELETE FROM `block` WHERE `usr`='".intval($_GET['id'])."'"); 
header("Location: /mod_3.php?mod=ban");



case 'ban':
echo" <div class ='title'>ban</div>
<div class ='line'></div> ";

$cop=5;
$ca=mysql_result(mysql_query("SELECT COUNT(*) FROM `block` WHERE `ban_time`>'$time' "),0);
$cp=ceil($ca/$cop);
if(isset($_GET[page]) && is_numeric($_GET[page])){
$page = $_GET[page];
if($_GET[page]>$cp) $page=$cp;
if($_GET[page]<1)$page=1;
}else{
$page=1;
}
$start=$page*$cop-$cop;
$dlist = 'list1';


$time=time();

$req = mysql_query("SELECT * FROM `block` WHERE `ban_time`>'$time' ORDER by `id` DESC LIMIT $start,$cop");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>=1){
While($mag = mysql_fetch_array($req))
{   
$_user = mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id`='".$mag[usr]."'"));
$_user2 = mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id`='".$mag[nick]."'"));
////////////////////////


echo ' <div class ="block">
<img src="pic/main/'.$_user[sex].'.png" alt="*"/> 
<a href="../users.php?id='.$_user['id'].'"> '.$_user[login].' </a> (<a href="../admin/mod_3.php?mod=bandel&id='.$_user['id'].'">Снать бан</a>)
</br>Забанил: <a href="../users.php?id='.$_user2[id].'"> '.$_user2[login].' </a>
 <br> Причина: '.$mag[text].'</font>';
echo '<br>';

$mag[ban_time]=$mag[ban_time]-time();


if($mag[ban_time]<60){
echo " Время блокировки:
<font color=IndianRed1> $mag[ban_time] сек.</font>";

}elseif($mag[ban_time]>60 and $mag[ban_time]<3600){
$mag[ban_time]=round($mag[ban_time]/60);
echo "Время блокировки:<font color=IndianRed1> $mag[ban_time] мин.</font>";

}else{
$mag[ban_time]=round($mag[ban_time]/3600);
echo " Время блокировки:<font color=IndianRed1> $mag[ban_time] час.</font>";
}
   echo '</div> ';

//////////////
echo '
 <div class ="line"></div> ';
}
echo ' <div class="empty_block top pagi item_center">
<center>';

if($page-1>0){

echo '<a href="mod_3.php?mod=ban&page='.($page-1).'">&lt;</a> ';

}


if($page-1>0){

echo '<a href="mod_3.php?mod=ban&page='.($page-1).'">'.($page-1).'</a> ';

}

echo '<b>'.$page.'</b>';

if($page+1<=$cp){

echo ' <a href="mod_3.php?mod=ban&page='.($page+1).'">'.($page+1).'</a>';

}

if($page+1<=$cp){

echo ' <a href="mod_3.php?mod=ban&page='.($page+1).'">&gt;</a>';

}
echo '</center></div>';

}else{
echo ' <div class="empty_block del_bottom item_center"> Нет нарушителей</div>';



   


}
echo'<div class="line"></div>';
	echo '<div class="block_link"> <a href="/admin"> <img src="../img/foot/index.png" alt="*"/> В админку</a></div>';

break;
}


}else{
header ("Location: index.php"); exit;
}
include '../system/foot.php';
?>
