<?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['bllst-add-tit'];
  $helppage = "";

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

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

  if(empty($_POST['address'])) puterror3($TEXT['bllst-error1']);
  if(strlen($_POST['address'])>65) puterror3($TEXT['bllst-error2']);
  if(empty($_POST['tip'])) puterror3($TEXT['error-tip1']);
  if(strlen($_POST['tip'])>8) puterror3($TEXT['error-tip2']);
  if(empty($_POST['message'])) puterror3($TEXT['bllst-error3']);
  if(strlen($_POST['message'])>255) puterror3($TEXT['bllst-error4']);

  if(isset($_POST['address'])) $address=trim($_POST['address']);
    else $address="";
     if (empty($address)) puterror3($TEXT['bllst-error5']);

  $_POST['address'] = rep($_POST['address']);
  $_POST['tip'] = rep($_POST['tip']);
  $_POST['message'] = rep($_POST['message']);

  //*************************************
  $ip = $_SERVER['REMOTE_ADDR'];
  $doing = $TEXT['log-ex-bl-add'];
  $what = $_POST['address']." (".$_POST['tip'].")";
  $who = $result2['fullname'];
  //*************************************
  $query = "INSERT INTO `blacklists` ( `address` , `type` , `message` ) VALUES ('".$_POST['address']."', '".$_POST['tip']."', '".$_POST['message']."')";
  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-tbl28']);
  require_once "../../util/bottom.php";
?>
