mirror of
https://github.com/billz/raspap-webgui.git
synced 2023-10-10 13:37:24 +02:00
Bugfix + documentation
This commit is contained in:
parent
de787c424a
commit
bcab63bb30
@ -113,9 +113,9 @@ function removeDnsmasqConfig($iface,$status)
|
|||||||
function scanConfigDir($dir_conf,$interface,$status)
|
function scanConfigDir($dir_conf,$interface,$status)
|
||||||
{
|
{
|
||||||
$syscnf = preg_grep('~\.(conf)$~', scandir($dir_conf));
|
$syscnf = preg_grep('~\.(conf)$~', scandir($dir_conf));
|
||||||
foreach ($syscnf as $key => $file) {
|
foreach ($syscnf as $cnf) {
|
||||||
if ($file !== '090_adblock.conf' && !preg_match('/.*_'.$interface.'.conf/', $file)) {
|
if ($cnf !== '090_adblock.conf' && !preg_match('/.*_'.$interface.'.conf/', $cnf)) {
|
||||||
removeDnsmasqConfig($interface,$status);
|
system('sudo rm /etc/dnsmasq.d/'.$cnf, $result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $status;
|
return $status;
|
||||||
|
@ -8,7 +8,7 @@ require_once 'includes/config.php';
|
|||||||
getWifiInterface();
|
getWifiInterface();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Initialize hostapd values, display interface
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function DisplayHostAPDConfig()
|
function DisplayHostAPDConfig()
|
||||||
@ -34,7 +34,6 @@ function DisplayHostAPDConfig()
|
|||||||
SaveHostAPDConfig($arrSecurity, $arrEncType, $arr80211Standard, $interfaces, $status);
|
SaveHostAPDConfig($arrSecurity, $arrEncType, $arr80211Standard, $interfaces, $status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$arrHostapdConf = parse_ini_file('/etc/raspap/hostapd.ini');
|
$arrHostapdConf = parse_ini_file('/etc/raspap/hostapd.ini');
|
||||||
|
|
||||||
if (!RASPI_MONITOR_ENABLED) {
|
if (!RASPI_MONITOR_ENABLED) {
|
||||||
@ -71,7 +70,6 @@ function DisplayHostAPDConfig()
|
|||||||
if (strlen($hostapdconfigline) === 0) {
|
if (strlen($hostapdconfigline) === 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($hostapdconfigline[0] != "#") {
|
if ($hostapdconfigline[0] != "#") {
|
||||||
$arrLine = explode("=", $hostapdconfigline);
|
$arrLine = explode("=", $hostapdconfigline);
|
||||||
$arrConfig[$arrLine[0]]=$arrLine[1];
|
$arrConfig[$arrLine[0]]=$arrLine[1];
|
||||||
@ -107,6 +105,16 @@ function DisplayHostAPDConfig()
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate user input, save configs for hostapd, dnsmasq & dhcp
|
||||||
|
*
|
||||||
|
* @param array $wpa_array
|
||||||
|
* @param array $enc_types
|
||||||
|
* @param array $modes
|
||||||
|
* @param string $interface
|
||||||
|
* @param object $status
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
|
function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
|
||||||
{
|
{
|
||||||
// It should not be possible to send bad data for these fields so clearly
|
// It should not be possible to send bad data for these fields so clearly
|
||||||
@ -125,12 +133,10 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
|
|||||||
$status->addMessage('Attempting to set channel to invalid number.', 'danger');
|
$status->addMessage('Attempting to set channel to invalid number.', 'danger');
|
||||||
$good_input = false;
|
$good_input = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (intval($_POST['channel']) < 1 || intval($_POST['channel']) > RASPI_5GHZ_MAX_CHANNEL) {
|
if (intval($_POST['channel']) < 1 || intval($_POST['channel']) > RASPI_5GHZ_MAX_CHANNEL) {
|
||||||
$status->addMessage('Attempting to set channel outside of permitted range', 'danger');
|
$status->addMessage('Attempting to set channel outside of permitted range', 'danger');
|
||||||
$good_input = false;
|
$good_input = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for Bridged AP mode checkbox
|
// Check for Bridged AP mode checkbox
|
||||||
$bridgedEnable = 0;
|
$bridgedEnable = 0;
|
||||||
if ($arrHostapdConf['BridgedEnable'] == 0) {
|
if ($arrHostapdConf['BridgedEnable'] == 0) {
|
||||||
@ -173,12 +179,12 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// persist user-defined options to /etc/raspap
|
||||||
$cfg = [];
|
$cfg = [];
|
||||||
$cfg['WifiInterface'] = $_POST['interface'];
|
$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, RASPI_CONFIG.'/hostapd.ini');
|
write_php_ini($cfg, RASPI_CONFIG.'/hostapd.ini');
|
||||||
@ -236,6 +242,7 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
|
|||||||
$_POST['max_num_sta'] = $_POST['max_num_sta'] > 2007 ? 2007 : $_POST['max_num_sta'];
|
$_POST['max_num_sta'] = $_POST['max_num_sta'] > 2007 ? 2007 : $_POST['max_num_sta'];
|
||||||
$_POST['max_num_sta'] = $_POST['max_num_sta'] < 1 ? null : $_POST['max_num_sta'];
|
$_POST['max_num_sta'] = $_POST['max_num_sta'] < 1 ? null : $_POST['max_num_sta'];
|
||||||
|
|
||||||
|
// populate hostapd.conf
|
||||||
if ($good_input) {
|
if ($good_input) {
|
||||||
// Fixed values
|
// Fixed values
|
||||||
$country_code = $_POST['country_code'];
|
$country_code = $_POST['country_code'];
|
||||||
@ -409,6 +416,5 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
|
|||||||
$status->addMessage('Unable to save wifi hotspot settings', 'danger');
|
$status->addMessage('Unable to save wifi hotspot settings', 'danger');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user