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

  require_once "../config.php";
  require_once "../util/top.php";
  //require_once "../lang/".$lang."/trans.php";

  if(is_file ("../lang/".$lang."/trans.php")) include "../lang/".$lang."/trans.php";
   else include "../lang/ru/trans.php";

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

  if(empty($_POST['familiya'])) $_POST['familiya'] = "";
  if(empty($_POST['name'])) $_POST['name'] = "";
  if(empty($_POST['otchestvo'])) $_POST['otchestvo'] = "";

  if(!isset($title)) $title = $TEXT['usr-title'];
  if(!isset($button)) $button = $TEXT['btn_gen'];
  if(!isset($action)) $action = "user_translit.php";

  if(strlen($_POST['familiya'])>200) puterror2($TEXT['error-user3']);
  if(strlen($_POST['name'])>200) puterror2($TEXT['error-user4']);
  if(strlen($_POST['otchestvo'])>200) puterror2($TEXT['error-user5']);
  $_POST['familiya'] = rep($_POST['familiya']);
  $_POST['name'] = rep($_POST['name']);
  $_POST['otchestvo'] = rep($_POST['otchestvo']);

  $name=$_POST['name'];
  $familiya=$_POST['familiya'];
  $otchestvo=$_POST['otchestvo'];

?>
<form enctype='multipart/form-data' action=<?php echo $action; ?> method=post>
<table width="70%" align="center">
<tr><td class="useraddedit"><?php echo $TEXT['tbl-lastname']; ?></td><td class="useraddedit"><input size=50 maxlength=50 class="inputmandatory" type=text name=familiya value='<?php echo $familiya; ?>'></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['tbl-name']; ?></td><td class="useraddedit"><input size=50 maxlength=50 class="inputmandatory" type=text name=name value='<?php echo $name; ?>'></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['tbl-otch']; ?></td><td class="useraddedit"><input size=50 maxlength=50 class="inputmandatory" type=text name=otchestvo value='<?php echo $otchestvo; ?>'></td></tr>
<tr><td></td><td><input class=button type=submit value='<?php echo $button; ?>' /></td></tr>
</table>
<br>
<table class="table" border="1" cellpadding="3" cellspacing="0" width="70%">
<?php
$name_tmp=substr($_POST['name'], 0,2);
$name_tmp2=substr($_POST['name'], 0,4);
$otch_tmp=substr($_POST['otchestvo'], 0,2);
$otch_tmp2=substr($_POST['otchestvo'], 0,4);
$full_name1=$name_tmp.".".$_POST['familiya'];
$full_name2=$name_tmp2.".".$_POST['familiya'];
$full_name3=$_POST['name'].".".$_POST['familiya'];
$full_name4=$name_tmp.".".$otch_tmp.".".$_POST['familiya'];
$full_name5=$name_tmp2.".".$otch_tmp.".".$_POST['familiya'];
$full_name6=$name_tmp.".".$otch_tmp2.".".$_POST['familiya'];
$full_name7=$name_tmp2.".".$otch_tmp2.".".$_POST['familiya'];

$mail1 = translate($full_name1);
$mail2 = translate($full_name2);
$mail3 = translate($full_name3);
$mail4 = translate($full_name4);
$mail5 = translate($full_name5);
$mail6 = translate($full_name6);
$mail7 = translate($full_name7);

$mail1_1 = strtolower($mail1);
$mail2_1 = strtolower($mail2);
$mail3_1 = strtolower($mail3);
$mail4_1 = strtolower($mail4);
$mail5_1 = strtolower($mail5);
$mail6_1 = strtolower($mail6);
$mail7_1 = strtolower($mail7);

