File size: 2Kb
<?php
require '../inc/func.php';
bk_head('Mail');
require '../inc/head.php';
if(!$user){
header('location: /index.php');
}
echo '<div class="list1"><div class="tt"> '.$index_mail['title'].'</div>';
####pages#####
$total = mysql_result(mysql_query("SELECT COUNT(id) FROM `cont` WHERE `id_ser` = '$userid' OR `id_ger` = '$userid'") ,0);
$display = 3;
$count_pages = ceil($total/$display);
$page = (isset($_GET['page']) and is_numeric($_GET['page']) and $_GET['page']>1 and $_GET['page']<=$count_pages) ? $_GET['page'] : 1;
$start = $page*$display-$display;
#############
$qcont = mysql_query("SELECT * FROM `cont` WHERE `id_ser` = '$userid' OR `id_ger` = '$userid' ORDER BY `time` DESC LIMIT $start, $display");
if($total > 0){
while($contact = mysql_fetch_assoc($qcont)){
if($contact['id_ser'] == $userid){
$contact['id_ser'] = $contact['id_ger'];
}
$qmsg = mysql_fetch_assoc(mysql_query("SELECT * FROM `messages` WHERE `cont` = '$contact[id]' ORDER BY `time` DESC LIMIT 1"));
?>
<?php
echo '<div class="list1">';
echo '<a href="/mail/write'.$contact['id'].'">'; ?>
<table>
<tr>
<td><?php avatar($contact['id_ser'], 33, 50); ?></td>
<td> <a href=""><?php echo user($contact['id_ser']); ?>(<?=time_post($contact['time']);?>)</a>
<br/>
<?php
$msg = mb_substr($qmsg['msg'], 0, 150, 'UTF-8');
if (mb_strlen($qmsg['msg']) > 150) {
$vmsg = '...';
} else {
$vmsg = '';
}
if($qmsg['read'] == '0' && $qmsg['id_ger'] == $userid){
echo ''.smiles(tags($msg)).''.$vmsg.' <img src="/images/new.gif" />';
}else{
echo ''.smiles(tags($msg)).''.$vmsg.'';
}
?>
</td></tr>
</table>
</a></div>
<?php
}
if($total > 3 && $page < $count_pages)
{
echo '<div class="shadow">';
pages($page,$count_pages,'?page=');
echo '</div><br />';
}
}else{
err ('Trống');
}
echo '<hr><div class="shadow"><a href="/users/my.php"><b>My Menu</b></a> | <a href="/u/'.$userid.'"><b>Profile</b></a> | <a href="/exit.php"><b>LogOut</b></a></div></div>';
bk_foot();
?>