Файл: monst/ajaxChat_get.php
Строк: 69
<?php
$headmod = 'chat';
include('files/db.php');
include('files/ajaxAuth.php');
$count=result(q("SELECT count(*) FROM `chat` WHERE `p` = 0 OR (`p` = 1 AND (`to` = '".$udata['usr']."' OR `nick` = '".$udata['usr']."'));"));
$allpage=ceil($count/$onpage);
$page = (int)$_POST['page'];
if(!$page OR $page < 0) $page = 1;
if($allpage>20)$allpage=20;
if($page>$allpage)$page=$allpage;
$start=($page-1)*$onpage;
$q=q("SELECT users.vip, users.vipIco, users.selectedTit, users.nickCol, chat.* FROM `chat` LEFT JOIN users ON users.id = chat.uid WHERE chat.p = 0 OR (chat.p = 1 AND (chat.to = '".$udata['usr']."' OR chat.nick = '".$udata['usr']."')) ORDER BY chat.time DESC LIMIT $start, $onpage");
$data=array();
if(@num_rows($q)){
while($row=assoc($q)){
$row['komentaras']=str_replace($udata['usr'].',',$udata['usr'].',',$row['komentaras']);
if(eregi($udata['usr'].',', $row['komentaras'])) {
if($row['p']) {
$row['komentaras']=str_replace($udata['usr'].',','<b>'.nickName($udata['usr']).'</b>, <span style="color: red;">',$row['komentaras']);
}else{
$row['komentaras']=str_replace($udata['usr'].',','<b>'.nickName($udata['usr']).'</b>, <span style="color: lightgreen;">',$row['komentaras']);
$row['komentaras'].='</span>';
}
}
// $row['komentaras'] = smileys($row['komentaras']);
if(in_array($row['uid'],$admin_arr) OR in_array($row['uid']['id'],$moder_arr))
$row['komentaras'] = bbcode($row['komentaras']);
$data[]=$row;
}
}
if(!$data)
echo 'Сообщений нет, будь первым!';
else {
for($i = 0; $i < count($data); $i++) {
$tt = "javascript: $(mess_to_send).val('".$data[$i]['nick'].", '); $(to).val('".$data[$i]['nick']."'); ";
$newText = 0;
if($data[$i]['id'] > $_SESSION['lastChatMsgId'])
$newText = 1;
/*
if($data[$i]['id'] > $_SESSION['lastChatMsgId'] AND $data[$i]['nick'] != $udata['usr']) {
echo '<big style="color: red;">!</big> ';
}
*/
$p1 = '';
$p2 = '';
if($data[$i]['p']) {
//$p1 = ' <big style="color: orange;">!</big> ';
$p1 = '<img src="/tpl/default/pic/ico/!(new).png" alt=""/>';
$p2 = '<small style="color: dodgerblue;">шепчет</small> ';
}
echo $p1.'<span class="miniText" '.(($newText)?'style="color: red;"':'').'>'.$data[$i]['kada'].'</span> <a href="'.$data[$i]['nick'].'" onclick="'.$tt.' return false"><b>'.nickName($data[$i]['nick']).'</b></a> <a href="/search.php?nick='.$data[$i]['nick'].'&go=go">[i]</a>'.$p2.'<span class="cText"><small>»</small> ';
if($newText)
echo '<span style="color: lightblue;">';
$m = $data[$i]['komentaras'];
// if ( $udata['usr'] == 'aNhotty') {
// $m = str_replace('03_biggrin.gif"', 'r1.png" width="30"', $m);
// $m = str_replace('03_lol.gif"', 'r1.png" width="30"', $m);
// }
echo $m;
if($newText)
echo '</span>';
echo '</span>';
if(ismoder()) {
echo '<a href="/confirm.php?ajaxChat.php?mod=del_post&p='.$data[$i]['id'].'"><small>[x]</small></a>';
}
echo '<br/>';
}
}
$_SESSION['lastChatMsgId'] = $data[1]['id'];
// $musicfile = "sounds/1.mp3";
// $audio = '<embed autostart="true" src='.$musicfile.'>';
//echo time();
// echo '<div style="display:block;">'.$audio.'</div>';
?>