<?
$title = 'Почта';
include_once '../../sys/fnc.php';
include_once '../../sys/head.php';
echo '<div class="razdel">Почта</div>';
if (!isset($user)){header("Location: /");exit;}
// `ank` ASC,
$q=mysql_query("SELECT DISTINCT (`ank`) FROM `mail` WHERE `user` = '$user->id' ORDER BY `time` ASC");
while ($f=mysql_fetch_assoc($q))
{
if($f['ank']!=$ank['id'])
{
$ank = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$f[ank]' LIMIT 1"));
if($ank==NULL)$ank['login']='System';
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `mail` WHERE `user` = '$user->id' AND `ank` = '$ank[id]' AND `read` = '0'"), 0);
echo "<a class='link' href='/mail/read/$ank[id]'><span class='arrow'><img width='32' height='32' src='$ank[imguser]' /> ".html($ank['login'])." </span>".($count>0?" <font color='red'>+$count</font>":null)."</a>";
}
}
if (mysql_num_rows($q)==0)echo "<a class='link' href='#'><span class='arrow'><img src='style/img/icon1.png' alt='icon' />Диалогов Нет!</span></a>";
echo '<a class="link" href="/mail/new"><span class="arrow"><img src="/style/img/icon1.png" alt="icon" /> Создать диалог</span></a>';
echo '';
include_once '../../sys/foot.php';
?>