<?php
  ///////////////////////////////////////////////////
  //2010 (C)
  //Карпухин Павел
  ///////////////////////////////////////////////////

  require_once "utils/chlang_osn.php";

  $title = $TEXT['aut-title-info'];

  require_once "config.php";
  require_once "utils/functions.php";
  require_once "utils/top.php";

  if($result2['administrator'] == 0 && $result2['user'] == 0) {puterror2($result2['skin'],$TEXT['error-loginform5']); require_once "utils/bottom.php"; exit();}

  if(empty($_GET['book_id'])) {puterror2($result2['skin'],$TEXT['error-book5']); require_once "utils/bottom.php"; exit();}
  if(strlen($_GET['book_id'])>255) {puterror2($result2['skin'],$TEXT['error-book6']); require_once "utils/bottom.php"; exit();}
  $_GET['book_id'] = rep($_GET['book_id']);

$query_iskh = "SELECT 
tbl_book.*,
YEAR(tbl_book.data_postupleniya) AS data_postupleniya_year,
MONTH(tbl_book.data_postupleniya) AS data_postupleniya_month,
DAY(tbl_book.data_postupleniya) AS data_postupleniya_day,
YEAR(tbl_book.data_vidachi) AS data_vidachi_year,
MONTH(tbl_book.data_vidachi) AS data_vidachi_month,
DAY(tbl_book.data_vidachi) AS data_vidachi_day,
YEAR(tbl_book.data_sdachi) AS data_sdachi_year,
MONTH(tbl_book.data_sdachi) AS data_sdachi_month,
DAY(tbl_book.data_sdachi) AS data_sdachi_day,
YEAR(tbl_book.data_zakaza) AS data_zakaza_year,
MONTH(tbl_book.data_zakaza) AS data_zakaza_month,
DAY(tbl_book.data_zakaza) AS data_zakaza_day,
tbl_cicle.cicle,
tbl_biblioteka.name AS biblioteka,
tbl_biblioteka.bibl_id,
tbl_zhanr.zhanr_id,
tbl_zhanr.zhanr,
tbl_tip_izd.tip_izd_id,
tbl_tip_izd.tip_izd,
tbl_zal.zal_id,
tbl_zal.zal,
tbl_shkaf.shkaf_id,
tbl_shkaf.shkaf,
tbl_polka.polka_id,
tbl_polka.polka,
tbl_seriya.ser_id,
tbl_seriya.seriya,
lang1.bl_id AS bl_id1,
lang1.booklang AS booklang1,
lang1.picture AS picture1,
lang2.bl_id AS bl_id2,
lang2.booklang AS booklang2,
lang2.picture AS picture2
FROM tbl_book
JOIN tbl_cicle ON tbl_book.cicle_id=tbl_cicle.cicle_id
JOIN tbl_biblioteka ON tbl_book.bibl_id=tbl_biblioteka.bibl_id
JOIN tbl_zhanr ON tbl_book.zhanr_id=tbl_zhanr.zhanr_id
JOIN tbl_tip_izd ON tbl_book.tip_izd_id=tbl_tip_izd.tip_izd_id
JOIN tbl_zal ON tbl_book.zal_id=tbl_zal.zal_id
JOIN tbl_shkaf ON tbl_book.shkaf_id=tbl_shkaf.shkaf_id
JOIN tbl_polka ON tbl_book.polka_id=tbl_polka.polka_id
JOIN tbl_seriya ON tbl_book.ser_id=tbl_seriya.ser_id
JOIN tbl_booklang AS lang1 ON tbl_book.bl_id=lang1.bl_id
JOIN tbl_booklang AS lang2 ON tbl_book.bl2_id=lang2.bl_id
WHERE tbl_book.book_id = '".$_GET['book_id']."' ";
  $result_iskh = mysqli_query($dbcnx,$query_iskh);
  if(!$result_iskh) {puterror2($result2['skin'],$TEXT['error-tbl3']); require_once "utils/bottom.php"; exit();}
      $result_iskh2 = mysqli_fetch_array($result_iskh);

     $bnt = substr($result_iskh2['book_num'],0,1);
      if($bnt == '0')
      {
       $book_n = substr($result_iskh2['book_num'],1,1);
        if($book_n == '0')
        {
         $book_num = substr($result_iskh2['book_num'],2,3);
        } else {$book_num = substr($result_iskh2['book_num'],1,3);}
       } else {$book_num = $result_iskh2['book_num'];}

      $date_day = $result_iskh2['data_postupleniya_day'];
      $date_month = $result_iskh2['data_postupleniya_month'];
      $date_year = $result_iskh2['data_postupleniya_year'];
      if($date_year == "0000" || $date_year == "1970") {$data_r = "---";}
       else {$data_r = $date_day." ".$month[$date_month]." ".$date_year." ".$TEXT['year2'];}

      $date_day2 = $result_iskh2['data_izdaniya'];
      if($date_day2 == "0000" || $date_day2 == "1970") {$data_r2 = "---";}
       else {$data_r2 = $date_day2." ".$TEXT['year'];}

      $date_day3 = $result_iskh2['data_vidachi_day'];
      $date_month3 = $result_iskh2['data_vidachi_month'];
      $date_year3 = $result_iskh2['data_vidachi_year'];
      if($date_year3 == "0000" || $date_year3 == "1970") {$data_r3 = "---";}
       else {$data_r3 = $date_day3." ".$month[$date_month3]." ".$date_year3." ".$TEXT['year2'];}

      $date_day4 = $result_iskh2['data_sdachi_day'];
      $date_month4 = $result_iskh2['data_sdachi_month'];
      $date_year4 = $result_iskh2['data_sdachi_year'];
      if($date_year4 == "0000" || $date_year4 == "1970") {$data_r4 = "---";}
       else {$data_r4 = $date_day4." ".$month[$date_month4]." ".$date_year4." ".$TEXT['year2'];}

      $date_day5 = $result_iskh2['data_zakaza_day'];
      $date_month5 = $result_iskh2['data_zakaza_month'];
      $date_year5 = $result_iskh2['data_zakaza_year'];
      if($date_year5 == "0000" || $date_year5 == "1970") {$data_r5 = "---";}
       else {$data_r5 = $date_day5." ".$month[$date_month5]." ".$date_year5." ".$TEXT['year2'];}

      if($result_iskh2['book_rating'] > 0) {$book_rating = "&nbsp;&#40;".$TEXT['book-rating']."&#61; ".$result_iskh2['book_rating']."&#41;";}
        else {$book_rating = "";}

     $query_autor = "SELECT
     tbl_s_book_aut.*,
     tbl_autor.autor_id,
     tbl_autor.name,
     tbl_autor.familiya,
     tbl_autor.otchestvo
     FROM tbl_s_book_aut
     JOIN tbl_autor ON tbl_s_book_aut.autor_id=tbl_autor.autor_id
    WHERE book_id = '".$_GET['book_id']."' ";
    $result_autor = mysqli_query($dbcnx,$query_autor);
     if(!$result_autor) {puterror2($result2['skin'],$TEXT['error-tbl16']); require_once "utils/bottom.php"; exit();}
      while($result_autor2 = mysqli_fetch_array($result_autor))
       {
       $autor .="<a href='extsearch.php?autor_id=".$result_autor2['autor_id']."&amp;autor_ch=on' target=_blank title='".$TEXT['search-all-aut']."'>".rep_back($result_autor2['name'])." ".rep_back($result_autor2['otchestvo'])." ".rep_back($result_autor2['familiya'])."</a>, ";
       }
       $autors =substr($autor, 0,-2);

     $query_izd = "SELECT
     tbl_s_book_izd.*,
     tbl_izdatelstvo.*
     FROM tbl_s_book_izd
     JOIN tbl_izdatelstvo ON tbl_s_book_izd.izd_id=tbl_izdatelstvo.izd_id
     WHERE book_id = '".$_GET['book_id']."' ";
     $result_izd = mysqli_query($dbcnx,$query_izd);
      if(!$result_izd) {puterror2($result2['skin'],$TEXT['error-tbl17']); require_once "utils/bottom.php"; exit();}
      while($result_izd2 = mysqli_fetch_array($result_izd))
       {
       $izd .="<a href='extsearch.php?izd_id=".$result_izd2['izd_id']."&amp;izd_ch=on' target=_blank title='".$TEXT['search-all-izd']."'>".rep_back($result_izd2['izdatelstvo'])."</a>, ";
       }
       $izds =substr($izd, 0,-2);

      if(!empty($result_iskh2['site_name'])) {$address_aut = "<a href='".$result_iskh2['site_protocol']."://".$result_iskh2['site_name']."' target=_blank title=".$TEXT['aut-site'].">".$result_iskh2['site_protocol']."://".$result_iskh2['site_name']."</a>";}
       else {$address_aut = "";}

      $sm = preg_replace("/\.\.+./","",$result_iskh2['photo_book']);
      if(!empty($result_iskh2['photo_book']) && file_exists($sm) && $result2['administrator'] == '1') {$result_image = "<div id='resz-container'><a href='books/editform.php?book_id=".$_GET['book_id']."' title='".$TEXT['edit-tit']."'><img class='intro-container' alt='".$TEXT['global-alt']."' src='".$sm."' /></a></div>";}
       elseif(!empty($result_iskh2['photo_book']) && file_exists($sm) && $result2['administrator'] == '0') {$result_image = "<div id='resz-container'><img alt='".$TEXT['global-alt']."' src='".$sm."' /></div>";}
        elseif(empty($result_iskh2['photo_book']) && $result2['administrator'] == '1') {$result_image = "<a href='books/editform.php?book_id=".$_GET['book_id']."' title='".$TEXT['edit-tit']."'><img alt='".$TEXT['global-alt']."' src='skins/".$result2['skin']."/nophoto.png' /></a>";}
         elseif(!empty($result_iskh2['photo_book']) && $result2['administrator'] == '1') {$result_image = "<a href='books/editform.php?book_id=".$_GET['book_id']."' title='".$TEXT['edit-tit']."'><img alt='".$TEXT['global-alt']."' src='skins/".$result2['skin']."/nophoto.png' /></a>";}
          else {$result_image = "<img alt='".$TEXT['global-alt']."' src='skins/".$result2['skin']."/nophoto.png' />";}

      if($result2['administrator'] == 0)
      {
      if($result_iskh2['napominalka'] == '1') {$nap =  "<img alt='".$TEXT['book-show2']."' src='skins/".$result2['skin']."/nap_on.png' />";}
       else {$nap = "<img align='top' alt='".$TEXT['book-show2']."' src='skins/".$result2['skin']."/nap_off.png' />";}
      }
      else
      {
      if($result_iskh2['napominalka'] == '1') {$nap =  "<a href='nap_off.php?book_id=".$_GET['book_id']."' title='".$TEXT['book-nap-off']."'><img alt='".$TEXT['book-show2']."' src='skins/".$result2['skin']."/nap_on.png' /></a>";}
        else {$nap = "<a href='nap_on.php?book_id=".$_GET['book_id']."' title='".$TEXT['book-nap']."'><img align='top' alt='".$TEXT['book-show2']."' src='skins/".$result2['skin']."/nap_off.png' /></a>";}
      }

      #start 26.02.2019
      if(!empty($result_iskh2['paper_copy'] == "yes")) {$result_bl_pic_p = "&nbsp;<img align='top' alt='book' src='skins/".$result2['skin']."/book.png' />";}
        else {$result_bl_pic_p = "";}

      if(!empty($result_iskh2['remote_copy'] == "yes")) {$result_bl_pic_e = "&nbsp;<img align='top' alt='remote' src='skins/".$result2['skin']."/internet.png' />";}
        else {$result_bl_pic_e = "";}

      $usr_agnt = $_SERVER['HTTP_USER_AGENT'];
      $user_agent = device_check($usr_agnt);
      $bl = preg_replace("/\.\.+./","",$result_iskh2['picture1']);
      $bl2 = preg_replace("/\.\.+./","",$result_iskh2['picture2']);
      if($result_iskh2['bl_id1'] == $result_iskh2['bl_id2']) 
        {
        if(!empty($result_iskh2['picture1']) && file_exists($bl)) {
            if($user_agent == "book") {$result_bl = "<span class='inform'>".$TEXT['menu-btn35']." &raquo; ".$result_iskh2['booklang1']."</span>";}
              else {$result_bl = "<img alt='".$result_iskh2['booklang1']."' src='".$bl."' />";}
            $result_bl_tit = $TEXT['menu-btn35']." &raquo; ".$result_iskh2['booklang1'];
          }
            else {$result_bl = "<span class='inform'>".$TEXT['menu-btn35']." &raquo; ".$result_iskh2['booklang1']."</span>";
                  $result_bl_tit = $TEXT['menu-btn35']." &raquo; ".$result_iskh2['booklang1'];
                 }
        } 
        else 
              {
               if(!empty($result_iskh2['picture1']) && file_exists($bl) && !empty($result_iskh2['picture2']) && file_exists($bl2)) {
                 if($user_agent == "book") {$result_bl = "<span class='inform'>".$TEXT['menu-btn35']." &raquo; ".$result_iskh2['booklang1']."&comma;&nbsp;".$result_iskh2['booklang2']."</span>";}
                   else {$result_bl = "<img alt='".$result_iskh2['booklang1']."' src='".$bl."' />&nbsp;<img alt='".$result_iskh2['booklang2']."' src='".$bl2."' />";}
                 $result_bl_tit = $TEXT['menu-btn35']." &raquo; ".$result_iskh2['booklang1']."&comma;&nbsp;".$result_iskh2['booklang2'];
                 }
                  else {$result_bl = "<span class='inform'>".$TEXT['menu-btn35']." &raquo; ".$result_iskh2['booklang1']."&comma;&nbsp;".$result_iskh2['booklang2']."</span>";
                        $result_bl_tit = $TEXT['menu-btn35']." &raquo; ".$result_iskh2['booklang1']."&comma;&nbsp;".$result_iskh2['booklang2'];
                       }
               }

      ## end 26.02.19
               
       $result_iskh2['opisanie'] = rep_back($result_iskh2['opisanie']);
       $result_iskh2['oglavlenie'] = rep_back($result_iskh2['oglavlenie']);
       $result_iskh2['book_name'] = rep_back($result_iskh2['book_name']);
       $result_iskh2['isbn'] = rep_back($result_iskh2['isbn']);

