<?
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;}
$new=mysql_fetch_array(mysql_query("SELECT * FROM `news` WHERE `id` = '$post[id_news]' LIMIT 1"));
$set['title']='Новости "'.htmlspecialchars($new['title']).'" - редактирование комментария'; // заголовок страницы
include_once '../../sys/inc/thead.php';if(!isset($user))header("Location:?new=$new[id]");
if(isset($user) && $user['level']>2 || $user['id']==$post['id_user'] && $post['time']>time()-600)
{
if (isset($_GET['ok']) && isset($_POST['msg'])){$msg=esc(stripcslashes(htmlspecialchars($_POST['msg'])));
if(strlen2($msg)<1)$err='Слишком короткое сообщение';
if(strlen2($msg)>1024)$err='Слишком длинное сообщение';
$msg=my_esc($msg);
if(!isset($err))
{
mysql_query("UPDATE `news_komm` SET `msg` = '$msg' WHERE `id` = '$post[id]' LIMIT 1");
header("Location:?new=$new[id]");
}
}
title();
aut();
err();
echo "<form method='post' action='?edit_komm=$post[id]&ok'>";
echo "Сообщение: (1024 символa)<br />";
echo "<textarea name='msg' rows='5' cols='30'>$post[msg]</textarea><br />";
echo "<input value='Изменить' type='submit' /><br />";
echo "<div class='foot'><img src='img/back.png' /> <a href='?new=$new[id]'>Назад</a></div>";
}
else header("Location:?new=$new[id]");
include_once '../../sys/inc/tfoot.php';
?>