<?
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['id']) || !is_numeric($_GET['id']))
{
header("Location: /index.php?");
}
$id=intval($_GET['id']);

if (isset($_GET['ok']))
{
$id=intval($_GET['ok']);

$post=mysql_fetch_array(mysql_query("SELECT * FROM `us_wall` WHERE `id`= '$id' LIMIT 1"));
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$post[id_user]' LIMIT 1"));
if ($_POST['translit'] == 1)
{
$repl=translit($_POST['reply']);
}
else
{
$repl=$_POST['reply'];
}
$reply=mysql_real_escape_string($repl);
$uadm = get_user($post['id_user_adm']);

if ($user['pol']==1)
{
$ost = "ответил";
}
else
{
$ost = "ответила";
}

$msg2="[b]$user[nick][/b] ".$ost." на Bашу запись на [url=http://xlofes.ru/wall/?id=$post[id_user_adm]] стене [/url] у пользователя $uadm[nick]";
mysql_query("INSERT INTO `jurnal` (`id_user`, `id_kont`, `msg`, `time`) values('0', '$ank[id]', '$msg2', '$time')");

mysql_query("UPDATE `us_wall` SET `reply` = '$reply', `who_reply` = '$user[id]' WHERE `id` = '$post[id]' LIMIT 1");

$q = mysql_query("SELECT * FROM `frends` WHERE `user` = '$user[id]'");
while ($f = mysql_fetch_array($q))
{
$a = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$f[frend]' LIMIT 1"));

if ($user['pol']==1)
{
$ost = "ответил";
$vash = "Ваш";
}
else
{
$ost = "ответила";
$vash = "Ваша";
}

$msg_lenta="".$vash." друг [b]$user[nick][/b] ".$ost." на запись $ank[nick] на [url=http://xlofes.ru/wall/?id=$post[id_user_adm]] стене [/url] у пользователя [b]$uadm[nick][/b]";

mysql_query("INSERT INTO `lenta` (`id_user`, `id_kont`, `msg`, `time`) values('$user[id]', '$a[id]', '$msg_lenta', '$time')"); 
}


header("Location: /wall/?id=$post[id_user_adm]");
exit;
}

$id=intval($_GET['id']);

$post=mysql_fetch_array(mysql_query("SELECT * FROM `us_wall` WHERE `id` = '$id' LIMIT 1"));
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$post[id_user]' LIMIT 1"));

echo "<div class='rowup'>";
echo "&raquo; $ank[nick] пишет: <br />";
echo "".esc(trim(br(bbcode(smiles(links(stripcslashes(htmlspecialchars($post['msg']))))))))."</div>";
echo '<form method="post" action="reply.php?id='.$id.'&amp;ok='.$id.'">';
echo '<div class="forma">Ответ: | <a href="/smiles/">Смайлы</a><br /><textarea name="reply">'.$ank['nick'].', </textarea><br/>';
if ($user['set_translit']==1)echo "<label><input type=\"checkbox\" name=\"translit\" value=\"1\" /> Транслит</label><br />\n";
echo '<input type="submit" value="Ответить"/>';
echo '</form></div>';

echo "&raquo; <a href='/wall/?id=$post[id_user_adm]'>Назад</a><br />\n";

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