<?php
  /////////////////////////////////////////////////////////////////////////////////////
  //База знаний, поправки, удаление замечаний из статьи
  //2010 (C)
  //Карпухин Павел
  ////////////////////////////////////////////////////////////////////////////////////

  $lang = substr($_SERVER["HTTP_ACCEPT_LANGUAGE"], 0,2);
  if(is_file ("../lang/".$lang.".php")) include "../lang/".$lang.".php";
     else include "../lang/ru.php";

  $title=$titlepage = $TEXT['zhurn-del'];
  $helppage = $TEXT['zhurn-del-help'];

  require_once "../config.php";
  require_once "top.php";
  ?>
  <title><?php echo $title; ?></title>
  <link rel="StyleSheet" type="text/css" href="../utils/grid.css" />
  </head>
  <body>
  <?php

  if(empty($_GET['zh_str_id'])) puterror2($TEXT['error-zhurn1']);
  if(strlen($_GET['zh_str_id'])>11) puterror2($TEXT['error-zhurn2']);
  if(empty($_GET['zhurn_id'])) puterror2($TEXT['error-zhurn11']);
  if(strlen($_GET['zhurn_id'])>11) puterror2($TEXT['error-zhurn12']);
  if(strlen($_GET['tr_id'])>11) puterror2($TEXT['error-popr1']);
  if(strlen($_GET['otkr'])>1) puterror2($TEXT['error-zhurn12']);

  if($_GET['all_tr'] == "1")
  {
   $tr_id = "";
   $log_tr = $TEXT['log-know8'];
  } else
      {
      $tr_id = " AND `tr_id` = '".$_GET['tr_id']."'";
      $log_tr = $TEXT['log-know9'];
      }

 $query = "DELETE FROM `tbl_know_prim` WHERE `zhurn_id`='".$_GET['zhurn_id']."' $tr_id";
   $res = mysql_query($query);
     if(!$res) puterror2($TEXT['error-tbl47']);

 $query_log = "SELECT `zh_tema` FROM `tbl_bd_zhnaniy` WHERE `zhurn_id`=".$_GET['zhurn_id']."";
   $res_log = mysql_query($query_log);
     if(!$res_log) puterror2($TEXT['error-tbl46']);
     $res_log_inf = mysql_fetch_array($res_log,MYSQL_ASSOC);

  //*************************************
  $ip = $_SERVER['REMOTE_ADDR'];
  $doing = $TEXT['log-know7'];
  $what = $log_tr."&laquo;".$res_log_inf['zh_tema']."&raquo;";
  $who = $result2['fullname'];
  //*************************************
  $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=know_view.php?zh_str_id=".$_GET['zh_str_id']."&amp;zhurn_id=".$_GET['zhurn_id']."&amp;otkr=".$_GET['otkr']."'  />
               </head></html>";
           } else puterror2($TEXT['error-log']);
?>
</body>
</html>