<?
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_level(4);

$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();
aut(); // форма авторизации
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `mail` WHERE `id_user` = $us_mail and `kto` = $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_user` = $us_mail and `kto` = $us_mail 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"));
$ank2=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $post[id_kont] LIMIT 1"));

echo "  <td class='p_t'>\n";
echo "Oт: ".online($ank['id'])."<a href='/info.php?id=$ank[id]'>$ank[nick]</a></br>\n";
echo "K: ".online($ank2['id'])."<a href='/info.php?id=$ank2[id]'>$ank2[nick]</a>\n";
echo "(<a href='/adm_panel/mailshpion3.php?id=$ank2[id]'>Исх.</a>/<a href='/adm_panel/mailshpion2.php?id=$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";

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