<?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['know-izm'];
  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 leftmargin="0" marginheight="0" marginwidth="0" rightmargin="0" bottommargin="0" topmargin="0" >
  <?php
  $_GET['s'] == 0;
  if(strlen($_GET['zh_str_id'])>11) puterror2($TEXT['error-zhurn2']);
  if(!empty($_GET['zh_str_id']))
   {
    $tmp_zh_str_id = "&amp;zh_str_id=".$_GET['zh_str_id']."";
    $old_zh_str_id = $_GET['zh_str_id'];
    if($_GET['koren'] == "on")
    {
      $koren_tmp = "&amp;koren=on";
      $koren = "";
      $koren_check = "checked";
      $ord = "tbl_bd_zhnaniy.position DESC, tbl_bd_zhnaniy.data DESC";
    }
     else
     {
       $koren = " AND tbl_bd_zhnaniy.zh_str_id='".$_GET['zh_str_id']."'";
       $ord = "tbl_bd_zhnaniy.position DESC, tbl_bd_zhnaniy.data DESC";
     }
   }
   elseif(!empty($_POST['zh_str_id']))
   {
    $tmp_zh_str_id = "&amp;zh_str_id=".$_POST['zh_str_id']."";
    $old_zh_str_id = $_POST['zh_str_id'];
    if($_POST['koren'] == "on")
    {
     $koren_tmp = "&amp;koren=on";
     $koren = "";
     $koren_check = "checked";
     $ord = "tbl_bd_zhnaniy.position DESC, tbl_bd_zhnaniy.data DESC";
    }
     else
     {
       $koren = " AND tbl_bd_zhnaniy.zh_str_id='".$_POST['zh_str_id']."'";
       $ord = "tbl_bd_zhnaniy.position DESC, tbl_bd_zhnaniy.data DESC";
     }
   }
   else
   {
     $koren = "";
     $ord = "tbl_bd_zhnaniy.data DESC";
     if($_GET['koren'] == "on" || $_POST['koren'] == "on") $koren_check = "checked";
   }

  if($_GET['dop'] == "off" && $result2['administrator'] == 1) {
      $dop = "<td><a href=knowledge.php?dop=on&amp;zh_str_id=".$_GET['zh_str_id']." ><img class='tipsimg_open_close' alt='open_close' src='../img/plus.png' /></a></td>";
      $imp ="";
      $exp = "";
      }
   elseif($_GET['dop'] == "" && $result2['administrator'] == 1) {
       $dop = "<td><a href=knowledge.php?dop=on&amp;zh_str_id=".$_GET['zh_str_id']." ><img class='tipsimg_open_close' alt='open_close' src='../img/plus.png' /></a></td>";
      }
   elseif($_GET['dop'] == "on" && $result2['administrator'] == 1) {
       $dop = "<td><a href=knowledge.php?dop=off&amp;zh_str_id=".$_GET['zh_str_id']." ><img class='tipsimg_open_close' alt='open_close' src='../img/minus.png' /></a></td>";
       $imp ="<tr><td></td><td>&nbsp;<img class='formainimg' alt='import' src='../img/import.png' /></td><td class='newsdesch'>&nbsp;<a href='know_impform.php?zh_str_id=".$_GET['zh_str_id']."' class='news3' title='".$TEXT['pass-imp-tit']."'>".$TEXT['pass-imp']."</a></td><td></td></tr>";
       $exp = "<tr><td></td><td>&nbsp;<img class='formainimg' alt='export' src='../img/export.png' /></td><td class='newsdesch'>&nbsp;<a href='know_export.php?zh_str_id=".$_GET['zh_str_id']."' class='news3' title='".$TEXT['pass-exp-tit']."'>".$TEXT['pass-exp']."</a></td><td></td></tr>";
       }
    else $dop = "<td></td>";

  if(strlen($_GET['k'])>8) puterror2($TEXT['error-paging1']);
  if(empty($_GET['k'])) $_GET['k']=0;
  $stop_r = $_GET['k'];
  if($stop_r == 0) $lim_ogr = "20";
   else $lim_ogr = $stop_r.",20";

  $ktblvis = $stop_r+20;
  $str = $ktblvis/20;

  if(empty($_POST['search'])) $_POST['search'] = $_GET['search'];
  if(empty($_POST['typepar'])) $_POST['typepar'] = $_GET['typepar'];

  if(!empty($_POST['search'])) {
   $tmp_srch = "&amp;search=".$_POST['search']."";
   $tmp_tppr = "&amp;typepar=".$_POST['typepar']."";
  } else {
     $tmp_srch = "";
     $tmp_tppr = "";
  }

  if(strlen($_POST['search'])>100) puterror2($TEXT['search-err2']);
  if(strlen($_POST['typepar'])>10) puterror2($TEXT['search-err3']);
  $_POST['search'] = rep($_POST['search']);
  $_POST['typepar'] = rep($_POST['typepar']);
  $_POST['lgn_id'] = rep($_POST['lgn_id']);

    switch($_POST['typepar'])
      {
      case 1: //сквозной
      $action_pre = ", MATCH (tbl_bd_zhnaniy.zh_soobschenie) AGAINST ('".$_POST['search']."' IN NATURAL LANGUAGE MODE) AS score ";
      $action = " AND (LOWER(tbl_bd_zhnaniy.zh_tema) LIKE LOWER('%".$_POST['search']."%') OR MATCH (tbl_bd_zhnaniy.zh_soobschenie) AGAINST ('".$_POST['search']."' IN BOOLEAN MODE) )";
      $action_post = "score DESC, ";
      break;
      case 2: //тема
      $action_pre = "";
      $action = " AND LOWER(tbl_bd_zhnaniy.zh_tema) LIKE LOWER('%".$_POST['search']."%')";
      $action_post = "";
      break;
      case 3: //сообщение
      $action_pre = ", MATCH (tbl_bd_zhnaniy.zh_soobschenie) AGAINST ('".$_POST['search']."' IN NATURAL LANGUAGE MODE) AS score ";
      $action = " AND MATCH (tbl_bd_zhnaniy.zh_soobschenie) AGAINST ('".$_POST['search']."' IN BOOLEAN MODE) ";
      $action_post = "score DESC, ";
      break;
      }

  if($_POST['krit_ch'] == "on") {
      $krit_ch_tmp = "&amp;krit_ch=on";
      $krit_id = " AND tbl_bd_zhnaniy.krit_id='".$_POST['krit_id']."' ";
      $krit_check = "checked";
      $krt_id = $_POST['krit_id'];
      $krt_str = "&amp;krit_id=".$krt_id."&amp;krit_ch=on";
    }
    elseif($_GET['krit_ch'] == "on") {
      $krit_id = " AND tbl_bd_zhnaniy.krit_id='".$_GET['krit_id']."' ";
      $krit_check = "checked";
      $krt_id = $_GET['krit_id'];
      $krt_str = "&amp;krit_id=".$krt_id."&amp;krit_ch=on";
  }
   else   {
       $krit_id = "";
       $krt_str = "";
   }

  if($_POST['login_ch'] == "on") {
      $lgn_check = "checked";
      $login_id = " AND tbl_bd_zhnaniy.login_id='".$_POST['lgn_id']."' ";
      $ord = "cnt_popr DESC, tbl_bd_zhnaniy.data DESC";
      $lgn_id = $_POST['lgn_id'];
      $lgn_str = "&amp;lgn_id=".$lgn_id."&amp;login_ch=on";
  }
  elseif($_GET['login_ch'] == "on") {
      $lgn_check = "checked";
      $login_id = " AND tbl_bd_zhnaniy.login_id='".$_GET['lgn_id']."' ";
      $ord = "cnt_popr DESC, tbl_bd_zhnaniy.data DESC";
      $lgn_id = $_GET['lgn_id'];
      $lgn_str = "&amp;lgn_id=".$lgn_id."&amp;login_ch=on";
  }
   else {
       $login_id = "";
       $lgn_str = "";
   }

   // Проверяем наличие замечаний в общем
   $query_all_z = mysql_query("SELECT COUNT(tbl_know_prim.tr_id) FROM tbl_know_prim WHERE tbl_know_prim.login_id=".$result2['login_id']." ");
    $coun_rows_z = mysql_result($query_all_z, 0);
    
   // Хлебные крошки Breadcrumbs
   if(!empty($_GET['zh_str_id']))
   {
   $resourcebr = "SELECT parent, zh_str_id, strukt_name FROM tbl_zhnaniy_strukt WHERE zh_str_id=".$_GET['zh_str_id']."";
    $resultbr=mysql_query($resourcebr);
     $result_bread=mysql_fetch_array($resultbr);

   $item_id = $_GET['zh_str_id'];
   $item_par = $result_bread['parent'];
   $item_name = "<a class='news3' href=knowledge.php?zh_str_id=".$item_id.">".$result_bread['strukt_name']."</a>";

   while($item_par != 0)
    {
    $resourcebr2 = "SELECT parent, zh_str_id, strukt_name FROM tbl_zhnaniy_strukt WHERE zh_str_id=".$item_par."";
    $resultbr2=mysql_query($resourcebr2);
     $num_br = mysql_num_rows($resultbr2);
     if($num_br > 0)
     {
     $result_bread2=mysql_fetch_array($resultbr2);
     $item_id = $result_bread2['zh_str_id'];
     $item_par = $result_bread2['parent'];
     $item_name = "<a class='news3' href=knowledge.php?zh_str_id=".$item_id.">".$result_bread2['strukt_name']."</a> &#187; ".$item_name;
     }
    }
   }
   //echo $item_name;
  // конец хлебных крошек

  if($_POST['typepar'] == 1) {
   $type_chk1 = "checked";
   $type_chk2 = "";
   $type_chk3 = "";
  }
  elseif($_POST['typepar'] == 2) {
   $type_chk1 = "";
   $type_chk2 = "checked";
   $type_chk3 = "";
  }
  elseif($_POST['typepar'] == 3) {
   $type_chk1 = "";
   $type_chk2 = "";
   $type_chk3 = "checked";
  }
  else {
   $type_chk1 = "checked";
   $type_chk2 = "";
   $type_chk3 = "";
  }
