Configure client

Client settings

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 ) { echo '
Wifi settings updated successfully
'; } else { echo '
Wifi settings failed to be updated
'; } // scan networks } 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 echo '
'; echo '
'; echo '

Networks found

'; echo ''; foreach( $return as $network ) { $arrNetwork = preg_split("/[\t]+/",$network); $bssid = $arrNetwork[0]; $channel = ConvertToChannel($arrNetwork[1]); $signal = $arrNetwork[2] . " dBm"; $security = $arrNetwork[3]; $ssid = $arrNetwork[4]; echo '"; } echo '
SSIDChannelSignalSecurity
' . $ssid . " " . $channel . "" . $signal . "". ConvertToSecurity($security) ."
'; } else { // default action, output configured network(s) exec(' sudo cat ' . RASPI_WPA_SUPPLICANT_CONFIG, $return); $ssid = array(); $psk = array(); foreach($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); $output = '
'; if ( $numSSIDs > 0 ) { for( $ssids = 0; $ssids < $numSSIDs; $ssids++ ) { $output .= '
'; } $output .= '
'; } else { $status = '
Not connected
'; } $output .= '
'; $output .= ''; echo $output; } ?>