// rating range //
  $query_otziv = "SELECT COUNT(otz_id) AS bad_books FROM tbl_otziv WHERE
           tbl_otziv.book_id = '".$_GET['book_id']."'
           AND tbl_otziv.use_prog = '1' 
           AND (tbl_otziv.usr_rating = '1' OR tbl_otziv.usr_rating = '2')";
   $result_otz = mysqli_query($dbcnx,$query_otziv);
    if(!$result_otz) {puterror2($result2['skin'],$TEXT['error-tbl22']); require_once "utils/bottom.php"; exit();}
     $result_otziv = mysqli_fetch_array($result_otz);
     $bad_books = $result_otziv['bad_books'];

  $query_otziv2 = "SELECT COUNT(otz_id) AS good_books FROM tbl_otziv WHERE
           tbl_otziv.book_id = '".$_GET['book_id']."'
           AND tbl_otziv.use_prog = '1' 
           AND (tbl_otziv.usr_rating = '4' OR tbl_otziv.usr_rating = '5')";
   $result_otz2 = mysqli_query($dbcnx,$query_otziv2);
    if(!$result_otz2) {puterror2($result2['skin'],$TEXT['error-tbl22']); require_once "utils/bottom.php"; exit();}
     $result_otziv2 = mysqli_fetch_array($result_otz2);
     $good_books = $result_otziv2['good_books'];

  $query_otziv3 = "SELECT COUNT(otz_id) AS v_good_books FROM tbl_otziv WHERE
           tbl_otziv.book_id = '".$_GET['book_id']."'
           AND tbl_otziv.use_prog = '1' 
           AND tbl_otziv.usr_rating = '5'";
   $result_otz3 = mysqli_query($dbcnx,$query_otziv3);
    if(!$result_otz3) {puterror2($result2['skin'],$TEXT['error-tbl22']); require_once "utils/bottom.php"; exit();}
     $result_otziv3 = mysqli_fetch_array($result_otz3);
     $v_good_books = $result_otziv3['v_good_books'];

  $query_otziv4 = "SELECT COUNT(otz_id) AS nv_good_books FROM tbl_otziv WHERE
           tbl_otziv.book_id = '".$_GET['book_id']."'
           AND tbl_otziv.use_prog = '1' 
           AND tbl_otziv.usr_rating = '4'";
   $result_otz4 = mysqli_query($dbcnx,$query_otziv4);
    if(!$result_otz4) {puterror2($result2['skin'],$TEXT['error-tbl22']); require_once "utils/bottom.php"; exit();}
     $result_otziv4 = mysqli_fetch_array($result_otz4);
     $nv_good_books = $result_otziv4['nv_good_books'];

  $query_otziv5 = "SELECT COUNT(otz_id) AS srd_books FROM tbl_otziv WHERE
           tbl_otziv.book_id = '".$_GET['book_id']."'
           AND tbl_otziv.use_prog = '1' 
           AND tbl_otziv.usr_rating = '3'";
   $result_otz5 = mysqli_query($dbcnx,$query_otziv5);
    if(!$result_otz5) {puterror2($result2['skin'],$TEXT['error-tbl22']); require_once "utils/bottom.php"; exit();}
     $result_otziv5 = mysqli_fetch_array($result_otz5);
     $srd_books = $result_otziv5['srd_books'];

