<?

include '../../config.php';
include '../../func.php';
head();

if ( isset($_GET['id']) ) {
    $id = num($_GET['id']);
    } else {
if ( empty($_SESSION['panel_user']) ) {
    
    header('Location: index.php');
    exit();
} else {
    $id = $_SESSION['panel_user'];
}

}

$user = mysql_fetch_assoc(mysql_query("SELECT * FROM `profile` WHERE `id` = '".$id."'"));


/*if ( $level_session < $user['level'] OR $id_session == $user['id'] OR $id_session != 4) {
    
    echo head . 'Пользователь <b>'.$user['login'].'</b>' . div . katalog;
    echo 'Доступ запрещен';
    echo div;
    navig();
    foot();
    exit();
    
}*/
if ( isset($_POST['submit']) ) {
    
    $login = html($_POST['login']);
    $pass = html($_POST['pass']);
    $email = html($_POST['mail']);
            
    $level = num($_POST['level']);
    $level_fo = num($_POST['level_fo']);
    $level_forum = num($_POST['level_forum']);
    $chat_postov = num($_POST['chat_postov']);
    $forum_postov = num($_POST['postov_forum']);
            
    $extra = num($_POST['extra']);
    $otvet_um = num($_POST['otvet_um']);
    $kumar = num($_POST['kumar']);
    $narush = num($_POST['narush']);
    $zlob = num($_POST['zlob']);
    $rating = num($_POST['rating']); 
    $iq = num($_POST['iq']);  
    $alcohol = num($_POST['alcohol']);  
    $aa2 = num($_POST['aa2']);  
    $ratingmany = num($_POST['ratingmany']); 
    $result = mysql_query("UPDATE `profile` SET `aa2` = '".$aa2."', `extra` = '".$extra."', `iq` = '".$iq."', `alcohol` = '".$alcohol."', `login` = '".$login."', `pass` = '".$pass."',`mail` = '".$email."', `level` = '".$level."', `level_fo` = '".$level_fo."', `level_forum` = '".$level_forum."', `postov` = '".$chat_postov."', `postov_forum` = '".$forum_postov."', `rating` = '".$rating."'  WHERE `id` = '".$id."'");   
    
    if ( $result != NULL ) {
        
        echo katalog . 'Информация успешно обновлена' . div;
        
    } else {
        
        echo katalog . 'Возникла ошибка' . div;
    
    }
    
    unset($_SESSION['panel_user']);
}
echo head . 'Пользователь <b>'.$user['login'].'</b>' . div . katalog;
        $_SESSION['panel_user'] = $user['id']; 
        echo "IP: <b>".$user['ip']."</b><br/>";
        echo "Браузер: <b>".$user['brauser']."</b><br/><br/ >";
        echo '<form action="edit.php" method="post" name="form">';
        echo link1 . '
        
        Логин:<br/ ><input name="login" value="'.$user['login'].'" type="text" maxlength="30"/><br/ >
        Пароль:<br/ ><input name="pass" value="'.$user['pass'].'" type="text" maxlength="30"/><br/ >
        E-Mail:<br/ ><input name="mail" value="'.$user['mail'].'" type="text" maxlength="30"/><br/ >
        ' . div;
        
        echo link2 . '
        
        Общий уровень:<br/><select name="level">
        <option value="'.$user['level'].'">Не изменять</option>
        <option value="0">Пользователь</option>
        <option value="1">Киллер</option>
        <option value="2">Модератор</option>
        <option value="3">Старший модератор</option>';
        
        if ( $level_session == 5 ) {
        echo '
        <option value="4">Администратор</option>
        <option value="5">Создатель</option>';
        }
        
        echo '</select><br/>';
        
        echo '
        Уровень в обменнике файлов:<br/>
        <select name="level_fo">
        <option value="'.$user['level_fo'].'">Не изменять</option>
        <option value="0">Пользователь</option>
        <option value="1">Модератор</option>';
        if ( $level_session == 5 ) {
        echo '<option value="2">Ст. Модератор</option>
        <option value="3">Администратор</option>';
        }
        
        echo '</select><br/>';
        
        echo '
        Уровень на форуме:<br/>
        <select name="level_forum">
        <option value="'.$user['level_forum'].'">Не изменять</option>
        <option value="0">Пользователь</option>
        <option value="1">Модератор</option>
        <option value="2">Ст. Модератор</option>';
        
        if ( $level_session == 5 ) {
        echo '<option value="3">Администратор</option>';
        }
        
        echo '</select><br/>
        ' . div;
        
        echo link2 . '
        
        Постов в чате:<br/ ><input name="chat_postov" value="'.$user['postov'].'" type="text" maxlength="30"/><br/ >
        Постов в форуме:<br/ ><input name="postov_forum" value="'.$user['postov_forum'].'" type="text" maxlength="30"/><br/ >
        
        
        ' . div;
        
        echo link2 . '
        Рейтинг:<br/ ><input name="rating" value="'.$user['rating'].'" type="text" maxlength="30"/><br/ >
        IQ:<br/><input type="text" name="iq" maxlength="5" value="' . $user['iq'] . '"/><br/ >
        Алкоголь:<br/><input type="text" name="alcohol" maxlength="5" value="' . $user['alcohol'] . '"/><br/ >
        Баллов:<br/><input type="text" name="extra" maxlength="100" value="' . $user['extra'] . '"/><br/ >
        Людей в гареме:<br/><input type="text" name="aa2" maxlength="100" value="' . $user['aa2'] . '"/><br/ >
        ' . div;
        
        echo link1 . '<input name="submit" type="submit" class="button" value="Сохранить" /></form>' . div;
        $_SESSION['panel_user'] = $user['id'];
        echo div . kub . '<img src="../../style/img/kub.gif" alt="" />' . div . katalog . '
        [<a href="../banip/ban.php">Бан IP</a>] [<a href="../ban/ban.php">Бан ника</a>] [<a href="../pin/pin.php">Пнуть</a>] [<a href="del.php">Удалить</a>]
        
        ' . div;
        
navig();
foot();
?>