<?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['alias-title'];
  $helppage = $TEXT['alias-help'];
  require_once "../../config.php";
  require_once "../../util/top_layer2.php";
  if($result2['administrator'] == 0) puterror3($TEXT['error-loginform4']);

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

  if(empty($_POST['recipients'])) $_POST['recipients'] = "";
  if(strlen($_POST['recipients'])>2001) puterror3($TEXT['alias-error4']);
  $_POST['recipients'] = rep($_POST['recipients']);

  $recipients_per=$_POST['recipients'];
?>
<img alt="<?php echo $TEXT['alias-add']; ?>" src= "../../img/insert.png" height="15" align="top" /><a class="boldit" href="addform.php" title="<?php echo $TEXT['alias-add-title']; ?>"><?php echo $TEXT['alias-add']; ?></a>
<form enctype='multipart/form-data' action=<?php echo $action; ?> method=post>
<table class="table" border="0" cellpadding="0" cellspacing="0" width="30%">
<tr><td>
<fieldset class="filterr">
<legend align="left" title="<?php echo $TEXT['log-tit7']; ?>"><?php echo $TEXT['btn_filter']; ?></legend>
<table class="table" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr class=zag2><td><?php echo $TEXT['alias-where']; ?></td></tr>
<tr><td><input style="font-weight: bold" size=30 maxlength=200 class=input type=text name=recipients title='<?php echo $TEXT['exusr-example1']; ?>' value='<?php echo $recipients_per; ?>'></td>
    <td><input class=button type=submit value='<?php echo $button; ?>'></td>
</tr>
</table>
</fieldset>
</td></tr>
</table>
</form>
 <br />
 <span class="tabledata"><?php echo $TEXT['alias-text1']; ?></span>
<table class="table" border="1" cellpadding="3" cellspacing="0" width="80%">
<?php
   if(!empty($_POST['recipients'])) $rcpt_q = "WHERE `recipients`REGEXP '".$_POST['recipients']."' ";
    else $rcpt_q = "";

     $query = "SELECT * FROM `aliases` ".$rcpt_q." ORDER BY `local_part`";
     $result = mysql_query($query);
     if(!$result) puterror3($TEXT['error-tbl32']);
       if(mysql_num_rows($result)>0);
         {
           echo "<tr class='tableheadercat'>
            <td>".$TEXT['alias-who']."</td>
            <td>".$TEXT['tbl-domain']."</td>
            <td>".$TEXT['alias-where']."</td>
            <td colspan=2>".$TEXT['tbl-action']."</td>
                 </tr>";
             while($result_alias = mysql_fetch_array($result,MYSQL_ASSOC))
               {
              $edit = "<a href=editform.php?local=".$result_alias['local_part']." title='".$TEXT['bllst-text3']."'>".$TEXT['tbl-edit']."</a>";
              $delete = "<a href=delete.php?local=".$result_alias['local_part']." title='".$TEXT['bllst-text4']."'>".$TEXT['tbl-delete']."</a>";
           ?>
           <tr class='tabledata' onmouseover="this.style.backgroundColor='#cccccc';" onmouseout="this.style.backgroundColor='#ffffff';">
              <td><?php echo $result_alias['local_part']; ?></td>
              <td><?php echo $result_alias['domain']; ?></td>
              <td><?php echo $result_alias['recipients']; ?></td>
              <td><?php echo $edit; ?></td>
              <td><?php echo $delete; ?></td>
           </tr>
           <?php
               }
         }
?>
</table>
<?php
  require_once "../../util/bottom_exp.php";
?>