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 = '';