diff --git a/includes/configure_client.php b/includes/configure_client.php index f13f6917..52a9d276 100755 --- a/includes/configure_client.php +++ b/includes/configure_client.php @@ -6,7 +6,7 @@ */ function DisplayWPAConfig(){ $status = new StatusMessages(); - $scanned_networks = array(); + $networks = array(); // Find currently configured networks exec(' sudo cat ' . RASPI_WPA_SUPPLICANT_CONFIG, $known_return); @@ -49,7 +49,11 @@ function DisplayWPAConfig(){ } } - if ( isset($_POST['client_settings']) && CSRFValidate() ) { + if ( isset($_POST['connect']) ) { + $result = 0; + exec ( 'sudo wpa_cli -i ' . RASPI_WPA_CTRL_INTERFACE . ' select_network '.strval($_POST['connect'] )); + } + else if ( isset($_POST['client_settings']) && CSRFValidate() ) { $tmp_networks = $networks; if ($wpa_file = fopen('/tmp/wifidata', 'w')) { fwrite($wpa_file, 'ctrl_interface=DIR=' . RASPI_WPA_CTRL_INTERFACE . ' GROUP=netdev' . PHP_EOL); @@ -107,31 +111,40 @@ function DisplayWPAConfig(){ if ($ok) { system( 'sudo cp /tmp/wifidata ' . RASPI_WPA_SUPPLICANT_CONFIG, $returnval ); if( $returnval == 0 ) { - exec('sudo wpa_cli reconfigure', $reconfigure_out, $reconfigure_return ); + exec('sudo wpa_cli -i ' . RASPI_WIFI_CLIENT_INTERFACE . ' reconfigure', $reconfigure_out, $reconfigure_return ); if ($reconfigure_return == 0) { $status->addMessage('Wifi settings updated successfully', 'success'); $networks = $tmp_networks; } else { - $status->addMessage('Wifi settings updated but cannot restart (cannot execute "wpa_cli reconfigure")', 'danger'); + $status->addMessage('Wifi settings updated but cannot restart (cannon execute "wpa_cli reconfigure")', 'danger'); } } else { $status->addMessage('Wifi settings failed to be updated', 'danger'); } } } else { - $status->addMessage('Failed to update wifi settings', 'danger'); + $status->addMessage('Failed to updated wifi settings', 'danger'); } } exec( 'sudo wpa_cli -i ' . RASPI_WIFI_CLIENT_INTERFACE . ' scan' ); sleep(3); exec( 'sudo wpa_cli -i ' . RASPI_WIFI_CLIENT_INTERFACE . ' scan_results',$scan_return ); - for( $shift = 0; $shift < 1; $shift++ ) { + + for( $shift = 0; $shift < 2; $shift++ ) { array_shift($scan_return); } + // display output foreach( $scan_return as $network ) { - $arrNetwork = preg_split("/[\t]+/",$network); + $arrNetwork = preg_split("/[\t]+/",$network); // split result into array + + // Save RSSI + if (array_key_exists(4, $arrNetwork)) { + $networks[$arrNetwork[4]]['RSSI'] = $arrNetwork[2]; + } + + // If network is saved if (array_key_exists(4, $arrNetwork) && array_key_exists($arrNetwork[4], $networks)) { $networks[$arrNetwork[4]]['visible'] = true; $networks[$arrNetwork[4]]['channel'] = ConvertToChannel($arrNetwork[1]); @@ -158,78 +171,124 @@ function DisplayWPAConfig(){
-
+

showMessages(); ?>

-
+
-
-
- - - - - - - - - - - - - $network) { ?> - - - - - - - - - - - - - - - + +
+
Channel
+
+ + + + X + +
+
+ +
+
RSSI
+
+ = -50) { echo 100; } + else if($network['RSSI'] <= -100) { echo 0;} + else {echo 2*($network['RSSI'] + 100); } + echo "%)"; + ?> +
+
+ + + + + + +
+
Security
+
+
+ +
+
+ Passphrase + + --- + + + + + + +
+
+ +
+ + " id="update" name="update" /> + + + " id="update" name="update" /> + + " name="delete" /> +
+ + + + + + -
- - - - - - - + + + + + + + + + $network) { ?> + +
+
+
+ - -
X - - - - - --- - - -
- - " id="update" name="update" /> - - " id="update" name="update" /> - - " name="delete" /> +

+ +
+
Status
+
+ + + + + + +
-
+
- +