Файл: news/edit_komm.php
Строк: 52
<?php
/*
 * Новости
 * DCMS Special
 * Модифицировал densnet
 * Файл edit_komm.php
 */
only_reg();
$post = mysql_fetch_array(mysql_query("SELECT * FROM `news_komm` WHERE `id` = '" . intval($_GET['edit_komm']) . "' LIMIT 1"));
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `news_komm` WHERE `id` = '$post[id]'"), 0) == 0) {
    header("Location:?");
    exit;
}
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `news` WHERE `id` = '$post[id_news]'"), 0) == 0) {
    header("Location:?");
    exit;
}
$news = mysql_fetch_array(mysql_query("SELECT * FROM `news` WHERE `id` = '$post[id_news]' LIMIT 1"));
$set['title'] = 'Новости "' . htmlspecialchars($news['title']) . '" - редактирование комментария';
require_once '../sys/inc/thead.php';
if (!isset($user)) {
    header("Location:?news=$news[id]");
}
if (isset($user) && $user['level'] > 2 || $user['id'] == $post['id_user'] && $post['time'] > time() - 600) {
    if (isset($_GET['ok']) && isset($_POST['msg'])) {
        $msg = text::esc(stripcslashes(htmlspecialchars($_POST['msg'])));
        if (utf8_strlen($msg) < 1) {
            $err = 'Слишком короткое сообщение';
        }
        if (utf8_strlen($msg) > 1024) {
            $err = 'Слишком длинное сообщение';
        }
        $msg = mysql_real_escape_string($msg);
        if (!isset($err)) {
            mysql_query("UPDATE `news_komm` SET `msg` = '$msg' WHERE `id` = '$post[id]' LIMIT 1");
            header("Location: ?news=$news[id]");
        }
    }
    err();
    #Навигация
    echo "<div class = 'razd'><a href = '/index.php'>Главная</a> > <a href = '/news/'>Новости</a> > <a href = '/news/?news=$news[id]'>" . htmlspecialchars($news['title']) . "</a> > <a href = '?edit_komm=$post[id]'><b>Комментарий</b></a></div>";
    echo "<div class = 'razdel'>Редактирование комментария</div>";
    echo "<form class = 'razd' name = 'msg_edit' method = 'POST' action = '?edit_komm=$post[id]&ok'>";
    echo "Сообщение: (1024 символa)<br/>";
    echo text::auto_bb('msg_edit', 'msg');
    echo L . "<textarea name = 'msg' >$post[msg]</textarea><br/>";
    echo "<button class = 'action'>";
    echo "<span class = 'label'><span class = 'icon icon67' /> Сохранить</span>";
    echo "</button></form>";
    echo "<div class = 'razd'>" . img('left.png') . " <a href = '?news=$news[id]'>Вернуться</a></div>";
} else {
    header("Location: ?news=$news[id]");
}
require_once '../sys/inc/tfoot.php';