<?
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';
################################################################################
$us_adm=intval($_GET['id']);
$ank_adm=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $us_adm LIMIT 1"));
################################################################################
if (isset($user))$ank['id']=$user['id'];
if (isset($_GET['id']))$ank['id']=intval($_GET['id']);
################################################################################
$set['title']="Комментарии к аватару \"$ank_adm[nick]\"";
include_once '../../sys/inc/thead.php';
title();
################################################################################
if(isset($_GET['msg'])){msg('Сообщение добавлено');}
################################################################################
if (isset($_POST['msg']) && isset($user))
{
$msg=$_POST['msg'];
if (isset($_POST['translit']) && $_POST['translit']==1)$msg=translit($msg);
if (strlen2($msg)>1024){$err='Сообщение слишком длинное';}
elseif (strlen2($msg)<2){$err='Короткое сообщение';}
else{
$msg=mysql_escape_string($msg);
mysql_query("INSERT INTO `avkom` (id_user,id_user_adm, time, msg) values('$user[id]', '$us_adm', '$time', '".my_esc($msg)."')");
mysql_query("UPDATE `user` SET `balls` = '".($user['balls']+1)."' WHERE `id` = '$user[id]' LIMIT 1");
########## Реётинг активности ENK   #################
mysql_query("UPDATE `user` SET `akt_rating` = '".($user['akt_rating']+0.001)."' WHERE `id` = '$user[id]' LIMIT 1");
########## Реётинг активности ENK   #################
header("Location: ?id=$ank[id]&msg");
if (isset($user) && $user['id']!=$us_adm){
$msg2="[url=/info.php?id=$user[id]]$user[nick][/url] оставил сообщение к вашему [url=/anketa/ava/?id=$ank[id]]аватару[/url]";
mysql_query("INSERT INTO `jurnal` (`id_user`, `id_kont`, `msg`, `time`) values('0', '$us_adm', '$msg2', '$time')");
}}}
################################################################################
echo "<div class='f1'><center>";
avatar($ank['id']);
echo "</center></div>";
################################################################################
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `avkom` WHERE `id_user_adm` = $us_adm"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
echo "<table class='post'>\n";
if ($k_post==0)
{
echo "   <tr>\n";
echo "  <td class='p_t'>\n";
echo "Нет сообщений\n";
echo "  </td>\n";
echo "   </tr>\n";
}

$q=mysql_query("SELECT * FROM `avkom` WHERE `id_user_adm` = $us_adm ORDER BY id DESC LIMIT $start, $set[p_str]");
while ($post = mysql_fetch_array($q))
{
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $post[id_user] LIMIT 1"));
echo "   <tr>\n";
echo "  <td class='icon14'>\n";
avatar4($ank['id']);
echo "  </td>\n";
echo "  <td class='p_t'>\n";
echo "<a href='/id$ank[id]'><span style=\"color:$ank[ncolor]\">$ank[nick]</span></a>\n";
echo "".medal($ank['id'])." ".online($ank['id'])." (".vremja($post['time']).")";
echo "  </td>\n";
echo "   </tr>\n";
echo "   <tr>\n";
if ($set['set_show_icon'])echo "  <td class='p_m' colspan='2'>\n"; else echo "  <td class='p_m'>\n";
echo esc(trim(br(bbcode(smiles(links(stripcslashes(htmlspecialchars($post['msg']))))))))."<br />\n";
if ($post['reply']!=NULL){
echo "<div class='cit'>\n";
echo "<font color='red'><b>Ответ:</b></font>\n";
echo output_text($post['reply'])."<br />\n";
echo "</div>";
}
if (isset($user) && $user['id']==$ank_adm['id']){
echo '[<a href="reply.php?id='.$post['id'].'">Ответить</a>] ';
echo "[<a href='delete.php?id=$post[id]'>Удалить</a>]<br />\n";
}
if (user_access('guest_delete'))
if (isset($user) && $user['id']!=$ank_adm['id'])echo " [<a href='delete.php?id=$post[id]'>Удалить</a>]<br />\n";
echo "  </td>\n";
echo "   </tr>\n";
}
echo "</table>\n";

if ($k_page>1)str('?id='.$ank_adm['id'].'&amp;',$k_page,$page); // Вывод страниц

if (isset($user))
{
echo "<div class='textmes'>";
echo '<form method="post" action="index.php?id='.$us_adm.'">';
echo "Сообщение | <a href='/smiles/'>Смайлы</a><br />\n<textarea name=\"msg\"></textarea><br />\n";
if ($user['set_translit']==1)echo "<label><input type=\"checkbox\" name=\"translit\" value=\"1\" /> Транслит</label><br />\n";
if (!isset($user))echo "<img src=\"img.php?".SID."\" width=\"100\" height=\"30\" alt=\"Проверочное число\"/><br />\n<input name=\"chislo\" size=\"5\" maxlength=\"5\" value=\"\" type=\"text\" /><br/>\n";
echo "<input value=\"Отправить сообщение\" type=\"submit\" />\n";
echo "</form>\n";
echo "</div>\n";
}

echo "<div class='niz2'>\n";
echo "<img src='/images/Back.gif'> <a href='/info.php?id=$ank_adm[id]'>Страничка</a> (<span style=\"color:$ank_adm[ncolor]\">$ank_adm[nick]</span>)\n";
echo "</div>\n";
include_once '../../sys/inc/tfoot.php';
?>