<?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['usr-title3'];
  $helppage = $TEXT['usr-help3'];

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

  if($result2['master'] == 1) puterror2($TEXT['error-loginform4']);
  if($result2['manager'] == 1) puterror2($TEXT['error-loginform4']);

  if(!isset($title)) $title = $TEXT['usr-title3'];
  if(!isset($button)) $button = $TEXT['btn_del'];
  if(!isset($action)) $action = "delete.php";
  if(!isset($button2)) $button2 = $TEXT['btn_back'];
  if(!isset($action2)) $action2 = "index.php";
?>
<table class="table" border="0" cellpadding="0" cellspacing="0" width="50%">
<?php
  if(strlen($_GET['user_id'])>11) puterror2($TEXT['error-user2']);
  $_GET['user_id'] = rep($_GET['user_id']);

  $old_user_id = $_GET['user_id'];

  $query = "SELECT user_id, familiya, name, otchestvo, (SELECT COUNT(pas_id) FROM `tbl_pass_keep` WHERE `usr_id`='".$_GET['user_id']."') AS countpass FROM `tbl_users` WHERE `user_id`='".$_GET['user_id']."' ";
  $result = mysql_query($query);
  if(!$result) puterror2($TEXT['error-tbl2']);
       if(mysql_num_rows($result)>0);
         {
          $result_user = mysql_fetch_array($result);
           echo "<tr class='delit'><td class='delitright' width='50%'>".$TEXT['usr-now']."</td><td class='delitleft'>".$result_user['familiya']." ".$result_user['name']." ".$result_user['otchestvo']."</td></tr>";
         }
?>
</table>
<?php
  $query1 = "SELECT * FROM `tbl_users` WHERE `user_id`='".$_GET['user_id']."' ";
  $result1 = mysql_query($query1);
  if(!$result1) puterror2($TEXT['error-tbl2']);
       if(mysql_num_rows($result1)>0);
         {
          $result_user1 = mysql_fetch_array($result1);
          $user_name = $result_user1['familiya']." ".$result_user1['name']." ".$result_user1['otchestvo'];
         }

  $query22 = "SELECT * FROM `tbl_resource` WHERE `user_id`='".$_GET['user_id']."' ";
  $result22 = mysql_query($query22);
  if(!$result22) puterror2($TEXT['error-tbl16']);
    $num_rows = mysql_num_rows($result22);
       if($num_rows>0)
          {
           echo "<p><u>".$TEXT['global-title3']."</u></p>
            <table class='table' border='1' cellpadding='3' cellspacing='0' width='40%'>
            <tr class='tableheadercat'>
            <td width='30%'>".$TEXT['tbl-fio']."</td>
            <td>".$TEXT['res-field3']."</td>
            <td width='10%'>".$TEXT['tbl-action']."</td>
                 </tr>";

           while($result_resource = mysql_fetch_array($result22))
            {
            $res_res = $result_resource['resource'];
            $edit = "<a href=editresform.php?res_id=".$result_resource['res_id']."&user_id=".$_GET['user_id']." title='".$TEXT['tbl-edit2-tit']."'>".$TEXT['tbl-edit2']."</a>";
            ?>
           <tr class='tabledata' onmouseover="this.style.backgroundColor='#cccccc';" onmouseout="this.style.backgroundColor='#ffffff';">
            <td><?php echo $user_name; ?></td>
            <td><b><i><?php echo $res_res; ?></i></b></td>
            <td><?php echo $edit; ?></td>
                 </tr>
           <?php
            }
	    echo "</table>";
          }
          if($num_rows !== 0) $action_end = $action2;
          else $action_end = $action;

          if($num_rows !== 0) $button_end = $button2;
          else $button_end = $button;

?>
<form enctype='multipart/form-data' action=<?php echo $action_end; ?> method=post>
<table class="table" border="0" cellpadding="0" cellspacing="0" width="50%">
<?php
if($result2['administrator'] == 1 && $result_user['countpass'] > 0) echo "<tr class='delit'><td class='delitright'>".$TEXT['pass-del']."</td><td class='delitleft'><input type=checkbox name=del_key /></td></tr>";
?>
<tr><td width='50%'></td><td>
<input class=button type=submit value='<?php echo $button_end; ?>' />
<input type=hidden name=user_id value='<?php echo $old_user_id; ?>' />
</td></tr>
</table>
</form>
<?php
  require_once "../util/bottom.php";
?>