Файл: forum/edittopic.php
Строк: 110
<?php
# Script by seg0ro http://mobilarts.ru
# Not for sale!!!
defined('_IN_JOHNCMS') or die('Error: restricted access');
$textl .= ' | Изменение';
require_once('../incfiles/head.php');
if (!$topic){
echo functions::display_error('Отсутствует идентификатор темы!<br /><a href="index.php">Форум</a>');
require_once('../incfiles/end.php');
exit;
}
if ($rights != 3 && $rights < 6){
echo functions::display_error('У вас недостаточно прав для просмотра этой страницы!<br /><a href="index.php">Форум</a>');
require_once('../incfiles/end.php');
exit;
}
$name = $_POST['topicname'] ? trim($_POST['topicname']) : $topicRes['topicname'];
$pollName = isset($_POST['poll_name']) ? trim($_POST['poll_name']) : $topicRes['poll_name'];
$tree = array('<a href="index.php">Форум</a>', '<a href="index.php?topic='.$topic.'&page='.$page.'">'.functions::checkout($topicRes['topicname']).'</a>', 'Изменение темы');
echo '<div class="phdr">'.functions::display_menu($tree).'</div>';
if (isset($_GET['close'])){
mysql_query("UPDATE `forum_topics` SET
`close` = '1'
WHERE `topic` = '$topic' LIMIT 1
");
header ('Refresh:1; URL=index.php?topic='.$topic.'&page='.$page);
echo '<div class="gmenu">Тема закрыта<br /><a href="index.php?topic='.$topic.'&page='.$page.'">Далее</a></div>';
require_once('../incfiles/end.php');
exit;
}
if (isset($_GET['open'])){
mysql_query("UPDATE `forum_topics` SET
`close` = '0'
WHERE `topic` = '$topic' LIMIT 1
");
header ('Refresh:1; URL=index.php?topic='.$topic.'&page='.$page);
echo '<div class="gmenu">Тема открыта<br /><a href="index.php?topic='.$topic.'&page='.$page.'">Далее</a></div>';
require_once('../incfiles/end.php');
exit;
}
if (isset($_POST['send'])){
if (empty($name))
$error .= 'Не введено название!<br />';
if ($topicRes['topicname'] != $name){
$check = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_topics` WHERE `topicname` = '".mysql_real_escape_string($name)."' AND `forum` = '".$topicRes['forum']."' LIMIT 1 "), 0);
if ($check)
$error .= 'Тема с таким названием уже существует!<br />';
}
if (!$error){
mysql_query("UPDATE `forum_topics` SET
`topicname` = '".mysql_real_escape_string($name)."',
`close` = '".abs(intval($_POST['close']))."',
`sticky` = '".abs(intval($_POST['sticky']))."',
`clip` = '".abs(intval($_POST['clip']))."'
WHERE `topic` = '$topic' LIMIT 1
");
if ($topicRes['topicname'] != $name){
mysql_query("INSERT INTO `forum_posts` SET
`topic` = '$topic',
`time` = '".time()."',
`user_id` = '$user_id',
`user` = '$login',
`text` = 'Тема переименована (cтарое название [b]".mysql_real_escape_string($topicRes['topicname'])."[/b])',
`files` = '0',
`browser` = '".mysql_real_escape_string($agn)."',
`ip` = '".core::$ip."',
`ip_via_proxy` = '".core::$ip_via_proxy."' ");
$pid = mysql_insert_id();
if ($topicRes['user_id'] != $user_id)
journal::addEntry($topicRes['user_id'], 'Ваша [url='.$set['homeurl'].'/forum/index.php?post='.$pid.'&find]тема[/url] переименована (cтарое название [b]'.$topicRes['topicname'].'[/b])');
mysql_query("UPDATE `forum_topics` SET
`time` = '".time()."',
`lastpost` = '$login:|:$pid',
`count` = count + 1 WHERE `topic` = '$topic' LIMIT 1 ");
mysql_query("UPDATE `forum_forums` SET `last_topic` = '$topic:|:$name:|:".time()."' WHERE `forum` = '".$topicRes['forum']."' LIMIT 1 ");
mysql_query("UPDATE `users` SET `lastpost` = '".time()."', `postforum` = postforum + 1 WHERE `id` = '$user_id' ");
}
if ($rights >= 7){
$user = mysql_fetch_array(mysql_query("SELECT `rights` FROM `users` WHERE `id` = '".abs(intval($_POST['curator']))."' LIMIT 1 "));
if ($user['rights'] != 3 && $user['rights'] < 6 && intval($_POST['curator']) != $user_id)
mysql_query("UPDATE `forum_topics` SET `curator` = '".abs(intval($_POST['curator']))."' WHERE `topic` = '$topic' ");
}
header ('Refresh:1; URL=index.php?topic='.$topic.'&page='.$page);
echo '<div class="gmenu">Тема изменена<br /><a href="index.php?topic='.$topic.'&page='.$page.'">Далее</a></div>';
require_once('../incfiles/end.php');
exit;
}
}
if ($error)
echo functions::display_error($error);
echo '<form id="form" action="index.php?act=edittopic&topic='.$topic.'&page='.$page.'" method="post">'.
'<div class="list1">Название <img style="cursor: pointer;" onclick="alert(this.title);" src="images/question.png" alt="?" title="Максимально 100 символов" />:<br /><input type="text" name="topicname" value="'.text($name).'" /></div><div class="rmenu">'.
'<label><input type="checkbox" '.($topicRes['clip'] ? 'checked="checed" ' : '').'name="clip" value="1" /> Закрепить 1-ое сообщение</label><br />'.
'<label><input type="checkbox" '.($topicRes['close'] ? 'checked="checed" ' : '').'name="close" value="1" /> Закрыть</label><br />'.
'<label><input type="checkbox" '.($topicRes['sticky'] ? 'checked="checed" ' : '').'name="sticky" value="1" /> Закрепить</label><br />';
if ($rights >= 7)
echo 'ID куратора: <input type="text" size="5" name="curator" value="'.$topicRes['curator'].'" /><br />';
echo '<input type="submit" name="send" value="Сохранить" /></div></form>';