From 677a6c52b0a25da298d08b30abf1dde4c94e59ce Mon Sep 17 00:00:00 2001 From: billz Date: Sun, 7 Jun 2020 14:23:40 +0100 Subject: [PATCH] Get/set wireless iface from ini, store in _SESSION --- includes/hostapd.php | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/includes/hostapd.php b/includes/hostapd.php index 34fbfd59..67f93255 100755 --- a/includes/hostapd.php +++ b/includes/hostapd.php @@ -4,6 +4,15 @@ require_once 'includes/status_messages.php'; require_once 'app/lib/system.php'; require_once 'config.php'; +if (empty($_SESSION['client_iface'])) { + $arrHostapdConf = parse_ini_file(RASPI_CONFIG.'/hostapd.ini'); + if (isset($arrHostapdConf['WifiInterface'])) { + $_SESSION['client_iface'] = $arrHostapdConf['WifiInterface']; + } else { // fallback to default + $_SESSSION['client_iface'] = RASPI_WIFI_CLIENT_INTERFACE; + } +} + /** * * @@ -146,27 +155,28 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status) if ($arrHostapdConf['LogEnable'] == 0) { if (isset($_POST['logEnable'])) { $logEnable = 1; - exec('sudo /etc/raspap/hostapd/enablelog.sh'); + exec('sudo '.RASPI_CONFIG.'/hostapd/enablelog.sh'); } else { - exec('sudo /etc/raspap/hostapd/disablelog.sh'); + exec('sudo '.RASPI_CONFIG.'/hostapd/disablelog.sh'); } } else { if (isset($_POST['logEnable'])) { $logEnable = 1; - exec('sudo /etc/raspap/hostapd/enablelog.sh'); + exec('sudo '.RASPI_CONFIG.'/hostapd/enablelog.sh'); } else { - exec('sudo /etc/raspap/hostapd/disablelog.sh'); + exec('sudo '.RASPI_CONFIG.'/hostapd/disablelog.sh'); } } $cfg = []; + $cfg['WifiInterface'] = $_POST['interface']; $cfg['LogEnable'] = $logEnable; // Save previous Client mode status when Bridged $cfg['WifiAPEnable'] = ($bridgedEnable == 1 ? $arrHostapdConf['WifiAPEnable'] : $wifiAPEnable); $cfg['BridgedEnable'] = $bridgedEnable; $cfg['WifiManaged'] = $_POST['interface']; - write_php_ini($cfg, '/etc/raspap/hostapd.ini'); + write_php_ini($cfg, RASPI_CONFIG.'/hostapd.ini'); // Verify input if (empty($_POST['ssid']) || strlen($_POST['ssid']) > 32) { @@ -335,11 +345,8 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status) if (preg_match("/^([0-9]{1,3}\.){3}/",$dhcp_range,$def_ip) ) $ip_address = $def_ip[0]."1/24"; // use static IP assigned to interface only, if consistent with the selected dhcp range if (preg_match("/^([0-9]{1,3}\.){3}/",$intConfig['ip_address'],$int_ip) && $def_ip[0] === $int_ip[0]) $ip_address = $intConfig['ip_address']; - - $routers = ""; // NO default route to be set for the hotspot. This screws up the routing! $config[] = 'interface '.$_POST['interface']; $config[] = 'static ip_address='.$ip_address; - $config[] = 'static routers='.$routers; $config[] = 'static domain_name_server='.$domain_name_server; $config[] = PHP_EOL;