bugfix ... prevent that the newest messages are "blocked" (and loaded later)

main
hecht 13 years ago
parent 166a82f235
commit 6b801380ad

@ -84,13 +84,21 @@ function getClanChatMessages($requester, $clan_chat_id, $count, $asc, $msg_id =
$max_id_row = mysql_fetch_row(mysql_query('Select max(msg_id) from clan_chatroom_messages WHERE clan_chat_id = ' . $clan_chat_id)); $max_id_row = mysql_fetch_row(mysql_query('Select max(msg_id) from clan_chatroom_messages WHERE clan_chat_id = ' . $clan_chat_id));
$sql .= ' AND msg_id > ' . ($max_id_row[0] - $count); $sql .= ' AND msg_id > ' . ($max_id_row[0] - $count);
} }
$sql .= ' ORDER BY msg_id ' . ($asc?'asc':'desc') . ' LIMIT ' .$count; $sql .= ' ORDER BY msg_id ASC LIMIT ' .$count;
$qry = db_query($sql); $qry = db_query($sql);
while($row = mysql_fetch_assoc($qry)) { while($row = mysql_fetch_assoc($qry)) {
$result['max_id'] = max($result['max_id'], $row['msg_id']); $result['max_id'] = max($result['max_id'], $row['msg_id']);
$result['chat_rows'][] = formatTimestampShortYear($row['zeit']) . ' ' . generateUserNameByID($row['user_id']) . ': ' . encodeNoHTMLWithBB($row['message']); $result['chat_rows'][] = formatTimestampShortYear($row['zeit']) . ' ' . generateUserNameByID($row['user_id']) . ': ' . encodeNoHTMLWithBB($row['message']);
} }
if(!$asc) {
$copy = array();
for ($i=0; $i<count($result['chat_rows']); $i++) {
$copy[$i] = $result['chat_rows'][count($result['chat_rows']) - ($i + 1)];
}
$result['chat_rows'] = $copy;
}
return $result; return $result;
} }
return NULL; return NULL;

@ -77,16 +77,24 @@ function getChatMessages($userid, $messageid = 0, $asc = true, $limit = 25){
$minid = $messageid; $minid = $messageid;
} }
$result = db_query('SELECT *, Minute(zeit) as m, Hour(zeit) as h FROM ag_chat WHERE id > '.$minid.' ORDER BY ID '.($asc?'ASC':'DESC').' LIMIT '.$limit); $result = db_query('SELECT *, Minute(zeit) as m, Hour(zeit) as h FROM ag_chat WHERE id > '.$minid.' ORDER BY ID ASC LIMIT '.$limit);
while ($row = mysql_fetch_assoc($result)) { while ($row = mysql_fetch_assoc($result)) {
$h = $row['h']; $h = $row['h'];
if($h < 10){ $h = '0'.$h;} if($h < 10){ $h = '0'.$h;}
$m = $row['m']; $m = $row['m'];
if($m < 10){ $m = '0'.$m;} if($m < 10){ $m = '0'.$m;}
$resultstring .= '<div>'.$h.':'.$m.' '.$row['user'].': '.$row['nachricht'].'</div>'; if(!$asc) {
$resultstring = '<div>'.$h.':'.$m.' '.$row['user'].': '.$row['nachricht'].'</div>'.$resultstring;
} else {
$resultstring .= '<div>'.$h.':'.$m.' '.$row['user'].': '.$row['nachricht'].'</div>';
}
} }
if(isSpammer($userid)){ if(isSpammer($userid)){
$resultstring.= '<div style="color:red">SPAM-BLOCKIERUNG!!</div>'; if(!$asc) {
$resultstring = '<div style="color:red">SPAM-BLOCKIERUNG!!</div>'.$resultstring;
} else {
$resultstring.= '<div style="color:red">SPAM-BLOCKIERUNG!!</div>';
}
} }
return $maxid.';'.$resultstring; return $maxid.';'.$resultstring;
} }

Loading…
Cancel
Save