<?
require_once '../core/system.php';
echo only_reg();
$header = 'Почта';
require_once '../core/head.php';
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `users_konts` WHERE `id_user` = '".$user[id]."' AND `new_msg`"),0);
$k_page = k_page($k_post,$set['p_str']);
$page = page($k_page);
$start = $set['p_str']*$page-$set['p_str'];
$q = mysql_query("SELECT * FROM `users_konts` WHERE `id_user` = '".$user[id]."' AND `new_msg` ORDER BY `new_msg` DESC LIMIT $start, $set[p_str]");
echo "<div class='player menuList'>";
if($k_post == 0)echo "<span class='grey'>Нет новых сообщений!</span>";
while ($post = mysql_fetch_assoc($q)){
$ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = $post[id_kont] LIMIT 1"));
$mess = mysql_query("SELECT * FROM `mail` WHERE `id_user` = '$user[id]' AND `id_kont` = '$ank[id]' OR `id_user` = '$ank[id]' AND `id_kont` = '$user[id]' ORDER BY id DESC LIMIT 1");
$msg = mysql_fetch_assoc($mess);
echo "<li><a href='mail.php?id=$ank[id]'>";
if ($ank['storona'] == '0') {?><img src="/images/icon/0.png" height="11" alt="a"/> <?php }
	    if ($ank['storona'] == '1') {?><img src="/images/icon/1.png" height="11" alt="d"/> <?php }
echo online($ank[id]);
echo $ank[nick];
echo ", <span class='dgreen'>".vremja($msg[time])."</span>";
echo "<br><span class='white'>".rez_text($msg[msg])."</span></a></li>";
echo "<div class=dot-line'></div>";
}
echo "</div>";
if ($k_page>1)str('?',$k_page,$page); // Вывод страниц
echo "</div>";
require_once '../core/foot.php';
?>