?>
<form action=knowledge.php method=post>
<table class="tabledata" border="0" cellpadding="2" cellspacing="0" width="100%">
<tr align="center">
  <td>
    <table width=100% class="topheader" border="0" cellspacing="3">
     <tr align="center" valign="middle">
     <td align="right"><input class="inputsearch" size=30 maxlength=30 type=text name=search title="<?php echo $TEXT['search-btn-title']; ?>" value="<?php echo $_POST['search']; ?>" >&nbsp;<input class="button" type=submit value='<?php echo $TEXT['search-btn']; ?>'></td>
     </tr>
     <tr>
       <td align="right" class="menu">
         <input type=hidden name=zh_str_id value='<?php echo $old_zh_str_id; ?>' />
         <input type=checkbox name=koren <?php echo $koren_check; ?> /><?php echo $TEXT['zhurn-search2']; ?>
         <input type=radio name=typepar value=1 <?php echo $type_chk1; ?> /><?php echo $TEXT['zhurn-search1']; ?>
         <input type=radio name=typepar value=2 <?php echo $type_chk2; ?> /><?php echo $TEXT['izm-tema']; ?>
         <input type=radio name=typepar value=3 <?php echo $type_chk3; ?> /><?php echo $TEXT['izm-soobsch']; ?>
         <input type=checkbox name=krit_ch <?php echo $krit_check; ?> />
         <select name=krit_id class="button">
    <?php
        $query4 = "SELECT * FROM `tbl_kritichnost` ORDER BY position, kritichnost";
        $kritichnost_tmp = mysql_query($query4);
          if(!$kritichnost_tmp) puterror2($TEXT['error-tbl39']);
          while($kritichnost = mysql_fetch_array($kritichnost_tmp,MYSQL_ASSOC))
                {
                 if($kritichnost['krit_id'] == $krt_id)
                   {
                   $chk = "<option selected value=".$kritichnost['krit_id'].">".$kritichnost['kritichnost']."";
                   }
                 else $chk = "<option value=".$kritichnost['krit_id'].">".$kritichnost['kritichnost']."";
                 echo $chk;
                }
    ?>
    </select>
         <input type=checkbox name=login_ch <?php echo $lgn_check; ?> />
         <select name=lgn_id class="button">
    <?php
    $query4 = "SELECT
            DISTINCT tbl_bd_zhnaniy.login_id AS lgn_id,
            tbl_logins.fullname
            FROM tbl_bd_zhnaniy
            LEFT JOIN tbl_logins ON tbl_bd_zhnaniy.login_id=tbl_logins.login_id
            ORDER BY tbl_logins.fullname";
        $lgn_tmp = mysql_query($query4);
          if(!$lgn_tmp) puterror2(mysql_error());
              while($lgns = mysql_fetch_array($lgn_tmp,MYSQL_ASSOC))
                {
                 if($lgns['lgn_id'] == $lgn_id)
                   {
                   $chk2 = "<option selected value=".$lgns['lgn_id'].">".$lgns['fullname']."";
                   }
                 else $chk2 = "<option value=".$lgns['lgn_id'].">".$lgns['fullname']."";
                 echo $chk2;
                }
    ?>
    </select>
         <a href="know_rss.php" class=link target="_blank" title="<?php echo $TEXT['global-rss']; ?>"><img alt="rss" src="../img/rss.gif" /></a>
       </td>
     </tr>
    </table>
