<?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['exusr-title4'];
  $helppage = $TEXT['exusr-help2'];

  require_once "../../config.php";
  require_once "../../util/top_layer2.php";

  if($result2['administrator'] == 0) puterror3($TEXT['error-loginform4']);

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

  if(empty($_GET['userid']))
   {
   $_GET['userid'] = "0";

  if(strlen($_GET['userid'])>11) puterror3($TEXT['error-user2']);
  $_GET['userid'] = rep($_GET['userid']);

  if(empty($_GET['id'])) puterror3($TEXT['exusr-error1']);
  if(strlen($_GET['id'])>220) puterror3($TEXT['error-user18']);
  $_GET['id'] = rep($_GET['id']);

  $old_id = $_GET['id'];

  $query = "SELECT id, name, user_id, passwd, uid, gid, mbox_host, shell, home, quota, active FROM `users` WHERE `id`='".$_GET['id']."' ";
  $result = mysql_query($query);
  if(!$result) puterror3($TEXT['error-tbl28']);
      $result2 = mysql_fetch_array($result);
         $id = $result2['id'];
  	 $user=$result2['user_id'];
  	 $shl=$result2['shell'];
  	 $uid=$result2['uid'];
  	 $gid=$result2['gid'];
  	 $home=$result2['home'];
  	 $quo=$result2['quota'];
  	 $name=$result2['name'];
  	 $passwd=$result2['passwd'];
	 $mbox_host=$result2['mbox_host'];

  if($result2['active'] == "Y") $visible = "checked";
    else $visible = "";

  $old_id = $_GET['id'];
?>
<form enctype='multipart/form-data' action=<?php echo $action; ?> method=post>
<table>
<tr><td class="useraddedit"><?php echo $TEXT['ex-bat-ex5']; ?>: </td><td class="useraddedit"><?php echo $id; ?>@<?php echo $mbox_host; ?></td></tr>
<tr><td class="useraddedit"><a href='user_add2.php?id=<?php echo $id; ?>' title='<?php echo $TEXT['exusr-title5']; ?>'><?php echo $TEXT['login-user']; ?></a>: </td><td class="useraddedit"><input size=50 maxlength=255 class="inputmandatory" type=text name=name value='<?php echo $name; ?>'></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['login-password']; ?>: </td><td class="useraddedit"><input size=50 maxlength=255 class="inputmandatory" type=text name=passwd value='<?php echo $passwd; ?>'></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['user-uid']; ?></td><td class="useraddedit"><input size=50 maxlength=10 class="inputmandatory" type=text name=uid value='<?php echo $uid; ?>'></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['user-gid']; ?></td><td class="useraddedit"><input size=50 maxlength=10 class="inputmandatory" type=text name=gid value='<?php echo $gid; ?>'></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['user-shell']; ?></td><td class="useraddedit"><input size=50 maxlength=32 class="inputmandatory" type=text name=shl value='<?php echo $shl; ?>'></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['user-hom']; ?></td><td class="useraddedit"><input size=50 maxlength=128 class="inputmandatory" type=text name=hom value='<?php echo $home; ?>'></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['exusr-kvota']; ?>: </td><td class="useraddedit"><input size=50 maxlength=7 class="inputmandatory" type=text name=kvota value='<?php echo $quo; ?>'></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['exusr-act4']; ?></td><td><input type=checkbox name=visible <?php echo $visible; ?>></td></tr>
<tr><td></td><td>
<input class="button" type=submit value='<?php echo $button; ?>' />
<input type=hidden name=id value='<?php echo $old_id; ?>' />
<input type=hidden name=user_id value='<?php echo $user; ?>' />
<input type=hidden name=mbox_host value='<?php echo $mbox_host; ?>' />
</td></tr>
</table>
</form>
<?php
   }
   else
   {
  if(strlen($_GET['userid'])>11) puterror3($TEXT['error-user2']);
  $_GET['userid'] = rep($_GET['userid']);
  if(empty($_GET['id'])) puterror3($TEXT['exusr-error1']);
  if(strlen($_GET['id'])>220) puterror3($TEXT['error-user18']);
  $_GET['id'] = rep($_GET['id']);

  $query1 = "SELECT tbl_users.user_id, tbl_users.familiya, tbl_users.name, tbl_users.otchestvo, tbl_users.mail,  tbl_domain.domain 
FROM tbl_users 
JOIN tbl_domain ON tbl_users.dom_id=tbl_domain.dom_id 
WHERE `user_id` = '".$_GET['userid']."'";
  $result1 = mysql_query($query1);
  if(!$result1) puterror3($TEXT['error-tbl2']);
    $res = mysql_fetch_array($result1);
    $name=$res['familiya']." ".$res['name']." ".$res['otchestvo'];
    $user=$_GET['userid'];

  $query = "SELECT id, name, user_id, passwd, uid, gid, mbox_host, shell, home, quota, active FROM `users` WHERE `id`='".$_GET['id']."' ";
  $result = mysql_query($query);
  if(!$result) puterror3($TEXT['error-tbl28']);
      $result2 = mysql_fetch_array($result);
         $id = $result2['id'];
  	 //$user=$result2['user_id'];
  	 $shl=$result2['shell'];
  	 $uid=$result2['uid'];
  	 $gid=$result2['gid'];
  	 $home=$result2['home'];
  	 $quo=$result2['quota'];
  	 //$name=$result2['name'];
  	 $passwd=$result2['passwd'];
	   $mbox_host=$result2['mbox_host'];

  if($result2['active'] == "Y") $visible = "checked";
    else $visible = "";

  $old_id = $_GET['id'];
?>
<form enctype='multipart/form-data' action=<?php echo $action; ?> method=post>
<table>
<tr><td class="useraddedit"><p class=zag2><?php echo $TEXT['ex-bat-ex5']; ?>: </td><td class="useraddedit"><?php echo $id; ?>@<?php echo $mbox_host; ?></td></tr>
<tr><td class="useraddedit"><p class=zag2><a href='user_add2.php?id=<?php echo $id; ?>' title='<?php echo $TEXT['exusr-title5']; ?>'><?php echo $TEXT['login-user']; ?></a>: </td><td class="useraddedit"><input size=50 maxlength=255 class="inputmandatory" type=text name=name value='<?php echo $name; ?>'></td></tr>
<tr><td class="useraddedit"><p class=zag2><?php echo $TEXT['login-password']; ?>: </td><td class="useraddedit"><input size=50 maxlength=255 class="inputmandatory" type=text name=passwd value='<?php echo $passwd; ?>'></td></tr>
<tr><td class="useraddedit"><p class=zag2><?php echo $TEXT['user-uid']; ?></td><td class="useraddedit"><input size=50 maxlength=10 class="inputmandatory" type=text name=uid value='<?php echo $uid; ?>'></td></tr>
<tr><td class="useraddedit"><p class=zag2><?php echo $TEXT['user-gid']; ?></td><td class="useraddedit"><input size=50 maxlength=10 class="inputmandatory" type=text name=gid value='<?php echo $gid; ?>'></td></tr>
<tr><td class="useraddedit"><p class=zag2><?php echo $TEXT['user-shell']; ?></td><td class="useraddedit"><input size=50 maxlength=32 class="inputmandatory" type=text name=shl value='<?php echo $shl; ?>'></td></tr>
<tr><td class="useraddedit"><p class=zag2><?php echo $TEXT['user-hom']; ?></td><td class="useraddedit"><input size=50 maxlength=128 class="inputmandatory" type=text name=hom value='<?php echo $home; ?>'></td></tr>
<tr><td class="useraddedit"><p class=zag2><?php echo $TEXT['exusr-kvota']; ?>: </td><td class="useraddedit"><input size=50 maxlength=4 class="inputmandatory" type=text name=kvota value='<?php echo $quo; ?>'></td></tr>
<tr><td><p class=zag2><?php echo $TEXT['exusr-act4']; ?></td><td><input type=checkbox name=visible <?php echo $visible; ?>></td></tr>
<tr><td></td><td>
<input class="button" type=submit value='<?php echo $button; ?>' />
<input type=hidden name=id value='<?php echo $old_id; ?>' />
<input type=hidden name=user_id value='<?php echo $user; ?>' />
<input type=hidden name=mbox_host value='<?php echo $mbox_host; ?>' />
</td></tr>
</table>
</form>
<?php
   }
  require_once "../../util/bottom.php";
?>