<?php
require_once '../core/system.php';
echo only_reg();
echo ban();
if (isset($_GET['id'])) {
If (mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_razdel` WHERE `id` = '$get_id' and `main_forum` = '0'"),0) == true) {
$sub_forum = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_razdel` WHERE `id`  = '$get_id' And `main_forum` = '0'"));
$sub_forum_parent = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_razdel` WHERE `id`  = '$sub_forum[attached_to]' And `main_forum` = '1'"));
}
$header = $sub_forum[name];
}Elseif (isset($_GET['parent_id'])){
$parent = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_razdel` WHERE `id`  = '$get_parent_id' And `main_forum` = '1'"));
$header = $parent[name];
}Else{
$header = 'Форум';
}

include_once '../core/head.php';
if (!isset($_GET['id'])  && !isset($_GET['parent_id'])) {


$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_razdel` WHERE `clan_forum` = '0'"),0);
$q = mysql_query("SELECT * FROM `forum_razdel` WHERE `clan_forum` = '0' and `type` = 'public_property' ORDER BY `news_post` DESC, `id` ASC");
if($k_post == '0')echo "<div class='center player grey'>Разделов нет</div><div class='mini-line'></div>";
echo "<div class='player menuList'>";
while($post = mysql_fetch_assoc($q)) {
if ($post['main_forum'] == '1' && $post['sub_forum'] == '0') {
if($user['level']>=0 && ($post['private_post']==1 && $user['prava'] >=4 || $post['private_post']==0))echo "<li><a href='/forum?parent_id=$post[id]'><img src='/images/icon/section.png'>$post[name]</a></li><div class='dot-line'></div>";
}elseif ($post['main_forum'] == '0') {
if($user['level']>=0 && ($post['private_post']==1 && $user['prava'] >=4 || $post['private_post']==0))echo "<li><a href='/forum?id=$post[id]'><img src='/images/icon/section.png'>$post[name]</a></li><div class='dot-line'></div>";
//echo "<div class='dot-line'></div>";
}
}
echo "</div>";
if($user[prava] >= 5){
echo "<div class='player menuList'>";
echo "<li><a href='/moder_tools/add_forum'><img src='/images/icon/arrow.png'>Создать Раздел</a></li>";
echo "</div>";
}
echo "</div>";
}

Elseif (isset($_GET['id'])){
if ($sub_forum['clan_forum'] == '1'){
include 'include_clan_sub_forum.php';
}
elseif ($sub_forum['clan_forum'] == '0') {
include 'include_sub_forum.php';
}else{
header("Location: /forum");
$_SESSION['err'] = 'Раздел не найден!';
exit();
}
}
Elseif (isset($_GET['parent_id'])){
if ($parent['clan_forum'] == '1') {
include 'include_clan_forum.php';
}elseif ($parent['clan_forum'] == '0') {
include 'include_parent_forum.php';
}else {
header("Location: /forum");
$_SESSION['err'] = 'Раздел не найден!';
exit();
}
}
Include_once '../core/foot.php';
?>