Файл: library.php
Строк: 112
<?php
session_start();
define('IN_SCRIPT', true);
include "includes/ini.php";
include "includes/header.php";
If (!isset($_GET['do']) || !ereg("^[a-z0-9_-]{1,15}$",$_GET['do'])) $do=false; else $do=$_GET['do'];
switch ($do) {
case 'info':
if (isset($_SESSION['auth'])){
$login = $_SESSION['login'];
$login = htmlspecialchars(trim($login));
$login = mysql_real_escape_string($login);
$count = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE login='$login'"));
$qy=mysql_query("select* from `inbox` where (`idto`='".$count['id']."' && `status`='0');");
$ne=mysql_num_rows($qy);
if($ne > 0){
echo '<div class="output_err"><center>У Вас <b><a href="mail.php?do=inbox">'.$ne.'</a></b> новых сообщений.</center></div>';
}
}
$c = mysql_result(mysql_query("SELECT COUNT(*) FROM `inform` WHERE `id` = '".$id."';"), 0);
if ($c>0)
{
$count = mysql_fetch_array(mysql_query("SELECT * FROM `inform` WHERE `id` = '".$id."';"));
echo '<div class="title_page">'.htmlspecialchars(stripslashes($count['nazv'])).'</div>';
echo '<div class="box_2">'.$count['text'].'</div>';
} else echo '<div class="title_page">Библиотека</div><div class="box_2">Информация не обнаружена!</div>';
echo '<div class="title_page"><img src="imag/home.png" ><a href="index.php">Главная</a>/<a href="library.php?do=razd&razd='.htmlspecialchars(stripslashes($count['razd'])).'">Библиотека</a></div>';
break;
case 'razd':
if (isset($_SESSION['auth'])){
$login = $_SESSION['login'];
$login = htmlspecialchars(trim($login));
$login = mysql_real_escape_string($login);
$count = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE login='$login'"));
$qy=mysql_query("select* from `inbox` where (`idto`='".$count['id']."' && `status`='0');");
$ne=mysql_num_rows($qy);
if($ne > 0){
echo '<div class="output_err"><center>У Вас <b><a href="mail.php?do=inbox">'.$ne.'</a></b> новых сообщений.</center></div>';
}
}
$id=$_GET['razd'];
$sql = mysql_query("SELECT * FROM `inform` WHERE `id` = '".$id."'");
$sql = mysql_fetch_array($sql);
echo '<div class="title_page">'.htmlspecialchars(stripslashes($sql['nazv'])).'</div>';
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `inform` WHERE `razd` = '".$id."' AND `podrazd` = '".$id."';"), 0);
if ($count > 0)
{
$qwq = mysql_query("SELECT * FROM `inform` WHERE `razd` = '".$id."' AND `podrazd` = '".$id."'");
$ss = mysql_fetch_array($qwq);
$page = intval(@$_GET['page']);
$start = intval(@$_GET['start']);
$onpage = 15;
$all = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM `inform` WHERE `razd` = '".$id."' AND `podrazd` = '".$id."'"));
$all = $all[0];
$pages = ceil($all/$onpage);
if(!$pages) $pages = 1;
if($page>$pages or $page<=0) $page=1;
if($start>$all or $start<=0) $start = 0;
if($page) $start = ($page - 1) * $onpage; else $start = 0;
$sql = mysql_query("SELECT * FROM `inform` WHERE `razd` = '".$id."' AND `podrazd` = '".$id."' ORDER BY `por` LIMIT ".$start.", ".$onpage);
while ($row = mysql_fetch_array($sql))
{
getfont();
echo ''.$font_row.'<b class="b">»</b> <a href="library.php?do=info&id='.$row['id'].'">'.htmlspecialchars(stripslashes($row['nazv'])).'</a></div>';
}
} else echo '<div class="box_1">Информация не обнаружена!</div>';
if($all > 15){
echo '<div class="box_1">Страницы:</div>';
$asd = $page - 2;
$asd2 = $page + 3; if ($pages>1){
if($asd<$all && $asd>0 && $page>3 ) echo ' <a href="library.php?do=info&razd='.$id.'&page=1">1</a> ... ';
for($i=$asd; $i<$asd2;$i++)
{
if($i<$all && $i>0)
{
if ($i > $pages ) break;
if ($page==$i) echo '<span><b>'.$i.'</b></span> ';
else echo '<a href="library.php?do=info&razd='.$id.'&page='.$i.'">'.$i.'</a> ';
}
}
if ($i <= $pages)
{
if($asd2<$all) echo ' ... <a href="library.php?do=info&razd='.$id.'&page='.$pages.'">'.$pages.'</a>';
}
}
}
echo '<div class="title_page"><img src="imag/home.png" ><a href="index.php">Главная</a><br/><img src="imag/edit.gif" ><a href="library.php">Библиотека</a></div>';
break;
case 'index':
default:
if (isset($_SESSION['auth'])){
$login = $_SESSION['login'];
$login = htmlspecialchars(trim($login));
$login = mysql_real_escape_string($login);
$count = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE login='$login'"));
$qy=mysql_query("select* from `inbox` where (`idto`='".$count['id']."' && `status`='0');");
$ne=mysql_num_rows($qy);
if($ne > 0){
echo '<div class="output_err"><center>У Вас <b><a href="mail.php?do=inbox">'.$ne.'</a></b> новых сообщений.</center></div>';
}
}
echo '<div class="title_page"><img src="imag/edit.gif" >Библиотека</div>';
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `inform` WHERE `razd` = '0' AND `podrazd` = '0';"), 0);
if ($count > 0)
{
$sql = mysql_query("SELECT * FROM `inform` WHERE `razd` = '0' AND `podrazd` = '0' ORDER BY `por` ");
while ($row = mysql_fetch_array($sql))
{
getfont();
echo ''.$font_row.'<b class="b">»</b> <a href="library.php?do=razd&razd='.$row['id'].'">'.htmlspecialchars(stripslashes($row['nazv'])).'</a>
</div>';
}
} else echo '<div class="box_2">Информация не обнаружена!</div>';
echo '<div class="title_page"><img src="imag/home.png" ><a href="index.php">Главная</a></div>';
break;
}
include "includes/footer.php";
mysql_close();
?>