mirror of
				https://github.com/billz/raspap-webgui.git
				synced 2025-03-01 10:31:47 +00:00 
			
		
		
		
	Get/set wireless iface from ini, store in _SESSION
This commit is contained in:
		@@ -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;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user