<?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['domain-title3'];
  $helppage = "";

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

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

  if(empty($_GET['domain'])) puterror3($TEXT['error-domain1']);
  if(strlen($_GET['domain'])>200) puterror3($TEXT['error-domain2']);
  $_GET['domain'] = rep($_GET['domain']);

  $query_cou = mysql_query("SELECT COUNT(id) FROM users WHERE mbox_host='".$_GET['domain']."' ");
  $coun = mysql_result($query_cou, 0);
  if($coun > 0) puterror3($TEXT['exusr-error17']."<b>&laquo;".$coun."&raquo;</b>".$TEXT['exusr-error18']);

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

  $ip = $_SERVER['REMOTE_ADDR'];
  $doing = $TEXT['log-domain2'];
  $what = $result2['domain']." (".$result2['type'].")";
  $who = $result2['fullname'];
  //*************************************
  $query = "DELETE FROM `domains` WHERE `domain`='".$_GET['domain']."' 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-domain7']);
  require_once "../../util/bottom.php";
?>
