mirror of
https://github.com/unraid/webgui.git
synced 2026-05-04 16:59:27 -05:00
Code refacturing
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user