Файл: public_html/blog/grin.php
Строк: 216
<?
include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/user.php';
$set['title']='Дневники';
include_once '../sys/inc/thead.php';
title();
aut(); // форма авторизации
If (!isset($_GET['sort']) || !ereg("^[a-z0-9_-]{1,15}$",$_GET['sort'])) $sort=false; else $sort=$_GET['sort'];
switch ($sort){
case 'rating':
echo "<div class="z">";
echo "<span class="ank_n"><img src='icon/080.png' alt='X' /> Сортировать по: </span>";
echo " <span class="ank_n"><a href='grin.php'> Дате </a></span> | <span class="ank_n"> Рейтингу </span> | <span class="ank_n"><a href='grin.php?sort=prosm'> Кол-ву просмотров </a></span></div>";
$num = 5;
if(isset($_GET['page']) and is_numeric($_GET['page'])) {
$page = intval($_GET['page']);
} else { $page = 1; }
$result = mysql_query("SELECT COUNT(*) FROM `blog_s` ORDER BY `id` DESC ");
echo "<table width="100%" border="0" cellspacing="1" cellpadding="1">n";
$posts = mysql_result($result,0);
if ($posts==0) { echo 'Блогов нет!<br/>';
break;}
$total = intval(($posts - 1) / $num) + 1;
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * $num - $num;
$result = mysql_query("SELECT * FROM `blog_s` ORDER BY rating DESC LIMIT $start, $num");
while ($myrow = mysql_fetch_array($result)){
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $myrow[avtor] LIMIT 1"));
$comms=@mysql_query("SELECT * FROM `blog_comm` WHERE `blog` = '".$myrow['id']."' ");
$comm=@mysql_num_rows($comms);
echo " <tr>n";
echo " <td class='p_t'>n";
echo "<a href='blog.php?id=".$myrow['id']."'> <b>$myrow[name]</b></a> (".vremja($myrow['data']).")<br/>";
echo " </td>n";
echo " </tr>n";
echo " <tr>n";
if ($set['set_show_icon']==1)echo " <td class='p_m' colspan='2'>n"; else echo " <td class='p_m'>n";
echo "Автор:<a href='/info.php?id=$ank[id]'> <b>$ank[nick]</b></a><br/>";
echo "Рейтинг: <b>$myrow[rating]</b><br/>";
echo "Комментариев: <b>$comm</b><br/>";
echo "Просмотров: <b>$myrow[prosm]</b><br/>";
echo " </td>n";
echo " </tr>n";
}
echo "</table>n";
if ($page != 1) $pervpage = '<a href="?sort=rating&page=1"><<</a>
<a href="?sort=rating&page='. ($page - 1) .'"><</a> ';
if ($page != $total) $nextpage = ' <a href="?sort=rating&page='. ($page + 1) .'">></a>
<a href="?sort=rating&page=' .$total. '">>></a>';
if($page - 2 > 0) $page2left = ' <a href="?sort=rating&page='. ($page - 2) .'">'. ($page - 2) .'</a> ';
if($page - 1 > 0) $page1left = ' <a href="?sort=rating&page='. ($page - 1) .'">'. ($page - 1) .'</a> ';
if($page + 2 <= $total) $page2right = ' <a href="?sort=rating&page='. ($page + 2) .'">'. ($page + 2) .'</a>';
if($page + 1 <= $total) $page1right = ' <a href="?sort=rating&page='. ($page + 1) .'">'. ($page + 1) .'</a>';
@$xxx = '<small>'.$pervpage.$page2left.$page1left.'</small>'.$page.'<small>'.$page1right.$page2right.$nextpage.'</small>';
echo str_replace("<small></small>1<small></small>","",$xxx);
break;
case 'prosm':
echo "<div class="z">";
echo "<span class="ank_n"><img src='icon/080.png' alt='X' /> Сортировать по: </span>";
echo " <span class="ank_n"><a href='grin.php'> Дате </a></span> | <span class="ank_n"><a href='grin.php?sort=rating'> Рейтингу </a></span> | <span class="ank_n"> Кол-ву просмотров </span></div>";
$num = 5;
if(isset($_GET['page']) and is_numeric($_GET['page'])) {
$page = intval($_GET['page']);
} else { $page = 1; }
$result = mysql_query("SELECT COUNT(*) FROM `blog_s` ORDER BY `id` DESC ");
echo "<table width="100%" border="0" cellspacing="1" cellpadding="1">n";
$posts = mysql_result($result,0);
if ($posts==0) { echo 'Блогов нет!<br/>';
break;}
$total = intval(($posts - 1) / $num) + 1;
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * $num - $num;
$result = mysql_query("SELECT * FROM `blog_s` ORDER BY prosm DESC LIMIT $start, $num");
while ($myrow = mysql_fetch_array($result)){
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $myrow[avtor] LIMIT 1"));
$comms=@mysql_query("SELECT * FROM `blog_comm` WHERE `blog` = '".$myrow['id']."' ");
$comm=@mysql_num_rows($comms);
echo " <tr>n";
echo " <td class='p_t'>n";
echo "<a href='blog.php?id=".$myrow['id']."'> <b>$myrow[name]</b></a> (".vremja($myrow['data']).")<br/>";
echo " </td>n";
echo " </tr>n";
echo " <tr>n";
if ($set['set_show_icon']==1)echo " <td class='p_m' colspan='2'>n"; else echo " <td class='p_m'>n";
echo "Автор:<a href='/info.php?id=$ank[id]'> <b>$ank[nick]</b></a><br/>";
echo "Рейтинг: <b>$myrow[rating]</b><br/>";
echo "Комментариев: <b>$comm</b><br/>";
echo "Просмотров: <b>$myrow[prosm]</b><br/>";
echo " </td>n";
echo " </tr>n";
}
echo "</table>n";
if ($page != 1) $pervpage = '<a href="?sort=prosm&page=1"><<</a>
<a href="?sort=prosm&page='. ($page - 1) .'"><</a> ';
if ($page != $total) $nextpage = ' <a href="?sort=prosm&page='. ($page + 1) .'">></a>
<a href="?sort=prosm&page=' .$total. '">>></a>';
if($page - 2 > 0) $page2left = ' <a href="?sort=prosm&page='. ($page - 2) .'">'. ($page - 2) .'</a> ';
if($page - 1 > 0) $page1left = ' <a href="?sort=prosm&page='. ($page - 1) .'">'. ($page - 1) .'</a> ';
if($page + 2 <= $total) $page2right = ' <a href="?sort=prosm&page='. ($page + 2) .'">'. ($page + 2) .'</a>';
if($page + 1 <= $total) $page1right = ' <a href="?sort=prosm&page='. ($page + 1) .'">'. ($page + 1) .'</a>';
@$xxx = '<small>'.$pervpage.$page2left.$page1left.'</small>'.$page.'<small>'.$page1right.$page2right.$nextpage.'</small>';
echo str_replace("<small></small>1<small></small>","",$xxx);
break;
case false:
default:
echo "<div class="z">";
echo "<span class="ank_n"><img src='icon/080.png' alt='X' /> Сортировать по: </span>";
echo " <span class="ank_n"> Дате </span> | <span class="ank_n"><a href='grin.php?sort=rating'> Рейтингу </a></span> | <span class="ank_n"><a href='grin.php?sort=prosm'> Кол-ву просмотров </a></span></div>";
$num = 5;
if(isset($_GET['page']) and is_numeric($_GET['page'])) {
$page = intval($_GET['page']);
} else { $page = 1; }
$result = mysql_query("SELECT COUNT(*) FROM `blog_s` ORDER BY `id` DESC ");
echo "<table width="100%" border="0" cellspacing="1" cellpadding="1">n";
$posts = mysql_result($result,0);
if ($posts==0) { echo 'Блогов нет!<br/>';
break;}
$total = intval(($posts - 1) / $num) + 1;
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * $num - $num;
$result = mysql_query("SELECT * FROM `blog_s` ORDER BY id DESC LIMIT $start, $num");
while ($myrow = mysql_fetch_array($result)){
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $myrow[avtor] LIMIT 1"));
$comms=@mysql_query("SELECT * FROM `blog_comm` WHERE `blog` = '".$myrow['id']."' ");
$comm=@mysql_num_rows($comms);
echo " <tr>n";
echo " <td class='p_t'>n";
echo "<a href='blog.php?id=".$myrow['id']."'> <b>$myrow[name]</b></a> (".vremja($myrow['data']).")<br/>";
echo " </td>n";
echo " </tr>n";
echo " <tr>n";
if ($set['set_show_icon']==1)echo " <td class='p_m' colspan='2'>n"; else echo " <td class='p_m'>n";
echo "Автор:<a href='/info.php?id=$ank[id]'> <b>$ank[nick]</b></a><br/>";
echo "Рейтинг: <b>$myrow[rating]</b><br/>";
echo "Комментариев: <b>$comm</b><br/>";
echo "Просмотров: <b>$myrow[prosm]</b><br/>";
echo " </td>n";
echo " </tr>n";
}
echo "</table>n";
if ($page != 1) $pervpage = '<a href="?page=1"><<</a>
<a href="?page='. ($page - 1) .'"><</a> ';
if ($page != $total) $nextpage = ' <a href="?page='. ($page + 1) .'">></a>
<a href="?page=' .$total. '">>></a>';
if($page - 2 > 0) $page2left = ' <a href="?page='. ($page - 2) .'">'. ($page - 2) .'</a> ';
if($page - 1 > 0) $page1left = ' <a href="?page='. ($page - 1) .'">'. ($page - 1) .'</a> ';
if($page + 2 <= $total) $page2right = ' <a href="?page='. ($page + 2) .'">'. ($page + 2) .'</a>';
if($page + 1 <= $total) $page1right = ' <a href="?page='. ($page + 1) .'">'. ($page + 1) .'</a>';
@$xxx = '<small>'.$pervpage.$page2left.$page1left.'</small>'.$page.'<small>'.$page1right.$page2right.$nextpage.'</small>';
echo str_replace("<small></small>1<small></small>","",$xxx);
}
echo "<div class='foot'>« <a href='index.php'>В начало</a></div>";
include_once '../sys/inc/tfoot.php';
?>