//    if($result_iskh2['book_rating'] !== "0") {$book_rat = "<span class='opis'>&nbsp;&nbsp;&#124;&nbsp;&nbsp;&nbsp;".$TEXT['book-rating']."&#040;".$result_iskh2['book_rating']."&#041;&nbsp;</span>";}
    if($result_iskh2['book_rating'] !== "0") {$book_rat = $TEXT['book-rating']."&#040;".$result_iskh2['book_rating']."&#041;";}

    if($srd_books > $good_books || $srd_books > $bad_books) {$rating_pic = "&nbsp;&nbsp;<img alt='".$book_rat."' src='skins/".$result2['skin']."/boredom.gif' />";}
    else {
    if($good_books > $bad_books) {$rating_pic = "&nbsp;&nbsp;<img alt='".$book_rat."' src='skins/".$result2['skin']."/yes.gif' />";
     if($v_good_books > $nv_good_books) {$rating_pic = "&nbsp;&nbsp;<img alt='".$book_rat."' src='skins/".$result2['skin']."/good2.gif' />";}
      else {$rating_pic = "&nbsp;&nbsp;<img alt='".$book_rat."' src='skins/".$result2['skin']."/yes.gif' />";}
    }
    elseif($bad_books > $good_books) {$rating_pic = "&nbsp;&nbsp;<img alt='".$book_rat."' src='skins/".$result2['skin']."/bad.gif' />";}
     else {$rating_pic = "&nbsp;&nbsp;<img alt='".$book_rat."' src='skins/".$result2['skin']."/boredom.gif' />";}
    }