$mail_size_1 = strlen($mail1_1);
$mail_size_2 = strlen($mail2_1);
$mail_size_3 = strlen($mail3_1);
$mail_size_4 = strlen($mail4_1);
$mail_size_5 = strlen($mail5_1);
$mail_size_6 = strlen($mail6_1);
$mail_size_7 = strlen($mail7_1);

  $query1 = "SELECT `user_id`, `mail` FROM `tbl_users` WHERE `mail`='$mail1_1'";
  $result1 = mysql_query($query1);
  if(!$result1) puterror2($TEXT['error-tbl21']);
    $res_mail1 = mysql_fetch_array($result1,MYSQL_ASSOC);
       if($res_mail1['mail'] == $mail1_1) $result_mail1 = "<a href# onClick=window.open('../../user.php?user_id=".$res_mail1['user_id']."','popup','top=".$TEXT['user-top'].",left=".$TEXT['user-left'].",width=".$TEXT['user-width'].",height=".$TEXT['user-height'].",status=no,scrollbars=no,location=no,menubar=no,toolbar=no') title='".$TEXT['btn_test']."'><span class='translit_no'>".$TEXT['tbl-addr-use']."</span></a>";
         else $result_mail1 = "<b class='translit_ok'>".$TEXT['tbl-addr-notuse']."</b>";

  $query2 = "SELECT `user_id`, `mail` FROM `tbl_users` WHERE `mail`='$mail2_1'";
  $result2 = mysql_query($query2);
  if(!$result2) puterror2($TEXT['error-tbl22']);
    $res_mail2 = mysql_fetch_array($result2,MYSQL_ASSOC);
       if($res_mail2['mail'] == $mail2_1) $result_mail2 = "<a href# onClick=window.open('../../user.php?user_id=".$res_mail2['user_id']."','popup','top=".$TEXT['user-top'].",left=".$TEXT['user-left'].",width=".$TEXT['user-width'].",height=".$TEXT['user-height'].",status=no,scrollbars=no,location=no,menubar=no,toolbar=no') title='".$TEXT['btn_test']."'><span class='translit_no'>".$TEXT['tbl-addr-use']."</span></a>";
         else $result_mail2 = "<b class='translit_ok'>".$TEXT['tbl-addr-notuse']."</b>";

  $query3 = "SELECT `user_id`, `mail` FROM `tbl_users` WHERE `mail`='$mail3_1'";
  $result3 = mysql_query($query3);
  if(!$result3) puterror2($TEXT['error-tbl23']);
    $res_mail3 = mysql_fetch_array($result3,MYSQL_ASSOC);
       if($res_mail3['mail'] == $mail3_1) $result_mail3 = "<a href# onClick=window.open('../../user.php?user_id=".$res_mail3['user_id']."','popup','top=".$TEXT['user-top'].",left=".$TEXT['user-left'].",width=".$TEXT['user-width'].",height=".$TEXT['user-height'].",status=no,scrollbars=no,location=no,menubar=no,toolbar=no') title='".$TEXT['btn_test']."'><span class='translit_no'>".$TEXT['tbl-addr-use']."</span></a>";
         else $result_mail3 = "<b class='translit_ok'>".$TEXT['tbl-addr-notuse']."</b>";

  $query4 = "SELECT `user_id`, `mail` FROM `tbl_users` WHERE `mail`='$mail4_1'";
  $result4 = mysql_query($query4);
  if(!$result4) puterror2($TEXT['error-tbl24']);
    $res_mail4 = mysql_fetch_array($result4,MYSQL_ASSOC);
       if($res_mail4['mail'] == $mail4_1) $result_mail4 = "<a href# onClick=window.open('../../user.php?user_id=".$res_mail4['user_id']."','popup','top=".$TEXT['user-top'].",left=".$TEXT['user-left'].",width=".$TEXT['user-width'].",height=".$TEXT['user-height'].",status=no,scrollbars=no,location=no,menubar=no,toolbar=no') title='".$TEXT['btn_test']."'><span class='translit_no'>".$TEXT['tbl-addr-use']."</span></a>";
         else $result_mail4 = "<b class='translit_ok'>".$TEXT['tbl-addr-notuse']."</b>";

  $query5 = "SELECT `user_id`, `mail` FROM `tbl_users` WHERE `mail`='$mail5_1'";
  $result5 = mysql_query($query5);
  if(!$result5) puterror2($TEXT['error-tbl25']);
    $res_mail5 = mysql_fetch_array($result5,MYSQL_ASSOC);
       if($res_mail5['mail'] == $mail5_1) $result_mail5 = "<a href# onClick=window.open('../../user.php?user_id=".$res_mail5['user_id']."','popup','top=".$TEXT['user-top'].",left=".$TEXT['user-left'].",width=".$TEXT['user-width'].",height=".$TEXT['user-height'].",status=no,scrollbars=no,location=no,menubar=no,toolbar=no') title='".$TEXT['btn_test']."'><span class='translit_no'>".$TEXT['tbl-addr-use']."</span></a>";
         else $result_mail5 = "<b class='translit_ok'>".$TEXT['tbl-addr-notuse']."</b>";

  $query6 = "SELECT `user_id`, `mail` FROM `tbl_users` WHERE `mail`='$mail6_1'";
  $result6 = mysql_query($query6);
  if(!$result6) puterror2($TEXT['error-tbl26']);
    $res_mail6 = mysql_fetch_array($result6,MYSQL_ASSOC);
       if($res_mail6['mail'] == $mail6_1) $result_mail6 = "<a href# onClick=window.open('../../user.php?user_id=".$res_mail6['user_id']."','popup','top=".$TEXT['user-top'].",left=".$TEXT['user-left'].",width=".$TEXT['user-width'].",height=".$TEXT['user-height'].",status=no,scrollbars=no,location=no,menubar=no,toolbar=no') title='".$TEXT['btn_test']."'><span class='translit_no'>".$TEXT['tbl-addr-use']."</span></a>";
         else $result_mail6 = "<b class='translit_ok'>".$TEXT['tbl-addr-notuse']."</b>";

  $query7 = "SELECT `user_id`, `mail` FROM `tbl_users` WHERE `mail`='$mail7_1'";
  $result7 = mysql_query($query7);
  if(!$result7) puterror2($TEXT['error-tbl27']);
    $res_mail7 = mysql_fetch_array($result7,MYSQL_ASSOC);
      if($res_mail7['mail'] == $mail7_1) $result_mail7 = "<a href# onClick=window.open('../../user.php?user_id=".$res_mail7['user_id']."','popup','top=".$TEXT['user-top'].",left=".$TEXT['user-left'].",width=".$TEXT['user-width'].",height=".$TEXT['user-height'].",status=no,scrollbars=no,location=no,menubar=no,toolbar=no') title='".$TEXT['btn_test']."'><span class='translit_no'>".$TEXT['tbl-addr-use']."</span></a>";
        else $result_mail7 = "<b class='translit_ok'>".$TEXT['tbl-addr-notuse']."</b>";

           echo "<tr class='tableheadercat' border='1'>
            <td>".$TEXT['tbl-var']."</td>
            <td>".$TEXT['tbl-verd']."</td>
            <td>".$TEXT['tbl-action']."</td>
                 </tr>";

           echo "<tr class='tabledata'>
              <td>".$mail1_1." (".$mail_size_1." ".$TEXT['global-simbol'].")</td>
              <td>".$result_mail1."</td>
              <td><a href='addform.php?mail=$mail1_1&name=$name&familiya=$familiya&otchestvo=$otchestvo' title='".$TEXT['tbl-add-tit']."'>".$TEXT['btn_add']."</a></td>
                 </tr>
                <tr class='tabledata'>
              <td>".$mail2_1." (".$mail_size_2." ".$TEXT['global-simbol'].")</td>
              <td>".$result_mail2."</td>
              <td><a href='addform.php?mail=$mail2_1&name=$name&familiya=$familiya&otchestvo=$otchestvo' title='".$TEXT['tbl-add-tit']."'>".$TEXT['btn_add']."</a></td>
                 </tr>
                <tr class='tabledata'>
              <td>".$mail3_1." (".$mail_size_3." ".$TEXT['global-simbol'].")</td>
              <td>".$result_mail3."</td>
              <td><a href='addform.php?mail=$mail3_1&name=$name&familiya=$familiya&otchestvo=$otchestvo' title='".$TEXT['tbl-add-tit']."'>".$TEXT['btn_add']."</a></td>
                 </tr>
                <tr class='tabledata'>
              <td>".$mail4_1." (".$mail_size_4." ".$TEXT['global-simbol'].")</td>
              <td>".$result_mail4."</td>
              <td><a href='addform.php?mail=$mail4_1&name=$name&familiya=$familiya&otchestvo=$otchestvo' title='".$TEXT['tbl-add-tit']."'>".$TEXT['btn_add']."</a></td>
                 </tr>
                <tr class='tabledata'>
              <td>".$mail5_1." (".$mail_size_5." ".$TEXT['global-simbol'].")</td>
              <td>".$result_mail5."</td>
              <td><a href='addform.php?mail=$mail5_1&name=$name&familiya=$familiya&otchestvo=$otchestvo' title='".$TEXT['tbl-add-tit']."'>".$TEXT['btn_add']."</a></td>
                 </tr>
                <tr class='tabledata'>
              <td>".$mail6_1." (".$mail_size_6." ".$TEXT['global-simbol'].")</td>
              <td>".$result_mail6."</td>
              <td><a href='addform.php?mail=$mail6_1&name=$name&familiya=$familiya&otchestvo=$otchestvo' title='".$TEXT['tbl-add-tit']."'>".$TEXT['btn_add']."</a></td>
                 </tr>
                <tr class='tabledata'>
              <td>".$mail7_1." (".$mail_size_7." ".$TEXT['global-simbol'].")</td>
              <td>".$result_mail7."</td>
              <td><a href='addform.php?mail=$mail7_1&name=$name&familiya=$familiya&otchestvo=$otchestvo' title='".$TEXT['tbl-add-tit']."'>".$TEXT['btn_add']."</a></td>
                 </tr>";

  require_once "../util/bottom.php";
?>
</table>