Файл: test.otwap.aux.su/test/news.php
Строк: 44
<?php
session_start();
define ("TITLE", "Новости | WAP-казино");
include("head.php");
include("config.php");
include("bd.php");
$page = intval(@$_GET['page']);
$start = intval(@$_GET['start']);
$onpage = 5;
$all = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM news"));
$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;
echo '<div class="title"><div class="titletext"><b>Новости</b></div></div>';
if(isset($_SESSION['auth'])){
$result = mysql_query("SELECT * FROM news ORDER BY id DESC LIMIT $start,$onpage");
$row = mysql_fetch_array($result);
do
{
echo "<div class='bl'><div class='bltext'><b>$row[date]</b><br>$row[text]</div></div>";
}
while($row = mysql_fetch_array($result));
if($all > 5){
echo "---<br/>Страницы: ";
}
$asd = $page - 2;
$asd2 = $page + 3; if ($pages>1){
if($asd<$all && $asd>0 && $page>3 ) echo ' <a href="news.php?'.session_name().'='.session_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="news.php?'.session_name().'='.session_id().'&page='.$i.'">'.$i.'</a> ';
}
}
if ($i <= $pages)
{
if($asd2<$all) echo ' ... <a href="news.php?'.session_name().'='.session_id().'&page='.$pages.'">'.$pages.'</a>';
}
}
echo '<div class="bl"><div class="bltext"><a href="panel.php?'.session_name().'='.session_id().'">Личный кабинет</a></div></div>';
include("foot.php");
}else{
$result = mysql_query("SELECT * FROM news ORDER BY id DESC LIMIT $start,$onpage");
$row = mysql_fetch_array($result);
do
{
printf("<div class='bl'><div class='bltext'><b>%s</b><br>%s</div></div>",$row['date'],$row['text']);
}
while($row = mysql_fetch_array($result));
if($all > 5){
echo "---<br/>Страницы: ";
}
$asd = $page - 2;
$asd2 = $page + 3; if ($pages>1){
if($asd<$all && $asd>0 && $page>3 ) echo ' <a href="news.php&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="news.php&page='.$i.'">'.$i.'</a> ';
}
}
if ($i <= $pages)
{
if($asd2<$all) echo ' ... <a href="news.php&page='.$pages.'">'.$pages.'</a>';
}
}
echo "<div class='bl'><div class='bltext'><a href='index.php'>Назад</a></div></div>";
include("foot.php");
}
?>