<?php
$location = true;
require_once($_SERVER['DOCUMENT_ROOT']."/core/func.php");
head("Почта",$uid);
//
//
$r = rand(100000,999999);
//
//
$count = $BaseConnect->query("SELECT (id) FROM `contacts_mail` WHERE `del` != '".$uid."'  AND `id_user` = '".$uid."'")->rowCount(); 
$str = '10';
$url = "/contacts/";
$num = abs(is('1'));
$result = $count; 
$msg_q = $BaseConnect->query("SELECT * FROM `contacts_mail` WHERE `del` != '".$uid."'  AND `id_user` = '".$uid."' ORDER BY `new_msg` DESC, `time` DESC LIMIT ".page($num,$str,$result).",$str ");
// 
//
if($count == 0)echo '<div class="list cntr">Сообщений еще нет</div>';
//
//
$i = 1;
//
//
while($msg = $msg_q->fetch(PDO::FETCH_ASSOC)){ 
//
//
if($msg['new_msg'] == 0)$check = '';
else $check = '<font color="lime">(не прочитано)</font>';
//
//
$ank = fch("SELECT * FROM `users` WHERE `id` = ? LIMIT 1", array($msg['id_ank']));
//
//
$message = fch("SELECT * FROM `mail` WHERE `id_user` = ? AND `id_ank` = ? OR `id_user` = ? AND `id_ank` = ? ORDER BY `id` DESC LIMIT 1", array($uid,$ank['id'],$ank['id'],$uid));
//
//
if($i % 2 == 0)echo '<div class="tophead2">'; 
//
//
if($i % 2 != 0)echo '<div class="tophead">'; 
//
//
?>

<?=user_list2($msg['id_ank']);?> 
<?=$check;?>
<span  style="float: right;">
<small>
<?=clock($message['time']);?>
</small>
</span>
<br>
<font color="#888">
<?=bbcode(text_msg($message['text']));?>
</font>
</div>

<?
//
//
$i ++;
}
//
//
ppage($url,$num,$str,$result);
//
//
foot($uid);
//
//
?>