авторизованным посетителям'; if ($error) { require_once ("../incfiles/head.php"); echo '

' . $error . '

'; require_once ("../incfiles/end.php"); exit; } // Заголовки библиотеки if (empty ($id)) { $textl = 'Библиотека'; }else{ $req = mysql_query("SELECT * FROM `lib` WHERE `id`= '" . $id . "' LIMIT 1;"); $zag = mysql_fetch_array($req); $hdr = $zag['type'] == 'bk' ? $zag['name'] : $zag['text']; $hdr = htmlentities(mb_substr($hdr, 0, 100), ENT_QUOTES, 'UTF-8'); $textl = mb_strlen($res['text']) > 100 ? $hdr . '...' : $hdr; } require_once ("../incfiles/head.php"); $do = array('my', 'java', 'symb', 'search', 'new', 'moder', 'addkomm', 'komm', 'del', 'edit', 'load', 'write', 'mkcat', 'topread', 'move', 'sdvig'); if (in_array($act, $do) ) { require_once ($act . '.php'); }else{ if (!$set['mod_lib']) echo '

Библиотека закрыта!

'; if (!$id) { echo '
Библиотека
'; if ($rights == 5 || $rights >= 6) { // Считаем число статей, ожидающих модерацию $req = mysql_query("SELECT COUNT(*) FROM `lib` WHERE `type` = 'bk' AND `moder` = '0'"); $res = mysql_result($req, 0); if ($res > 0) echo '
Модерации ожидают [' . $res . ' статей]
'; } // Сколько суток считать статьи новыми? $old = $realtime - (3 * 24 * 3600); // Считаем новое в библиотеке $req = mysql_query("SELECT COUNT(*) FROM `lib` WHERE `time` > '" . $old . "' AND `type`='bk' AND `moder`='1'"); $res = mysql_result($req, 0); echo '

'; if ($res > 0) echo 'Новые статьи [' . $res . ']
'; echo 'Самые читаемые

