From db7acf97edfe569f66db787fbf919b35177c1434 Mon Sep 17 00:00:00 2001 From: Alvin Schiller <103769832+AlvinSchiller@users.noreply.github.com> Date: Fri, 8 Mar 2024 21:10:34 +0000 Subject: [PATCH] reorder active connection to front. use uuid for iteration. --- htdocs/inc.setWifi.php | 36 +++++++++++++--------- scripts/helperscripts/inc.networkHelper.sh | 8 ++--- 2 files changed, 26 insertions(+), 18 deletions(-) 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 @@ ?>