<?
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"));

$set['title']='Спасибо пользователю '.$ank_adm['nick']; // заголовок страницы

include_once '../sys/inc/thead.php';
title();



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='Короткое сообщение';}
elseif (mysql_result(mysql_query("SELECT COUNT(*) FROM `sps` WHERE `id_user` = '$user[id]' AND `msg` = '".my_esc($msg)."' LIMIT 1"),0)!=0){$err='Ваше сообщение повторяет предыдущее';}
else{
$msg=mysql_escape_string($msg);
mysql_query("INSERT INTO `sps` (id_user,id_user_adm, time, msg) values('$user[id]', '$us_adm', '$time', '$msg')");
mysql_query("UPDATE `user` SET `balls` = '".($user['balls']+1)."' WHERE `id` = '$user[id]' LIMIT 1");
msg('Сообщение успешно добавлено');
}
}
err();
aut(); // форма авторизации
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `sps` 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 "Нет сообщений<br/>\n";
echo "  </td>\n";
echo "   </tr>\n";
}

$q=mysql_query("SELECT * FROM `sps` 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";

if ($set['set_show_icon']==2){
echo "  <td class='icon48' rowspan='2'>\n";
avatar($ank['id']);
echo "  </td>\n";
}
elseif ($set['set_show_icon']==1)
{
echo "  <td class='icon14'>\n";
echo "".status($ank['id'])."";
echo "  </td>\n";
}



echo "  <td class='p_t'>\n";
echo "<a href='/info.php?id=$ank[id]'>$ank[nick]</a>".online($ank['id'])."\n";
//echo "".adm($ank['id'])."\n";

echo "(".vremja($post['time']).")<br/>\n";
echo "  </td>\n";
echo "   </tr>\n";
echo "   <tr>\n";
if ($set['set_show_icon']==1)echo "  <td class='p_m' colspan='2'>\n"; else echo "  <td class='p_m'>\n";
echo "<span style='color:$ank[color]'>\n";
echo esc(trim(br(bbcode(smiles(links(stripcslashes(htmlspecialchars($post['msg']))))))))."<br />\n";
if (user_access('adm_panel_show'))echo "<a href='/pages/delete.php?id=$post[id]'>Удалить</a>\n";
echo "</span>\n";
echo "  </td>\n";
echo "   </tr>\n";
}

echo "</table>\n";
################################################################################

if (isset($user))
{
echo '<form method="post" action="sps.php?id='.$us_adm.'">';
echo "Причина:<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";
}
################################################################################
if ($k_page>1)str('?id='.$ank_adm['id'].'&amp;',$k_page,$page); // Вывод страниц

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