Файл: modules/forum/index.php
Строк: 245
<?php
/* DCMS Special
* Дата последнего редактирования 11.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 "<ol class='breadcrumb'>";
echo "<li><a href='/'><span class='fa fa-home fa-fw'></span></a></li>";
echo "<li class='active'>Форум</li>";
echo "</ol>";
echo "<div class='list-group-item' 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='Создать подфорум'><span class='fa fa-plus fa-fw'></span></span></a>";
}
echo "<a data-toggle='modal' data-target='#menu_forum' href='/?users_set'><span style='padding: 10px;' data-toggle='tooltip' data-placement='left' title='Выберите действие'><span class='fa fa-ellipsis-v fa-lg'></span></span></a>";
} else {
if (access('forum_for_create')) {
echo "<a data-toggle='modal' data-target='#forum_add' href='" . DIR_FORUM . "?create_forum'><span title='Создать подфорум'><span class='fa fa-plus fa-fw'></span></span></a>";
}
echo "<a data-toggle='modal' data-target='#menu_forum' href='/?users_set'><span style='padding: 10px;' title='Выберите действие'><span class='fa fa-ellipsis-v fa-lg'></span></span></a>";
}
echo "</span></div>n";
echo "Форум</div>n";
#Всплывающее меню
echo "<div class='modal fade' id='forum_add' tabindex='-1' role='dialog' aria-labelledby='mySmallModalLabel' 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' id='exampleModalLabel'>Новый подфорум</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 "Название подфорума (40 символов):<br />";
echo "<input type='text' class='form-control' name='name' value='' />";
echo "Описание подфорума (100 символов):<br />";
echo "<textarea class='form-control' name='description'></textarea>";
echo "Позиция: <br />";
echo "<input type='text' class='form-control' name='number' value='$next_number' />";
echo "<div class='hr'></div>";
echo "Доступ:<br />";
echo "<label class='c-input c-radio'><input type='radio' name='access' value='0' checked='checked' /><span class='c-indicator'></span> Все</label><br />";
echo "<label class='c-input c-radio'><input type='radio' name='access' value='1' /><span class='c-indicator'></span> Только администраторы</label><br />";
echo "<label class='c-input c-radio'><input type='radio' name='access' value='2' /><span class='c-indicator'></span> Администраторы + модераторы</label>";
echo "<div class='hr'></div>";
echo "Вывод подфорума:<br />";
echo "<label class='c-input c-checkbox'><input type='checkbox' name='output' value='1' /><span class='c-indicator'></span> Отображать список разделов вместо описания</label><br />";
echo "<div class='hr'></div>";
echo "<button name='create' class='btn btn-success'>Создать</button> ";
echo "<button name='cancel' class='btn btn-secondary'>Отменить</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-labelledby='mySmallModalLabel' 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' id='exampleModalLabel'>Меню форума</h5>";
echo "</div>";
echo "<div class='list-group' style='margin-top: -1px;'>";
echo "<a href='" . DIR_FORUM . "search.html' class='list-group-item'><span class='fa fa-search fa-fw'></span> Поиск</a>n";
echo "<a href='" . DIR_FORUM . "new_themes.html' class='list-group-item'><span class='fa fa-asterisk fa-fw'></span> Новые темы <span class='label label-info pull-right'>$new_themes</span></a>n";
if (isset($user)) {
echo "<a href='" . DIR_FORUM . "my_themes.html' class='list-group-item'><span class='fa fa-user fa-fw'></span> Мои темы <span class='label label-info pull-right'>$my_themes</span></a>n";
echo "<a href='" . DIR_FORUM . "journal.php' class='list-group-item'><span class='fa fa-bell fa-fw'></span> Уведомления <span class='label label-info pull-right'>$f_journal $new_journal</span></a>n";
}
if (access('forum_them_edit')) {
echo "<a href='" . DIR_FORUM . "reports.html' class='list-group-item'><span class='fa fa-flag fa-fw'></span> Жалобы на темы <span class='label label-info pull-right'>$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'>n";
echo "<span class='fa fa-info-circle fa-fw'></span> Нет результатов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'>n";
echo "<a href='" . DIR_FORUM . "$forum->id/'><span class='fa fa-folder fa-fw'></span> " . 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'><span class='fa fa-pencil-square-o fa-fw'></span></a>" : null) . " <span class='label label-primary pull-right'>$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/'> <span class='fa fa-folder-open fa-fw'></span> " . 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';