Файл: my/mail_ajax.php
Строк: 64
<?
define('ROOT','../');
require_once (ROOT.'system/power.php');
switch($mode){
default:
$count = $db -> dbcount('COUNT(`id`)','dialogs','`user` = '.$ya['id'].' or `oid` = '.$ya['id'].'');
$num = isset($ya['num']) ? $ya['num'] : 10;
$total = intval(($count - 1) / $num) + 1;
if (!isset($_GET['page']) || !is_numeric($_GET['page']) || $_GET['page'] < 1 )
{
$page = 1;
} elseif($_GET['page'] > $total)
{ $page = $total;
} else $page = (int)$_GET['page'];
$start = $page * $num - $num;
if ($count > 0) {
echo '<div id="emoji_unicode">';
$sql = $db -> query("SELECT * FROM `dialogs` WHERE `user` = '".$ya['id']."' or `oid` = '".$ya['id']."' ORDER BY `time` desc LIMIT ".$start.",".$num);
while ($arr = $sql -> fetch_assoc()) {
if($arr['user']==$ya['id'])$us=$arr['oid']; else $us=$arr['user'];
$f= $db -> query("SELECT `login`,`id`,`sex` FROM `users` WHERE `id` = '".$us."' LIMIT 1") -> fetch_assoc();
//новые сообщения
$count = $db -> dbcount('COUNT(`id`)','mail','`dialog` = '.$arr['id'].' and `fid` = '.$ya['id'].' and `read`="no"');
if($count>0)$new='<span class="count"><span class="chet">+'.$count.'</span></span>'; else $new=null;
///последнее сообщение
$max = $db -> query("SELECT * FROM `mail` WHERE `dialog` = '".$arr['id']."' order by `time` desc");
if($max->num_rows>0){
$post_max=$max->fetch_assoc();
if($post_max['oid']==$ya['id'])$us_max=$ya['id']; else $us_max=$post_max['oid'];
}
echo '<a href="'.ROOT.'my/mail.php?act=read&id='.$arr['id'].'" class="mail">
<table width=100%><tr valign="top">
<td width="5%">'.$fuser->avatar($us).'</td>
<td>'.$fuser->famname($us).'<br/>
'.$fuser->online($us).'
'.$new.'<br/>';
if($max->num_rows>0) echo $func -> vremja($post_max['time'],$ya['gmt']);
echo '</td>';
if(($_COOKIE['version']=='web' or !isset($_COOKIE['version']))and(VERSION=='1')and($max->num_rows>0)){
echo '<td width="40%" style="padding-left:5px;">';
if($max>0){
if($arr['oid']!=$post_max['oid'])echo''.$fuser->avatar($us_max,24,24,1).' ';
echo mb_substr($post_max['text'],0,20).'...<br/>';
}
echo '</td>';
}
echo'<td width="20%" style="padding-left:5px;">
<a href="'.ROOT.'my/mail.php?id='.$arr['id'].'&act=deldialog">'.language('Удалить').'</a></td>
</tr></table></a>
';
}
if($db->settings('emoji')==true and $_COOKIE['version']=='web'){
require_once (ROOT.'system/lib/emojiarea/include.php');
?>
<html>
</div>
<script>
$("#emoji_unicode").each(function() {
$(this).html(emojione.shortnameToImage($(this).html()));
});
</script>
</html>
<?
}
echo $func -> pagenav(ROOT.'my/mail.php?',$page,$total);
} else echo '<div class="fon">'.language('Сообщений пока нет').'</div>';
}
?>