Вход Регистрация
Файл: New_top/AdmPanel/users.php
Строк: 103
<?php
$title 
'Панель управления сайтом - Управление пользователями';
require_once(
'../Sys/head.php');
reg();
level(2);
switch(
$act)
    {
        default:
        default:
        echo 
'<div class="block">Управление пользователями</div>';

        if (isset(
$_POST['sort1']))
$_SESSION['sort1'] = $_POST['sort1'] ? 0;
if (isset(
$_POST['sort2']))
$_SESSION['sort2'] = $_POST['sort2'] ? 0;
$sort '`id` DESC';
if (isset(
$_SESSION['sort1'])) $sort $_SESSION['sort1'] ? '`login`' '`id`';
if (isset(
$_SESSION['sort2'])) $sort .= $_SESSION['sort2'] ? ' ASC' ' DESC';
        
        
                        
$count $mysqli->query("SELECT `id` FROM `".$prefix."users`")->num_rows;
                        if(
$count 0)
                            {
                                
$total=intval(($count-1)/$pageUsers)+1;
                                
$page = (isset($_GET['page'])) ? abs(intval($_GET['page'])) : '';
                                if(empty(
$page) OR $page 0)
                                    {
                                        
$page 1;
                                    }
                                if(
$page $total)
                                    {
                                        
$page $total;
                                    }
                                
$past intval($count/$pageUsers);
                                
$start $page*$pageUsers-$pageUsers;
                                
$users $mysqli->query("SELECT `id`,`login`,`platformsCount` FROM `".$prefix."users` ORDER BY ".$sort." LIMIT ".$start.",".$pageUsers."");
                                while(
$row $users->fetch_assoc())
                                    {
                                        
$start++;
                                        echo 
'<div class="l1"><span class="o">'.$start.'</span> Логин: <strong>'.$row['login'].'</strong>  <a href="http://'.$_SERVER['HTTP_HOST'].'/controlPanel/users/deleteUser/'.$row['id'].'">[X]</a> <a href="http://'.$_SERVER['HTTP_HOST'].'/controlPanel/users/editUser/'.$row['id'].'">[Ред]</a> </div>';
                                        echo 
'<div class="li">Сайтов: '.$row['platformsCount'].'</div>';
                                        
                                    }
                                if(
$count $pageUsers)
                                    {
                                        
navigation($total,$page,'http://'.$_SERVER['HTTP_HOST'].'/controlPanel/users/');
                                    }
                            }
                        else
                            {
                                echo 
'<div class="l1">';
                                echo 
'По вашему запросу ничего не найдено.<br/>';
                                echo 
'</div>';
                            }
                            
        
// Вывод меню сортировки
echo '<div class="l1"><form action="" method="post"><b>Сортировка: </b><select name="sort1"><option value="0"' . (!$_SESSION['sort1'] ? ' selected="selected"' '') . '>по ID</option><option value="1"' . ($_SESSION['sort1'] ?
            
' selected="selected"' '') . '>по логину</option></select> | <select name="sort2"><option value="0"' . (!$_SESSION['sort2'] ? ' selected="selected"' '') . '>по убыванию</option><option value="1"' . ($_SESSION['sort2'] ?
            
' selected="selected"' '') . '>по возрастанию</option></select><input type="submit" value="&gt;&gt;"/></form></div>';                    
                    
        break;
        case 
'deleteUser':
        
$userIsset $mysqli->query("SELECT `id`,`login`,`level` FROM `".$prefix."users` WHERE `id` = '".$id."' LIMIT 1");
        if(
$userIsset->num_rows 0)
            {
                
$user $userIsset->fetch_assoc();
                echo 
'<div class="block">Удаление пользователя <strong>'.$user['login'].'</strong></div>';
                if(
$id == $user_data['id'] OR $user['level'] == 2)
                    {
                        echo 
'<div class="l1">Удаление невозможно.</div>';
                    }
                else
                    {
                        if(!isset(
$_GET['ok']))
                            {
                                echo 
'<div class="l1">';
                                echo 
'Вы действительно хотите удалить пользователя <strong>'.$user['login'].'</strong> ?<br/>';
                                echo 
'<a href="http://'.$_SERVER['HTTP_HOST'].'/controlPanel/users/deleteUser/'.$id.'/ok">Да</a> | <a href="http://'.$_SERVER['HTTP_HOST'].'/controlPanel">Нет</a><br/>';
                                echo 
'</div>';
                            }
                        else
                        {
                            
$platforms $mysqli->query("SELECT `id`,`category` FROM `".$prefix."sait` WHERE `uid` = '".$id."' LIMIT 1");
                            while(
$sait $platforms->fetch_assoc())
                                {
                                    
$deleteBrowsers $mysqli->query("DELETE FROM `".$prefix."browsers` WHERE `sid` = '".$sait['id']."'");
                                    
$deleteComplaint $mysqli->query("DELETE FROM `".$prefix."complaint` WHERE `sid` = '".$sait['id']."'");
                                    
$deleteCompression $mysqli->query("DELETE FROM `".$prefix."compression` WHERE `sid` = '".$sait['id']."'");
                                    
$deleteCountry $mysqli->query("DELETE FROM `".$prefix."country` WHERE `sid` = '".$sait['id']."'");
                                    
$deleteHours $mysqli->query("DELETE FROM `".$prefix."hours` WHERE `sid` = '".$sait['id']."'");
                                    
$deleteDays $mysqli->query("DELETE FROM `".$prefix."days` WHERE `sid` = '".$sait['id']."'");
                                    
$deleteMonth $mysqli->query("DELETE FROM `".$prefix."month` WHERE `sid` = '".$sait['id']."'");
                                    
$deleteOperators $mysqli->query("DELETE FROM `".$prefix."operators` WHERE `sid` = '".$sait['id']."'");
                                    
$deleteOnline $mysqli->query("DELETE FROM `".$prefix."saitsOnline` WHERE `sid` = '".$sait['id']."'");
                                    
$deleteGo $mysqli->query("DELETE FROM `".$prefix."go` WHERE `sid` = '".$sait['id']."'");
                                    
$deleteShows $mysqli->query("DELETE FROM `".$prefix."shows` WHERE `sid` = '".$sait['id']."'");
                                    
$updateCat $mysqli->query("UPDATE `".$prefix."cat` SET `count` = (`count` - 1) WHERE `id` = '".$sait['category']."'");
                                    
$deletePlatform $mysqli->query("DELETE FROM `".$prefix."sait` WHERE `uid` = '".$id."'");
                                }
                            
$deleteUser $mysqli->query("DELETE FROM `".$prefix."users` WHERE `id` = '".$id."'");
                            echo 
'<div class="l1">';
                            echo 
'Пользователь успешно удален.<br/>';
                            echo 
'</div>';
                        }
                    }
            }
        else
            {
                echo 
'<div class="l1">';
                echo 
'Пользователь не найден.<br/>';
                echo 
'</div>';
            }
        break;
        case 
'editUser':
        
$userIsset $mysqli->query("SELECT `id`,`login`,`level` ,`timeReg` FROM `".$prefix."users` WHERE `id` = '".$id."' LIMIT 1");
        if(
$userIsset->num_rows 0)
            {
                
$user $userIsset->fetch_assoc();
                echo 
'<div class="block">Редактирование пользователя <strong>'.$user['login'].'</strong></div>';
                        if(!isset(
$_POST['ok']))
                            {
                                echo 
'<div class="l1">';
                                echo 
'<form action="" method="post" name="form">';
                                echo 
'Логин (max.30):<br/>';
                                echo 
'<input type="text" class="form" name="login" maxlength="30" class="do_button" value="'.$user['login'].'"/><br/>';
                                echo 
'Уровень доступа:<br/>';
                                echo 
'<select name="level">';
                                if (
$user['level'] == 1)
                                    {
                                        echo 
'<option value="1">Пользователь</option><br/>';
                                        echo 
'<option value="2">Администратор</option><br/>';
                                    }
                                else
                                    {
                                        echo 
'<option value="2">Администратор</option><br/>';
                                        echo 
'<option value="1">Пользователь</option><br/>';
                                    }
                                echo 
'</select><br/>';

                                echo 
'Регистрации: ['.date("j-m-Y H:i:s",$user['timeReg']).']<br/>';

                                echo 
'<input name="ok" type="submit" class="button" value="Сохранить" /></form></div>';
                            }
                        else
                            {
                                
$login filter($_POST['login']);
                                
$level abs(intval($_POST['level']));
                                
$error '';
                                if(empty(
$login))
                                    {
                                        
$error .= 'Поле "Логин" пустое.<br/>';
                                    }
                                if(!empty(
$error))
                                    {
                                        echo 
'<div class="l1">';
                                        echo 
'В результате заполнения полей , выявились ошибки:<br/>';
                                        echo 
$error;
                                        echo 
'<a href="http://'.$_SERVER['HTTP_HOST'].'/controlPanel/users/editUser/'.$id.'">Назад</a><br/>';
                                        echo 
'</div>';
                                    }
                                else
                                    {
                                        
$mysqli->query("UPDATE `".$prefix."users` SET `login` = '".$login."', `level` = '".$level."' WHERE `id` = '".$id."'");
                                        echo 
'<div class="l1">';
                                        echo 
'Пользователь успешно отредактирован.<br/>';
                                        echo 
'</div>';
                                    }
                            }
            }
        else
            {
                echo 
'<div class="l1">';
                echo 
'Пользователь не найден.<br/>';
                echo 
'</div>';
            }
        break;
    }
echo 
'<div class="li">';
echo 
'<a href="http://'.$_SERVER['HTTP_HOST'].'/controlPanel/users">К управлению пользователями</a><br/>';
echo 
'<a href="http://'.$_SERVER['HTTP_HOST'].'/controlPanel">В Админку</a><br/>';
echo 
'</div>';
?>
Онлайн: 3
Реклама