'; $id = 0; $tip = "cat"; }else{ $tip = $zag['type']; if ($tip == "cat") { echo '
' . htmlentities($zag['text'], ENT_QUOTES, 'UTF-8') . '
'; } } switch ($tip) { case 'cat' : $req = mysql_query("SELECT COUNT(*) FROM `lib` WHERE `type` = 'cat' AND `refid` = '" . $id . "'"); $totalcat = mysql_result($req, 0); $bkz = mysql_query("SELECT COUNT(*) FROM `lib` WHERE `type` = 'bk' AND `refid` = '" . $id . "' AND `moder`='1'"); $totalbk = mysql_result($bkz, 0); if ($totalcat > 0) { $total = $totalcat; $req = mysql_query("SELECT `id`, `text` FROM `lib` WHERE `type` = 'cat' AND `refid` = '" . $id . "' ORDER BY `sort` ASC LIMIT " . $start . "," . $kmess); if ($rights == 5 || $rights >= 6) echo '
'; while ($cat1 = mysql_fetch_array($req)) { $cat2 = mysql_query("select `id` from `lib` where type = 'cat' and refid = '" . $cat1['id'] . "'"); $totalcat2 = mysql_num_rows($cat2); $bk2 = mysql_query("select `id` from `lib` where type = 'bk' and refid = '" . $cat1['id'] . "' and moder='1'"); $totalbk2 = mysql_num_rows($bk2); if ($totalcat2 != 0) { $kol = "$totalcat2 кат."; } elseif ($totalbk2 != 0) { $kol = "$totalbk2 ст."; }else{ $kol = "0"; } echo is_integer($i / 2) ? '
' : '
'; echo ($rights == 5 || $rights >= 6 ? ' ' : '') . '' . $cat1['text'] . ' [' . $kol . ']' . ($rights == 5 || $rights >= 6 ? '' : '') . '
'; ++$i; } echo '
Всего категорий: ' . $totalcat . '
'; if ($rights == 5 || $rights >= 6) echo '
'; } elseif ($totalbk > 0) { $total = $totalbk; $bk = mysql_query("select * from `lib` where type = 'bk' and refid = '" . $id . "' and moder='1' order by `time` desc LIMIT " . $start . "," . $kmess); if ($rights == 5 || $rights >= 6) echo '
'; while ($bk1 = mysql_fetch_array($bk)) { echo is_integer($i / 2) ? '
' : '
'; $vr = $bk1['time'] + $set_user['sdvig'] + $set['timeshift'] * 3600; $vr = date("d.m.y / H:i", $vr); echo $div . ($rights == 5 || $rights >= 6 ? ' ' : '') . '' . htmlentities($bk1['name'], ENT_QUOTES, 'UTF-8') . '
'; echo htmlentities($bk1['announce'], ENT_QUOTES, 'UTF-8') . '
'; $req = mysql_query("SELECT * FROM `users` WHERE `name`= '".$bk1['avtor']."'"); $user = mysql_fetch_assoc($req); echo 'Добавил: ' . $bk1['avtor'] . ' [анк] (' . $vr . ')
'; echo 'Прочтений: ' . $bk1['count'] . '
'; echo 'Рейтинг: ' . $bk1['rate'] . '
'; $zzz = mysql_query("select `komm` from `lib` where type = 'cat' and id = '" . $id . "'"); $zzz = mysql_fetch_array($zzz); if ($zzz['komm'] != 'no') { $komm_count = mysql_result(mysql_query("SELECT COUNT(*) FROM `lib` WHERE type = 'komm' AND refid = '" . $bk1['id'] . "'"), 0); echo 'Комментарии: ' . $komm_count; } echo '
'; ++$i; } echo '
Всего статей: ' . $totalbk . '
'; if ($rights == 5 || $rights >= 6) echo '
'; }else{ $total = 0; } // Навигация по страницам if ($total > $kmess) { echo '
' . functions::display_pagination('index.php?id=' . $id . '&', $start, $total, $kmess) . '
'; echo '
'; } if (($rights == 5 || $rights >= 6) && $id != 0) { $ct = mysql_query("select `id` from `lib` where type='cat' and refid='" . $id . "'"); $ct1 = mysql_num_rows($ct); if ($ct1 == 0) { echo ""; } echo ""; } if (($rights == 5 || $rights >= 6) && ($zag['ip'] == 1 || $id == 0)) { echo ""; } if ($zag['ip'] == 0 && $id != 0) { if (($rights == 5 || $rights >= 6) || ($zag['soft'] == 1 && !empty ($_SESSION['uid']))) { echo ""; } if ($rights == 5 || $rights >= 6) { echo ""; } } if ($id != 0) { $dnam = mysql_query("select `id`, `refid`, `text` from `lib` where type = 'cat' and id = '" . $id . "'"); $dnam1 = mysql_fetch_array($dnam); $dnam2 = mysql_query("select `id`, `refid`, `text` from `lib` where type = 'cat' and id = '" . $dnam1['refid'] . "'"); $dnam3 = mysql_fetch_array($dnam2); $catname = "$dnam3[text]"; $dirid = "$dnam1[id]"; $nadir = $dnam1['refid']; while ($nadir != "0") { echo ""; $dnamm = mysql_query("select `id`, `refid`, `text` from `lib` where type = 'cat' and id = '" . $nadir . "'"); $dnamm1 = mysql_fetch_array($dnamm); $dnamm2 = mysql_query("select `id`, `refid`, `text` from `lib` where type = 'cat' and id = '" . $dnamm1['refid'] . "'"); $dnamm3 = mysql_fetch_array($dnamm2); $nadir = $dnamm1['refid']; $catname = $dnamm3['text']; } }else{ echo "
Настройки
"; echo "
"; echo "Поиск статьи:

Метод поиска:

"; echo "
"; } break; case 'bk' : // Читаем статью if (!empty ($_SESSION['symb'])) { $simvol = $_SESSION['symb']; }else{ $simvol = 2000; // Число символов на страницу по умолчанию } // Счетчик прочтений if ($_SESSION['lib'] != $id) { $_SESSION['lib'] = $id; $libcount = intval($zag['count']) + 1; mysql_query("UPDATE `lib` SET `count` = '" . $libcount . "' WHERE `id` = '" . $id . "'"); } // Заголовок статьи echo '
' . htmlentities($zag['name'], ENT_QUOTES, 'UTF-8') . '
'; // Автор книги $vr5 = $zag['time'] + $set_user['sdvig'] + $set['timeshift'] * 3600; $vr6 = date("d.m.y / H:i", $vr5); $aft = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `name` = '" . $zag['avtor'] . "';")); $aft = (int) $aft['id']; echo ''; }else{ echo '' . ($zag['rate'] != 0 ? ($zag['rate'] > 0 ? '' : '') : '') . $zag['rate'] . '
'; } // Постраничная навигация читаемой статьи // Используется модифицированный код от hintoz $tx = $zag['text']; $strrpos = mb_strrpos($tx, " "); $pages = 1; // Вычисляем номер страницы if (isset ($_GET['page'])) { $page = abs(intval($_GET['page'])); if ($page == 0) $page = 1; $start = $page - 1; }else{ $page = $start + 1; } $t_si = 0; if ($strrpos) { while ($t_si < $strrpos) { $string = mb_substr($tx, $t_si, $simvol); $t_ki = mb_strrpos($string, " "); $m_sim = $t_ki; $strings[$pages] = $string; $t_si = $t_ki + $t_si; if ($page == $pages) { $page_text = $strings[$pages]; } if ($strings[$pages] == "") { $t_si = $strrpos++; }else{ $pages++; } } if ($page >= $pages) { $page = $pages - 1; $page_text = $strings[$page]; } $pages = $pages - 1; if ($page != $pages) { $prb = mb_strrpos($page_text, " "); $page_text = mb_substr($page_text, 0, $prb); } }else{ $page_text = $tx; } // Текст статьи $page_text = htmlentities($page_text, ENT_QUOTES, 'UTF-8'); echo '

