<?
require_once '../core/system.php';
echo admin();
$header = 'Бан';
require_once H.'core/head.php';
if($user[prava] == 7 ){
if (isset($_GET['id']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `id` = '".intval($_GET['id'])."'"),0) == true){
$ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id`  = '".intval($_GET['id'])."'"));
}



if(isset($_GET['id'])){
	$id = abs((int)$_GET['id']);
	$info = mysql_query("SELECT * FROM `user` WHERE id='".$id."'") or die(mysql_error());
	$i = mysql_fetch_array($info);
	$cnt = mysql_num_rows($info);
if($cnt == '0'){header('Location: /');}
}else{
	header('Location: /');
}

if(isset($_POST['edit'])){
	$prich = mysql_real_escape_string(strip_tags(stripslashes(htmlspecialchars($_POST['prich']))));
	$time = intval($_POST['time']);
	$time_ban = $_POST['time_ban'];
	///////////////////////////////////////////////////////////////////
	if ($time_ban == 'sek')$timeban = $time;
	if ($time_ban == 'min')$timeban = $time*60;
	if ($time_ban == 'hour')$timeban = $time*60*60;
	if ($time_ban == 'day')$timeban = $time*60*60*24;
	if ($time_ban == 'week')$timeban = $time*60*60*24*7;
	if ($time_ban == 'month')$timeban = $time*60*60*24*7*4;
	$timebanned = time() + $timeban;
	///////////////////////////////////////////////////////////////////
	if($time_ban == 'no'){ $err=('Время'); }
	elseif($time == ''){ $err=('Время'); }
	else
	{
		mysql_query("UPDATE `user` SET `banned` = '$timebanned', `prich` = '".$prich."' WHERE `id` = '".$i['id']."'") or die(mysql_error());
		echo '<center>Успешно забанен</center>';
	}
}

echo "<div class='mini-line'></div>";
echo "<div class='player menuList'>";

if($err)echo $err;

echo '<center>Бан для: '.$ank['nick'].'';

echo '</center><center>
	<form action="" method="post">
                     
			Причина блокировки: <br/>
			<input type="text" name="prich" /><br/>
			Время (цифры): <br/>
			<input type="text" name="time" value="10"/><br/>
			На какое время:<br/>
			<select name="time_ban">
				<option value="sek">Секунд</option>
				<option value="min">Минут</option>
				<option value="hour">Часов</option>
				<option value="day">Дней</option>
				<option value="week">Недель</option>
				<option value="month">Месяцев</option>
			</select><br/>
		</div><center>
		<input type="submit" value="Забанить" name="edit"/>
	</form></div></center>
	';
	
echo "</div>";
}
require_once H.'core/foot.php';
?>