<?php
  ///////////////////////////////////////////////////
  //2007 (C)
  //Карпухин Павел
  ///////////////////////////////////////////////////

  $lang = substr($_SERVER["HTTP_ACCEPT_LANGUAGE"], 0,2);
  if (is_file ("../lang/".$lang."/".$lang.".php")) include "../lang/".$lang."/".$lang.".php";
     else include "../lang/ru/ru.php";

  $title=$titlepage = $TEXT['login-title3'];
  $helppage = $TEXT['login-help3'];

  require_once "../config.php";
  require_once "../util/top.php";
  require_once "../util/pass.php";

  if($result2['administrator'] == 0) puterror2($TEXT['error-loginform2']);

  if(!isset($title)) $title = $TEXT['login-title3'];
  if(!isset($button)) $button = $TEXT['btn_edit'];
  if(!isset($action)) $action = "edit.php";

  if(empty($_GET['login_id'])) puterror2($TEXT['error-login15']);
  if(strlen($_GET['login_id'])>50) puterror2($TEXT['error-login14']);
  $_GET['login_id'] = rep($_GET['login_id']);

  $old_login_id = $_GET['login_id'];
  $passwd=passgen($spr_pass);

  $query = "SELECT * FROM `tbl_logins` WHERE `login_id`='".$_GET['login_id']."' ";
  $result = mysql_query($query);
  if(!$result) puterror2($TEXT['error-tbl20']);
      $result2 = mysql_fetch_array($result);
         $login = $result2['login'];
         $fullname = $result2['fullname'];
         if($result2['moderator'] == 1) $moder = "checked";
           else $moder = "";
         if($result2['administrator'] == 1) $admin = "checked";
           else $admin = "";
         if($result2['user'] == 1) $user = "checked";
           else $user = "";
         if($result2['manager'] == 1) $manager = "checked";
           else $manager = "";
         if($result2['master'] == 1) $master = "checked";
           else $master = "";
         if($result2['otvetstvenniy'] == 1) $otvetstvenniy = "checked";
           else $otvetstvenniy = "";
         if($result2['chk_upd'] == "yes") $upd_checkbox = "checked";
          else $upd_checkbox = "";

?>
<form enctype='multipart/form-data' action=<?php echo $action; ?> method=post>
<table>
<tr><td class="useraddedit"><?php echo $TEXT['login-name']; ?></td><td class="useraddedit"><input size=50 maxlength=30 class="inputmandatory" type=text name=login value='<?php echo $login; ?>'></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['login-fullname']; ?></td><td class="useraddedit"><input size=50 maxlength=127 type=text name=fullname value='<?php echo $fullname; ?>'></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['login-password3']; ?></td><td class="useraddedit"><input size=50 maxlength=100 type=password name=oldpassword ></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['login-password4']; ?></td><td class="useraddedit"><input size=50 maxlength=100 type=text name=password value='<?php echo $passwd; ?>'></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['login-password2']; ?></td><td class="useraddedit"><input size=50 maxlength=100 type=text name=password2 ></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['login-moderator']; ?></td><td><input type=checkbox name=moderator <?php echo $moder; ?>></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['login-administrator']; ?></td><td><input type=checkbox name=administrator <?php echo $admin; ?>></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['login-user']; ?></td><td><input type=checkbox name=user <?php echo $user; ?>></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['login-manager']; ?></td><td><input type=checkbox name=manager <?php echo $manager; ?>></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['login-master']; ?></td><td><input type=checkbox name=master <?php echo $master; ?>></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['res-field18']; ?></td><td><input type=checkbox name=otvetstvenniy <?php echo $otvetstvenniy; ?>></td></tr>
<tr>
    <td class="useraddedit"><?php echo $TEXT['login-split']; ?></td><td><input type=checkbox name=iduser >
    <select class="input" name="user_id">
    <?php
        $query = "SELECT * FROM `tbl_users` WHERE `visible` != 'hide' ORDER BY `familiya`";
        $user_tmp = mysql_query($query);
          if(!$user_tmp) puterror2($TEXT['error-tbl2']);
              while($user = mysql_fetch_array($user_tmp))
                {
                 if($user['user_id'] == $result2['usr_id'])
                   {
                   $chk = "<option selected value=".$user['user_id'].">".$user['familiya']." ".$user['name']." ".$user['otchestvo'];
                   }
                 else $chk = "<option value=".$user['user_id'].">".$user['familiya']." ".$user['name']." ".$user['otchestvo'];
                 echo $chk;
                }
    ?>
    </select></td>
</tr>
<tr><td class="useraddedit"><?php echo $TEXT['tbl-unpriv']; ?></td><td><input type=checkbox name=unpriv ></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['global-chk-updates']; ?></td><td><input type=checkbox name=chk_upd <?php echo $upd_checkbox; ?>></td></tr>
<tr><td></td><td>
<input class="button" type=submit value='<?php echo $button; ?>' />
<input type=hidden name=login_id value='<?php echo $old_login_id; ?>' />
</td></tr>
</table>
</form>
<?php
  require_once "../util/bottom.php";
?>
