".
"| ".generate_device_link($result, shorthost($result['hostname']))." | ".
"".generate_device_link($result,
diff --git a/html/includes/front/top_ports.inc.php b/html/includes/front/top_ports.inc.php
index a20795163..9a09f3057 100644
--- a/html/includes/front/top_ports.inc.php
+++ b/html/includes/front/top_ports.inc.php
@@ -15,20 +15,36 @@
$minutes = 15;
$seconds = $minutes * 60;
$top = $config['front_page_settings']['top']['ports'];
-$query = "
- 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 < $seconds
- AND ( p.ifInOctets_rate > 0
- OR p.ifOutOctets_rate > 0 )
- ORDER BY total desc
- LIMIT $top
-";
+if (is_admin() === TRUE || is_read() === TRUE) {
+ $query = "
+ 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 < $seconds
+ AND ( p.ifInOctets_rate > 0
+ OR p.ifOutOctets_rate > 0 )
+ ORDER BY total desc
+ LIMIT $top
+ ";
+} else {
+ $query = "
+ SELECT *, I.ifInOctets_rate + I.ifOutOctets_rate as total
+ FROM ports as I, devices as d,
+ `devices_perms` AS `P`, `ports_perms` AS `PP`
+ WHERE ((`P`.`user_id` = ? AND `P`.`device_id` = `d`.`device_id`) 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 < $seconds
+ AND ( I.ifInOctets_rate > 0
+ OR I.ifOutOctets_rate > 0 )
+ ORDER BY total desc
+ LIMIT $top
+ ";
+ $param[] = array($_SESSION['user_id'],$_SESSION['user_id']);
+}
echo("Top $top ports (last $minutes minutes)\n");
echo("\n");
-foreach (dbFetchRows($query) as $result) {
+foreach (dbFetchRows($query,$param) as $result) {
echo("".
"| ".generate_device_link($result, shorthost($result['hostname']))." | ".
"".generate_port_link($result)." | ".
|