Файл: soc-set/moduls/forum/transfer.php
Строк: 41
<?php
require_once('../../core/start.php');
check_auth();
$theme = DB::$dbs->queryFetch("SELECT * FROM ".FORUMS_THEME." WHERE `id` = ? ", array(abs(num($_GET['theme']))));
if (empty($theme)) {
head('Тема не найдена');
echo DIV_TITLE . 'Тема не найдена' . CLOSE_DIV;
echo DIV_ERROR . 'Ошибка!' . CLOSE_DIV;
echo DIV_GO . '<a href="'.HOME.'/">Главная</a> / <a href="'.HOME.'/forum/">Форум</a> / <b>Тема не найдена</b>' . CLOSE_DIV;
require_once('../../core/stop.php');
exit();
}
if (privilegy('forum_moder') == FALSE) {
head('Ошибка доступа');
echo DIV_TITLE . 'Ошибка доступа' . CLOSE_DIV;
echo DIV_ERROR . 'Ошибка!' . CLOSE_DIV;
echo DIV_GO . '<a href="'.HOME.'/">Главная</a> / <a href="'.HOME.'/forum/">Форум</a> / <b>Ошибка доступа</b>' . CLOSE_DIV;
require_once('../../core/stop.php');
exit();
}
head('Перенос темы: ' . $theme['name']);
panel();
if (!empty($_POST['send'])) {
$id = abs(num($_POST['forumc']));
if (DB::$dbs->querySingle("SELECT COUNT(`id`) FROM ".FORUMS_CAT." WHERE `id` = ?", array($id)) == TRUE) {
/* Старое расположение */
$forum = DB::$dbs->queryFetch("SELECT * FROM ".FORUMS." WHERE `id` = ? ", array($theme['forum_id']));
$forumc = DB::$dbs->queryFetch("SELECT * FROM ".FORUMS_CAT." WHERE `id` = ? ", array($theme['forumc_id']));
/* */
/* Новое расположение */
$forumc_new = DB::$dbs->queryFetch("SELECT * FROM ".FORUMS_CAT." WHERE `id` = ? ", array($id));
$forum_new = DB::$dbs->queryFetch("SELECT * FROM ".FORUMS." WHERE `id` = ? ", array($forumc_new['forum_id']));
/* */
DB::$dbs->query("UPDATE ".FORUMS_THEME." SET `forum_id` = ?, `forumc_id` = ? WHERE `id` = ? ", array($forumc_new['forum_id'], $forumc_new['id'], $theme['id']));
/* Формируем сообщение о переносе */
$msg = 'Тема перенесена из подфорума <b>' . $forum['name'] . '/' . $forumc['name'] . '</b> в <b>' . $forum_new['name'] . '/' . $forumc_new['name'] . '</b>';
DB::$dbs->query("INSERT INTO ".FORUM_POST." (`forum_id`, `forumc_id`, `theme_id`, `msg`, `user_id`, `time`, `file`, `ct`) VALUES
(?,?,?,?,?,?,?,?)", array($forum_new['id'], $forumc_new['id'], $theme['id'], $msg, $user['user_id'], time(), 0, 0));
$posts = DB::$dbs->querySingle("SELECT COUNT(`id`) FROM ".FORUMS_POST." WHERE `theme_id` = ? ", array($theme['id']));
$page = ceil(($posts / $config['write']['forum_post']));
header("Location: ".HOME."/forum/".$forum_new['id']."/".$forumc_new['id']."/".$theme['id']."/?p=".$page);
} else {
echo DIV_ERROR . 'Подфорум не найден' . CLOSE_DIV;
}
}
echo DIV_BLOCK . 'Перенос темы: <b>' . $theme['name'] . '</b>' . CLOSE_DIV;
echo DIV_BLOCK
. '<form action="?" method="POST">'
. 'В подфорум:<br />'
. '<select name="forumc">';
$sql = DB::$dbs->query("SELECT * FROM ".FORUMS_CAT ." WHERE `id` != '".$theme['forumc_id']."'");
while($forumc = $sql -> fetch()) {
$forum = DB::$dbs->queryFetch("SELECT `name` FROM ".FORUMS." WHERE `id` = ? ", array($forumc['forum_id']));
echo '<option value="'.$forumc['id'].'">'.$forum['name'].'/'.$forumc['name'].'</option>';
}
echo '</select>'
. '<input type="submit" name="send" value="Перенести тему" />'
. '</form>';
echo CLOSE_DIV;
echo DIV_LI . '<a href="'.HOME.'/forum/'.$theme['forum_id'].'/'.$theme['forumc_id'].'/'.$theme['id'].'/"><b>Вернуться в тему</b></a>' . CLOSE_DIV;
$array = array('Форум');
nav($array);
require_once('../../core/stop.php');
?>