Просмотр файла admin_panel/ip.php

Размер файла: 2.41Kb
<?
include('../core/core.php');
include(BASEDIR.INC.'func.php');
include(BASEDIR.INC.'session.php');
include(BASEDIR.INC.'session_user.php');
$mode = htmlspecialchars($_GET['mode']);
include(BASEDIR.INC.'head.php');
show_title('IP бан панель');
if (is_admin(array(101, 102))) {
$users = mysql_query('SELECT * FROM users WHERE login = "'.$_COOKIE['login'].'"');
$users = mysql_fetch_assoc($users);
$admin = $users['status'];
echo'<div class="razdel">Админ-панель</div>'; 
$act = '<img src="'.BASEDIR.''.IMG.'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);
$page=(int)$_GET['page'];  
     
   $q=mysql_result(mysql_query("SELECT COUNT(*) FROM `ban` WHERE `ip`"),0);  
      
    $total = intval(($q - 1) / TOPAGE) + 1;  
      
    if(empty($page) or $page < 0) $page = 1;  
      
    if($page > $total) $page = $total;  
      
    $start = $page * TOPAGE -TOPAGE;  

    $g=mysql_query("SELECT * FROM `ban` WHERE `ip` ORDER BY `id` DESC LIMIT $start,".TOPAGE."");  
while($u=mysql_fetch_array($g)){ 
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 != $total) $nextpage = ' <a href="?mode=index&page='. ($page + 1) .'">Далее</a>';  
      if($page - 1 > 0) $pageback = '<a href="?mode=index&page='. ($page - 1) .'">Назад</a> ';  
echo''.$pageback.' '.$nextpage.'';




break;
case 'del':
$id = abs($_GET['id']);
mysql_query('DELETE FROM `ban` WHERE `id` = "'.$id.'"');
header ('location: ?mode=index'); 
break;
case 'add':
$ip = check($_POST['ip']);
$ban = check($_POST['ban']);
mysql_query('INSERT INTO `ban`(`ip`,`ban`) VALUES ("'.$ip.'","'.$ban.'")');
header ('location: ?mode=index'); 
break;
default: 
header ('location: ?mode=index'); 
endswitch;
echo'<div class="menu"><a href="/">На главную</a></div>';
} else {header ('location: /index.php?mode=index'); } 
include(BASEDIR.INC.'foot.php');
?>