// end rating range //
?>
<table align="center" width="98%" border="0">
<?php
if($result_iskh2['vidano'] == '3') {echo "<tr><td class='zagolovok_zak'>&nbsp;".$result_iskh2['book_name']."</td><td width='15%' align='right' title='".$result_bl_tit."'>".$result_bl."</td></tr>";}
 elseif($result_iskh2['vidano'] == '2') {echo "<tr><td class='zagolovok_sp'>&nbsp;".$result_iskh2['book_name']."</td><td width='15%' align='right' title='".$result_bl_tit."'>".$result_bl."</td></tr>";}
else {echo "<tr><td class='zagolovok'>&nbsp;".$result_iskh2['book_name']."</td><td width='15%' align='right' title='".$result_bl_tit."'>".$result_bl."</td></tr>";}
?>
<tr><td>
</table>
<hr width="98%" />
<table align="center" width="98%" border="0">
<tr>
<td width="4%" valign="top">
   <table align="left" border="0" width="100%">
    <tr><td class="informcntr"><?php echo $result_image; ?></td></tr>
    <?php
    $fl = substr($result_iskh2['e_book'],3,255);
    if(!empty($result_iskh2['cicle']) && $result_iskh2['cicle'] !== "---") {$cicle_books_dwnl = "&nbsp;<a class='opis' href='get_book.php?book_id=".$result_iskh2['book_id']."&amp;cicl_show=OK' target=_blank title='".$TEXT['search-all-ser2']."'>&#8261;&#8803;&#8262;</a>";}
        else {$cicle_books_dwnl = "";}
     if(!empty($result_iskh2['e_book']) && file_exists($fl)) {
         $e_book = "<tr><td class='informcntr'><a class='informcntr' href='get_book.php?book_id=".$result_iskh2['book_id']."' target=_blank title='".$result_iskh2['book_name']."'>".$TEXT['book-ebook']."</a>".$cicle_books_dwnl."</td></tr>";
         $result_bl_pic_l = "&nbsp;<img align='top' alt='E-book' src='skins/".$result2['skin']."/clip.png' />";
     }
      else {
          $e_book = "";
          $result_bl_pic_l = "";
      }
      echo $e_book;
    
     $fla = substr($result_iskh2['a_book'],3,255);
     if(!empty($result_iskh2['cicle']) && $result_iskh2['cicle'] !== "---") {$cicle_abooks_dwnl = "&nbsp;<a class='opis' href='get_abook.php?book_id=".$result_iskh2['book_id']."&amp;cicl_show=OK' target=_blank title='".$TEXT['search-all-ser2']."'>&#8261;&#8803;&#8262;</a>";}
        else {$cicle_abooks_dwnl = "";}
     if(!empty($result_iskh2['a_book']) && file_exists($fla)) {
         $a_book = "<tr><td class='informcntr'><a class='informcntr' href='get_abook.php?book_id=".$result_iskh2['book_id']."' target=_blank title='".$result_iskh2['book_name']."'>".$TEXT['book-audio']."</a>".$cicle_abooks_dwnl."</td></tr>";
         $result_bl_pic_la = "&nbsp;<img align='top' alt='Audio' src='skins/".$result2['skin']."/audio.png' />";
     }
      else {
          $a_book = "";
          $result_bl_pic_la = "";
      }
      echo $a_book;
    
     $flcd = substr($result_iskh2['cd_book'],3,255);
     if(!empty($result_iskh2['cd_book']) && file_exists($flcd)) {
         $cd_book = "<tr><td class='informcntr'><a class='informcntr' href='get_cdbook.php?book_id=".$result_iskh2['book_id']."' target=_blank title='".$result_iskh2['book_name']."'>".$TEXT['book-cdrom']."</a></td></tr>";
         $result_bl_pic_lcd = "&nbsp;<img align='top' alt='CD-ROM' src='skins/".$result2['skin']."/cdrom.png' />";
     }
      else {
          $cd_book = "";
          $result_bl_pic_lcd = "";
      }
      echo $cd_book;
    
     if($result_iskh2['prev_books'] !== "0") {$prev_books = "<tr><td class='informcntr'><div id='formaupdate2'>&#9753;&nbsp;<a class='informcntr' href='extsearch.php?cicle_id=".$result_iskh2['prev_books']."&amp;cicle_ch=on' target=_blank title='".$TEXT['book-prereq2']."'>".$TEXT['book-prereq']."</a>&nbsp;&#10087;</div></td></tr>";}
      else {$prev_books = "";}
      echo $prev_books;
    ?>
    </table>
