Файл: modules/forum/rename_topic.php
Строк: 83
<?php
/****
* @package LiveCMS
* @link livecms.org
* @author MyZik
* @version See attached file VERSION.txt
* @license See attached file LICENSE.txt
* @copyright Copyright (C) LiveCMS Development Team
****/
ob_start();
$lang_forum = load_lng('forum'); // Подключаем файл языка
$title = $lang_forum['forum']; // Заголовок страницы
$module = 'forum'; // Модуль
/**
* Проверка наличия авторизации
**/
if (!isset($user)) {
require_once(HOME .'/incfiles/header.php');
echo '<div class="error">' . $lang['only_users'] . '</div>';
echo '<div class="home">' .
'<img src="/design/themes/' . $set_user['theme'] . '/images/back.png" alt="" /> <a href="/index.php">' . $lang['back'] . '</a>' .
'</div>';
require_once(HOME .'/incfiles/footer.php');
}
/**
* Проверяем, задан ли параметр
**/
if (!isset($_GET['id']) || empty($_GET['id']) || !is_numeric($_GET['id'])) {
require_once(HOME .'/incfiles/header.php');
echo '<div class="error">' . $lang['error_parameter'] . '</div>';
echo '<div class="home">' .
'<img src="/design/themes/' . $set_user['theme'] . '/images/back.png" alt="" /> <a href="index.php">' . $lang['back'] . '</a>' .
'</div>';
require_once(HOME .'/incfiles/footer.php');
}
/**
* Проверяем наличие темы
**/
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_forum_topics` WHERE `id` = '" . num($_GET['id']) . "'"), 0) == 0) {
require_once(HOME .'/incfiles/header.php');
echo '<div class="error">' . $lang_forum['topic_not_exists'] . '</div>';
echo '<div class="home">' .
'<img src="/design/themes/' . $set_user['theme'] . '/images/back.png" alt="" /> <a href="index.php">' . $lang['back'] . '</a>' .
'</div>';
require_once(HOME .'/incfiles/footer.php');
}
$ID = num($_GET['id']);
$topic = mysql_fetch_assoc(mysql_query("SELECT * FROM `cms_forum_topics` WHERE `id` = '$ID' LIMIT 1"));
$section = mysql_fetch_assoc(mysql_query("SELECT * FROM `cms_forum_sections` WHERE `id` = '" . $topic['section_id'] . "' LIMIT 1"));
$category = mysql_fetch_assoc(mysql_query("SELECT * FROM `cms_forum_categories` WHERE `id` = '" . $topic['category_id'] . "' LIMIT 1"));
$user_topic = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '" . $topic['author_id'] . "' LIMIT 1"));
/**
* Проверяем права доступа
**/
if (($user['rights'] == 3 || $user['rights'] >= 7) && ($user_topic['rights'] <= $user['rights'])) {
require_once(HOME .'/incfiles/header.php'); // Подключаем шапку
/**
* Небольшая панель навигации
**/
echo '<div class="title"><a href="/forum/">' . $lang['forum'] . '</a> | <a href="category.php?id=' . $category['id'] . '">' . txt($category['name']) . '</a> | <a href="section.php?id=' . $section['id'] . '">' . txt($section['name']) . '</a></div>';
if (isset($_POST['save'])) {
$name = input(mb_substr($_POST['name'], 0, 60));
/**
* Проверяем длину названия темы
**/
if (strlen($name) < 2)
$err[] = $lang_forum['short_name_topic'];
/**
* Проверяем, есть ли тема с таким названием в этом разделе
**/
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_forum_topics` WHERE `name` = '$name' AND `section_id` = '$ID'"), 0) != 0)
$err[] = $lang_forum['topic_name_exists'];
/**
* Если нет ошибок, заносим данные
**/
if (!isset($err)) {
mysql_query("UPDATE `cms_forum_topics` SET `name` = '$name' WHERE `id` = '$ID'");
header("Location: topic.php?id=$ID");
} else {
echo error($err); // Выводим ошибки
}
}
/**
* Форма
**/
echo '<div class="main"><form method="post" action="rename_topic.php?id=' . $ID . '">' .
$lang_forum['new_topic_name'] . ':<br />' .
'<input type="text" name="name" value="' . $topic['name'] . '" /><br />' .
'<input type="submit" name="save" value="' . $lang['save'] . '" />' .
'</form></div>';
require_once(HOME .'/incfiles/footer.php'); // Подключаем ноги
} else {
header("Location: topic.php?id=$ID");
}
ob_end_flush();
?>