From f6b6fe36dafa2899d4927829513fc27f670f12a3 Mon Sep 17 00:00:00 2001 From: leiweibau <105860611+leiweibau@users.noreply.github.com> Date: Thu, 28 Jul 2022 21:53:52 +0200 Subject: [PATCH] add multiple hosts per port support --- front/network.php | 73 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 54 insertions(+), 19 deletions(-) diff --git a/front/network.php b/front/network.php index 4f885ce4..58ce87c8 100644 --- a/front/network.php +++ b/front/network.php @@ -163,10 +163,6 @@ function createnetworktabcontent($pia_func_netdevid, $pia_func_netdevname, $pia_ $network_device_portmac = array(); $network_device_portip = array(); $network_device_portstate = array(); - if ($pia_func_netdevport > 1) - { - for ($x=1; $x<=$pia_func_netdevport; $x++) { $network_device_portname[$x] = ''; $network_device_portmac[$x] = ''; $network_device_portip[$x] = ''; $network_device_portstate[$x] = ''; } - } // make sql query for Network Hardware ID global $db; $func_sql = 'SELECT * FROM "Devices" WHERE "dev_Infrastructure" = "'.$pia_func_netdevid.'"'; @@ -178,10 +174,14 @@ function createnetworktabcontent($pia_func_netdevid, $pia_func_netdevname, $pia_ if ($pia_func_netdevport > 1) { if (stristr($func_res['dev_Infrastructure_port'], ',') == '') { - $network_device_portname[$func_res['dev_Infrastructure_port']] = $func_res['dev_Name']; - $network_device_portmac[$func_res['dev_Infrastructure_port']] = $func_res['dev_MAC']; - $network_device_portip[$func_res['dev_Infrastructure_port']] = $func_res['dev_LastIP']; - $network_device_portstate[$func_res['dev_Infrastructure_port']] = $func_res['dev_PresentLastScan']; + if ($network_device_portname[$func_res['dev_Infrastructure_port']] != '') {$network_device_portname[$func_res['dev_Infrastructure_port']] = $network_device_portname[$func_res['dev_Infrastructure_port']].','.$func_res['dev_Name'];} else {$network_device_portname[$func_res['dev_Infrastructure_port']] = $func_res['dev_Name'];} + if ($network_device_portmac[$func_res['dev_Infrastructure_port']] != '') {$network_device_portmac[$func_res['dev_Infrastructure_port']] = $network_device_portmac[$func_res['dev_Infrastructure_port']].','.$func_res['dev_MAC'];} else {$network_device_portmac[$func_res['dev_Infrastructure_port']] = $func_res['dev_MAC'];} + if ($network_device_portip[$func_res['dev_Infrastructure_port']] != '') {$network_device_portip[$func_res['dev_Infrastructure_port']] = $network_device_portip[$func_res['dev_Infrastructure_port']].','.$func_res['dev_LastIP'];} else {$network_device_portip[$func_res['dev_Infrastructure_port']] = $func_res['dev_LastIP'];} + if (isset($network_device_portstate[$func_res['dev_Infrastructure_port']])) {$network_device_portstate[$func_res['dev_Infrastructure_port']] = $network_device_portstate[$func_res['dev_Infrastructure_port']].','.$func_res['dev_PresentLastScan'];} else {$network_device_portstate[$func_res['dev_Infrastructure_port']] = $func_res['dev_PresentLastScan'];} + //$network_device_portname[$func_res['dev_Infrastructure_port']] = $func_res['dev_Name']; + //$network_device_portmac[$func_res['dev_Infrastructure_port']] = $func_res['dev_MAC']; + //$network_device_portip[$func_res['dev_Infrastructure_port']] = $func_res['dev_LastIP']; + //$network_device_portstate[$func_res['dev_Infrastructure_port']] = $func_res['dev_PresentLastScan']; } else { $multiport = array(); $multiport = explode(',',$func_res['dev_Infrastructure_port']); @@ -193,10 +193,6 @@ function createnetworktabcontent($pia_func_netdevid, $pia_func_netdevname, $pia_ } unset($multiport); } - // $network_device_portname[$func_res['dev_Infrastructure_port']] = $func_res['dev_Name']; - // $network_device_portmac[$func_res['dev_Infrastructure_port']] = $func_res['dev_MAC']; - // $network_device_portip[$func_res['dev_Infrastructure_port']] = $func_res['dev_LastIP']; - // $network_device_portstate[$func_res['dev_Infrastructure_port']] = $func_res['dev_PresentLastScan']; } else { // Table without Port > echo values echo '