From 4a5a39c2bc7d7fcf2a2bcf16ea13c8b309a40a6f Mon Sep 17 00:00:00 2001 From: glaszig Date: Tue, 30 Jul 2019 22:24:01 +0200 Subject: [PATCH 1/2] fix display of ipv6 addresses --- includes/dashboard.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/includes/dashboard.php b/includes/dashboard.php index b0c89df7..2139459d 100755 --- a/includes/dashboard.php +++ b/includes/dashboard.php @@ -48,13 +48,8 @@ function DisplayDashboard() if (!preg_match_all('/inet6 ([a-f0-9:]+)/i', $stdoutIpWRepeatedSpaces, $matchesIpv6Addr)) { $ipv6Addrs = _('No IPv6 Address Found'); } else { - $numMatchesIpv6Addr = count($matchesIpv6Addr); - for ($i = 1; $i < $numMatchesIpv6Addr; ++$i) { - if ($i > 1) { - $ipv6Addrs .= ' '; - } - - $ipv6Addrs .= $matchesIpv6Addr[$i]; + if (isset($matchesIpv6Addr[1])) { + $ipv6Addrs = implode(' ', $matchesIpv6Addr[1]); } } From c2ed6c6e0262e4626897f30dbb3338dbd1b4d385 Mon Sep 17 00:00:00 2001 From: glaszig Date: Tue, 30 Jul 2019 23:15:08 +0200 Subject: [PATCH 2/2] fix display of multiple ipv4 addresses, netmasks on dashboard --- includes/dashboard.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/includes/dashboard.php b/includes/dashboard.php index 2139459d..32de76d9 100755 --- a/includes/dashboard.php +++ b/includes/dashboard.php @@ -29,19 +29,19 @@ function DisplayDashboard() $ipv4Addrs = ''; $ipv4Netmasks = ''; - if (!preg_match_all('/inet (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\/([0-3][0-9])/i', $stdoutIpWRepeatedSpaces, $matchesIpv4AddrAndSubnet)) { + if (!preg_match_all('/inet (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\/([0-3][0-9])/i', $stdoutIpWRepeatedSpaces, $matchesIpv4AddrAndSubnet, PREG_SET_ORDER)) { $ipv4Addrs = _('No IPv4 Address Found'); } else { - $numMatchesIpv4AddrAndSubnet = count($matchesIpv4AddrAndSubnet); - for ($i = 1; $i < $numMatchesIpv4AddrAndSubnet; $i += 2) { - if ($i > 2) { - $ipv4Netmasks .= ' '; - $ipv4Addrs .= ' '; - } + foreach ($matchesIpv4AddrAndSubnet as $inet) { + $address = $inet[1]; + $suffix = (int) $inet[2]; + $netmask = long2ip(-1 << (32 - $suffix)); - $ipv4Addrs .= $matchesIpv4AddrAndSubnet[$i][0]; - $ipv4Netmasks .= long2ip(-1 << (32 -(int)$matchesIpv4AddrAndSubnet[$i+1][0])); + $ipv4Addrs .= " $address"; + $ipv4Netmasks .= " $netmask"; } + $ipv4Addrs = trim($ipv4Addrs); + $ipv4Netmasks = trim($ipv4Netmasks); } $ipv6Addrs = '';