' . bbcode::tags(functions::smileys(nl2br($page_text), 0)) . '

'; if ($pages > 1) { echo '
' . functions::display_pagination('index.php?id=' . $id . '&', $start, $pages, 1) . '
'; echo '
'; } echo ''; // Ссылка на комментарии $mmm = mysql_query("select `komm` from `lib` where type = 'cat' and id = '" . $zag['refid'] . "'"); $mmm = mysql_fetch_array($mmm); if (($set['mod_lib_comm'] || $rights >= 7) && $mmm['komm'] != 'no') { echo '
Комментарии
'; $cnt = mysql_result(mysql_query("SELECT COUNT(*) FROM `lib` WHERE type = 'komm' AND refid = '" . $id . "'"), 0); if ($cnt == 0) { echo '
Нет комментариев, будь первым!
'; }else{ $km = mysql_query("select * from `lib` where type = 'komm' and refid = '" . $id . "' LIMIT 10;"); while ($mass = mysql_fetch_assoc($km)) { echo ($i % 2) ? '
' : '
'; $uz = mysql_query("select * from `users` where name='" . functions::check($mass['avtor']) . "';"); $mass1 = mysql_fetch_array($uz); if ((!empty($_SESSION['uid'])) && ($_SESSION['uid'] != $mass1['id'])) { echo "$mass[avtor]"; }else{ echo $mass['avtor']; } $vr = $mass['time'] + $set_user['sdvig'] + $set['timeshift'] * 3600; $vr1 = date("d.m.Y / H:i", $vr); switch ($mass1['rights']) { case 7 : echo ' [Adm] '; break; case 6 : echo ' [Smd] '; break; case 5 : echo ' [Mod] '; break; case 1 : echo ' [Kil] '; break; } $ontime = $mass1['lastdate']; $ontime2 = $ontime + 300; if ($realtime > $ontime2) { echo ' [OFF]'; }else{ echo ' [ON]'; } echo " ($vr1)
"; if ($set_user['smileys']) { $tekst = functions::smileys($mass['text'], ($mass['from'] == $nickadmina || $mass['from'] == $nickadmina2 || $mass1['rights'] >= 1) ? 1 : 0); }else{ $tekst = $mass['text']; } echo "$tekst
"; if ($rights == 5 || $rights >= 6) { echo "(Удалить)"; } echo '
'; ++$i; } } if ($user_id) { echo "
Cообщение(max. 500)

Транслит
"; } echo ""; } $dnam = mysql_query("select `id`, `refid`, `text` from `lib` where type = 'cat' and id = '" . $zag['refid'] . "'"); $dnam1 = mysql_fetch_array($dnam); $catname = "$dnam1[text]"; $dirid = "$dnam1[id]"; $nadir = $zag['refid']; while ($nadir != "0") { echo ""; $dnamm = mysql_query("select `id`, `refid`, `text` from `lib` where type = 'cat' and id = '" . $nadir . "'"); $dnamm1 = mysql_fetch_array($dnamm); $dnamm2 = mysql_query("select `id`, `refid`, `text` from `lib` where type = 'cat' and id = '" . $dnamm1['refid'] . "'"); $dnamm3 = mysql_fetch_array($dnamm2); $nadir = $dnamm1['refid']; $catname = $dnamm3['text']; } break; default : header("location: index.php"); break; } } require_once ('../incfiles/end.php');