Файл: modules/forum/view/forum.php
Строк: 220
<?php
/* DCMS Special
* Дата последнего редактирования 18.12.2015
* Модифицировал densnet
* Автор yadalay
*/
$forum = mysql_fetch_object(mysql_query('SELECT * FROM `forum` WHERE `id` = ' . intval($_GET['forum'])));
if (!$forum || ($forum->access == 1 && $user['group_access'] < 8) || ($forum->access == 2 && $user['group_access'] < 3)) {
header('Location: ' . DIR_FORUM);
exit;
} else {
$set['title'] = (isset($_GET['create_razdel'])) ? toOutput($forum->name, 1, 1, 0, 0, 0) . ' - Создание раздела' : 'Подфорум - ' . toOutput($forum->name, 1, 1, 0, 0, 0);
if (isset($_GET['create_razdel'])) {
require_once 'action/create_razdel.php'; #Создание раздела.
} elseif (isset($_GET['edit_razdel'])) {
require_once 'action/edit_razdel.php'; #Редактирование раздела.
}
if (isset($_SESSION['msg'])) {
echo $_SESSION['msg'];
unset($_SESSION['msg']);
}
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 "<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'>" . toOutput($forum->name, 1, 1, 0, 0, 0) . "</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='#add_razdel' href='/?users_set'><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='#add_razdel' href='/?users_set'><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='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";
echo "<div class='modal fade' id='add_razdel' 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_razdels` WHERE `id_forum` = ' . $forum->id), 0) + 1;
echo "<form action='" . DIR_FORUM . "$forum->id/create_razdel.html' style='margin-top: -1px;' class='list-group-item' method='post'>";
echo "<div class='row'>";
echo "<div class='input-field col s12'>";
echo "<input id='name' name='name' length='40' 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 "<div class='switch'>";
echo "Могут создавать темы только:<br />";
echo "<label><input type='checkbox' name='type' value='1'><span class='lever'></span>Администраторы + модераторы</label>";
echo "</div>";
echo "<div class='hr'></div>";
echo "<div class='switch'>";
echo "Вывод раздела:<br />";
echo "<label><input type='checkbox' name='output' value='1'><span class='lever'></span>Отображать посл. 3 темы</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";
$k_post = mysql_result(mysql_query('SELECT COUNT(*) FROM `forum_razdels` WHERE `id_forum` = ' . $forum->id), 0);
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
if ($k_post == 0) {
echo "<div class='list-group-item'>";
echo "<i class='material-icons'>feedback</i> Нет результатов";
echo "</div>";
} else {
$razdels = mysql_query('SELECT * FROM `forum_razdels` WHERE `id_forum` = ' . $forum->id . ' ORDER BY `number` ASC LIMIT ' . $start . ', ' . $set['p_str']);
while ($razdel = mysql_fetch_object($razdels)) {
$count_themes = mysql_result(mysql_query('SELECT COUNT(*) FROM `forum_themes` WHERE `id_razdel` = ' . $razdel->id), 0);
echo "<div class='list-group-item' style='margin-top: 5px;margin-bottom: 5px;'>n";
echo "<a href='" . DIR_FORUM . "$forum->id/$razdel->id/'><i class='material-icons'>folder</i> " . toOutput($razdel->name, 1, 1, 0, 0, 0) . "</a> " . (access('forum_for_edit') ? "<a href='" . DIR_FORUM . "$forum->id/$razdel->id/edit_razdel.html' title='Редактировать' data-toggle='tooltip' data-placement='top'><i class='material-icons'>border_color</i></a>" : null) . " <span class='badge'>$count_themes</span>";
if ($razdel->description != NULL && $razdel->output == 0) {
echo "<br /><small style='color: #9197a3;'>" . toOutput($razdel->description, 1, 1, 0, 1, 1) . "</small>";
} elseif ($razdel->output == 1 && $count_themes > 0) {
$themes = mysql_query('SELECT `id`, `name`, `reason_close`, `type` FROM `forum_themes` WHERE `id_razdel` = ' . $razdel->id . ' ORDER BY `time` DESC LIMIT 3');
while ($theme = mysql_fetch_object($themes)) {
if ($theme->type == 1) {
$type = '_up';
} elseif ($theme->reason_close != NULL) {
$type = '_close';
} else {
$type = NULL;
}
echo "<br /><a href='" . DIR_FORUM . "$forum->id/$razdel->id/$theme->id.html'> <i class='material-icons'>description</i> " . toOutput($theme->name, 1, 1, 0, 0, 0) . "</a>";
}
}
echo "</div>";
}
if ($k_page > 1) {
echo "<div class='list-group-item'>";
str(DIR_FORUM . $forum->id . '/', $k_page, $page);
echo "</div>";
}
}
}