Файл: comment.php
Строк: 62
<?php
include_once 'inc/bd.php';
include_once 'inc/fun.php';
####
$idst = num($_GET['id']);
$whatis = mysql_fetch_assoc(mysql_query("SELECT * FROM `text` WHERE `id` = '$idst'"));
$title = 'Комментарии к статье "'.html($whatis['name']).'"';
include_once 'inc/v.php';
###
if ($whatis['comment'] == 1) {echo '<div class="err">Нельзя комментировать эту статью!</div>';}
else
{
if (mysql_num_rows(mysql_query("SELECT * FROM `text` WHERE `id` = '$idst'"))==0)
{echo '<div class="err">Нет такой статьи!</div>';}
else {
####
$all = mysql_result(mysql_query("SELECT COUNT(*) FROM `comment` WHERE `text_id` = '$idst'"), 0, 0);
####
echo '<div class="rmenu"><a href="'.$home.'/say/'.$idst.'">Добавить</a> | <a href="'.$home.'/blog/'.$idst.'">К статье</a></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)
{$sql = mysql_query("SELECT * FROM `comment` WHERE `text_id` = '$idst' ORDER BY `id` DESC LIMIT $start,$npage ");
while ($row = mysql_fetch_assoc($sql)) {
$id = num($row['id']);
$user = antirek(html($row['user']));
if ($user == $adminlogin) {$user = '<font color="990000">'.$user.' (УКДПЕ)</font>';} else
$date = $row['date'];
$text = html($row['text']);
$text = nl2br($text);
$text = parsebb(smiles($text));
####
echo '<div class="menu">';
if ($version == web){echo '<img src="'.$home.'/img/comment_web.png"/> ';}
else {echo '<img src="'.$home.'/img/comment.png" alt=""/> ';}
if(mysql_result(mysql_query("select count(`id`) from `users` where `login`='".mysql_real_escape_string($row['user'])."' limit 1;"), 0)) {
$user = $row['user'];
echo '<a href="'.$home.'/profile/?u='.mysql_real_escape_string($row['user']).'"><strong>'.$user.'</strong></a> (<a href="'.$home.'/say.php?id='.$idst.'&u='.$id.'">отв</a>)| ';
} else echo '<a href="'.$home.'/say.php?id='.$idst.'&u='.$id.'"><strong>'.$user.'</strong></a> | ';
echo '<span style="font-size:9px">'.$date.'</span><br/>'.($user != $adminlogin ? replace($text) : $text).'</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.'/comment/'.$idst.'/'.$backpage.'">«</a> ';
if($pp<$all && $pp>0 && $page>3)
echo '<a class="str" href="'.$home.'/comment/'.$idst.'/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.'/comment/'.$idst.'/'.$i.'">'.$i.'</a> ';
}
}
if ($i <= $str) {if($pp2<$all) echo ' ... <a class="str" href="'.$home.'/comment/'.$idst.'/'.$str.'">'.$str.'</a>';}
if ($page < $str)
{
echo '<a class="str" href="'.$home.'/comment/'.$idst.'/'.$uppage.'">»</a> ';
}
echo '</div>';
}
}
else {echo '<div class="menu">Комментариев нет!</div>';}
####
}
}
####
include_once 'inc/n.php';
?>