<?
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/user.php';
only_level(1);
if (isset($_GET['id']))$ank['id']=intval($_GET['id']);
else {header("Location: /index.php?".SID);exit;}


if (mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `id` = '$ank[id]' LIMIT 1"),0)==0){header("Location: /index.php?".SID);exit;}
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $ank[id] LIMIT 1"));
if ($user['level']!=4 && $user['level']<=$ank['level'] || $user['id']==$ank['id']){header("Location: /index.php?".SID);exit;}


$set['title']='Бан пользователя '.$ank['nick'];
include_once '../sys/inc/thead.php';
title();

if (isset($_GET['act']) && $_GET['act']=='del' && isset($access['ban_unset']))
{
mysql_query("UPDATE `user` SET `ban` = '0', `ban_pr` = null WHERE `id` = '$ank[id]' LIMIT 1");
msg('Пользователь разбанен');
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $ank[id] LIMIT 1"));
}

if (isset($_POST['ban_pr']) && isset($_POST['time']) && isset($_POST['vremja']) && isset($access['ban_set']))
{
$timeban=0;
if ($_POST['vremja']=='min')$timeban=intval($_POST['time'])*60;
if ($_POST['vremja']=='chas')$timeban=intval($_POST['time'])*60*60;
if ($_POST['vremja']=='sut')$timeban=intval($_POST['time'])*60*60*24;
if ($_POST['vremja']=='mes')$timeban=intval($_POST['time'])*60*60*24*30;

mysql_query("UPDATE `user` SET `ban` = '".($timeban+time())."', `ban_pr` = '".mysql_escape_string(stripcslashes(htmlspecialchars($_POST['ban_pr'])))."' WHERE `id` = '$ank[id]' LIMIT 1");
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $ank[id] LIMIT 1"));
msg('Пользователь успешно забанен');
}


aut();





if (isset($access['ban_set'])){
echo "<form action=\"ban.php?id=$ank[id]\" method=\"post\">\n";
if ($time<$ank['ban'])echo "До: ".vremja($ank['ban'])."<br />\n";
echo "Причина:<br />\n<input type=\"text\" name=\"ban_pr\" title=\"Причина бана\" value=\"$ank[ban_pr]\" maxlength=\"64\" /><br />\n";
echo "Время бана:<br />\n<input type=\"text\" name=\"time\" title=\"Время бана\" value=\"10\" maxlength=\"11\" /><br />\n";
echo "<select class=\"form\" name=\"vremja\">\n";
echo "<option value=\"min\">Минуты</option>\n";
echo "<option value=\"chas\">Часы</option>\n";
echo "<option value=\"sut\">Сутки</option>\n";
echo "<option value=\"mes\">Месяцы</option>\n";
echo "</select><br />\n";
echo "<input type=\"submit\" value=\"Забанить\" />";
echo "</form>\n";
}
else
{
echo "<div class='err'>Нет прав для того, чтобы забанить пользователя</div>\n";
}

echo "<div class='foot'>\n";
if ($ank['ban']>$time && isset($access['ban_unset']))echo "&raquo;<a href='/adm_panel/ban.php?id=$ank[id]&amp;act=del'>Снять бан</a><br />\n";
echo "&raquo;<a href=\"/mail.php?id=$ank[id]\">Написать сообщение</a><br />\n";
echo "&laquo;<a href=\"/info.php?id=$ank[id]\">В анкету</a><br />\n";

echo "&laquo;<a href='/adm_panel/'>В админку</a><br />\n";
echo "</div>\n";



include_once '../sys/inc/tfoot.php';
?>