</td>
<td width="48%" valign="top">
<fieldset>
    <legend align="left" title="<?php echo $TEXT['book-fldset1-tit']; ?>"><?php echo $TEXT['book-fldset1']; ?></legend>
<table align="left" width="100%" border="0">
<tr><td class="inform" width="30%"><?php echo $TEXT['menu-btn23']; ?>:&nbsp;</td><td class="input"><?php echo $autors; ?></td></tr>
<tr><td class="inform"><?php echo $TEXT['menu-btn22']; ?>:&nbsp;</td><td class="input"><?php echo $izds; ?></td></tr>
<?php
if(!empty($result_iskh2['isbn'])) {echo "<tr><td class='inform'>".$TEXT['book-isbn'].":&nbsp;</td><td class='input'>".$result_iskh2['isbn']."</td></tr>";}
?>
<tr><td class="inform"><?php echo $TEXT['book-zhanr']; ?>:&nbsp;</td><td class="input"><a href='extsearch.php?zhanr_id=<?php echo $result_iskh2['zhanr_id']; ?>&amp;zhanr_ch=on' target=_blank title='<?php echo $TEXT['search-all-zhanr']; ?>'><?php echo rep_back($result_iskh2['zhanr']); ?></a></td></tr>
<?php
if(!empty($result_iskh2['cicle']) && $result_iskh2['cicle'] !== "---") {echo "<tr><td class='inform'>".$TEXT['book-cicle'].":&nbsp;</td><td class='input'><a href='extsearch.php?cicle_id=".$result_iskh2['cicle_id']."&amp;cicle_ch=on' target=_blank title='".$TEXT['search-all-cicl']."'>".rep_back($result_iskh2['cicle'])."</a></td></tr>";}
if(!empty($result_iskh2['book_num']) && $result_iskh2['book_num'] !== "0") {echo "<tr><td class='inform'>".$TEXT['book-num'].":&nbsp;</td><td class='input'>".$book_num."</td></tr>";}
if(!empty($result_iskh2['opisanie'])) {echo "<tr><td class='inform'>".$TEXT['book-opis'].":&nbsp;</td><td class='opis'>".nl2br($result_iskh2['opisanie'])."</td></tr>";}
if(!empty($result_iskh2['oglavlenie'])) {echo "<tr><td class='inform'>".$TEXT['book-oglavl'].":&nbsp;</td><td class='ogl'><hr class='hr50left' />".nl2br( $result_iskh2['oglavlenie'])."</td></tr>";}

