Файл: tag.php
Строк: 71
<?php
include_once 'inc/bd.php';
include_once 'inc/fun.php';
include_once 'inc/v.php';
#########################
$tags = html(rawurldecode($_GET['t']));
#########################
if (!empty($tags))
{
#########################
$all = mysql_result(mysql_query("SELECT COUNT(*) FROM `text` WHERE `tags` LIKE '%".$tags."%'"),0,0);
#########################
echo '<div class="rmenu">Меток "'.$tags.'" : '.$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)
{
$res = mysql_query("SELECT * FROM `text` WHERE `tags` LIKE '%".$tags."%' ORDER BY `id` DESC LIMIT $start,$npage");
while ($row = mysql_fetch_assoc($res))
{
$id = num($row['id']);
$cat = num($row['cat_id']);
$catnames = mysql_fetch_assoc(mysql_query("SELECT * FROM `cat` WHERE `id`='$cat'"));
if(empty($catnames)) {$catname = 'Нет категории';} else{$catname = html($catnames['name']);}
$date = $row['date'];
$news = num($row['news']);
$comment = num($row['comment']);
$comm = html($row['comm']);
$name = html($row['name']);
$text = html($row['text']);
$text = anonc($text,$anonc);
$text = nl2br($text);
$text = adminbb(parsebb(smiles($text)));
$text = $text.'...';
####
$nname = mysql_fetch_assoc(mysql_query("SELECT * FROM `comment` WHERE `text_id` = '$id' ORDER BY `id` DESC LIMIT 1"));
$user = antirek(html($nname['user']));
if ($user == $adminlogin) {$user = '<span style="color:#900">'.$user.' (Админ)</font>';}
if (!empty($user)) {$lcom = ' <sup>'.$user.'</sup>';} else {$lcom = '';}
if (!empty($news)){$div = '<div class="info"><strong>Новость: ';}else{$div = '<div class="menu"><strong>';}
####
echo $div.'<a href="'.$home.'/blog/'.$id.'">'.$name.'</a></strong> | '.$date.'<hr>
<span class="anonc">'.$text.'</span><br/>
<a href="'.$home.'/blog/'.$id.'">Далее →</a> ';
if ($comment !== 1){
echo '| <a href="'.$home.'/comment/'.$id.'">Комменты</a> ('.$comm.') '.$lcom.'';
}
echo '</div>';
}
}
else
{
echo '<div class="menu">Нет таких меток!</div>';}
if ($all > $npage)
{
####
$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.'/tags.php?page='.$backpage.'&t='.$search.'">«</a> ';
if($pp<$all && $pp>0 && $page>3)
echo '<a class="str" href="'.$home.'/tags.php?page=1&t='.$search.'">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.'/tags.php?page='.$i.'&t='.$search.'">'.$i.'</a> ';
}
}
if ($i <= $str) {if($pp2<$all) echo ' ... <a class="str" href="'.$home.'/tags.php?page='.$str.'&t='.$search.'">'.$str.'</a>';}
if ($page < $str)
{
echo '<a class="str" href="'.$home.'/tags.php?page='.$uppage.'&t='.$search.'">»</a> ';
}
echo '</div>';
}
####
}
}
else{echo 'Пустое значение метки!';}
#########################
include_once 'inc/n.php';
?>