<tr>
<tr>
  <td>
    <table border="0" width="86%" cellpadding="0" cellspacing="0" align="left" class="formainbread">
     <tr><td></td><td></td><td></td></tr>
     <tr>
       <td></td>
       <td class="newsdesch">&nbsp;&nbsp;<a class='news3' href=knowledge.php ><?php echo $TEXT['zhurn-path']; ?></a><?php echo $item_name; ?></td>
       <td></td>
     </tr>
     <tr><td></td><td></td><td></td></tr>
    </table>
    <table border="0" width="11%" cellpadding="0" cellspacing="0" align="right" class="formainbtnpass">
     <tr><td></td><td></td><td></td><td></td></tr>
     <tr>
       <td></td>
       <td>&nbsp;<img class="formainimg" alt="add" src="../img/add.png" /></td>
       <td class="newsdesch"><a href="know_addform.php?zh_str_id=<?php echo $_GET['zh_str_id']; ?>" class="news3" title="<?php echo $TEXT['zhurn-izm-add-title']; ?>"><?php echo $TEXT['btn_add']; ?></a></td>
       <?php echo $dop; ?>
       <?php echo $exp; ?>
       <?php echo $imp; ?>
     </tr>
     <tr><td></td><td></td><td></td><td></td></tr>
    </table>
