Файл: monst/core/jphp/chat/load_mess.php
Строк: 55
<?
$HOME = $_SERVER['DOCUMENT_ROOT'];
include $HOME . '/core/in/j.php';
if ( !empty($_POST['room']) ) {
$room = 1;
if ( isset($_POST['limit'] ) ) {
$limit = (int)$_POST['limit'];
} else {
$limit = 15;
}
$find = $_chat -> find(
[
'$or' => [
[
'p' => 0
],
[
'p' => 1,
'$or' => [
[
'user_id' => $user['id']
],
[
'to_id' => $user['id']
]
]
]
],
]
) -> limit($limit) -> sort(
[
'id' => -1
]
);
$mess_count = $_chat -> find() -> count();
$_SESSION['last_mess_id2'] = @$_SESSION['last_mess_id'];
$_SESSION['last_mess_id'] = 0;
$mess_array = array();
$i = 1;
if ( $find ) {
foreach($find as $array) {
if ( isset($array['id']) ) {
if ( !isset($_SESSION['last_mess_id']) ) {
$_SESSION['last_mess_id'] = $array['id'];
}
$to = '';
$to_av = av($array['to_id']);
if ( !empty($array['to_id']) ) {
$to = '› <span style="cursor: pointer;" OnClick="to(''.null_html(Name($array['to_id'])).'', ''.$array['to_id'].'', ''.$to_av.'');">'.Name($array['to_id']).'</span>';
}
$mess = $array['mess'];
$mess = str_replace("nn", "", $mess);
$mess_temp = str_replace("n", "", $mess, $repl_count);
if ( $repl_count >= 10 ) {
$mess = str_replace("n", "", $mess);
}
$mess = nl2br($mess);
$temp_mess = $mess;
if ( $array['p'] AND $array['to_id'] ) {
$mess = '<span class="private_mess">'.$mess.'</span>';
} else {
if ( $array['to_id'] == $user['id'] ) {
$mess = '<span class="mess_to_me">'.$mess.'</span>';
} else {
$mess = '<span class="mess">'.$mess.'</span>';
}
}
$av = av($array['user_id']);
$mess_array[] = '
<div id="mess_'.$array['id'].'" class="mess_box">
<a href="/id'.$array['user_id'].'">
<img src="'.$av.'" alt="av" width="50" style="float: left; margin-right: 10px;" class="av"/> </a>
<span style="cursor: pointer;" OnClick="to(''.null_html(Name($array['user_id'])).'', ''.$array['user_id'].'', ''.$av.'');">
'.Name($array['user_id']).'
</span>'.$to.'<br/>
<span class="mess">'.$mess.'</span><br/>
<span style="font-size: 9px; color: '.$user['theme_color'].'; float: right;">'.replace_time($array['time']).'</span>
</div>
<div style="clear: both;"></div>
<hr/>
';
$i++;
}
}
?>
<div class='mess_box'>
<?
// / $mess_array = array_reverse($mess);
foreach ( $mess_array as $line ) {
print $line;
}
?>
</div>
<?
if ( $limit < $mess_count ) {
?>
<br/><br/>
<div style='text-align: center;'>
<div id="first_chat_mess" OnClick='history(); clearInterval(mess_upd)' class='bu2tton_black'>
<span style='color: <?=$user['theme_color']?>; font-size: 15px; cursor: pointer;'>↓ История (<?=($mess_count - $limit)?>)</span>
</div>
</div>
<br/>
<br/>
<?
}
} else {
print 'Сообщений пока нет, будь первым!';
}
}