|
|
@ -70,13 +70,23 @@ function getChatMessages($userid, $messageid = 0, $asc = true, $limit = 25){
|
|
|
|
if(!is_numeric($messageid)){
|
|
|
|
if(!is_numeric($messageid)){
|
|
|
|
$messageid = 0;
|
|
|
|
$messageid = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$row = mysql_fetch_row(db_query('Select max(id) from ag_chat'));
|
|
|
|
$row = mysql_fetch_row(db_query('Select max(id), count(id) from ag_chat'));
|
|
|
|
$maxid = $row[0];
|
|
|
|
$maxid = $row[0];
|
|
|
|
$minid = $maxid - $limit;
|
|
|
|
$count = $row[1];
|
|
|
|
|
|
|
|
if($maxid === null) {
|
|
|
|
|
|
|
|
$maxid = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if($count > $limit) {
|
|
|
|
|
|
|
|
$minid = $maxid - $limit;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$minid = $maxid - $count;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if($messageid > $minid){
|
|
|
|
if($messageid > $minid){
|
|
|
|
$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 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'];
|
|
|
|