<?php
  $query4 = "SELECT 
    tbl_bd_zhnaniy.zhurn_id,
    tbl_bd_zhnaniy.krit_id,
    tbl_bd_zhnaniy.zh_str_id,
    tbl_bd_zhnaniy.zh_tema,
    SUBSTRING_INDEX(tbl_bd_zhnaniy.zh_soobschenie, ' ', 20) AS zh_soobschenie,
    tbl_bd_zhnaniy.position,
    tbl_bd_zhnaniy.visible,
    YEAR(tbl_bd_zhnaniy.data) AS zhnan_year,
    MONTH(tbl_bd_zhnaniy.data) AS zhnan_month,
    DAY(tbl_bd_zhnaniy.data) AS zhnan_day,
    TIME(tbl_bd_zhnaniy.data) AS zhnan_hour,
    tbl_bd_zhnaniy.login_id,
    tbl_logins.fullname,
    tbl_kritichnost.pic_krit,
    tbl_kritichnost.kritichnost,
    (SELECT COUNT(tbl_know_prim.tr_id) FROM tbl_know_prim WHERE tbl_know_prim.zhurn_id=tbl_bd_zhnaniy.zhurn_id ) AS cnt_popr
    $action_pre
    FROM tbl_bd_zhnaniy
    JOIN tbl_logins ON tbl_bd_zhnaniy.login_id=tbl_logins.login_id
    JOIN tbl_kritichnost ON tbl_bd_zhnaniy.krit_id=tbl_kritichnost.krit_id
    WHERE tbl_bd_zhnaniy.zhurn_id != 0 ".$koren." ".$krit_id." ".$login_id." ".$action."
    ORDER BY ".$action_post.$ord." LIMIT $lim_ogr";
    $tmp4 = mysql_query($query4);
     if(!$tmp4) puterror2(mysql_error());
      $num_rows = mysql_num_rows($tmp4);
        if($num_rows == 0)
          {
           echo "<tr><td align='center' class='zagolovok'>";
           echo "<br />".$TEXT['zhurn-nodata']."";
           echo "</td></tr>";
          }
           else
           {
 ?>
  <tr>
    <td align="center">
      <table border="0" width="95%" cellpadding="0" cellspacing="0" class="formain">
       <tr>
         <td></td>
         <td></td>
         <td></td>
         <td></td>
         <td></td>
       </tr>
       <?php
           while($sost4 = mysql_fetch_array($tmp4,MYSQL_ASSOC))
           {
            if(!empty($sost4['pic_krit']) && $sost4['pic_krit']!="-") $krit_image = "<img alt='".$sost4['kritichnost']."' title='".$sost4['kritichnost']."' src='".$sost4['pic_krit']."' />";
              else $krit_image = $sost4['kritichnost'];

           $date_day = $sost4['zhnan_day'];
           $date_month = $sost4['zhnan_month'];
           $date_year = $sost4['zhnan_year'];
           $date_time = $sost4['zhnan_hour'];
           $year = $TEXT['year'];
           if($sost4['zhnan_year'] == "" || $sost4['zhnan_year'] == "0") $data_r = "---";
            else $data_r = $date_day." ".$month[$date_month]." ".$date_year." ".$year." ".$date_time;

          $sost4['zh_soobschenie'] = str_replace(":smile:","<img alt='picture' src='../img/smile.png' align=middle border=0 />",$sost4['zh_soobschenie']);
          $sost4['zh_soobschenie'] = str_replace(":tongue:","<img alt='picture' src='../img/tongue.png' align=middle border=0 />",$sost4['zh_soobschenie']);
          $sost4['zh_soobschenie'] = str_replace(":wink:","<img alt='picture' src='../img/wink.png' align=middle border=0 />",$sost4['zh_soobschenie']);
          $sost4['zh_soobschenie'] = str_replace(":wassat:","<img alt='picture' src='../img/wassat.png' align=middle border=0 />",$sost4['zh_soobschenie']);
          $sost4['zh_soobschenie'] = str_replace(":sad:","<img alt='picture' src='../img/sad.png' align=middle border=0 />",$sost4['zh_soobschenie']);
          $sost4['zh_soobschenie'] = str_replace(":crying:","<img alt='picture' src='../img/crying.png' align=middle border=0 />",$sost4['zh_soobschenie']);
          $sost4['zh_soobschenie'] = str_replace(":angry:","<img alt='picture' src='../img/angry.png' align=middle border=0 />",$sost4['zh_soobschenie']);
          $sost4['zh_soobschenie'] = str_replace("  ","&nbsp;&nbsp;",$sost4['zh_soobschenie']);
          $sost4['zh_soobschenie'] = rep_back($sost4['zh_soobschenie']);
          $sost4['zh_tema'] = rep_back($sost4['zh_tema']);

          if($sost4['primechanie'] !== "") $primechanie = "<div class='tips_mesto_prim'><p class='tips'><img class='tipsimg' alt='картинка' src='../img/note.png' />".nl2br($sost4['primechanie'])."</p></div>";
          $move_up = "<a href=know_up_down.php?zhurn_id=".$sost4['zhurn_id']."&amp;zh_str_id=".$sost4['zh_str_id']."&amp;k=".$stop_r."&amp;position=".$sost4['position']."&amp;moving=down title='".$TEXT['global-up-down-tit']."'><img class='imgbcg' alt='up' src='../img/up.png' height='16' width='16' align='top' /></a>";
          $move_down = "<a href=know_up_down.php?zhurn_id=".$sost4['zhurn_id']."&amp;zh_str_id=".$sost4['zh_str_id']."&amp;k=".$stop_r."&amp;position=".$sost4['position']."&amp;moving=up title='".$TEXT['global-up-down-tit']."'><img alt='down' src='../img/down.png' height='16' width='16' align='top' />&nbsp;</a>";
          $print = "<a href=know_printform.php?zhurn_id=".$sost4['zhurn_id']."&amp;zh_str_id=".$sost4['zh_str_id']."&amp;k=".$stop_r." title='".$TEXT['kat-edit-tit']."'><img alt='".$TEXT['print-vers']."' src='../img/printer.png' height='16' width='16' align='top' />&nbsp;</a>";
          if($_GET['s'] == 0) $ssilka = "<a href=knowledge.php?zhurn_id=".$sost4['zhurn_id']."&amp;zh_str_id=".$sost4['zh_str_id']."&amp;k=".$stop_r."&amp;s=2 title='".$TEXT['know-cross-tit2']."'><img alt='".$TEXT['print-vers']."' src='../img/ftp16.png' height='16' width='16' align='top' />&nbsp;</a>";
           else $ssilka = "<a href=knowledge.php?zhurn_id=".$sost4['zhurn_id']."&amp;zh_str_id=".$sost4['zh_str_id']."&amp;k=".$stop_r."&amp;s=0 title='".$TEXT['know-cross-tit2']."'><img alt='".$TEXT['print-vers']."' src='../img/ftp16.png' height='16' width='16' align='top' />&nbsp;</a>";

          if($result2['administrator'] == 1 || $result2['login_id'] == $sost4['login_id']) $edit = "<a href=know_editform.php?zhurn_id=".$sost4['zhurn_id']."&amp;zh_str_id=".$sost4['zh_str_id']."&amp;k=".$stop_r." title='".$TEXT['kat-edit-tit']."'><img alt='".$TEXT['tbl-edit']."' src='../img/edit.png' height='16' width='16' align='top' />&nbsp;</a>";
           else $edit = "";

          if($result2['administrator'] == 1 || $result2['login_id'] == $sost4['login_id']) $delete = "<a href=know_deleteform.php?zhurn_id=".$sost4['zhurn_id']."&amp;zh_str_id=".$sost4['zh_str_id']."&amp;k=".$stop_r." title='".$TEXT['kat-del-tit']."'><img alt='".$TEXT['tbl-delete']."' src='../img/drop.png' height='16' width='16' align='top' /></a>";
           else $delete = "";

           if($sost4['cnt_popr'] > 0 && $result2['login_id'] == $sost4['login_id']) $cnt_popr = "<img alt='".$TEXT['know-zam2']."' src='../img/tema_it.png' height='16' width='16' align='top' /> ".$TEXT['know-zam2']." - ".$sost4['cnt_popr'];
            else $cnt_popr = "";

            if($_GET['zhurn_id'] == $sost4['zhurn_id'])
            {
             echo "<tr>
              <td></td>
              <td colspan=3 >";
              ?>
             <fieldset class='zayavka' >
              <legend align="left" ><?php echo $krit_image; ?>&nbsp;<?php echo $sost4['zh_tema']; ?></legend>
               <table align='center' border='0' width='100%' cellpadding='0' cellspacing='0'>
                <tr>
                  <td class='newsdesch'><?php echo $cnt_popr; ?></td><td class="data"><?php echo $ssilka.$print.$move_up.$move_down.$edit.$delete; ?></td>
                </tr>
                <tr>
                  <td colspan="2" class="support" width="100%"><?php echo nl2br($sost4['zh_soobschenie']); ?>...<br /><br />
                </tr>
                <tr>
                  <td align="left"><a href=know_view.php?zhurn_id=<?php echo $sost4['zhurn_id']; ?>&amp;zh_str_id=<?php echo $sost4['zh_str_id']; ?>&amp;otkr=2&amp;s=1 target='_blank' title="<?php echo $TEXT['know-full']; ?>"><span class="knowfull"><?php echo $TEXT['know-full']; ?></span></a></td>
                  <td align="right"><span class="autor"><?php echo $TEXT['zhurn-autor'].$sost4['fullname']; ?></span><br /><span class="data"><?php echo $data_r; ?></span></td>
                </tr>
              </table>
              <?php
              if($_GET['s'] == 2) echo "<p class='statssilka'><img class='tipsimg' alt='tips' src='../img/ftp16.png' />&lt;a href=know_view.php?zhurn_id=".$sost4['zhurn_id']."&amp;zh_str_id=".$sost4['zh_str_id']."&amp;otkr=2 target='_blank' title='".$TEXT['know-cross-tit']."'&gt;&lt;span class='news3'&gt;".$sost4['zh_tema']."&lt;/span&gt;&lt;/a&gt;</p>";
            ?>
             </fieldset>
       <?php
              echo "</td><td></td>
             </tr>";
            }
            else
             {
             echo "<tr>
              <td>&nbsp;</td>
              <td width= '16px' class='newsdesch'>".$krit_image."</td>
              <td class='newsdesch'>&nbsp;&nbsp;<a href='knowledge.php?zhurn_id=".$sost4['zhurn_id'].$tmp_zh_str_id.$koren_tmp.$krt_str.$lgn_str.$tmp_srch.$tmp_tppr."&amp;k=".$stop_r."' class='news3' title='".$TEXT['support14']."'>".$sost4['zh_tema']."&nbsp;<span class='data'>&#040;".$data_r."&#041;</span></a>".$cnt_popr."</td>
              <td width= '90px' class='newsdesch'>".$move_up.$move_down.$edit.$delete."</td>
              <td></td>
             </tr>";
             }
           }
            ?>
             <tr>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
             </tr>
            </table>
           <?php
         }
            ?>
   </td>
  </tr>
