<?php
if ($user['prava'] < 4 && $sub_forum['private_post'] == 1) {
header('Location: /forum');
exit();
}

$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_topic` WHERE `id_razdel` = '$sub_forum[id]'"),0);
$k_page = k_page($k_post,$set['p_str']);
$page = page($k_page);
$start = $set['p_str']*$page-$set['p_str'];
$q = mysql_query("SELECT * FROM `forum_topic` WHERE `id_razdel` = '$sub_forum[id]' AND `verh` = '0' ORDER BY `last_msg_time` DESC LIMIT $start, $set[p_str]");
$p = mysql_query("SELECT * FROM `forum_topic` WHERE `id_razdel` = '$sub_forum[id]' AND `verh` = '1' ORDER BY `last_msg_time` DESC LIMIT $start, $set[p_str]");
if($k_post == 0)echo "<div class='center player grey'>В этом разделе нет топиков!</div><div class='mini-line'></div>";
echo "<div class='player menuList'>";
while($post2 = mysql_fetch_assoc($p)) {
echo '<li><a style="font-weight:bold;" href="/topic?id='.$post2[id].'"><img src="/images/icon/section_new.png">'.rawuridecode($post2[name]).'</a></li>';
echo "<div class='dot-line'></div>";
}
while($post = mysql_fetch_assoc($q)) {
echo '<li><a href="/topic?id='.$post[id].'"><img src="/images/icon/section_new.png">';
if($post[close] == 1){
echo '<span class="grey">'.rawuridecode($post[name]).'</span></a></li>';
}else{
echo ''.rawuridecode($post[name]).'</a></li>';
}
echo "<div class='dot-line'></div>";
} 
echo "</div>";
if ($k_page>1){
str('?',$k_page,$page); // Вывод страниц
echo "<div class='mini-line'></div>";
}
echo "<div class='player menuList'>";

if ($sub_forum['read_only'] == '0' || $sub_forum['parent_properties'] == '1' && $sub_forum_parent['read_only'] == '0' || $user['prava'] >= '4') {
echo "<li><a href='/create_topic?id=$sub_forum[id]'><img src='/images/icon/section_new.png'>Создать новый топик</a></li>";
}
echo '<li><a href="/moderators?forum='.$sub_forum['id'].'"><img src="/images/icon/user.png">Список Модераторов</a></li>';
// Панель "Изменить/Удалить" раздел.
Include 'forum_e_d_panel.php';
if ($sub_forum['type'] == 'public_property' && $sub_forum['sub_forum'] == '0') {
echo "<li><a href='/forum'><img src='/images/icon/section.png'>Вернуться в форум</a></li>";
} else {
echo "<li><a href='/forum?parent_id=$sub_forum[attached_to]'><img src='/images/icon/section.png'>Вернуться к разделам</a></li>";
}
echo "</div>";
?>