<?php
define('ROOT','../');
define('GCMS',true);
require_once (ROOT.'system/power.php');
$diz -> head('Форумы');
$diz -> title('<b>Форум</b>');
//Бан на форуме
$ban = $db -> query("SELECT * FROM `ban` WHERE `iduser` = '".$ya['id']."' and `serius` = 'forum' LIMIT 1");
if ($ban -> num_rows > 0) {
header('location: '.ROOT.'ban.php?mode=forum');
}
require_once (ROOT.'/new_mail.php');
if($aut==true){
$db -> query("UPDATE `online` SET `where` = 'forum' WHERE `login` = '".$ya['login']."'");
}
if ($aut == true) {
$nuts = $db -> dbcount('count(`id`)','nuts',"`user` = '".$ya['id']."' and `where`='forum'");
$msg .= '<div class="tochechki"><b>Мои: </b><a href="./my_tems.php?id='.$ya['id'].'">Темы</a> | <a href="./my_posts.php?id='.$ya['id'].'">Посты</a> | <a href="./my_nuts.php">Закладки</a> (<b>'.$nuts.'</b>)</br>';
$msg .= '<b>Новые: </b><a href="./new_tems.php">Темы</a> | <a href="./new_posts.php">Посты</a></br></div>';
}
$for = $db -> query("SELECT `id`,`name` FROM `forums`  ORDER BY `sid` ASC");
if ($for -> num_rows > 0) {
while ($assoc = $for -> fetch_assoc()) {
                                         $razd = $db -> query("SELECT `id` FROM `forum_razdel` WHERE `forum` = '".$assoc['id']."'");
                                         $gid = 0; $themes = 0; $m = 0; $my_post = 0;
       while ($them = $razd -> fetch_row()) {
                                              $gid = $db -> dbcount('COUNT(`id`)','forum_tems'," `razdel` = '".$them[0]."'");
                                              $themes += $gid;
                                            }
                                            $razd = $db -> query("SELECT * FROM `forum_razdel` WHERE `forum` = '".$assoc['id']."'   ORDER BY `sid` ASC");
                                              while($raz = $razd -> fetch_assoc()){
                                              $my_post = $db -> dbcount('COUNT(`id`)','`forum_posts`',"`razdel` = '".$raz['id']."'");
                                              $m += $my_post;
                                              }
                                            
                                         $msg .= '<div class="new">'.$diz -> img('f.png').'<a href="forum.php?id='.$assoc['id'].'">'.$assoc['name'].'</a> ('.$themes.'/'.$m.')</div>';

if($ya['razopen']=='yes'){
$razd = $db -> query("SELECT * FROM `forum_razdel` WHERE `forum` = '".$assoc['id']."'  ORDER BY `sid` ASC");
$msg.='<div class="fon">';
while($raz = $razd -> fetch_assoc()){
$t = $db -> dbcount('COUNT(*)','forum_tems','`razdel` = '.$raz['id'].'');
$p = $db -> dbcount('COUNT(*)','forum_posts','`razdel` = '.$raz['id'].'');
$msg .= ''.$diz -> img('r.png').'<a href="razdel.php?id='.$raz['id'].'">'.$raz['name'].'</a> ('.$t.'/'.$p.')</br>';
}
$msg.='</div>';
}
}
} else {
$msg .= '<div class="fon">Нет созданных форумов</div>';
}
require_once ('foot.php');
$msg .= '<div class="levo">'.$diz -> img('home.png').'<a href="/index.php">На главную</a></div>';
#####Копирайт#######
require_once (ROOT.'system/kopy.php');
$diz -> out($msg);
?>