diff --git a/html/includes/common/top-devices.inc.php b/html/includes/common/top-devices.inc.php index 9eb13229f..24e76c8cb 100644 --- a/html/includes/common/top-devices.inc.php +++ b/html/includes/common/top-devices.inc.php @@ -60,19 +60,19 @@ else { $common_output[] = '

Top '.$device_count.' devices (last '.$interval.' minutes)

'; - if (is_admin() || is_read()) { $query = ' SELECT *, sum(p.ifInOctets_rate + p.ifOutOctets_rate) as total FROM ports as p, devices as d WHERE d.device_id = p.device_id - AND unix_timestamp() - p.poll_time < '.$interval_seconds.' + AND unix_timestamp() - p.poll_time < ? AND ( p.ifInOctets_rate > 0 OR p.ifOutOctets_rate > 0 ) GROUP BY d.device_id ORDER BY total desc - LIMIT '.$device_count.' - '; + LIMIT ? + '; + $params = array($interval_seconds, $device_count); } else { $query = ' @@ -80,15 +80,15 @@ else { FROM ports as p, devices as d, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `d`.`device_id` AND d.device_id = p.device_id - AND unix_timestamp() - p.poll_time < '.$interval_seconds.' + AND unix_timestamp() - p.poll_time < ? AND ( p.ifInOctets_rate > 0 OR p.ifOutOctets_rate > 0 ) GROUP BY d.device_id ORDER BY total desc - LIMIT '.$device_count.' + LIMIT ? '; + $params = array($_SESSION['user_id'], $interval_seconds, $device_count); } - $common_output[] = '
@@ -101,7 +101,7 @@ else { '; - foreach (dbFetchRows($query, array($_SESSION['user_id'])) as $result) { + foreach (dbFetchRows($query, $params) as $result) { $common_output[] = ' diff --git a/html/includes/common/top-interfaces.inc.php b/html/includes/common/top-interfaces.inc.php index b7bfe0241..563da5825 100644 --- a/html/includes/common/top-interfaces.inc.php +++ b/html/includes/common/top-interfaces.inc.php @@ -65,12 +65,13 @@ else { SELECT *, p.ifInOctets_rate + p.ifOutOctets_rate as total FROM ports as p, devices as d WHERE d.device_id = p.device_id - AND unix_timestamp() - p.poll_time < '.$interval_seconds.' + AND unix_timestamp() - p.poll_time < ? AND ( p.ifInOctets_rate > 0 OR p.ifOutOctets_rate > 0 ) ORDER BY total desc - LIMIT '.$interface_count.' + LIMIT ? '; + $params = array($interval_seconds, $interface_count); } else { $query = ' @@ -81,12 +82,13 @@ else { OR (`PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` AND `I`.`device_id` = `d`.`device_id`)) AND d.device_id = I.device_id - AND unix_timestamp() - I.poll_time < '.$interval_seconds.' + AND unix_timestamp() - I.poll_time < ? AND ( I.ifInOctets_rate > 0 OR I.ifOutOctets_rate > 0 ) ORDER BY total desc - LIMIT '.$interface_count.' + LIMIT ? '; + $params = array($_SESSION['user_id'], $interval_seconds, $device_count); } $common_output[] = ' @@ -102,7 +104,7 @@ else { '; - foreach (dbFetchRows($query, array($_SESSION['user_id'])) as $result) { + foreach (dbFetchRows($query, $params) as $result) { $common_output[] = '
'.generate_device_link($result, shorthost($result['hostname'])).'
'.generate_device_link($result, shorthost($result['hostname'])).'