Файл: good.php
Строк: 129
<?php
include_once 'inc/bd.php';
include_once 'inc/fun.php';
include_once 'inc/v.php';
####
$all = mysql_result(mysql_query("SELECT COUNT(*) FROM `text` where `checked`='1'"),0,0);
$kat = mysql_result(mysql_query("SELECT COUNT(*) FROM `cat`"), 0, 0);
####
$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)
{
####
echo '<div class="menu">';
echo '
<img src="'.$home.'/img/r.png" alt="" /> <strong>Всего заметок</strong> ('.$all.')<br />
<img src="'.$home.'/img/r.png" alt="" /> <a href="'.$home.'/cat.php">Разделы </a>('.$kat.')<br />
<img src="'.$home.'/img/r.png" alt="" /> <a href="'.$home.'">Новые статьи</a><br />
<img src="'.$home.'/img/r.png" alt="" /> <a href="'.$home.'/good.php">Популярные</a><br />
<img src="'.$home.'/img/r.png" alt="" /> <a href="'.$home.'/bad.php">Хуйня</a><br /></div>';
//echo '</div><div class="rek_head">'.($profile ? '<a href="'.$home.'/user.php?logout=1">Выход</a>' : '<a href="'.$home.'/user.php">Вход / Регистрация</a>').' <br/><a href="'.$home.'/add/">Добавить статью/кидалу</a></div>';
####
//$sql = mysql_query("SELECT * FROM `text` ORDER BY `id` DESC LIMIT $start,$npage");
$sql = mysql_query("SELECT * FROM `text` where `checked`='1' ORDER BY `good` DESC LIMIT $start,$npage");
while ($row = mysql_fetch_assoc($sql))
{
$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.'...';
$good = num($row['good']);
####
$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.' <b>Сказали заебись '.$good.'</b><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>';
}
####
$pp = $page - 2;
$pp2 = $page + 3;
$backpage = $page - 1;
$uppage = $page + 1;
if ($str>1){
echo '<div class="menu">';
if ($page > 1)
echo '<a class="str" href="'.$home.'/good/'.$backpage.'">«</a> ';
if($pp<$all && $pp>0 && $page>3)
echo '<a class="str" href="'.$home.'/good/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.'/good/'.$i.'">'.$i.'</a> ';
}
}
if ($i <= $str) {if($pp2<$all) echo ' ... <a class="str" href="'.$home.'/good/'.$str.'">'.$str.'</a>';}
if ($page < $str)
{
echo '<a class="str" href="'.$home.'/good/'.$uppage.'">»</a> ';
}
echo '<form action="'.$home.'/poisk.php" method="GET">';
echo '<input class="str" type="text" name="s" size="14" maxlength="50" title="Введите запрос" value=""/> ';
echo '<input class="str" type="submit" title="Нажмите для поиска" value="Найти кидораса"/></form>';
echo '</div>';
}
}
else {echo '<div class="menu">Блог пуст!</div>';}
####
$ip = html(getenv("HTTP_X_FORWARDED_FOR"));
if (empty($ip) || $ip=='unknown') { $ip=html(getenv("REMOTE_ADDR"));}
$ua = html($_SERVER['HTTP_USER_AGENT']);
$gb = mysql_result(mysql_query("SELECT COUNT(*) FROM `gb`"), 0, 0);
$all = mysql_result(mysql_query("SELECT COUNT(*) FROM `text` where `checked`='1';"),0,0);
$kat = mysql_result(mysql_query("SELECT COUNT(*) FROM `cat`"), 0, 0);
$com = mysql_result(mysql_query("SELECT COUNT(*) FROM `comment`"), 0, 0);
$row = mysql_fetch_assoc(mysql_query("SELECT * FROM `comment` ORDER BY `id` DESC LIMIT 1"));
$res = mysql_fetch_assoc(mysql_query("SELECT * FROM `text` where `checked`='1' and `id` = '".num($row['text_id'])."'"));
$text_res = mysql_fetch_assoc(mysql_query("SELECT * FROM `text` WHERE `checked`='1' and `news`='0' ORDER BY `id` DESC LIMIT 1"));
$gb_res = mysql_fetch_assoc(mysql_query("SELECT * FROM `gb` ORDER BY `id` DESC LIMIT 1"));
$news_res = mysql_fetch_assoc(mysql_query("SELECT * FROM `text` WHERE `news`='1' and `checked`='1' ORDER BY `id` DESC LIMIT 1"));
$maxkol = mysql_fetch_assoc(mysql_query("SELECT * FROM `text` where `checked`='1' ORDER BY `kol` DESC LIMIT 1"));
$maxun = mysql_fetch_assoc(mysql_query("SELECT * FROM `text` where `checked`='1' ORDER BY `unikal` DESC LIMIT 1"));
//$rand = mysql_fetch_assoc(mysql_query("SELECT * FROM `text` where `checked`='1' ORDER BY `id` DESC LIMIT RAND"));
####
echo '<div class="menu">';
echo '
• Больше всего прочли статью <a href="'.$home.'/blog.php/?id='.num($maxun['id']).'">'.html($maxun['name']).'</a>: <strong>'.num($maxun['unikal']).'</strong><br/>
• Последний комментарий написал <strong>'.html($row['user']).'</strong> к статье <a href="'.$home.'/blog.php/?id='.num($res['id']).'">'.html($res['name']).'</a><br/>
• Последняя запись <a href="'.$home.'/blog.php/?id='.num($text_res['id']).'">'.html($text_res['name']).'</a> была добавлена <strong>'.$text_res['date'].'</strong><br/>
• Последняя статья-новость <a href="'.$home.'/blog.php/?id='.num($news_res['id']).'">'.html($news_res['name']).'</a> была добавлена <strong>'.$news_res['date'].'</strong><br/>
•<img src="'.$home.'/img/r.png" alt="" /> <a href="'.$home.'/s.php"><b>Рекламодателю</b></a><br />
•<img src="'.$home.'/img/r.png" alt="" /> <a href="'.$home.'/s.php?mod=cont">Обо мне/Контакты</a><br />
</div>';
include_once 'inc/n.php';
?>