Файл: spuff.ru/includes/top.php
Строк: 29
<?php
switch ($type) {
case 'blogs':
$title = 'Полезные коды';
$seen_t = 'просмотры';
$seen_row = 'Просмотров';
$where = '';
break;
case 'photos':
$title = 'Фото';
$seen_t = 'просмотры';
$seen_row = 'Просмотров';
$where = '';
break;
case 'loads':
$title = 'ЗЦ';
$seen_t = 'скачивания';
$seen_row = 'Скачиваний';
$where = 'WHERE `ok` = 1';
break;
}
switch ($_GET['sort']) {
case 'rating': $sort = 'rating'; $b3 = '<b>'; $b4 = '</b>'; break;
case 'time': $sort = 'time'; $b5 = '<b>'; $b6 = '</b>'; break;
default: $sort = 'seen'; $b1 = '<b>'; $b2 = '</b>'; break;
}
echo '<div class="title"><a href="index.php">'.$title.'</a>» ТОП</div><div class="rega">';
echo 'Сортировка: <a href="?act=top&sort=seen">'.$b1.$seen_t.$b2.'</a>, <a href="?act=top&sort=rating">'.$b3.'оценки'.$b4.'</a>, <a href="?act=top&sort=time">'.$b5.'новые'.$b6.'</a></div>';
$total = mysql_result(mysql_query("SELECT COUNT(`id`) FROM $type $where"), 0);
if ($total > 0) {
$pages = ceil($total / $config['onpage']);
if ($page > $pages or $page == 0) {
$page = 1;
}
$begin = ($page - 1) * $config['onpage'];
$top_r = mysql_query("SELECT * FROM $type $where ORDER BY $sort DESC LIMIT $begin, $config[onpage]");
while ($top = mysql_fetch_assoc($top_r)) {
echo '<div class="row"><a href="index.php?act=view&id='.$top['id'].'">'.$top['name'].' (<b>'.$top['rating'].'</b>)</a><br/>'.$seen_row.': '.$top['seen'].'<br/>';
$comm = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `".$type."_comm` WHERE `id_$type` = '$top[id]'"), 0);
echo '<a href="index.php?act=comm&id='.$top['id'].'">Коментарий: '.$comm.'</a>';
echo '</div>';
}
} else {
echo '<div class="error">Пусто</div>';
}
navig($page, '?act=top&sort='.$sort.'&', $pages);
?>