<?php
require_once('../classes/body.class.php');
require_once('../classes/db.class.php');
require_once('../classes/system.class.php');
$title= new Body;
$id = isset($_GET['id']) ? abs((int)$_GET['id']) : false;
$do = isset($_GET['do']) ? check($_GET['do']) : false;
$array = DB::$dbs->query("SELECT * FROM forum_razdel WHERE id = ? LIMIT 1", [$id]);
if ($array -> rowCount() == 0) {
header('location: /');
die();
}
$arr = $array -> fetch();
$title->SetTitle($arr['name'].' - Форум');
$title->GetHeader();
switch($do) {
default:
echo'<div class="tile"><div class="t-header th-alt bg-teal"><div class="th-title"><i class="zmdi zmdi-widgets"></i><a href="/"style="text-decoration:none; color:white;"> Главная</a> :: Форум</div></div></div>';
echo'<div class="list-group-item media"><span class="label label-danger">Новые</span> <a href="newtheme.php">Темы</a> | <a href="newposts.php">Сообщения</a></br>';
if (isset($b)) {
echo'</br><span class="label label-danger">Мои</span> <a href="user_thems.php?id='.$b['id'].'">Темы</a> | <a href="user_posts.php?id='.$b['id'].'">Сообщения</a> | <a href="podpis.php">Наблюдаемые</a>';
}
echo'</div>';
echo'<div class="tile"><div class="t-header th-alt bg-teal"><div class="th-title"><i class="zmdi zmdi-widgets"></i><a href="/forum"style="text-decoration:none; color:white;"> Форум</a> :: '.$arr['name'].'</div></div></div>';
if ($b['level'] > 2) {
echo '<div class="list-group-item media"><span class="label label-danger">Новый</span> <a href="?do=add&id='.$id.'"> Добавить подраздел</a> </div>';
}
echo'<div class="t-body"><div class="list-group lg-alt">';
$sql = DB::$dbs->query("SELECT * FROM forum_prazdel WHERE rid = ? ORDER BY id ASC", [$id]);
if ($sql -> rowCount() == 0) {
err('Подразделы ещё не созданы!');
} else {
while($a = $sql->fetch()) {
echo '<a href="viewthem.php?id='.$a['id'].'" class="list-group-item media"><div class="pull-left"><img class="img-circle pull-left" src="/assets/img/2.jpg" alt="" width="40" height="40"></div><div class="media-body"><div class="list-group-item-heading">'.$a['name'].'</div><small class="list-group-item-text">Топиков: '.DB::$dbs->querySingle("SELECT COUNT(id) FROM forum_topic WHERE prid = ?", [$a['id']]).' :: Сообщений: '.DB::$dbs->querySingle("SELECT COUNT(id) FROM forum_mess WHERE prid = ?", [$a['id']]).'</small></div></a>';
}
}
break;
case 'add':
echo'<div class="tile"><div class="t-header th-alt bg-teal"><div class="th-title"><i class="zmdi zmdi-widgets"></i><a href="/"style="text-decoration:none; color:white;"> Главная</a> :: Форум</div></div></div>';
echo'<div class="list-group-item media"><span class="label label-danger">Новые</span> <a href="newtheme.php">Темы</a> | <a href="newposts.php">Сообщения</a></br>';
if (isset($b)) {
echo'</br><span class="label label-danger">Мои</span> <a href="user_thems.php?id='.$b['id'].'">Темы</a> | <a href="user_posts.php?id='.$b['id'].'">Сообщения</a> | <a href="podpis.php">Наблюдаемые</a>';
}
echo'</div>';
echo'<div class="tile"><div class="t-header th-alt bg-teal"><div class="th-title"><i class="zmdi zmdi-widgets"></i><a href="/forum"style="text-decoration:none; color:white;"> Форум</a> :: '.$arr['name'].' :: Новый раздел</div></div></div>';
if ($b['level'] < 2) {
header('location: /');
die();
}
$array = DB::$dbs->query("SELECT * FROM forum_razdel WHERE id = ? LIMIT 1", [$id]);
if ($array -> rowCount() == 0) {
header('location: /');
die();
}
$arr = $array -> fetch();
if (isset($_POST['add'])) {
if (empty($_POST['name'])) {
err('Введите название!');
} else {
DB::$dbs->query("INSERT INTO forum_prazdel SET name = ?, rid = ?", [check($_POST['name']),$id]);
header('location: /forum/viewrazd.php?id='.$id);
}
}
echo '<div class="list-group-item media"><form action="?do=add&id='.$id.'" method="POST">Название:<br/> <input class="form-control" type="text" name="name"/><br/><input type="submit" class="btn btn-primary" name="add" value="Добавить"/></form></div>';
break;
}
echo'<div class="tile"><div class="t-header th-alt bg-teal"><div class="th-title"><i class="zmdi zmdi-format-list-bulleted"></i> <a href="/rules"style="text-decoration:none; color:white;">Правила</a> | <a href="/bbcodes"style="text-decoration:none; color:white;"> Справка BBcode</a> | <a href="/smiles"style="text-decoration:none; color:white;">Все смайлы</a> | <a href="search"style="text-decoration:none; color:white;">Поиск</a></div></div></div>';
$title->GetMenu();
$title->GetFooter();
?>