Файл: mpanel/ip.php
Строк: 72
<?php
include('../core/core.php');
include(MAINDIR.'style/head.php');
title('IP бан панель');
if (is_admin(array(101, 102))) {
$my = DB::run() -> queryFetch("SELECT * FROM `users` WHERE `login`=? LIMIT 1",array(check($_COOKIE['login'])));
$admin = $my['status'];
echo'<div class="title">Админ-панель</div>';
$act = '<img src="/images/act.png">';
switch ($mode):
case 'index':
$ip = check($_GET['ip']);
echo'<div class="menu">';
echo'<form action="?mode=add" method="post">
Ip-виновника:<br />
<input name="ip" type="text" maxlength="30" value="'.$ip.'" /><br />
Причина:<br />
<textarea name="ban" rows="4"></textarea><br />
<input name="" type="submit" value="Добавить" />
</form>';
echo'</div>';
define('TOPAGE',10); $num = TOPAGE;
$links = '?mode=index&page=';
$page = intval($_GET['page']);
$posts = DB::run() -> query("SELECT * FROM `ban` WHERE `ip`") -> rowCount();
$total = intval(($posts - 1) / $num) + 1;
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * $num - $num;
$themes = DB::run()->query("SELECT * FROM `ban` WHERE `ip` ORDER BY `id` DESC LIMIT $start,".TOPAGE."");
$themes = $themes -> fetchAll();
foreach($themes AS $u){
echo'<div class="menu">';
echo''.$u['ip'].'<br />'.$u['ban'].'<hr><a href="?mode=del&id='.$u['id'].'" onclick="return confirm('Вы подтверждаете удаление?')">Удалить</a>';
echo'</div>';
}
if ($page != 1) $pervpage = '<a href= '.$links.'1><<</a> <a href= '.$links.''. ($page - 1) .'><</a> ';
if ($page != $total) $nextpage = ' <a href= '.$links.''. ($page + 1) .'>></a> <a href= '.$links.'' .$total. '>>></a>';
if($page - 2 > 0) $page2left = ' <a href= '.$links.''. ($page - 2) .'>'. ($page - 2) .'</a> | ';
if($page - 1 > 0) $page1left = '<a href= '.$links.''. ($page - 1) .'>'. ($page - 1) .'</a> | ';
if($page + 2 <= $total) $page2right = ' | <a href= '.$links.''. ($page + 2) .'>'. ($page + 2) .'</a>';
if($page + 1 <= $total) $page1right = ' | <a href= '.$links.''. ($page + 1) .'>'. ($page + 1) .'</a>';
if($posts == 0){ echo'<div class="menu">База IP пуста!</div>'; } else {echo '<div class="menu_2">'.$pervpage.$page2left.$page1left.'<b>'.$page.'</b>'.$page1right.$page2right.$nextpage.'</div>'; }
break;
case 'del':
$id = abs(intval($_GET['id']));
DB::run()->query("DELETE FROM `ban` WHERE `id` =?",array($id));
header ('location: ?mode=index');
break;
case 'add':
$ip = check($_POST['ip']);
$ban = check($_POST['ban']);
DB::run()->query("INSERT INTO `ban`(`ip`,`ban`) VALUES (?,?)",array($ip,$ban));
header ('location: ?mode=index');
break;
default:
header ('location: ?mode=index');
endswitch;
echo'<div class="menu"><a href="/mpanel/">В админку</a></div>';
} else {header ('location: /index.php?mode=index'); }
include(MAINDIR.'style/foot.php');
?>