<?
include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/user.php';
only_reg();
$set['title']='Ответ на мнение';
include_once '../sys/inc/thead.php';
title();

if (isset($_GET['ok']))
{
$id_razd=(int)abs((int)$_GET['ok']);

$post = mysql_fetch_array(mysql_query("SELECT * FROM `us_mnenija` WHERE `id`='".$id_razd."' LIMIT 1"));
$ank = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id`=$post[id_user] LIMIT 1"));
$g_adm = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id`=$post[id_user_adm] LIMIT 1"));
$reply = $_POST['reply'];
$reply=mysql_escape_string($reply);

$msg2="[b]$user[nick][/b] ответил на ваше [url=http://".$_SERVER['HTTP_HOST']."/us_mnenija/?id=$g_adm[id]]анонимное мнение[/url]";
mysql_query("INSERT INTO `jurnal` (`id_user`, `id_kont`, `msg`, `time`) values('0', '$ank[id]', '$msg2', '$time')");

mysql_query("UPDATE `us_mnenija` SET `reply` = '$reply' WHERE `id` = '$post[id]' LIMIT 1");

header("Location: index.php?id=$post[id_user_adm]");
exit;
}

$id_razd=(int)abs((int)$_GET['id']);

$post = mysql_fetch_array(mysql_query("SELECT * FROM `us_mnenija` WHERE `id`='".$id_razd."' LIMIT 1"));
$ank = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id`=$post[id_user] LIMIT 1"));
$otv = esc(trim(br(bbcode(smiles(links(stripcslashes(htmlspecialchars($post['reply']))))))));
if (isset($user) && ($user['level']>$ank['level'] || $user['level']==4 || $user['id']=$us_adm)){
echo "<div class='p_t'>Ответ:</div>";
echo "<div class='p_m'>";
echo '<form method="post" action="reply.php?ok='.$id_razd.'">';
echo '<textarea name="reply">'.$otv.' </textarea><br/>';
echo '<input type="submit" value="Ответить"/>';
echo '</form>';
echo "</div>\n";}
else{
header("Location: index.php?id=$post[id_user_adm]".SID); }
echo "<a href='index.php?id=$post[id_user_adm]'>Назад</a><br />\n";

include_once '../sys/inc/tfoot.php';
?>