From 7b3a7dba1dec437e2e987122d78c521c4b377c7f Mon Sep 17 00:00:00 2001 From: billz Date: Mon, 20 Mar 2023 20:14:01 +0100 Subject: [PATCH] Move template logic to includes + code cleanup --- includes/functions.php | 3 +-- includes/hostapd.php | 28 +++++++++++++++++++++++++++- templates/hostapd/advanced.php | 6 ++---- templates/hostapd/basic.php | 32 +++----------------------------- 4 files changed, 33 insertions(+), 36 deletions(-) diff --git a/includes/functions.php b/includes/functions.php index df437037..35d285cf 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -800,7 +800,6 @@ function getTooltip($msg, $id, $visible = true, $data_html = false) { ($visible) ? $opt1 = 'visible' : $opt1 = 'invisible'; ($data_html) ? $opt2 = 'data-html="true"' : $opt2 = 'data-html="false"'; - $tooltip = ''; - return $tooltip; + echo ''; } diff --git a/includes/hostapd.php b/includes/hostapd.php index 6eb5909d..7f47cd7d 100755 --- a/includes/hostapd.php +++ b/includes/hostapd.php @@ -109,6 +109,30 @@ function DisplayHostAPDConfig() $txpower = $_POST['txpower']; } + $countries_5Ghz_max48ch = RASPI_5GHZ_ISO_ALPHA2; + $selectedHwMode = $arrConfig['hw_mode']; + if (isset($arrConfig['ieee80211n'])) { + if (strval($arrConfig['ieee80211n']) === '1') { + $selectedHwMode = 'n'; + } + } + if (isset($arrConfig['ieee80211ac'])) { + if (strval($arrConfig['ieee80211ac']) === '1') { + $selectedHwMode = 'ac'; + } + } + if (isset($arrConfig['ieee80211w'])) { + if (strval($arrConfig['ieee80211w']) === '2') { + $selectedHwMode = 'w'; + } + } + if (!in_array($arrConfig['country_code'], $countries_5Ghz_max48ch)) { + $hwModeDisabled = 'ac'; + if ($selectedHwMode === $hwModeDisabled) { + unset($selectedHwMode); + } + } + echo renderTemplate( "hostapd", compact( "status", @@ -124,7 +148,9 @@ function DisplayHostAPDConfig() "arrTxPower", "txpower", "arrHostapdConf", - "operatingSystem" + "operatingSystem", + "selectedHwMode", + "hwModeDisabled" ) ); } diff --git a/templates/hostapd/advanced.php b/templates/hostapd/advanced.php index 916b3308..d765d34c 100644 --- a/templates/hostapd/advanced.php +++ b/templates/hostapd/advanced.php @@ -56,10 +56,8 @@
- - + + txpower option for the AP interface and the configured country."); ?>
diff --git a/templates/hostapd/basic.php b/templates/hostapd/basic.php index ddc019ad..f421490d 100644 --- a/templates/hostapd/basic.php +++ b/templates/hostapd/basic.php @@ -3,9 +3,7 @@
- +
@@ -17,32 +15,8 @@
- - + +
">