<?
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/adm_check.php';
include_once '../sys/inc/user.php';
user_access('adm_mysql',null,'index.php?'.SID);
adm_check();
$us_mail = intval($_GET['id']);
$ank_mail=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $us_mail LIMIT 1"));

$set['title']='Mailshpion  - входящие  '.$ank_mail['nick']; // заголовок страницы

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

$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `mail` WHERE `id_kont` = $us_mail"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
echo "<div class='title'><center>Входящих писем у юзера: $k_post </center></div>\n";
echo "<table class='post'>\n";
if ($k_post==0)
{
echo "Нет сообщений<br/>\n";
}

$q=mysql_query("SELECT * FROM `mail` WHERE `id_kont` = $us_mail ORDER BY id DESC LIMIT $start, $set[p_str]");

while ($post = mysql_fetch_array($q))
{
$ank2=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $post[id_kont] LIMIT 1"));
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $post[id_user] LIMIT 1"));
echo "  <td class='p_t'>\n";
echo "</a>Oт:<a href='/info.php?id=$ank[id]'>$ank[nick]</a>".online($ank['id'])."</a>\n";
echo "(<a href='/adm_panel/mailshpion3.php?id=$ank[id]'>Исх.</a>/<a href='/adm_panel/mailshpion2.php?id=$ank[id]'>Вход.</a>)</a></br>\n";
echo "</a>K:<a href='/info.php?id=$ank2[id]'>$ank2[nick]</a>".online($ank2['id'])."</a><br/>\n";
echo "(".vremja($post['time']).")<br/>\n";


if ($post['read']==0)echo "<b><font color='red'>(не прочитано)</font></b><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
esc(trim(br(bbcode(smiles(links(stripcslashes(htmlspecialchars($post['msg']))))))))."<br />\n";
echo "</span>\n";
echo "<a href='/adm_panel/delete_mail.php?id=$post[id]'>Удалить</a><br />\n";
echo "  </td>\n";
echo "   </tr>\n";
}
echo "</table>\n";


echo "<div class='foot'>\n";
echo "&laquo;<a href='/adm_panel/mailshpion.php'>Почтовый Шпион</a><br />\n";
echo "</div>\n";
if ($k_page>1)str('?id='.$ank_mail['id'].'&amp;',$k_page,$page); // Вывод страниц
include_once '../sys/inc/tfoot.php';
?>