</table>
</form>
<form>
     <?php
       $query_count = mysql_query("SELECT COUNT(tbl_bd_zhnaniy.zhurn_id) FROM tbl_bd_zhnaniy WHERE tbl_bd_zhnaniy.zhurn_id != 0 ".$koren." ".$krit_id." ".$action." ");
       $coun_rows = mysql_result($query_count, 0);
       echo "<div id='formainitogo'><span class='news3'>".$TEXT['support39'].$TEXT['know-full3'].$coun_rows."</span></div>";
       if($coun_rows_z > 0) {
        echo "<div id='formainitogo2'><a class='news3' href=knowledge.php?lgn_id=".$result2['login_id']."&amp;login_ch=on><span class='news3'>".$TEXT['know-zam2']." &rArr; ".$coun_rows_z."</span>&nbsp;&nbsp;&nbsp;<img alt='".$TEXT['know-zam2']."' src='../img/tema_it.png' height='15' width='15' align='top' /></a></div>";
       }
               $pag = $coun_rows/20;
               if($pag<=1) $pag = ceil($pag);
                else
                {
                 ?>
                  <table align="center" border="0" cellpadding="0" cellspacing="0" width="60%" >
                   <tr align="center">
                    <td>
                <?php
                $pag=ceil($pag);
                $strn = $str-5;
                if($strn<1) $strn=1;
                $strk = $str+5;
                for($i=$strn; $i<=$pag; $i++)
                 {
                  if($i<=$strk)
                  {
                    if($i==$str)
                    {
                      $k = $i*20-20;
                      $kvis=$k+20;
                      $nvis=$k;
                      echo $pg = " <a class='zagolovok' href='knowledge.php?k=".$k.$tmp_zh_str_id.$koren_tmp.$krt_str.$lgn_str.$tmp_srch.$tmp_tppr."' title='".$TEXT['zhurn-details2'].$nvis.$TEXT['zhurn-details1'].$kvis."'>".$i."</a>";
                    }
                    else
                    {
                    $k = $i*20-20;
                    $kvis=$k+20;
                    $nvis=$k;
                    echo $pg = " <a href='knowledge.php?k=".$k.$tmp_zh_str_id.$koren_tmp.$krt_str.$lgn_str.$tmp_srch.$tmp_tppr."' title='".$TEXT['zhurn-details2'].$nvis.$TEXT['zhurn-details1'].$kvis."'>[".$i."]</a>";
                    }
                  }
                 }
                 ?>
                    <select name='k' onchange=window.location.href=this.options[this.selectedIndex].value;>
                    <?php
                    for($j=1; $j<=$pag; $j++)
                    {
                     $k = $j*20-20;
                     if($k == $_GET['k']) echo "<option selected value=knowledge.php?k=".$k.$tmp_zh_str_id.$koren_tmp.$krt_str.$lgn_str.$tmp_srch.$tmp_tppr.">".$j."</option>";
                       else echo "<option value=knowledge.php?k=".$k.$tmp_zh_str_id.$koren_tmp.$krt_str.$lgn_str.$tmp_srch.$tmp_tppr.">".$j."</option>";
                    }
                    ?>
                    </select>
                    </td>
                   </tr>
                  </table>
                 <?php
                }
               ?>
</form>
</body>
</html>