2 ) { exec( 'wpa_passphrase '.$ssid. ' ' . $psk,$network ); foreach($network as $b) { $config .= "$b "; } } } exec( "echo '$config' > /tmp/wifidata", $return ); system( 'sudo cp /tmp/wifidata ' . RASPI_WPA_SUPPLICANT_CONFIG, $returnval ); if( $returnval == 0 ) { $status->addMessage('Wifi settings updated successfully', 'success'); } else { $status->addMessage('Wifi settings failed to be updated', 'danger'); } } elseif( isset($_POST['Scan']) ) { $return = ''; exec( 'sudo wpa_cli scan',$return ); sleep(3); exec( 'sudo wpa_cli scan_results',$return ); for( $shift = 0; $shift < 4; $shift++ ) { array_shift($return); } // display output foreach( $return as $network ) { $arrNetwork = preg_split("/[\t]+/",$network); $scanned_networks[] = array( 'bssid' => $arrNetwork[0], 'channel' => ConvertToChannel($arrNetwork[1]), 'signal' => $arrNetwork[2] . " dBm", 'security' => ConvertToSecurity($arrNetwork[3]), 'ssid' => $arrNetwork[4] ); } echo ''; } // default action, output configured network(s) exec(' sudo cat ' . RASPI_WPA_SUPPLICANT_CONFIG, $supplicant_return); $ssid = array(); $psk = array(); foreach($supplicant_return as $a) { if(preg_match('/SSID/i',$a)) { $arrssid = explode("=",$a); $ssid[] = str_replace('"','',$arrssid[1]); } if(preg_match('/psk/i',$a)) { $arrpsk = explode("=",$a); $psk[] = str_replace('"','',$arrpsk[1]); } } $numSSIDs = count($ssid); ?>
showMessages(); ?>