<?
include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/user.php';
$set['title']='Популярные сообщества'; // заголовок страницы
include_once '../sys/inc/thead.php';
title();
aut();
if (isset($_GET['ASC']))$por='ASC'; // прямой порядок
if (isset($_GET['DESC']))$por='DESC'; // обратный порядок
$razd=mysql_fetch_array(mysql_query("SELECT * FROM `community_razd` WHERE `id` = '".intval($_GET['id_razd'])."'"));
//////////////////////////////////////
echo'<a href="index.php?">Сообщества</a> / <b>Популярные сообщества</b><hr>';
//////////////////////////////////////
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `community_comm` WHERE `id_razd` = '$razd[id]'"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
if ($k_post==0){echo "Нет сообществ<br/>\n";}
$q=mysql_query("SELECT * FROM `community_comm` WHERE `id_razd` = '$razd[id]' LIMIT $start, $set[p_str]");
while ($post = mysql_fetch_array($q))
{if($num==1){ 
echo "<div class='news'>"; 
$num=0;
}else{ 
echo "<div class='str'>"; 
$num=1;}

echo "<img src='/sys/img/soo.gif' alt='' class='icon'/>\n";
echo "<a href='comm.php?id=$post[id]'>$post[name]</a>";
//echo mysql_num_rows(mysql_query("SELECT `id` FROM `community_user_incomm` WHERE `cid` = '$post[id]'"));
//echo ")\n";
if (isset($user) && ($user['level']>$ank['level'] || $user['level']==4))
	echo " [<a href='adm_create.php?id=".$post[id]."'>Ред</a>]";
echo "</div>";

}
if ($k_page>1)str('?id_razd='.$razd['id'].'&amp;',$k_page,$page); // Вывод страниц

if(isset($user))
{
echo "<img src='/img/lj.gif' alt='' class='icon'/>\n";
echo "<a href='create_comm.php?id_razd=$razd[id]'>Создать сообщество</a><br/>\n";
}
include_once '../sys/inc/tfoot.php';
?>