#$query_otz = mysqli_query($dbcnx,"SELECT COUNT(otz_id) AS c_otz_id FROM tbl_otziv WHERE book_id = '".$_GET['book_id']."' AND otziv!='' AND use_prog = '1'");
$query_otz = mysqli_query($dbcnx,"SELECT COUNT(otz_id) AS c_otz_id FROM tbl_otziv WHERE book_id = '".$_GET['book_id']."' AND use_prog = '1'");
$coun_otz = mysqli_fetch_array($query_otz);
echo "<tr><td></td><td><hr class='hr50left' /></td></tr>";
if($coun_otz['c_otz_id'] > 0) {echo "<tr><td class='inform'></td><td class='input'><a href='otziv.php?book_id=".$_GET['book_id']."' title='".$TEXT['aut-viewtit'].$book_rating."'>".$TEXT['book-otziv2']."&nbsp;&#040;".$coun_otz['c_otz_id']."&#041;</a>".$rating_pic."</td></tr>";}
 else {echo "<tr><td class='inform'></td><td class='input'><a href='otziv.php?book_id=".$_GET['book_id']."' >".$TEXT['book-otziv2']."</a></td></tr>";}
?>
</table>
</fieldset>
</td>
<td width="48%" valign="top">
<fieldset>
    <legend align="left" title="<?php echo $TEXT['book-fldset2-tit']; ?>"><?php echo $TEXT['book-fldset2']; ?></legend>
<table align="right" width="100%" border="0">
<tr><td class="inform"><?php echo $TEXT['book-data']; ?>:&nbsp;</td><td class="input"><?php echo $data_r2; ?></td></tr>
<tr><td class="inform"><?php echo $TEXT['book-data2']; ?>:&nbsp;</td><td class="input"><?php echo $data_r; ?></td></tr>
<?php if(!empty($result_iskh2['seriya']) && $result_iskh2['seriya'] !== "---") {echo "<tr><td class='inform'>".$TEXT['ser-title'].":&nbsp;</td><td class='input'><a href='extsearch.php?ser_id=".$result_iskh2['ser_id']."&amp;ser_ch=on' target=_blank title='".$TEXT['search-all-ser']."'>".rep_back($result_iskh2['seriya'])."</a></td></tr>";} ?>
<tr><td class="inform"><?php echo $TEXT['book-tip-izd']; ?>:&nbsp;</td><td class="input"><a href='extsearch.php?tip_izd_id=<?php echo $result_iskh2['tip_izd_id']; ?>&amp;tip_izd_ch=on' target=_blank title='<?php echo $TEXT['search-all-tip-izd']; ?>'><?php echo rep_back($result_iskh2['tip_izd']); ?></a></td></tr>
<tr><td class="inform"><?php echo $TEXT['book-bibl']; ?>:&nbsp;</td><td class="input"><a href='extsearch.php?bibl_id=<?php echo $result_iskh2['bibl_id']; ?>&amp;bibl_ch=on' target=_blank title='<?php echo $TEXT['search-all-book']; ?>'><?php echo rep_back($result_iskh2['biblioteka']); ?></a></td></tr>
<tr><td class="inform"><?php echo $TEXT['book-zal']; ?>:&nbsp;</td><td class="input"><a href='extsearch.php?zal_id=<?php echo $result_iskh2['zal_id']; ?>&amp;zal_ch=on&amp;bibl_id=<?php echo $result_iskh2['bibl_id']; ?>&amp;bibl_ch=on' target=_blank title='<?php echo $TEXT['search-all-zal']; ?>'><?php echo rep_back($result_iskh2['zal']); ?></a></td></tr>
<tr><td class="inform"><?php echo $TEXT['book-shkaf']; ?>:&nbsp;</td><td class="input"><a href='extsearch.php?shkaf_id=<?php echo $result_iskh2['shkaf_id']; ?>&amp;shkaf_ch=on&amp;zal_id=<?php echo $result_iskh2['zal_id']; ?>&amp;zal_ch=on&amp;bibl_id=<?php echo $result_iskh2['bibl_id']; ?>&amp;bibl_ch=on' target=_blank title='<?php echo $TEXT['search-all-shkaf']; ?>'><?php echo $result_iskh2['shkaf']; ?></a></td></tr>
<tr><td class="inform"><?php echo $TEXT['book-polka']; ?>:&nbsp;</td><td class="input"><a href='extsearch.php?polka_id=<?php echo $result_iskh2['polka_id']; ?>&amp;polka_ch=on&amp;shkaf_id=<?php echo $result_iskh2['shkaf_id']; ?>&amp;shkaf_ch=on&amp;zal_id=<?php echo $result_iskh2['zal_id']; ?>&amp;zal_ch=on&amp;bibl_id=<?php echo $result_iskh2['bibl_id']; ?>&amp;bibl_ch=on' target=_blank title='<?php echo $TEXT['search-all-polka']; ?>'><?php echo $result_iskh2['polka']; ?></a></td></tr>
<tr><td class="inform"><?php echo $TEXT['book-place']; ?>:&nbsp;</td><td><?php echo $result_bl_pic_p.$result_bl_pic_la.$result_bl_pic_lcd.$result_bl_pic_l.$result_bl_pic_e; ?></td></tr>
</table>
</fieldset>
<fieldset>
    <legend align="left" title="<?php echo $TEXT['book-fldset3-tit']; ?>"><?php echo $TEXT['book-fldset3']; ?></legend>
