From 47f6366bf9092f1bcf31af5cf0f12d5a9ce7e5dd Mon Sep 17 00:00:00 2001 From: Lawrence Date: Wed, 4 Oct 2017 00:09:50 +0800 Subject: [PATCH 1/3] Changed the dashboard to use ip rather than ifconfig for Jessie/Stretch compatibility --- includes/dashboard.php | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/includes/dashboard.php b/includes/dashboard.php index e05ea0d4..234d6bc5 100755 --- a/includes/dashboard.php +++ b/includes/dashboard.php @@ -8,19 +8,28 @@ function DisplayDashboard(){ $status = new StatusMessages(); - exec( 'ifconfig wlan0', $return ); + exec( 'ip a s wlan0', $return ); exec( 'iwconfig wlan0', $return ); $strWlan0 = implode( " ", $return ); $strWlan0 = preg_replace( '/\s\s+/', ' ', $strWlan0 ); + var_dump($strWlan0); + // Parse results from ifconfig/iwconfig - preg_match( '/HWaddr ([0-9a-f:]+)/i',$strWlan0,$result ) || $result[1] = 'No MAC Address Found'; + preg_match( '/link\/ether ([0-9a-f:]+)/i',$strWlan0,$result ) || $result[1] = 'No MAC Address Found'; $strHWAddress = $result[1]; - preg_match( '/inet addr:([0-9.]+)/i',$strWlan0,$result ) || $result[1] = 'No IP Address Found'; - $strIPAddress = $result[1]; - preg_match( '/Mask:([0-9.]+)/i',$strWlan0,$result ) || $result[1] = 'No Subnet Mask Found'; - $strNetMask = $result[1]; + preg_match_all( '/inet ([0-9.]+)/i',$strWlan0,$result ) || $result[1] = 'No IP Address Found'; + $strIPAddress = ''; + foreach($result[1] as $ip) { + $strIPAddress .= $ip." "; + } + preg_match_all( '/[0-9.]+\/([0-3][0-9])/i',$strWlan0,$result ) || $result[1] = 'No Subnet Mask Found'; + $strNetMask = ''; + foreach($result[1] as $netmask) { + $strNetMask .= long2ip(-1 << (32 -(int)$netmask))." "; + } + //$strNetMask = long2ip(-1 << (32 - (int)$result[1][0])); preg_match( '/RX packets:(\d+)/',$strWlan0,$result ) || $result[1] = 'No Data'; $strRxPackets = $result[1]; preg_match( '/TX packets:(\d+)/',$strWlan0,$result ) || $result[1] = 'No Data'; @@ -44,7 +53,7 @@ function DisplayDashboard(){ preg_match('/Frequency:(\d+.\d+ GHz)/i',$strWlan0,$result) || $result[1] = ''; $strFrequency = $result[1]; - if(strpos( $strWlan0, "UP" ) !== false && strpos( $strWlan0, "RUNNING" ) !== false ) { + if(strpos( $strWlan0, "UP" ) !== false) { $status->addMessage('Interface is up', 'success'); $wlan0up = true; } else { From 29aabf1bbe3434a03028981e18eab3eac3d9418a Mon Sep 17 00:00:00 2001 From: Lawrence Date: Wed, 4 Oct 2017 00:15:53 +0800 Subject: [PATCH 2/3] Removing debug code --- includes/dashboard.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/includes/dashboard.php b/includes/dashboard.php index 234d6bc5..a4e4103c 100755 --- a/includes/dashboard.php +++ b/includes/dashboard.php @@ -14,8 +14,6 @@ function DisplayDashboard(){ $strWlan0 = implode( " ", $return ); $strWlan0 = preg_replace( '/\s\s+/', ' ', $strWlan0 ); - var_dump($strWlan0); - // Parse results from ifconfig/iwconfig preg_match( '/link\/ether ([0-9a-f:]+)/i',$strWlan0,$result ) || $result[1] = 'No MAC Address Found'; $strHWAddress = $result[1]; From 1fcb82ff8def0ae2c4b3cd5a7087245d57b1196c Mon Sep 17 00:00:00 2001 From: Lawrence Date: Wed, 4 Oct 2017 00:19:43 +0800 Subject: [PATCH 3/3] Still removing debug code --- includes/dashboard.php | 1 - 1 file changed, 1 deletion(-) diff --git a/includes/dashboard.php b/includes/dashboard.php index a4e4103c..eb090a94 100755 --- a/includes/dashboard.php +++ b/includes/dashboard.php @@ -27,7 +27,6 @@ function DisplayDashboard(){ foreach($result[1] as $netmask) { $strNetMask .= long2ip(-1 << (32 -(int)$netmask))." "; } - //$strNetMask = long2ip(-1 << (32 - (int)$result[1][0])); preg_match( '/RX packets:(\d+)/',$strWlan0,$result ) || $result[1] = 'No Data'; $strRxPackets = $result[1]; preg_match( '/TX packets:(\d+)/',$strWlan0,$result ) || $result[1] = 'No Data';