Файл: modules/forum/move_topic.php
Строк: 85
<?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'])) {
$new_section = num($_POST['new_section']);
$new_category = mysql_fetch_assoc(mysql_query("SELECT * FROM `cms_forum_sections` WHERE `id` = '$new_section'"));
mysql_query("UPDATE `cms_forum_topics` SET `section_id` = '$new_section', `category_id` = '" . $new_category['category_id'] . "' WHERE `id` = '$ID'");
header("Location: topic.php?id=$ID");
}
/**
* Форма
**/
echo '<div class="main"><form method="post" action="move_topic.php?id=' . $ID . '">' .
$lang_forum['select_new_section'] . ':';
$req = mysql_query("SELECT * FROM `cms_forum_sections` ORDER BY `category_id` ASC");
while ($res = mysql_fetch_assoc($req)) {
$cat = mysql_fetch_assoc(mysql_query("SELECT * FROM `cms_forum_categories` WHERE `id` = '" . $res['category_id'] . "'"));
echo '<br /><input type="radio" name="new_section" value="' . $res['id'] . '" ' . ($res['id'] == $topic['section_id'] ? 'checked="checked" ' : '') . '/> ' . $cat['name'] . ' / <b>' . $res['name'] . '</b>';
}
echo '<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();
?>