diff --git a/htdocs/inc.setWifi.php b/htdocs/inc.setWifi.php index b7b56f6e8..691e8a247 100755 --- a/htdocs/inc.setWifi.php +++ b/htdocs/inc.setWifi.php @@ -42,7 +42,7 @@ /* * get all configured wifis */ -$network_confs_shell = shell_exec("sudo bash -c 'source ".$conf['scripts_abs']."/helperscripts/inc.networkHelper.sh && get_all_wireless_networks'"); +$network_confs_shell = shell_exec("sudo bash -c 'source ".$conf['scripts_abs']."/helperscripts/inc.networkHelper.sh && get_wireless_networks'"); $network_confs = explode(' ',$network_confs_shell); $networks = array(); @@ -50,17 +50,25 @@ unset($temp_ssid); unset($temp_pass); unset($temp_prio); + unset($temp_active); $network_conf = explode(':',$line); $temp_ssid = trim($network_conf[0]); $temp_pass = trim($network_conf[1]); $temp_prio = trim($network_conf[2]); + $temp_active = isset($active_essid) && $temp_ssid == $active_essid; if(isset($temp_ssid) && $temp_ssid != "" && isset($temp_pass) && $temp_pass != "") { if(!isset($temp_prio) || !is_numeric($temp_prio)) { $temp_prio = 0; } - $networks[] = array($temp_ssid, $temp_pass, $temp_prio); + $temp_entry = array($temp_ssid => [ $temp_pass, $temp_prio, $temp_active ]); + # use different methods to have the same behavior: the data of the first appearance are kept, following will be ignored + if($temp_active) { + $networks = array_merge($temp_entry, $networks); + } else { + $networks = $networks + $temp_entry; + } } } unset($temp_ssid); @@ -89,12 +97,12 @@ ?>