re-sort traps if history enabled

This commit is contained in:
alejandro.campos@artica.es 2022-11-02 14:25:48 +01:00
parent 8ad0bbf892
commit 930da6c58f
1 changed files with 10 additions and 8 deletions

View File

@ -303,14 +303,7 @@ switch ($config['dbtype']) {
case 'mysql':
$sql = 'SELECT *
FROM ttrap
WHERE (
`source` IN ('.implode(',', $address_by_user_groups).") OR
`source`='' OR
`source` NOT IN (".implode(',', $all_address_agents).')
)
%s
ORDER BY timestamp DESC
LIMIT %d,%d';
ORDER BY timestamp DESC';
break;
case 'postgresql':
@ -674,6 +667,15 @@ $filter_resume['trap_type'] = $trap_types[$trap_type];
$traps = db_get_all_rows_sql($sql, true);
$trapcount = (int) db_get_value_sql($sql_count, false, true);
// Re-sort traps by timestamp if history db is enabled.
if ($config['history_db_enabled'] == 1) {
usort($traps, function($a, $b)
{
return strtotime($a['timestamp']) < strtotime($b['timestamp']);
}
);
}
// No traps.
if (empty($traps)) {
// Header