mirror of
https://github.com/RaspAP/raspap-webgui.git
synced 2024-11-22 07:30:23 +00:00
Get/set wireless iface from ini, store in _SESSION
This commit is contained in:
parent
95c5126776
commit
677a6c52b0
1 changed files with 15 additions and 8 deletions
|
@ -4,6 +4,15 @@ require_once 'includes/status_messages.php';
|
||||||
require_once 'app/lib/system.php';
|
require_once 'app/lib/system.php';
|
||||||
require_once 'config.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 ($arrHostapdConf['LogEnable'] == 0) {
|
||||||
if (isset($_POST['logEnable'])) {
|
if (isset($_POST['logEnable'])) {
|
||||||
$logEnable = 1;
|
$logEnable = 1;
|
||||||
exec('sudo /etc/raspap/hostapd/enablelog.sh');
|
exec('sudo '.RASPI_CONFIG.'/hostapd/enablelog.sh');
|
||||||
} else {
|
} else {
|
||||||
exec('sudo /etc/raspap/hostapd/disablelog.sh');
|
exec('sudo '.RASPI_CONFIG.'/hostapd/disablelog.sh');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (isset($_POST['logEnable'])) {
|
if (isset($_POST['logEnable'])) {
|
||||||
$logEnable = 1;
|
$logEnable = 1;
|
||||||
exec('sudo /etc/raspap/hostapd/enablelog.sh');
|
exec('sudo '.RASPI_CONFIG.'/hostapd/enablelog.sh');
|
||||||
} else {
|
} else {
|
||||||
exec('sudo /etc/raspap/hostapd/disablelog.sh');
|
exec('sudo '.RASPI_CONFIG.'/hostapd/disablelog.sh');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$cfg = [];
|
$cfg = [];
|
||||||
|
$cfg['WifiInterface'] = $_POST['interface'];
|
||||||
$cfg['LogEnable'] = $logEnable;
|
$cfg['LogEnable'] = $logEnable;
|
||||||
// Save previous Client mode status when Bridged
|
// Save previous Client mode status when Bridged
|
||||||
$cfg['WifiAPEnable'] = ($bridgedEnable == 1 ?
|
$cfg['WifiAPEnable'] = ($bridgedEnable == 1 ?
|
||||||
$arrHostapdConf['WifiAPEnable'] : $wifiAPEnable);
|
$arrHostapdConf['WifiAPEnable'] : $wifiAPEnable);
|
||||||
$cfg['BridgedEnable'] = $bridgedEnable;
|
$cfg['BridgedEnable'] = $bridgedEnable;
|
||||||
$cfg['WifiManaged'] = $_POST['interface'];
|
$cfg['WifiManaged'] = $_POST['interface'];
|
||||||
write_php_ini($cfg, '/etc/raspap/hostapd.ini');
|
write_php_ini($cfg, RASPI_CONFIG.'/hostapd.ini');
|
||||||
|
|
||||||
// Verify input
|
// Verify input
|
||||||
if (empty($_POST['ssid']) || strlen($_POST['ssid']) > 32) {
|
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";
|
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
|
// 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'];
|
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[] = 'interface '.$_POST['interface'];
|
||||||
$config[] = 'static ip_address='.$ip_address;
|
$config[] = 'static ip_address='.$ip_address;
|
||||||
$config[] = 'static routers='.$routers;
|
|
||||||
$config[] = 'static domain_name_server='.$domain_name_server;
|
$config[] = 'static domain_name_server='.$domain_name_server;
|
||||||
$config[] = PHP_EOL;
|
$config[] = PHP_EOL;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue