<?php
  ///////////////////////////////////////////////////
  //2010 (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 = $TEXT['login-title-edit'];
  $button = $TEXT['btn_save'];
  $action = "edit.php";

  require_once "../config_a.php";
  require_once "../utils/functions.php";
  require_once "../utils/top_adm.php";
  require_once "../utils/pass.php";

  if($result2['administrator'] == 0 && $result2['login_id'] !== $_GET['login_id']) {puterror($result2['skin'],$TEXT['error-loginform3']); require_once "../utils/bottom_adm.php"; exit();}
  $passwd=passgen($usr_pass);

  if(empty($_GET['login_id'])) {puterror($result2['skin'],$TEXT['error-login15']); require_once "../utils/bottom_adm.php"; exit();}
  if(strlen($_GET['login_id'])>15) {puterror($result2['skin'],$TEXT['error-login14']); require_once "../utils/bottom_adm.php"; exit();}
  $_GET['login_id'] = rep($_GET['login_id']);

$query_iskh = "SELECT * FROM `tbl_logins` WHERE `login_id`='".$_GET['login_id']."' ";
  $result_iskh = mysqli_query($dbcnx,$query_iskh);
  if(!$result_iskh) {puterror($result2['skin'],$TEXT['error-tbl7']); require_once "../utils/bottom_adm.php"; exit();}
      $result_iskh2 = mysqli_fetch_array($result_iskh,MYSQLI_ASSOC);
      $old_dom_id = $result_iskh2['dom_id'];
      $old_login_id = $_GET['login_id'];

         if($result_iskh2['administrator'] == 1) {$admin = "checked";}
           else {$admin = "";}
         if($result_iskh2['user'] == 1) {$user = "checked";}
           else {$user = "";}

         if($result_iskh2['chk_upd'] == "yes") {$upd_checkbox = "checked";}
          else {$upd_checkbox = "";}

         if($result_iskh2['maintenance'] == "yes") {$maint_checkbox = "checked";}
          else {$maint_checkbox = "";}

?>
<form enctype='multipart/form-data' action=<?php echo $action; ?> method=post>
<table align="center" border=0 width=50%>
 <tr><td>
<table align="left" >
<tr><td class="bold_it_page"><?php echo $TEXT['login-login']; ?>*</td><td><input size=40 maxlength=100 type=text name=login value='<?php echo $result_iskh2['login']; ?>'></td></tr>
<tr><td class="bold_it_page"><?php echo $TEXT['login-familiya']; ?></td><td><input size=40 maxlength=100 type=text name=familiya  value='<?php echo $result_iskh2['familiya']; ?>'></td></tr>
<tr><td class="bold_it_page"><?php echo $TEXT['login-name']; ?></td><td><input size=40 maxlength=100 type=text name=name  value='<?php echo $result_iskh2['name']; ?>'></td></tr>
<tr><td class="bold_it_page"><?php echo $TEXT['login-otchestvo']; ?></td><td><input size=40 maxlength=100 type=text name=otchestvo  value='<?php echo $result_iskh2['otchestvo']; ?>'></td></tr>
<tr><td class="bold_it_page"><?php echo $TEXT['login-password-last']; ?></td><td><input size=40 maxlength=100 type=password name=oldpassword ></td></tr>
<tr><td class="bold_it_page"><?php echo $TEXT['login-password-new']; ?></td><td><input size=40 maxlength=100 type=text name=password value='<?php echo $passwd; ?>'></td></tr>
<tr><td class="bold_it_page"><?php echo $TEXT['login-password2']; ?></td><td><input size=40 maxlength=100 type=text name=password2 ></td></tr>
<tr><td class="bold_it_page"><?php echo $TEXT['user-tel-mob']; ?></td><td><input size=40 maxlength=20 type=text name=phone  value='<?php echo $result_iskh2['phone']; ?>'></td></tr>
<tr><td class="bold_it_page"><?php echo $TEXT['user-e-mail']; ?></td><td><input size=20 maxlength=40 type=text name=mail  value='<?php echo $result_iskh2['e_mail']; ?>'> @
<select class="input" name="dom_id">
    <?php
        $query10 = "SELECT * FROM `tbl_domain` ORDER BY domain";
        $domain_tmp = mysqli_query($dbcnx,$query10);
          if(!$domain_tmp) {puterror($result2['skin'],$TEXT['error-tbl5']); require_once "../utils/bottom_adm.php"; exit();}
           while($domain = mysqli_fetch_array($domain_tmp,MYSQLI_ASSOC))
            {
             if($domain['dom_id'] == $result_iskh2['dom_id'])
              {
               $chk = "<option selected value=".$domain['dom_id'].">".$domain['domain'];
              }
               else {$chk = "<option value=".$domain['dom_id'].">".$domain['domain'];}
                 echo $chk;
            }
    ?>
    </select></td></tr>
<tr><td class="bold_it_page"><?php echo $TEXT['login-fltr']; ?></td><td><input size=4 maxlength=4 type=text name=fltr_size  value='<?php echo $result_iskh2['fltr_size']; ?>'></td></tr>
<tr><td class="bold_it_page"><?php echo $TEXT['global-tema']; ?></td><td>
<select class="input" name="skin">
    <?php
        $skin_dir = opendir("../skins");
         while(($dir = readdir($skin_dir)))
          {
           if(is_dir("../skins/".$dir) && $dir !== "." && $dir !== "..")
           {
            if($result_iskh2['skin'] == $dir)
             {
              $tema = "<option selected value=".$dir.">".$dir."";
             }
              else {$tema = "<option value=".$dir.">".$dir."";}
               echo $tema;
           }
          }
        closedir($skin_dir);
    ?>
    </select></td></tr>
<tr><td class="bold_it_page"><?php echo $TEXT['login-administrator']; ?></td><td><input type=checkbox name=administrator <?php echo $admin; ?>></td></tr>
<tr><td class="bold_it_page"><?php echo $TEXT['login-user']; ?></td><td><input type=checkbox name=user <?php echo $user; ?>></td></tr>
<?php
if($result_iskh2['administrator'] == 1) {
echo "<tr><td class='bold_it_page'>".$TEXT['global-chk-updates']."</td><td><input type='checkbox' name='chk_upd' ".$upd_checkbox." /></td></tr>";
echo "<tr><td class='bold_it_page'>".$TEXT['login-title-maintenance']."</td><td><input type='checkbox' name='chk_maint' ".$maint_checkbox." /></td></tr>";
}
?>
<tr><td></td><td>
<input class="button2" type="submit" value='<?php echo $button; ?>'>
<input type="hidden" name="old_dom_id" value='<?php echo $old_dom_id; ?>' />
<input type="hidden" name="login_id" value='<?php echo $old_login_id; ?>' />
</td></tr>
</table>
</td>
</tr>
</table>
</form>
<?php
  require_once "../utils/bottom_adm.php";
?>