Файл: last.php
Строк: 46
<?php
include_once 'inc/bd.php';
include_once 'inc/fun.php';
$title = 'Последние комментарии';
include_once 'inc/v.php';
####
$all = mysql_result(mysql_query("SELECT COUNT(*) FROM `comment`"), 0, 0);
echo '<div class="rmenu">Всего комментариев: '.$all.'</div>';
####
$get = num($_GET['page']);
if(isset($get))
{$page = $get;}
else{$page=1;}
$str = ceil($all/$npage);
if(!$str) $pages = 1;
if($page>$str or $page<=0) $page=1;
if($start>$all or $start<=0) $start = 0;
if($page) $start = ($page - 1) * $npage;
else $start = 0;
####
if ($all>0)
{
$sqlc = mysql_query("SELECT * FROM `comment` ORDER BY `id` DESC LIMIT $start,$npage");
while ($row = mysql_fetch_assoc($sqlc))
{
$idk = num($row['id']);
$idst = num($row['text_id']);
$user = html($row['user']);
if ($user == $adminlogin) {$user = '<font color="FF0000">'.$user.' (Админ)</font>';}
$text = html($row['text']);
$text = nl2br($text);
$text = parsebb(smiles($text));
####
$r = mysql_fetch_assoc(mysql_query("SELECT * FROM `text` WHERE `id` = '$idst'"));
$name = html($r['name']);
####
echo '<div class="menu">';
if ($version == web){echo '<img src="'.$home.'/img/comment_web.png"/> ';}
else {echo '<img src="'.$home.'/img/comment.png" alt=""/> ';}
echo '<a href="'.$home.'/comment/'.$idst.'"><strong>'.$user.'</a></strong> к статье <a href="'.$home.'/blog/'.$idst.'">'.$name.'</a>
<hr/>'.$text.'<br/><a href="'.$home.'/say.php?id='.$idst.'&u='.$idk.'">Ответить →</a></div>';
}
####
$pp = $page - 2;
$pp2 = $page + 3;
$backpage = $page - 1;
$uppage = $page + 1;
if ($str>1){
echo '<div class="nmenu">';
if ($page > 1)
echo '<a class="str" href="'.$home.'/last/'.$backpage.'">«</a> ';
if($pp<$all && $pp>0 && $page>3)
echo '<a class="str" href="'.$home.'/last/1">1</a> ... ';
for($i=$pp; $i<$pp2;$i++)
{
if($i<$all && $i>0)
{
if ($i > $str )
break;
if ($page==$i)
echo '<span class="str_active"><b>'.$i.'</b></span> ';
else echo '<a class="str" href="'.$home.'/last/'.$i.'">'.$i.'</a> ';
}
}
if ($i <= $str) {if($pp2<$all) echo ' ... <a class="str" href="'.$home.'/last/'.$str.'">'.$str.'</a>';}
if ($page < $str)
{
echo '<a class="str" href="'.$home.'/last/'.$uppage.'">»</a> ';
}
echo '</div>';
}
}
else {echo '<div class="menu">Комментариев нет!</div>';}
####
include_once 'inc/n.php';
?>