<?php
  ///////////////////////////////////////////////////
  //2008 (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-text2'];
  $helppage = "";

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

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

  if(empty($_GET['local'])) puterror3($TEXT['alias-error1']);
  if(strlen($_GET['local'])>65) puterror3($TEXT['alias-error2']);
  $_GET['local'] = rep($_GET['local']);

  //*************************************
  $query = "SELECT * FROM `aliases` WHERE `local_part`='".$_GET['local']."' ";
  $result = mysql_query($query);
  if (!$result) puterror3($TEXT['error-tbl32']);
      $result2 = mysql_fetch_array($result);

  $ip = $_SERVER['REMOTE_ADDR'];
  $doing = $TEXT['log-alias-del'];
  $what = $result2['local_part']."@".$result2['domain'];
  $who = $result2['fullname'];
  //*************************************
  $query = "DELETE FROM `aliases` WHERE `local_part`='".$_GET['local']."' LIMIT 1";
  if(mysql_query($query))
  {
    $query2 = "INSERT INTO tbl_logs ( `log_id` , `data` , `ip` , `who` , `doing` , `what` ) VALUES ( NULL , NOW() , '$ip' , '$who' , '$doing' , '$what')";
        if(mysql_query($query2))
           {
             echo "<html><head>
                   <meta HTTP-EQUIV='Refresh' CONTENT='0; URL=index.php' />
                   </head></html>";
           } else puterror3($TEXT['error-log']);
  } else puterror3($TEXT['error-tbl32']);
  require_once "../../util/bottom.php";
?>
