|
<?php
$title = 'Бан по IP';
require_once ('../system/function.php');
require_once ('../system/header.php');
if(!$user['id'] or $user['level'] > 4) {
exit(header('Location: '.$HOME));
}
switch($_GET['act'])
{
default:
if(!$user['id']){
header('Location: /');
exit();
}
if(isset($_POST['ok'])){
$ip = strong($_POST['ip']);
$ipc = mysql_query("SELECT COUNT(`id`) FROM `ban_ip` WHERE `ip` = '".$ip."'");
if (mysql_result($ipc, 0) > 0) {
$error = 'Такой IP уже существует!';
}
if(empty($ip)){
$error = 'Вы не ввели IP!';
}
if($error){
echo '<div class="menu">Ошибка</div>';
echo '<div class="podmenu"><b>'.$error.'</b></div>';
require_once ('../system/footer.php'); exit;
exit();
}
else
{
mysql_query("INSERT INTO `ban_ip` SET `time` = '".time()."', `user` = '".$user['id']."',`ip` = '".$ip."' ");
$_SESSION['okey'] = '<div class="podmenu"><font color="green"><b>Успешно!</b></font></div>';
}
}
echo '<div class="menu">Бан по IP</div>';
if (isset($_SESSION['okey'])) echo '<b>'.$_SESSION['okey'].'</b>'; unset($_SESSION['okey']);
echo '<form action="" method="POST">
<div class="podmenu">Введите IP формата: 0.0.0.0.0</div>
<div class="podmenu"><input type="text" name="ip"></div>
<div class="podmenu"><input type="submit" name="ok" value="Продолжить">
</form></div>';
echo '<div class="menu">Забаненые IP</div>';
$max = '10';
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `ban_ip`"),0);
$k_page = k_page($k_post,$max);
$page = page($k_page);
$start = $max*$page-$max;
$ip = mysql_query("SELECT * FROM `ban_ip` ORDER BY `id` DESC LIMIT $start, $max");
while($s = mysql_fetch_assoc($ip))
{
echo '<div class="podmenu"></a>IP: '.$s['ip'].' </a><a href="/panel/ban_ip/del'.$s['id'].'"> [уд]</a></div>';
}
if ($k_page>1) echo str('/panel/ban_ip?',$k_page,$page); // Вывод страниц
if($k_post == 0) echo '<div class="podmenu"><center><b>IP нет!</b></center></div>';
break;
case 'del':
$id = abs(intval($_GET['id']));
$ip = mysql_fetch_assoc(mysql_query("SELECT * FROM `ban_ip` WHERE `id` = '".$id."'"));
if($ip == 0) {
echo '<div class="title">Админка| Ошибка</div><div class="podmenu"><center><b>Данный IP в базе не найден!</b></center></div>';
require_once ('system/footer.php');
exit();
}
mysql_query("DELETE FROM `ban_ip` WHERE `id` = '".$id."'");
header('Location: /panel/ban_ip.php');
exit();
break;
}
require_once ('../system/footer.php'); exit;
?>