View file Modules/Category.php

File size: 2.59Kb
<?PHP
	include '../System/core.php';

	if (!isset($_GET['translit'])){header('Location: /');}

	$translit = xss($_GET['translit']);

	$query = mysql_query("SELECT * FROM `category` WHERE `translit` = '$translit'"); $sql_count++;

	if (mysql_num_rows($query) == TRUE)
	{
		$category = mysql_fetch_array($query);
		$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `site` WHERE `id_category` = '".$category['id']."' AND `mod` = '1' AND `ban` = '0'"),0); $sql_count++;
  
		$config['title'] = 'Категория - '.$category['name'];
		include '../System/header.php';
  
		if (isset($user))
		{
			?><div class="footer"><a href="/Panel/edit_category.php?id=<? echo $category['id']; ?>">Редактировать</a> <a href="/Panel/delete_category.php?id=<? echo $category['id']; ?>">Удалить</a></div><?
		}

		if ($count !== '0')
		{
			# Постраничная навигация
            $pages = $system['page'];
			$page = num($_GET['page']);
            $total = @intval(($count-1)/$pages) + 1;
			if (empty($page) OR $page < 0)
			{
				$page = 1;
			}
			if ($page > $total)
			{
				$page = $total;
			}
			$past = intval($count/$pages);
			$start = $page*$pages-$pages;



			# Нумерация сайтов
			if (!isset($_GET['page']))
			{
				$_GET['page'] = '1';
			}
 
			if ($count < $pages)
			{
				$num = $count*$_GET['page']-$count;
			}
			else
				$num = $pages*$_GET['page']-$pages;
				
			if($num < '0')
			{
				$num = '0';
			}



			$query_site = mysql_query("SELECT * FROM `site` WHERE `id_category` = '".$category['id']."' AND `mod` = '1' AND `ban` = '0' ORDER BY `time` DESC LIMIT ".$start.",".$pages.""); $sql_count++;
    
			while ($site = mysql_fetch_array($query_site))
			{
				$num++;
				?>
				<a href="/site/<? echo $site['url']; ?>">
					<div class="text">
						<b style="color: black;"><? echo $num; ?>.</b> <u><? echo $site['name']; ?></u><br />
						<small><? echo $site['about']; ?></small><br />
						<b style="color:#FF0000;">PR</b>: <? echo $site['pr']; ?> | <b style="color:#FF0000;">CY</b>: <? echo $site['cy']; ?><br />
					</div>
				</a>
				<?
			}
	
			# Вывод постраничной навигации
			if ($pages < $count)
				echo $navigation = navigation($total, $page, '/category/'.$translit.'/');
		}
		else
			{?><div class="text">Сайтов в данной категории нет</div><?}
	}
	else
	{
  
	}

	?><div class="back"><a href="/"><img src="/Style/icons/back.png" alt="" /> На главную</a></div><?



	include '../System/footer.php';
?>