<?php
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]."'"),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]."' ORDER BY time DESC LIMIT $start, $set[p_str]");
if($k_post == 0)echo "<div class='player grey'>Нет контактов!</div>";
echo "<div class='player menuList'>";
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);
if($msg[read] == 1)$color = 'white';
if($msg[read] == 0)$color = 'grey';
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='$color'>".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 class='player menuList'>";
//echo "<li><a href='clear_all'>Очистить почту</a></li></div>";
//echo "<li><a href='clear'>Удалить все прочитанное</a></li></div>";
echo "<li><a href='posters/mark_read_all'><img src='/images/icon/ok.png' />Отметить все как прочитанное</a></li>";
echo "</div>";
require_once '../core/foot.php';
?>