<?

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']='Список разделов &amp; '.$_SERVER['HTTP_HOST'];
include_once '../sys/inc/thead.php';

title();
aut();

echo '<div class="menu">';

// Доступ только уровнем 4
if($user['level']==10){
	include_once 'inc/razd_act.php';
	}

/*
$k_razd = mysql_num_rows(mysql_query("SELECT `id` FROM `community_razd`"));
$k_page=k_page($k_razd,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];

// Вывод директорий
$q=mysql_query("SELECT * FROM `community_razd` ORDER BY `sort` LIMIT $start, $set[p_str]");
*/

$q=mysql_query("SELECT * FROM `community_razd` ORDER BY `sort`");
while($post = mysql_fetch_array($q)){
$num=1;
if($num==1){
	echo '<div class="rowdown">';
	$num=0;
	}else{
		echo '<div class="rowup">';
		$num=1;
		}

$k_f=0;
$k_n=0;

$q3=mysql_query("SELECT * FROM `community_comm` WHERE `id_razd` = '$post[id]'");
while($post2 = mysql_fetch_array($q3)){
	$k_f=$k_f+mysql_result(mysql_query("SELECT COUNT(*) FROM `community_user_incomm` WHERE `cid` = '$post2[id]'"),0);
	$k_n=$k_n+mysql_result(mysql_query("SELECT COUNT(*) FROM `community_user_incomm` WHERE `cid` = '$post2[id]' AND `time` > '".(time()-86400)."'"),0);
	}

if($k_n==0){
	$k_n=NULL;
	}else{
		$k_n=' + '.$k_n.' сегодня';
		}

echo '<img src="/style/themes/'.$set['set_them'].'/comm/dir.gif" alt="" class="icon"/> <a href="razd.php?id_razd='.$post['id'].'">'.$post['name'].'</a>&nbsp;';
echo '<span class="ank_n">('.mysql_result(mysql_query("SELECT COUNT(*) FROM `community_comm` WHERE `id_razd` = '$post[id]'"),0).'</span>/';
echo '<span class="ank_n">'.$k_f.''.$k_n.'</span>)<br/>';

if($post['opis']!=NULL){
	echo output_text($post['opis']).'<br/>';
	}

// Доступ только уровнем 4
if($user['level']==10){
	echo '[<a href="index.php?razd=edit&amp;id_razd='.$post['id'].'">редактировать</a> | <a href="index.php?razd=delete&amp;id_razd='.$post['id'].'">Удалить</a>]';
	}

echo '</div>';
}

/*
if($k_page>1){
	str('index.php?',$k_page,$page);
	}
*/

// Доступ только уровнем 4
if($user['level']==10){
	include_once 'inc/razd_form.php';
	}

echo '</div>';
include_once '../sys/inc/tfoot.php';
?>