<?php
  ///////////////////////////////////////////////////
  //2010 (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['kat-title4'];
  $helppage = $TEXT['kat-help4'];

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

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

  if(empty($_POST['zh_str_id'])) puterror2($TEXT['error-kat8']);
  if(strlen($_POST['zh_str_id'])>11) puterror2($TEXT['error-kat9']);
  $_POST['zh_str_id'] = rep($_POST['zh_str_id']);

  //*************************************
  $query1 = "SELECT zh_str_id, strukt_name FROM `tbl_zhurn_strukt` WHERE `zh_str_id`='".$_POST['zh_str_id']."' ";
  $result = mysql_query($query1);
  if (!$result) puterror2($TEXT['error-tbl40']);
   $result2 = mysql_fetch_array($result);

  $ip = $_SERVER['REMOTE_ADDR'];
  $doing = $TEXT['log-kat3'];
  $what = $result2['strukt_name'].$TEXT['log-id'].$_POST['zh_str_id'];
  $who = $result2['fullname'];
  //*************************************
  $query = "DELETE FROM `tbl_zhurn_strukt` WHERE `zh_str_id`='".$_POST['zh_str_id']."' 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 puterror2($TEXT['error-log']);
  } else puterror2($TEXT['error-kat10']);
  require_once "../util/bottom.php";
?>