Файл: modules/forum/index.php
Строк: 254
<?php
/* DCMS Special
* Дата последнего редактирования 18.12.2015
* Модифицировал densnet
* Автор yadalay
*/
foreach (array('start', 'compress', 'sess', 'settings', 'db_connect', 'ipua', 'fnc', 'user') as $inc) {
require_once "../../sys/inc/{$inc}.php";
}
mb_internal_encoding('UTF-8');
#Константа облегчает ситуацию с перемещением папки в другие разделы сайта, меньше надо будет путь менять
#Путь к папке форума
define('DIR_FORUM', '/modules/forum/');
define('DIR_FORUM_FILES', '/modules/forum/files/');
$menu = (isset($_GET['menu'])) ? htmlspecialchars($_GET['menu']) : null;
require_once H . 'sys/inc/thead.php';
aut();
switch ($menu) {
default:
if (isset($_GET['create_forum'])) {
require_once 'action/create_forum.php'; #Создание подфорума.
} elseif (isset($_GET['edit_forum'])) {
require_once 'action/edit_forum.php'; #Редактирование подфорума.
}
if (isset($_SESSION['msg'])) {
echo $_SESSION['msg'];
unset($_SESSION['msg']);
}
$set['title'] = (isset($_GET['create_forum'])) ? 'Форум - Создание подфорума' : 'Форум';
$k_post = mysql_result(mysql_query('SELECT COUNT(*) FROM `forum`'), 0);
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
if (isset($user)) {
$new_journal = '+' . mysql_result(mysql_query('SELECT COUNT(*) FROM `f_journal` WHERE `read` = "0" AND `id_user` = ' . $user['id']), 0) . "";
$f_journal = mysql_result(mysql_query('SELECT COUNT(*) FROM `f_journal` WHERE `id_user` = ' . $user['id']), 0);
$my_themes = (isset($user)) ? mysql_result(mysql_query('SELECT COUNT(*) FROM `forum_themes` WHERE `id_user` = ' . $user['id']), 0) : NULL;
}
$new_themes = mysql_result(mysql_query('SELECT COUNT(*) FROM `forum_themes` WHERE `time` > ' . (time() - 60 * 60 * 24)), 0);
$reports = mysql_result(mysql_query('SELECT COUNT(*) FROM `forum_reports`'), 0);
#Навигация
echo "<nav class='navbar navbar-light' style='background-color: #607D8B; color: #fff;'>";
echo "<ul class='nav navbar-nav'>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='/'><i class='material-icons'>home</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'><i class='material-icons'>keyboard_arrow_right</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='" . DIR_FORUM . "'>Форум</a></li>";
echo "</ul>";
echo "</nav>";
echo "<div class='card-header' style='color: grey;'><div class='bd-example'><span style='float: right;'>n";
#Кнопка меню действий
if (IS_WEB) {
if (access('forum_for_create')) {
echo "<a data-toggle='modal' data-target='#forum_add' href='" . DIR_FORUM . "?create_forum'><span data-toggle='tooltip' data-placement='left' title='Создать подфорум'><i class='material-icons'>playlist_add</i></span></a>";
}
echo "<a data-toggle='modal' data-target='#menu_forum' href='/?users_set'><span style='padding-left: 10px;' data-toggle='tooltip' data-placement='left' title='Выберите действие'><i class='material-icons'>more_vert</i></span></a>";
} else {
if (access('forum_for_create')) {
echo "<a data-toggle='modal' data-target='#forum_add' href='" . DIR_FORUM . "?create_forum'><span title='Создать подфорум'><i class='material-icons'>playlist_add</i></span></a>";
}
echo "<a data-toggle='modal' data-target='#menu_forum' href='/?users_set'><span style='padding-left: 10px;' title='Выберите действие'><i class='material-icons'>more_vert</i></span></a>";
}
echo "</span></div>n";
echo "Форум</div>n";
#Всплывающее меню
echo "<div class='modal fade' id='forum_add' tabindex='-1' role='dialog' aria-hidden='true'>n";
echo "<div class='modal-dialog'>n";
echo "<div class='modal-content'>n";
echo "<div class='modal-header'>n";
echo "<button type='button' class='close' data-dismiss='modal' aria-label='Close'>";
echo "<span aria-hidden='true'>×</span>";
echo "<span class='sr-only'>Close</span>";
echo "</button>";
echo "<h5 class='modal-title'>Новый подфорум</h5>";
echo "</div>";
if (access('forum_for_create')) {
$next_number = mysql_result(mysql_query('SELECT MAX(`number`) FROM `forum`'), 0) + 1;
echo "<form class='list-group-item' style='margin-top: -1px;' action='" . DIR_FORUM . "?create_forum' method='post'>";
echo "<div class='row'>";
echo "<div class='input-field col s12'>";
echo "<input id='name' name='name' length='100' type='text' value='' class='validate'>";
echo "<label for='name'>Название подфорума</label>";
echo "</div>";
echo "</div>";
echo "<div class='row'>";
echo "<div class='input-field col s12'>";
echo "<textarea name='description' id='description' length='100' class='materialize-textarea'></textarea>";
echo "<label for='description'>Описание подфорума</label>";
echo "</div>";
echo "</div>";
echo "<div class='row'>";
echo "<div class='input-field col s12'>";
echo "<input id='number' name='number' type='text' value='$next_number' class='validate'>";
echo "<label for='number'>Позиция</label>";
echo "</div>";
echo "</div>";
echo "Доступ:<br />";
echo "<input class='with-gap' name='access' type='radio' checked='checked' id='access0' value='0' /><label for='access0'>Все</label><br />";
echo "<input class='with-gap' name='access' type='radio' id='access1' value='1' /><label for='access1'>Только администраторы</label><br />";
echo "<input class='with-gap' name='access' type='radio' id='access2' value='2' /><label for='access2'>Администраторы + модераторы</label>";
echo "<div class='hr'></div>";
echo "<div class='switch'>";
echo "<label><input type='checkbox' name='output' value='1'><span class='lever'></span>Список разделов</label>";
echo "</div>";
echo "<div class='hr'></div>";
echo "<button name='create' class='waves-effect waves-light btn'>Создать</button> ";
echo "<button name='cancel' class='btn btn-secondary waves-effect waves-light'>Отменить</button>";
echo "</form>";
}
echo "</div>n";
echo "</div>n";
echo "</div>n";
#Меню форума
echo "<div class='modal fade' id='menu_forum' tabindex='-1' role='dialog' aria-hidden='true'>n";
echo "<div class='modal-dialog'>n";
echo "<div class='modal-content'>n";
echo "<div class='modal-header'>n";
echo "<button type='button' class='close' data-dismiss='modal' aria-label='Close'>";
echo "<span aria-hidden='true'>×</span>";
echo "<span class='sr-only'>Close</span>";
echo "</button>";
echo "<h5 class='modal-title'>Меню форума</h5>";
echo "</div>";
echo "<div class='collection' style='margin-top: -1px;margin-bottom: -1px;'>";
echo "<a href='" . DIR_FORUM . "search.html' class='collection-item'><i class='material-icons left'>search</i> Поиск</a>n";
echo "<a href='" . DIR_FORUM . "new_themes.html' class='collection-item'><i class='material-icons left'>fiber_new</i> Новые темы <span class='badge'>$new_themes</span></a>n";
if (isset($user)) {
echo "<a href='" . DIR_FORUM . "my_themes.html' class='collection-item'><i class='material-icons left'>rate_review</i> Мои темы <span class='badge'>$my_themes</span></a>n";
echo "<a href='" . DIR_FORUM . "journal.php' class='collection-item'><i class='material-icons left'>notifications</i> Уведомления <span class='badge'>$f_journal $new_journal</span></a>n";
}
if (access('forum_them_edit')) {
echo "<a href='" . DIR_FORUM . "reports.html' class='collection-item'><i class='material-icons left'>assistant_photo</i> Жалобы на темы <span class='badge'>$reports</span></a>n";
}
echo "</div>n";
echo "</div>n";
echo "</div>n";
echo "</div>n";
#---------------------#
if ($k_post == 0) {
echo "<div class='list-group-item' style='margin-top: 5px;margin-bottom: 5px;'>n";
echo "<i class='material-icons'>feedback</i> Нет результатовn";
echo "</div>n";
} else {
$forums = mysql_query('SELECT * FROM `forum` ORDER BY `number` ASC LIMIT ' . $start . ', ' . $set['p_str']);
while ($forum = mysql_fetch_object($forums)) {
if ($forum->access == 0 || ($forum->access == 1 && $user['group_access'] > 7) || ($forum->access == 2 && $user['group_access'] > 2)) {
$count_razdels = mysql_result(mysql_query('SELECT COUNT(*) FROM `forum_razdels` WHERE `id_forum` = ' . $forum->id), 0);
$count_themes = mysql_result(mysql_query('SELECT COUNT(*) FROM `forum_themes` WHERE `id_forum` = ' . $forum->id), 0);
echo "<div class='list-group-item' style='margin-top: 5px;margin-bottom: 5px;'>n";
echo "<a href='" . DIR_FORUM . "$forum->id/'><i class='material-icons'>folder</i> " . toOutput($forum->name, 1, 1, 0, 0, 0) . "</a> " . (access('forum_for_edit') ? "<a href='" . DIR_FORUM . "?edit_forum=$forum->id' title='Редактировать' data-toggle='tooltip' data-placement='top'><i class='material-icons'>border_color</i></a>" : null) . " <span class='badge'>$count_razdels/$count_themes</span><br />";
#Выводим описание подфорума и разделы (если включены)
if ($forum->description != NULL && $forum->output == 0) {
echo "<small style='color: #9197a3;'>" . toOutput($forum->description, 1, 1, 0, 1, 1) . "</small>n";
} elseif ($forum->output == 1 && $count_razdels > 0) {
$razdels = mysql_query('SELECT `id`, `name` FROM `forum_razdels` WHERE `id_forum` = ' . $forum->id);
while ($razdel = mysql_fetch_object($razdels)) {
echo "<a href='" . DIR_FORUM . "$forum->id/$razdel->id/'> <i class='material-icons'>folder_open</i> " . toOutput($razdel->name) . "</a><br />n";
}
}
echo "</div>n";
}
}
if ($k_page > 1) {
echo "<div class='list-group-item'>n";
str('?', $k_page, $page);
echo "</div>n";
}
}
break;
case 'forum':
require_once 'view/forum.php'; #Подфорум.
break;
case 'razdel':
require_once 'view/razdel.php'; #Раздел.
break;
case 'theme':
require_once 'view/theme.php'; #Тема.
break;
case 'who':
require_once 'view/who.php'; #Кто в теме.
break;
case 'files':
require_once 'view/files_theme.php'; #Файлы темы.
break;
case 'add_file':
require_once 'action/add_file_post.php'; #Добавление файла.
break;
case 'reports':
require_once 'view/reports.php'; #Жалобы на темы.
break;
case 'new_themes':
require_once 'view/new_themes.php'; #Новые темы.
break;
case 'my_themes':
require_once 'view/my_themes.php'; #Новые темы.
break;
case 'search':
require_once 'view/search.php'; #Поиск по форуму.
break;
}
require_once H . 'sys/inc/tfoot.php';