Code refacturing

This commit is contained in:
bergware
2025-02-01 19:45:16 +01:00
parent 19bf71530a
commit 48d708e738
+15 -14
View File
@@ -23,24 +23,25 @@ $wifi = is_file($cfg) ? (array)parse_ini_file($cfg,true) : [];
$port = array_key_first($wifi);
$text = ["PORT=\"$port\""];
if (!in_array($arg,['no','yes'])) foreach ($wifi as $network => $block) {
if ($network == $port) continue;
if ($block['GROUP'] == $state && (!$arg || $arg == $network)) {
$text[] = "SSID=\"$network\"";
unset($block['GROUP']);
foreach ($block as $key => $value) $text[] = "$key=\"$value\"";
}
}
if ($arg == 'yes') {
exec("/etc/rc.d/rc.wireless start &>/dev/null &");
} elseif ($arg == 'no') {
exec("/etc/rc.d/rc.wireless stop");
exec("$docroot/webGui/scripts/update_services 5");
} elseif (count($text)>2) {
exec("/etc/rc.d/rc.wireless stop");
file_put_contents_atomic($ini,implode("\n",$text)."\n");
exec("/etc/rc.d/rc.wireless join &>/dev/null &");
exec("$docroot/webGui/scripts/update_services 20");
} else {
foreach ($wifi as $network => $block) {
if ($network == $port) continue;
if ($block['GROUP'] == $state && (!$arg || $arg == $network)) {
$text[] = "SSID=\"$network\"";
unset($block['GROUP']);
foreach ($block as $key => $value) $text[] = "$key=\"$value\"";
}
}
if (count($text)>2) {
exec("/etc/rc.d/rc.wireless stop");
file_put_contents_atomic($ini,implode("\n",$text)."\n");
exec("/etc/rc.d/rc.wireless join &>/dev/null &");
exec("$docroot/webGui/scripts/update_services 20");
}
}
?>