<?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['global-inst'];
  require_once "config.php";
  require_once "utils/top_inst_get.php";

  if(empty($_GET['instr_id'])) puterror($TEXT['error-zhurn11']);
  if(strlen($_GET['instr_id'])>15) puterror($TEXT['error-zhurn12']);
  $_GET['instr_id'] = rep($_GET['instr_id']);
  $count_view = 0;

  $query_iskh = "SELECT name, description, path, count_view FROM `tbl_instructions` WHERE `instr_id` = '".$_GET['instr_id']."'";
  $instruction = mysql_query($query_iskh);
   if(!$instruction) puterror($TEXT['error-tbl18']);
    $inst = mysql_fetch_array($instruction);
      $inpath = preg_replace("/\.\.+./","",$inst['path']);

  $count_view = $inst['count_view'] + 1;

  echo "<div class='upd'><img alt='Ok' src='img/ok.png' /></div><div class='upd'>".$TEXT['inst-vidano-now']."<a href='".$inpath."' target=_blank title='".$inst['description']."'><span class='informssilka'>".$inst['name']."</span></a></div>";

  $queryst = "UPDATE `tbl_instructions` SET `count_view` = ".$count_view." WHERE `instr_id`='".$_GET['instr_id']."'";
    if(mysql_query($queryst))
     {
      echo "<html><head>
            <meta HTTP-EQUIV='Refresh' CONTENT='0; URL=".$inpath."' target=_blank />
            </head></html>";
     } else puterror($TEXT['error-tbl18']);
  require_once "utils/bottom.php";
?>