Файл: modules/forum/action/edit_theme.php
Строк: 140
<?php
/* DCMS Special
* Дата последнего редактирования 19.12.2015
* Модифицировал densnet
* Автор yadalay
*/
if (!access('forum_them_edit') && $user['id'] != $theme->id_user) {
header('Location: ' . DIR_FORUM . $forum->id . '/' . $razdel->id . '/' . $theme->id . '.html');
exit;
} else {
if (isset($_POST['save'])) {
$name = mysql_real_escape_string(trim($_POST['name']));
$description = mysql_real_escape_string(trim($_POST['description']));
$type = ($user['group_access'] > 7 && isset($_POST['type'])) ? 1 : 0;
$razdel_id = intval($_POST['razdel']);
$forum_id = mysql_fetch_object(mysql_query('SELECT `id_forum` FROM `forum_razdels` WHERE `id` = ' . $razdel_id))->id_forum;
if (mb_strlen($name) < 3 || mb_strlen($name) > 40) {
echo "<div class='alert alert-danger'>В поле 'Название темы' можно использовать от 3 до 40 символов.</div>";
} elseif (mb_strlen($description) < 3) {
echo "<div class='alert alert-danger'>Слишком короткое содержание темы.</div>";
} else {
$_SESSION['success'] = '<div class="alert alert-success">Тема успешно изменена.</div>';
mysql_query('UPDATE `forum_themes` SET `id_forum` = ' . $forum_id . ', `id_razdel` = ' . $razdel_id . ', `id_admin` = ' . $user['id'] . ', `name` = "' . $name . '", `description` = "' . $description . '", `type` = ' . $type . ', `time_edit` = "' . $time . '" WHERE `id` = ' . $theme->id);
header('Location: ' . DIR_FORUM . $forum->id . '/' . $razdel->id . '/' . $theme->id . '.html');
exit;
}
} elseif (isset($_POST['delete']) && (access('forum_them_del'))) {
admin_log('Форум', 'Темы', 'Тема "' . $theme->name . '" была удалена из раздела "' . $razdel->name . '".');
$files = mysql_query('SELECT `name` FROM `forum_post_files` WHERE `id_theme` = ' . $theme->id);
while ($file = mysql_fetch_object($files)) {
unlink(DIR_FORUM_FILES . $file->name);
}
$votes = mysql_query('SELECT `id` FROM `forum_votes` WHERE `id_theme` = ' . $theme->id);
while ($vote = mysql_query($votes)) {
mysql_query('DELETE FROM `forum_vote_voices` WHERE `id_vote` = ' . $vote->id);
}
mysql_query('DELETE FROM `forum_votes` WHERE `id_theme` = ' . $theme->id);
mysql_query('DELETE FROM `forum_post_rating` WHERE `id_theme` = ' . $theme->id);
mysql_query('DELETE FROM `forum_posts` WHERE `id_theme` = ' . $theme->id);
mysql_query('DELETE FROM `forum_post_files` WHERE `id_theme` = ' . $theme->id);
mysql_query('DELETE FROM `forum_votes_var` WHERE `id_theme` = ' . $theme->id);
mysql_query('DELETE FROM `forum_themes` WHERE `id` = ' . $theme->id);
$_SESSION['msg'] = '<div class="alert alert-success">Тема успешно удалена.</div>';
header('Location: ' . DIR_FORUM . $forum->id . '/' . $razdel->id . '/');
exit;
}
#Навигация
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' href='" . DIR_FORUM . "$forum->id/'>" . toOutput($forum->name, 1, 1, 0, 0, 0) . "</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 . "$forum->id/$razdel->id/'>" . toOutput($razdel->name, 1, 1, 0, 0, 0) . "</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 . "$forum->id/$razdel->id/$theme->id.html'>" . toOutput($theme->name, 1, 0, 0, 0, 0) . "</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'>Редактирование</a></li>";
echo "</ul>";
echo "</nav>";
echo "<form action='" . DIR_FORUM . "$forum->id/$razdel->id/$theme->id/edit_theme.html' class='list-group-item' method='post'>";
echo "<div class='row'>";
echo "<div class='input-field col s12'>";
echo "<input id='name' name='name' length='100' type='text' value='$theme->name' 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='10024' class='materialize-textarea'>$theme->description</textarea>";
echo "<label for='description'>Содержание темы</label>";
echo "</div>";
echo "</div>";
echo "Категория:<br />";
echo "<select class='browser-default' name='razdel'>";
$forums = mysql_query('SELECT `id`, `name`, `access` FROM `forum`');
while ($forum_s = mysql_fetch_object($forums)) {
if ($forum_s->access == 0 || ($forum_s->access == 1 && $user['group_access'] > 7) || ($forum_s->access == 2 && $user['group_access'] > 2)) {
echo "<option disabled='disabled'><b>$forum_s->name</b></option>";
$razdels = mysql_query('SELECT `id`, `name` FROM `forum_razdels` WHERE `id_forum` = ' . $forum_s->id);
while ($cat = mysql_fetch_object($razdels)) {
echo "<option value='$cat->id' " . (($cat->id == $theme->id_razdel) ? 'selected = "selected"' : NULL) . ">>> $cat->name</option>";
}
} else {
continue;
}
}
echo "</select>";
if ($user['group_access'] > 7) {
echo "<div class='switch'>";
echo "Вывод темы в разделе:<br />";
echo "<label><input type='checkbox' name='type' value='1' " . (($theme->type == 1) ? 'checked="checked"' : NULL) . "><span class='lever'></span>Тема всегда вверху</label>";
echo "</div>";
}
echo "<div class='hr'></div>";
echo "<button name='save' class='btn waves-effect waves-light'><i class='material-icons'>save</i> Сохранить</button> ";
if (access('forum_them_del')) {
echo "<button name='delete' class='btn waves-effect waves-light btn-danger'><i class='material-icons'>delete</i> Удалить тему</button>";
}
echo "</form>";
require_once H . 'sys/inc/tfoot.php';
exit;
}