Просмотр файла includes/top.php

Размер файла: 1.88Kb
<?php
// by Mike O. (mides), coolcms.org

switch ($type) {
	case 'blogs':
		$title = 'Блоги';
		$seen_t = 'просмотры';
		$seen_row = 'Просмотров';
	break;

	case 'photos':
		$title = 'Фото';
		$seen_t = 'просмотры';
		$seen_row = 'Просмотров';
	break;

	case 'loads':
		$title = 'ЗЦ';
		$seen_t = 'скачивания';
		$seen_row = 'Скачиваний';
	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>&raquo; ТОП</div><div class="body">';
echo 'Сортировка: <a href="?act=top&amp;sort=seen">'.$b1.$seen_t.$b2.'</a>, <a href="?act=top&amp;sort=rating">'.$b3.'оценки'.$b4.'</a>, <a href="?act=top&amp;sort=time">'.$b5.'новые'.$b6.'</a></div>';

$total = mysql_result(mysql_query("SELECT COUNT(`id`) FROM $type"), 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 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&amp;id='.$top['id'].'">'.$top['name'].' (<b>'.$top['rating'].'</b>)<br />'.$seen_row.': '.$top['seen'].'<br />';
		$comm = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `".$type."_comm` WHERE `id_$type` = '$top[id]'"), 0);
		echo 'Коментарий: '.$comm.'<br />';
		echo '</a></div>';
	}
} else {
	echo 'Пусто';
}

echo '<div class="body">';
navig($page, '?act=top&amp;sort='.$sort.'&amp;', $pages);
echo '<a href="index.php">'.$title.'</a>&raquo; ТОП</div>';


?>