<?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['krit-title4'];
  $helppage = $TEXT['krit-help4'];

  require_once "../config.php";
  require_once "../util/top_layer1.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($_GET['krit_id'])) puterror2($TEXT['error-krit5']);
  if(strlen($_GET['krit_id'])>11) puterror2($TEXT['error-krit4']);
  if(empty($_GET['zhurn_id'])) puterror2($TEXT['error-zhurn11']);
  if(strlen($_GET['zhurn_id'])>11) puterror2($TEXT['error-zhurn12']);

  $_GET['krit_id'] = rep($_GET['krit_id']);
  $_GET['zhurn_id'] = rep($_GET['zhurn_id']);

  //*************************************
  $query_zh = "SELECT zh_tema FROM `tbl_zhurnal` WHERE `zhurn_id` = ".$_GET['zhurn_id']."";
  $result_zh = mysql_query($query_zh);
  if(!$result_zh) puterror2($TEXT['error-tbl41']);
   $result_log = mysql_fetch_array($result_zh);

  $ip = $_SERVER['REMOTE_ADDR'];
  $doing = $TEXT['log-zhurn3'];
  $what = $TEXT['log-zhurn4']."&laquo;".$result_log['zh_tema']."&raquo;".$TEXT['log-id'].$_GET['zhurn_id'];
  $who = $result2['fullname'];
  //*************************************
  $query = "DELETE FROM `tbl_zhurnal` WHERE `zhurn_id`='".$_GET['zhurn_id']."' ";
   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=deleteform.php?krit_id=".$_GET['krit_id']."' />
                   </head></html>";
           } else puterror2($TEXT['error-log']);
  } else puterror2($TEXT['error-tbl41']);
?>
</body>
</html>