From 5e44aae1c5b31d006f3b4c926f658f13202fc8cb Mon Sep 17 00:00:00 2001 From: Taikuh Date: Fri, 13 Mar 2020 05:02:26 +0800 Subject: [PATCH] Disable incompatible settings when bridged --- includes/hostapd.php | 37 +++++++++++++++++++++---------------- index.php | 9 +++++++-- templates/hostapd.php | 14 +++++++------- templates/networking.php | 8 ++++++++ 4 files changed, 43 insertions(+), 25 deletions(-) diff --git a/includes/hostapd.php b/includes/hostapd.php index acfe88c3..41d7afcf 100755 --- a/includes/hostapd.php +++ b/includes/hostapd.php @@ -31,10 +31,10 @@ function DisplayHostAPDConfig() SaveHostAPDConfig($arrSecurity, $arrEncType, $arr80211Standard, $interfaces, $status); } elseif (isset($_POST['StartHotspot']) || isset($_POST['RestartHotspot'])) { $status->addMessage('Attempting to start hotspot', 'info'); - if ($arrHostapdConf['WifiAPEnable'] == 1) { - exec('sudo /etc/raspap/hostapd/servicestart.sh --interface uap0 --seconds 3', $return); - } elseif ($arrHostapdConf['BridgedEnable'] == 1) { + if ($arrHostapdConf['BridgedEnable'] == 1) { exec('sudo /etc/raspap/hostapd/servicestart.sh --interface br0 --seconds 3', $return); + } elseif ($arrHostapdConf['WifiAPEnable'] == 1) { + exec('sudo /etc/raspap/hostapd/servicestart.sh --interface uap0 --seconds 3', $return); } else { exec('sudo /etc/raspap/hostapd/servicestart.sh --seconds 3', $return); } @@ -110,18 +110,6 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status) $good_input = true; - // Check for WiFi client AP mode checkbox - $wifiAPEnable = 0; - if ($arrHostapdConf['WifiAPEnable'] == 0) { - if (isset($_POST['wifiAPEnable'])) { - $wifiAPEnable = 1; - } - } else { - if (isset($_POST['wifiAPEnable'])) { - $wifiAPEnable = 1; - } - } - // Check for Bridged AP mode checkbox $bridgedEnable = 0; if ($arrHostapdConf['BridgedEnable'] == 0) { @@ -134,6 +122,20 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status) } } + // Check for WiFi client AP mode checkbox + $wifiAPEnable = 0; + if ($bridgedEnable == 0) { // enable client mode actions when not bridged + if ($arrHostapdConf['WifiAPEnable'] == 0) { + if (isset($_POST['wifiAPEnable'])) { + $wifiAPEnable = 1; + } + } else { + if (isset($_POST['wifiAPEnable'])) { + $wifiAPEnable = 1; + } + } + } + // Check for Logfile output checkbox $logEnable = 0; if ($arrHostapdConf['LogEnable'] == 0) { @@ -151,9 +153,12 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status) exec('sudo /etc/raspap/hostapd/disablelog.sh'); } } + $cfg = []; $cfg['LogEnable'] = $logEnable; - $cfg['WifiAPEnable'] = $wifiAPEnable; + // Save previous Client mode status when Bridged + $cfg['WifiAPEnable'] = ($bridgedEnable == 1 ? + $arrHostapdConf['WifiAPEnable'] : $wifiAPEnable); $cfg['BridgedEnable'] = $bridgedEnable; $cfg['WifiManaged'] = RASPI_WIFI_CLIENT_INTERFACE; write_php_ini($cfg, '/etc/raspap/hostapd.ini'); diff --git a/index.php b/index.php index 4f3d8939..2bedcd9b 100755 --- a/index.php +++ b/index.php @@ -55,6 +55,11 @@ if ($_COOKIE['sidebarToggled'] == 'true' ) { $toggleState = "toggled"; } +// Get Bridged AP mode status +$arrHostapdConf = parse_ini_file('/etc/raspap/hostapd.ini'); +// defaults to false +$bridgedEnabled = $arrHostapdConf['BridgedEnable']; + ?> @@ -124,7 +129,7 @@ if ($_COOKIE['sidebarToggled'] == 'true' ) { - + @@ -139,7 +144,7 @@ if ($_COOKIE['sidebarToggled'] == 'true' ) { - + diff --git a/templates/hostapd.php b/templates/hostapd.php index b7f97899..52433367 100755 --- a/templates/hostapd.php +++ b/templates/hostapd.php @@ -127,19 +127,19 @@
- - - /> - + + /> +
- - /> - + + + /> +
diff --git a/templates/networking.php b/templates/networking.php index acc8e793..7723733b 100755 --- a/templates/networking.php +++ b/templates/networking.php @@ -12,10 +12,18 @@