<?php
  ///////////////////////////////////////////////////
  //2012 (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['pass-exp'];
  $helppage = "";

  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($_GET['zh_str_id'])) puterror2($TEXT['error-zhurn1']);
  if(strlen($_GET['zh_str_id'])>11) puterror2($TEXT['error-zhurn2']);
  $_GET['zh_str_id'] = rep($_GET['zh_str_id']);

  $search = array("\r\n",";");
  $replace = array("<br /> ","t---z");

  $exp_path = "../NormDoc/knows-".date("YMd").".csv";
  $file = fopen($exp_path,"a");
  $exp_head = $TEXT['izm-krit'].";".$TEXT['izm-tema'].";".$TEXT['know-full2'].";".$TEXT['izm-pos'].";".$TEXT['meet-view'].";".$TEXT['pass-data1'].";".$TEXT['know-prim']."\r\n";
   fwrite($file, $exp_head, strlen($exp_head));

  $query = "SELECT * FROM `tbl_bd_zhnaniy` WHERE `zh_str_id` = '".$_GET['zh_str_id']."'";
     $result = mysql_query($query);
     if(!$result) puterror3($TEXT['error-tbl54']);
       if(mysql_num_rows($result)>0)
         {
          while($result_exps = mysql_fetch_array($result,MYSQL_ASSOC))
          {
           $primechanie = str_replace($search, $replace, $result_exps['primechanie']);
           $zh_soobschenie = str_replace($search, $replace, $result_exps['zh_soobschenie']);
           $visible = str_replace($search, $replace, $result_exps['visible']);
           $exp_string =  $result_exps['krit_id'].";".$result_exps['zh_tema'].";".$zh_soobschenie.";".$result_exps['position'].";".$visible.";".$result_exps['data'].";".$primechanie."\r\n";
  	       fwrite($file, $exp_string, strlen($exp_string));
          }
          fclose($file);
          echo "<table align='center' class='table' border='0' width='30%' >
           <tr class='cntrrslt'><td><img src='../img/ok.png'></td></tr>
           <tr class='cntrrslt'><td>".$TEXT['pass-exp-result']."</td></tr>
          </table>";
          echo "<html><head>
                   <meta HTTP-EQUIV='Refresh' CONTENT='0; URL=pass_transfer.php?trans=".$exp_path."' />
                   </head></html>";
         } else puterror2($TEXT['error-tbl52']);
?>
</body>
</html>