<table align="right" width="100%" border="0">
<?php
if($result_iskh2['vidano'] == '2' || $result_iskh2['vidano'] == '3')
{
$query_nal1 = "SELECT
tbl_book.user_id,
tbl_logins.login_id,
tbl_logins.familiya,
tbl_logins.name,
tbl_logins.otchestvo
FROM tbl_book
JOIN tbl_logins ON tbl_book.user_id=tbl_logins.login_id
WHERE book_id = '".$_GET['book_id']."' ";
  $result_nal = mysqli_query($dbcnx,$query_nal1);
  if(!$result_nal) {puterror2($result2['skin'],$TEXT['error-tbl3']); require_once "utils/bottom.php"; exit();}
    $result_nal1 = mysqli_fetch_array($result_nal);
      $user_name_nal1 = $result_nal1['familiya']." ".$result_nal1['name'];

   if($result_iskh2['vidano'] == '2')
   {

   if($result2['administrator'] == 0) {$nal=  "<img align='top' alt='".$TEXT['book-show3']."' src='skins/".$result2['skin']."/noobr.png' />";}
    else {$nal=  "<a href='nal_back.php?book_id=".$_GET['book_id']."' title='".$TEXT['book-nal']."'><img align='top' alt='".$TEXT['book-show3']."' src='skins/".$result2['skin']."/back-book.png' /></a>&nbsp;<a href='./books/index.php?book_name=".$result_iskh2['book_name']."' title='".$TEXT['delete-tit']."'><img align='top' alt='".$TEXT['delete-new']."' src='skins/".$result2['skin']."/noobr.png' /></a>";}

   echo "<tr><td class='inform'>".$TEXT['book-show3'].":&nbsp;</td><td class='input'>".$nal."</td></tr>";
   echo "<tr><td class='inform'>".$TEXT['book-who-viv'].":&nbsp;</td><td class='input'>".$user_name_nal1."</td></tr>";
   echo "<tr><td class='inform'>".$TEXT['book-data6'].":&nbsp;</td><td class='input'>".$data_r3."</td></tr>";
   echo "<tr><td class='inform'>".$TEXT['book-prichina'].":&nbsp;</td><td class='input'>".$result_iskh2['prichina']."</td></tr>";
   }
   else
    {
     if($result2['administrator'] == 0) {$nal="<img align='top' alt='".$TEXT['book-show5']."' src='skins/".$result2['skin']."/soon.png' />";}
      else {$nal="<a href='nal_back.php?book_id=".$_GET['book_id']."&amp;z=1' title='".$TEXT['book-zak']."'><img align='top' alt='".$TEXT['book-show5']."' src='skins/".$result2['skin']."/zakupka.png' /></a>&nbsp;<a href='./books/index.php?book_name=".$result_iskh2['book_name']."' title='".$TEXT['delete-tit']."'><img align='top' alt='".$TEXT['delete-new']."' src='skins/".$result2['skin']."/noobr.png' /></a>";}

    echo "<tr><td class='inform'>".$TEXT['book-show6'].":&nbsp;</td><td class='input'>".$nal."</td></tr>";
    echo "<tr><td class='inform'>".$TEXT['book-who-zak'].":&nbsp;</td><td class='input'>".$user_name_nal1."</td></tr>";
    echo "<tr><td class='inform'>".$TEXT['book-data5'].":&nbsp;</td><td class='input'>".$data_r3."</td></tr>";
    }
}
else
{

if($result_iskh2['vidano'] == '0')
{
$nal=  "<img align='top' alt='".$TEXT['book-show2']."' src='skins/".$result2['skin']."/online.png' />";
$nal2=  "<a href='nal_off_frm.php?book_id=".$_GET['book_id']."&amp;user_id=".$result_iskh2['user_id_zak']."' title='".$TEXT['book-nal-off']."'><img align='top' alt='".$TEXT['book-show2']."' src='skins/".$result2['skin']."/online.png' /></a>";
  if($result2['administrator'] == 0) {echo "<tr><td class='inform'>".$TEXT['book-fldset3'].":&nbsp;</td><td class='input'>".$nal."</td></tr>";}
   else {echo "<tr><td class='inform'>".$TEXT['book-fldset3'].":&nbsp;</td><td class='input'>".$nal2."</td></tr>";}
}
   else
{
$query_nal1 = "SELECT
tbl_book.user_id,
tbl_logins.login_id,
tbl_logins.familiya,
tbl_logins.name,
tbl_logins.otchestvo
FROM tbl_book
JOIN tbl_logins ON tbl_book.user_id=tbl_logins.login_id
WHERE book_id = '".$_GET['book_id']."' ";
  $result_nal = mysqli_query($dbcnx,$query_nal1);
  if(!$result_nal) {puterror2($result2['skin'],$TEXT['error-tbl3']); require_once "utils/bottom.php"; exit();}
    $result_nal1 = mysqli_fetch_array($result_nal);
      $user_name_nal1 = $result_nal1['familiya']." ".$result_nal1['name']." ".$result_nal1['otchestvo'];

$nal= "<img align='top' alt='".$TEXT['book-show2']."' src='skins/".$result2['skin']."/rezervon.png' />";
$nal2= "<a href='nal_on_frm.php?book_id=".$_GET['book_id']."' title='".$TEXT['book-nal']."'><img align='top' alt='".$TEXT['book-show2']."' src='skins/".$result2['skin']."/rezervon.png' /></a>";
 if($result2['administrator'] == 0)
  {
  echo "<tr><td class='inform'>".$TEXT['book-fldset3'].":&nbsp;</td><td class='input'>".$nal."</td></tr>";
  echo "<tr><td class='inform'>".$TEXT['book-data3'].":&nbsp;</td><td class='input'>".$data_r3."</td></tr>";
  echo "<tr><td class='inform'>".$TEXT['book-data4'].":&nbsp;</td><td class='input'>".$data_r4."</td></tr>";
  echo "<tr><td class='inform'>".$TEXT['book-who-vid'].":&nbsp;</td><td class='input'>".$user_name_nal1."</td></tr>";
  echo "<tr><td class='inform'>".$TEXT['book-napom'].":&nbsp;</td><td class='input'>".$nap."</td></tr>";
  }
   else
   {
   echo "<tr><td class='inform'>".$TEXT['book-fldset3'].":&nbsp;</td><td class='input'>".$nal2."</td></tr>";
   echo "<tr><td class='inform'>".$TEXT['book-data3'].":&nbsp;</td><td class='input'>".$data_r3."</td></tr>";
   echo "<tr><td class='inform'>".$TEXT['book-data4'].":&nbsp;</td><td class='input'>".$data_r4."</td></tr>";
   echo "<tr><td class='inform'>".$TEXT['book-who-vid'].":&nbsp;</td><td class='input'>".$user_name_nal1."</td></tr>";
   echo "<tr><td class='inform'>".$TEXT['book-napom'].":&nbsp;</td><td class='input'>".$nap."</td></tr>";
   }
}

if($result_iskh2['zakazano'] == '1')
{
$query_rez1 = "SELECT
tbl_book.user_id_zak,
tbl_logins.login_id,
tbl_logins.familiya,
tbl_logins.name,
tbl_logins.otchestvo
FROM tbl_book
JOIN tbl_logins ON tbl_book.user_id_zak=tbl_logins.login_id
WHERE book_id = '".$_GET['book_id']."' ";
  $result_rez = mysqli_query($dbcnx,$query_rez1);
  if(!$result_rez) {puterror2($result2['skin'],$TEXT['error-tbl3']); require_once "utils/bottom.php"; exit();}
    $result_rez1 = mysqli_fetch_array($result_rez);
      $user_name_rez1 = rep_back($result_rez1['familiya'])." ".rep_back($result_rez1['name'])." ".rep_back($result_rez1['otchestvo']);

if($result_rez1['user_id_zak'] == $result2['login_id']) {$rez=  "<a href='rez_off.php?book_id=".$_GET['book_id']."' title='".$TEXT['book-rez-off']."'><img align='top' alt='".$TEXT['book-show2']."' src='skins/".$result2['skin']."/rezervon.png' /></a>";}
 else {$rez=  "<img align='top' alt='".$TEXT['book-show2']."' src='skins/".$result2['skin']."/offline.png' />";}

echo "<tr><td class='inform' width='47%'>".$TEXT['book-rez'].":&nbsp;</td><td class='input'>".$rez."</td></tr>";
echo "<tr><td class='inform'>".$TEXT['book-who-rez'].":&nbsp;</td><td class='input'>".$user_name_rez1."</td></tr>";
echo "<tr><td class='inform'>".$TEXT['book-data5'].":&nbsp;</td><td class='input'>".$data_r5."</td></tr>";
}
 else
{
if($result_iskh2['vidano'] == '0') {$rez= "<a href='rez_on_frm.php?book_id=".$_GET['book_id']."' title='".$TEXT['book-rez-on']."'><img align='top' alt='".$TEXT['book-show2']."' src='skins/".$result2['skin']."/online.png' /></a>";}
  else {$rez=  "<img align='top' alt='".$TEXT['book-show2']."' src='skins/".$result2['skin']."/offline.png' />";}

echo "<tr><td class='inform' width='47%'>".$TEXT['book-rez'].":&nbsp;</td><td class='input'>".$rez."</td></tr>";
}
}
?>
</table>
</fieldset>
</td></tr>
</table>
<?php
  require_once "utils/bottom.php";
?>