From 746f918a8a395ee3ff23a4a6fffe29f78a1f65a2 Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 14 Jul 2015 13:11:54 +0100 Subject: [PATCH] More map updates --- html/includes/print-map.inc.php | 84 ++++++++++++++++++++++++++------- 1 file changed, 66 insertions(+), 18 deletions(-) diff --git a/html/includes/print-map.inc.php b/html/includes/print-map.inc.php index 6fc83465b..45a814e25 100644 --- a/html/includes/print-map.inc.php +++ b/html/includes/print-map.inc.php @@ -17,21 +17,62 @@ $row_colour="#ffffff"; $sql_array= array(); if (!empty($device['hostname'])) { - $sql = ' `devices`.`hostname`=?'; - $sql_array = array($device['hostname']); + $sql = ' AND (`D1`.`hostname`=? OR `D2`.`hostname`=?)'; + $sql_array = array($device['hostname'], $device['hostname']); $mac_sql = ' AND `D`.`hostname` = ?'; $mac_array = array($device['hostname']); } else { $sql = ' '; } -$sql .= ' AND `local_device_id` != 0 AND `remote_device_id` != 0 '; -$sql .= ' AND `local_device_id` IS NOT NULL AND `remote_device_id` IS NOT NULL '; +if (is_admin() === false && is_read() === false) { + $join_sql .= ' LEFT JOIN `devices_perms` AS `DP` ON `D1`.`device_id` = `DP`.`device_id`'; + $sql .= ' AND `DP`.`user_id`=?'; + $sql_array[] = $_SESSION['user_id']; +} $tmp_devices = array(); $tmp_ids = array(); $tmp_links = array(); -foreach (dbFetchRows("SELECT + + +$ports = dbFetchRows("SELECT + `D1`.`device_id` AS `local_device_id`, + `D1`.`os` AS `local_os`, + `D1`.`hostname` AS `local_hostname`, + `D2`.`device_id` AS `remote_device_id`, + `D2`.`os` AS `remote_os`, + `D2`.`hostname` AS `remote_hostname`, + `P1`.`port_id` AS `local_port_id`, + `P1`.`device_id` AS `local_port_device_id`, + `P1`.`ifName` AS `local_ifname`, + `P1`.`ifSpeed` AS `local_ifspeed`, + `P1`.`ifOperStatus` AS `local_ifoperstatus`, + `P1`.`ifAdminStatus` AS `local_ifadminstatus`, + `P1`.`ifInOctets_rate` AS `local_ifinoctets_rate`, + `P1`.`ifOutOctets_rate` AS `local_ifoutoctets_rate`, + `P2`.`port_id` AS `remote_port_id`, + `P2`.`device_id` AS `remote_port_device_id`, + `P2`.`ifName` AS `remote_ifname`, + `P2`.`ifSpeed` AS `remote_ifspeed`, + `P2`.`ifOperStatus` AS `remote_ifoperstatus`, + `P2`.`ifAdminStatus` AS `remote_ifadminstatus`, + `P2`.`ifInOctets_rate` AS `remote_ifinoctets_rate`, + `P2`.`ifOutOctets_rate` AS `remote_ifoutoctets_rate` + FROM `ipv4_mac` AS `M` + LEFT JOIN `ports` AS `P1` ON `P1`.`port_id`=`M`.`port_id` + LEFT JOIN `ports` AS `P2` ON `P2`.`ifPhysAddress`=`M`.`mac_address` + LEFT JOIN `devices` AS `D1` ON `P1`.`device_id`=`D1`.`device_id` + LEFT JOIN `devices` AS `D2` ON `P2`.`device_id`=`D2`.`device_id` + $join_sql + WHERE + `P1`.`port_id` IS NOT NULL AND + `P2`.`port_id` IS NOT NULL AND + `D1`.`device_id` != `D2`.`device_id` + $sql + ", $sql_array); + +$devices = dbFetchRows("SELECT `D1`.`device_id` AS `local_device_id`, `D1`.`os` AS `local_os`, `D1`.`hostname` AS `local_hostname`, @@ -59,10 +100,19 @@ foreach (dbFetchRows("SELECT LEFT JOIN `devices` AS `D2` ON `D2`.`device_id`=`links`.`remote_device_id` LEFT JOIN `ports` AS `P1` ON `P1`.`port_id`=`links`.`local_port_id` LEFT JOIN `ports` AS `P2` ON `P2`.`port_id`=`links`.`remote_port_id` + $join_sql WHERE - `active`=1 + `active`=1 AND + `local_device_id` != 0 AND + `remote_device_id` != 0 AND + `local_device_id` IS NOT NULL AND + `remote_device_id` IS NOT NULL $sql - ",$sql_array) as $items) { + ", $sql_array); + +$list = array_merge($ports,$devices); + +foreach ($list as $items) { $local_device = array('device_id'=>$items['local_device_id'], 'os'=>$items['local_os'], 'hostname'=>$items['local_hostname']); $remote_device = array('device_id'=>$items['remote_device_id'], 'os'=>$items['remote_os'], 'hostname'=>$items['remote_hostname']); @@ -77,7 +127,7 @@ foreach (dbFetchRows("SELECT } array_push($tmp_ids,$items['local_device_id']); array_push($tmp_ids,$items['remote_device_id']); - $speed = $items['ifSpeed']/1000/1000; + $speed = $items['local_ifspeed']/1000/1000; if ($speed == 100) { $width = 3; } elseif ($speed == 1000) { @@ -117,7 +167,8 @@ if (count($node_devices) > 1 && count($tmp_links) > 0) {
-