<?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($result2['administrator'] == 0) puterror2($TEXT['error-supp11']);

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

//function disabled by php > 5.5.3
////import_request_variables("gP", "in_");
// before using only ->  while(list($id,$value) = @each($in_printitem))
 while(list($id2,$value2) = @each($_POST)) {
  if($id2 == "printitem") {
   while(list($id,$value) = each($value2)) {
     if($id > 0 && $value == 'on')
     {
      $query = "DELETE FROM `tbl_zhurnal` WHERE `zhurn_id`=".$id." ";
       $res = mysql_query($query);
        if(!$res) puterror2($TEXT['error-tbl41']);
      }
     }
    }
   }

  //*************************************
  $ip = $_SERVER['REMOTE_ADDR'];
  $doing = $TEXT['log-zhurn3'];
  $what = $TEXT['log-zhurn9'];
  $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=zhurnal.php?zh_str_id=".$_POST['zh_str_id']."' />
               </head></html>";
           } else puterror2($TEXT['error-log']);
?>
</body>
</html>
