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

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

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

  if(empty($_POST['news_id'])) puterror2($TEXT['error-new16']);
  if(strlen($_POST['news_id'])>11) puterror2($TEXT['error-new17']);
  $_POST['news_id'] = rep($_POST['news_id']);

  $query = "SELECT * FROM `tbl_news` WHERE `new_id`='".$_POST['news_id']."' ";
  $result = mysql_query($query);
  if(!$result) puterror2($TEXT['error-tbl17']);
//    {
//    if(mysql_num_rows($result)>0)
//    {
    $result2 = mysql_fetch_array($result);
//    if(file_exists("../".$result2['picture_big']) && $result2['picture_big'] != "-")
//         unlink("../".$result2['picture_big']);
//    if(file_exists("../".$result2['picture']) && $result2['picture'] != "-")
//         unlink("../".$result2['picture']);
//    }
//  }

  //*************************************
  $ip = $_SERVER['REMOTE_ADDR'];
  $doing = $TEXT['log-new2'];
  $what = $result2['header'].$TEXT['log-id'].$result2['new_id'];
  $who = $result2['fullname'];
  //*************************************
  $query_delete = "DELETE FROM `tbl_news` WHERE `new_id`='".$_POST['news_id']."' LIMIT 1";
  if(mysql_query($query_delete))
  {
    $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 puterror2($TEXT['error-log']);
  } else puterror2($TEXT['error-new18']);
  require_once "../util/bottom.php";
?>