mirror of
https://github.com/billz/raspap-webgui.git
synced 2023-10-10 13:37:24 +02:00
Merge branch 'master' of https://github.com:443/billz/raspap-webgui
This commit is contained in:
commit
3a7de3d734
@ -1,3 +1,6 @@
|
|||||||
|
### Before submitting an issue
|
||||||
|
The [FAQs](https://github.com/billz/raspap-webgui/wiki/FAQs) have answers to many common issues. Please check this before creating a new issue.
|
||||||
|
|
||||||
### Subject of the issue
|
### Subject of the issue
|
||||||
Describe your issue here.
|
Describe your issue here.
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
![](http://i.imgur.com/xeKD93p.png)
|
![](http://i.imgur.com/xeKD93p.png)
|
||||||
# `$ raspap-webgui` [![Release 1.3.1](https://img.shields.io/badge/Release-1.3.1-green.svg)](https://github.com/billz/raspap-webgui/releases) [![Awesome](https://awesome.re/badge.svg)](https://github.com/thibmaek/awesome-raspberry-pi)
|
# `$ raspap-webgui` [![Release 1.3.1](https://img.shields.io/badge/Release-1.3.1-green.svg)](https://github.com/billz/raspap-webgui/releases) [![Awesome](https://awesome.re/badge.svg)](https://github.com/thibmaek/awesome-raspberry-pi) [![Beerpay](https://img.shields.io/beerpay/hashdog/scrapfy-chrome-extension.svg)](https://beerpay.io/billz/raspap-webgui)
|
||||||
|
|
||||||
A simple, responsive web interface to control wifi, hostapd and related services on the Raspberry Pi.
|
A simple, responsive web interface to control wifi, hostapd and related services on the Raspberry Pi.
|
||||||
|
|
||||||
This project was inspired by a [**blog post**](http://sirlagz.net/2013/02/06/script-web-configuration-page-for-raspberry-pi/) by SirLagz about using a web page rather than ssh to configure wifi and hostapd settings on the Raspberry Pi. I mostly just prettified the UI by wrapping it in [**SB Admin 2**](https://github.com/BlackrockDigital/startbootstrap-sb-admin-2), a Bootstrap based admin theme. Since then, the project has evolved to include greater control over many aspects of a networked RPi, better security, authentication, a Quick Installer, support for themes and more. RaspAP has been featured on sites such as [Instructables](http://www.instructables.com/id/Raspberry-Pi-As-Completely-Wireless-Router/), [Adafruit](https://blog.adafruit.com/2016/06/24/raspap-wifi-configuration-portal-piday-raspberrypi-raspberry_pi/), [Raspberry Pi Weekly](https://www.raspberrypi.org/weekly/commander/) and [Awesome Raspberry Pi](https://project-awesome.org/thibmaek/awesome-raspberry-pi) and implemented in countless projects.
|
This project was inspired by a [**blog post**](http://sirlagz.net/2013/02/06/script-web-configuration-page-for-raspberry-pi/) by SirLagz about using a web page rather than ssh to configure wifi and hostapd settings on the Raspberry Pi. I mostly just prettified the UI by wrapping it in [**SB Admin 2**](https://github.com/BlackrockDigital/startbootstrap-sb-admin-2), a Bootstrap based admin theme. Since then, the project has evolved to include greater control over many aspects of a networked RPi, better security, authentication, a Quick Installer, support for themes and more. RaspAP has been featured on sites such as [Instructables](http://www.instructables.com/id/Raspberry-Pi-As-Completely-Wireless-Router/), [Adafruit](https://blog.adafruit.com/2016/06/24/raspap-wifi-configuration-portal-piday-raspberrypi-raspberry_pi/), [Raspberry Pi Weekly](https://www.raspberrypi.org/weekly/commander/) and [Awesome Raspberry Pi](https://project-awesome.org/thibmaek/awesome-raspberry-pi) and implemented in countless projects.
|
||||||
|
@ -29,7 +29,7 @@ function DisplayDHCPConfig() {
|
|||||||
$errors .= _('Invalid DHCP range end.').'<br />'.PHP_EOL;
|
$errors .= _('Invalid DHCP range end.').'<br />'.PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ctype_digit($_POST['RangeLeaseTime'])) {
|
if (!ctype_digit($_POST['RangeLeaseTime']) && $_POST['RangeLeaseTimeUnits'] !== 'infinite') {
|
||||||
$errors .= _('Invalid DHCP lease time, not a number.').'<br />'.PHP_EOL;
|
$errors .= _('Invalid DHCP lease time, not a number.').'<br />'.PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +41,12 @@ function DisplayDHCPConfig() {
|
|||||||
if (empty($errors)) {
|
if (empty($errors)) {
|
||||||
$config = 'interface='.$_POST['interface'].PHP_EOL.
|
$config = 'interface='.$_POST['interface'].PHP_EOL.
|
||||||
'dhcp-range='.$_POST['RangeStart'].','.$_POST['RangeEnd'].
|
'dhcp-range='.$_POST['RangeStart'].','.$_POST['RangeEnd'].
|
||||||
',255.255.255.0,'.$_POST['RangeLeaseTime'].$_POST['RangeLeaseTimeUnits'];
|
',255.255.255.0,';
|
||||||
|
if ($_POST['RangeLeaseTimeUnits'] !== 'infinite') {
|
||||||
|
$config .= $_POST['RangeLeaseTime'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$config .= $_POST['RangeLeaseTimeUnits'];
|
||||||
exec('echo "'.$config.'" > /tmp/dhcpddata', $temp);
|
exec('echo "'.$config.'" > /tmp/dhcpddata', $temp);
|
||||||
system('sudo cp /tmp/dhcpddata '.RASPI_DNSMASQ_CONFIG, $return);
|
system('sudo cp /tmp/dhcpddata '.RASPI_DNSMASQ_CONFIG, $return);
|
||||||
} else {
|
} else {
|
||||||
@ -107,25 +112,30 @@ function DisplayDHCPConfig() {
|
|||||||
$RangeStart = $arrRange[0];
|
$RangeStart = $arrRange[0];
|
||||||
$RangeEnd = $arrRange[1];
|
$RangeEnd = $arrRange[1];
|
||||||
$RangeMask = $arrRange[2];
|
$RangeMask = $arrRange[2];
|
||||||
preg_match( '/([0-9]*)([a-z])/i', $arrRange[3], $arrRangeLeaseTime );
|
$leaseTime = $arrRange[3];
|
||||||
|
|
||||||
$hselected = '';
|
$hselected = '';
|
||||||
$mselected = '';
|
$mselected = '';
|
||||||
$dselected = '';
|
$dselected = '';
|
||||||
|
$infiniteselected = '';
|
||||||
switch( $arrRangeLeaseTime[2] ) {
|
preg_match( '/([0-9]*)([a-z])/i', $leaseTime, $arrRangeLeaseTime );
|
||||||
case 'h':
|
if ($leaseTime === 'infinite') {
|
||||||
$hselected = ' selected="selected"';
|
$infiniteselected = ' selected="selected"';
|
||||||
break;
|
} else {
|
||||||
case 'm':
|
switch( $arrRangeLeaseTime[2] ) {
|
||||||
$mselected = ' selected="selected"';
|
case 'h':
|
||||||
break;
|
$hselected = ' selected="selected"';
|
||||||
case 'd':
|
break;
|
||||||
$dselected = ' selected="selected"';
|
case 'm':
|
||||||
break;
|
$mselected = ' selected="selected"';
|
||||||
|
break;
|
||||||
|
case 'd':
|
||||||
|
$dselected = ' selected="selected"';
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<div class="panel panel-primary">
|
<div class="panel panel-primary">
|
||||||
@ -156,7 +166,7 @@ function DisplayDHCPConfig() {
|
|||||||
foreach( $interfaces as $inet ) {
|
foreach( $interfaces as $inet ) {
|
||||||
$select = '';
|
$select = '';
|
||||||
if( $inet === $conf['interface'] ) {
|
if( $inet === $conf['interface'] ) {
|
||||||
$select = ' selected="selected"'; // FIXED use xhtml valid attribute
|
$select = ' selected="selected"';
|
||||||
}
|
}
|
||||||
|
|
||||||
echo ' <option value="'.htmlspecialchars($inet, ENT_QUOTES).'"'.
|
echo ' <option value="'.htmlspecialchars($inet, ENT_QUOTES).'"'.
|
||||||
@ -188,10 +198,10 @@ function DisplayDHCPConfig() {
|
|||||||
<div class="col-xs-2 col-sm-2">
|
<div class="col-xs-2 col-sm-2">
|
||||||
<label for="code"><?php echo _("Interval"); ?></label>
|
<label for="code"><?php echo _("Interval"); ?></label>
|
||||||
<select name="RangeLeaseTimeUnits" class="form-control" >
|
<select name="RangeLeaseTimeUnits" class="form-control" >
|
||||||
<option value="m" <?php echo $mselected; ?>>Minute(s)</option>
|
<option value="m"<?php echo $mselected; ?>><?php echo _("Minute(s)"); ?></option>
|
||||||
<option value="h" <?php echo $hselected; ?>>Hour(s)</option>
|
<option value="h"<?php echo $hselected; ?>><?php echo _("Hour(s)"); ?></option>
|
||||||
<option value="d" <?php echo $dselected; ?>>Day(s)</option>
|
<option value="d"<?php echo $dselected; ?>><?php echo _("Day(s)"); ?></option>
|
||||||
<option value="infinite">Infinite</option>
|
<option value="infinite"<?php echo $infiniteselected; ?>><?php echo _("Infinite"); ?></option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -89,8 +89,13 @@ function isAssoc($arr) {
|
|||||||
* If $options is an associative array this should be the key
|
* If $options is an associative array this should be the key
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function SelectorOptions($name, $options, $selected = null) {
|
function SelectorOptions($name, $options, $selected = null, $id = null) {
|
||||||
echo '<select class="form-control" name="'.htmlspecialchars($name, ENT_QUOTES).'">' , PHP_EOL;
|
echo '<select class="form-control" name="'.htmlspecialchars($name, ENT_QUOTES).'"';
|
||||||
|
if (isset($id)) {
|
||||||
|
echo ' id="' . htmlspecialchars($id, ENT_QUOTES) .'"';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '>' , PHP_EOL;
|
||||||
foreach ( $options as $opt => $label) {
|
foreach ( $options as $opt => $label) {
|
||||||
$select = '';
|
$select = '';
|
||||||
$key = isAssoc($options) ? $opt : $label;
|
$key = isAssoc($options) ? $opt : $label;
|
||||||
|
@ -6,22 +6,21 @@ include_once( 'includes/status_messages.php' );
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function DisplayHostAPDConfig(){
|
function DisplayHostAPDConfig()
|
||||||
|
{
|
||||||
$status = new StatusMessages();
|
$status = new StatusMessages();
|
||||||
|
|
||||||
$arrHostapdConf = parse_ini_file('/etc/raspap/hostapd.ini');
|
$arrHostapdConf = parse_ini_file('/etc/raspap/hostapd.ini');
|
||||||
|
|
||||||
$arrConfig = array();
|
$arrConfig = array();
|
||||||
$arrChannel = array('a','b','g');
|
$arr80211Standard = array('a','b','g','n');
|
||||||
$arrSecurity = array( 1 => 'WPA', 2 => 'WPA2',3=> 'WPA+WPA2');
|
$arrSecurity = array(1 => 'WPA', 2 => 'WPA2', 3 => 'WPA+WPA2', 'none' => _("None"));
|
||||||
$arrEncType = array('TKIP' => 'TKIP', 'CCMP' => 'CCMP', 'TKIP CCMP' => 'TKIP+CCMP');
|
$arrEncType = array('TKIP' => 'TKIP', 'CCMP' => 'CCMP', 'TKIP CCMP' => 'TKIP+CCMP');
|
||||||
exec("ip -o link show | awk -F': ' '{print $2}'", $interfaces);
|
exec("ip -o link show | awk -F': ' '{print $2}'", $interfaces);
|
||||||
|
|
||||||
|
|
||||||
if( isset($_POST['SaveHostAPDSettings']) ) {
|
if( isset($_POST['SaveHostAPDSettings']) ) {
|
||||||
if (CSRFValidate()) {
|
if (CSRFValidate()) {
|
||||||
SaveHostAPDConfig($arrSecurity, $arrEncType, $arrChannel, $interfaces, $status);
|
SaveHostAPDConfig($arrSecurity, $arrEncType, $arr80211Standard, $interfaces, $status);
|
||||||
} else {
|
} else {
|
||||||
error_log('CSRF violation');
|
error_log('CSRF violation');
|
||||||
}
|
}
|
||||||
@ -47,7 +46,7 @@ function DisplayHostAPDConfig(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exec( 'cat '. RASPI_HOSTAPD_CONFIG, $return );
|
exec( 'cat '. RASPI_HOSTAPD_CONFIG, $hostapdconfig );
|
||||||
exec( 'pidof hostapd | wc -l', $hostapdstatus);
|
exec( 'pidof hostapd | wc -l', $hostapdstatus);
|
||||||
|
|
||||||
if( $hostapdstatus[0] == 0 ) {
|
if( $hostapdstatus[0] == 0 ) {
|
||||||
@ -56,9 +55,13 @@ function DisplayHostAPDConfig(){
|
|||||||
$status->addMessage('HostAPD is running', 'success');
|
$status->addMessage('HostAPD is running', 'success');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach( $return as $a ) {
|
foreach( $hostapdconfig as $hostapdconfigline ) {
|
||||||
if( $a[0] != "#" ) {
|
if (strlen($hostapdconfigline) === 0) {
|
||||||
$arrLine = explode( "=",$a) ;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($hostapdconfigline[0] != "#" ) {
|
||||||
|
$arrLine = explode("=", $hostapdconfigline) ;
|
||||||
$arrConfig[$arrLine[0]]=$arrLine[1];
|
$arrConfig[$arrLine[0]]=$arrLine[1];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -88,28 +91,55 @@ function DisplayHostAPDConfig(){
|
|||||||
<?php CSRFToken() ?>
|
<?php CSRFToken() ?>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
<label for="code"><?php echo _("Interface") ;?></label>
|
<label for="cbxinterface"><?php echo _("Interface") ;?></label>
|
||||||
<?php
|
<?php
|
||||||
SelectorOptions('interface', $interfaces, $arrConfig['interface']);
|
SelectorOptions('interface', $interfaces, $arrConfig['interface'], 'cbxinterface');
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
<label for="code"><?php echo _("SSID"); ?></label>
|
<label for="txtssid"><?php echo _("SSID"); ?></label>
|
||||||
<input type="text" class="form-control" name="ssid" value="<?php echo htmlspecialchars($arrConfig['ssid'], ENT_QUOTES); ?>" />
|
<input type="text" id="txtssid" class="form-control" name="ssid" value="<?php echo htmlspecialchars($arrConfig['ssid'], ENT_QUOTES); ?>" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
<label for="code"><?php echo _("Wireless Mode") ;?></label>
|
<label for="cbxhwmode"><?php echo _("Wireless Mode") ;?></label>
|
||||||
<?php SelectorOptions('hw_mode', $arrChannel, $arrConfig['hw_mode']); ?>
|
<?php
|
||||||
|
$selectedHwMode = $arrConfig['hw_mode'];
|
||||||
|
if (isset($arrConfig['ieee80211n'])) {
|
||||||
|
if (strval($arrConfig['ieee80211n']) === '1') {
|
||||||
|
$selectedHwMode = 'n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectorOptions('hw_mode', $arr80211Standard, $selectedHwMode, 'cbxhwmode'); ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
<label for="code"><?php echo _("Channel"); ?></label>
|
<label for="cbxchannel"><?php echo _("Channel"); ?></label>
|
||||||
<?php SelectorOptions('channel', range(1, 14), intval($arrConfig['channel'])) ?>
|
<?php
|
||||||
|
$selectablechannels = range(1, 13);
|
||||||
|
$countries_2_4Ghz_max11ch = array('AG', 'BS', 'BB', 'BZ', 'CR', 'CU', 'DM', 'DO', 'SV', 'GD', 'GT',
|
||||||
|
'HT', 'HN', 'JM', 'MX', 'NI', 'PA', 'KN', 'LC', 'VC', 'TT',
|
||||||
|
'US', 'CA', 'UZ', 'CO');
|
||||||
|
$countries_2_4Ghz_max14ch = array('JA');
|
||||||
|
if (in_array($arrConfig['country_code'], $countries_max11channels)) {
|
||||||
|
// In North America till channel 11 is the maximum allowed wi-fi 2.4Ghz channel.
|
||||||
|
// Except for the US that allows channel 12 & 13 in low power mode with additional restrictions.
|
||||||
|
// Canada that allows channel 12 in low power mode. Because it's unsure if low powered mode
|
||||||
|
// can be supported the channels are not selectable for those countries.
|
||||||
|
// source: https://en.wikipedia.org/wiki/List_of_WLAN_channels#Interference_concerns
|
||||||
|
// Also Uzbekistan and Colombia allow to select till channel 11 as maximum channel on the 2.4Ghz wi-fi band.
|
||||||
|
$selectablechannels = range(1, 11);
|
||||||
|
} elseif (in_array($arrConfig['country_code'], $countries_2_4Ghz_max14ch)) {
|
||||||
|
if ($arrConfig['hw_mode'] === 'b') {
|
||||||
|
$selectablechannels = range(1, 14);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SelectorOptions('channel', $selectablechannels, intval($arrConfig['channel']), 'cbxchannel'); ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -117,20 +147,20 @@ function DisplayHostAPDConfig(){
|
|||||||
<h4><?php echo _("Security settings"); ?></h4>
|
<h4><?php echo _("Security settings"); ?></h4>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
<label for="code"><?php echo _("Security type"); ?></label>
|
<label for="cbxwpa"><?php echo _("Security type"); ?></label>
|
||||||
<?php SelectorOptions('wpa', $arrSecurity, $arrConfig['wpa']); ?>
|
<?php SelectorOptions('wpa', $arrSecurity, $arrConfig['wpa'], 'cbxwpa'); ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
<label for="code"><?php echo _("Encryption Type"); ?></label>
|
<label for="cbxwpapairwise"><?php echo _("Encryption Type"); ?></label>
|
||||||
<?php SelectorOptions('wpa_pairwise', $arrEncType, $arrConfig['wpa_pairwise']); ?>
|
<?php SelectorOptions('wpa_pairwise', $arrEncType, $arrConfig['wpa_pairwise'], 'cbxwpapairwise'); ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
<label for="code"><?php echo _("PSK"); ?></label>
|
<label for="txtwpapassphrase"><?php echo _("PSK"); ?></label>
|
||||||
<input type="text" class="form-control" name="wpa_passphrase" value="<?php echo htmlspecialchars($arrConfig['wpa_passphrase'], ENT_QUOTES); ?>" />
|
<input type="text" class="form-control" id="txtwpapassphrase" name="wpa_passphrase" value="<?php echo htmlspecialchars($arrConfig['wpa_passphrase'], ENT_QUOTES); ?>" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -153,25 +183,38 @@ function DisplayHostAPDConfig(){
|
|||||||
<h4><?php echo _("Advanced settings"); ?></h4>
|
<h4><?php echo _("Advanced settings"); ?></h4>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<label class="form-check-label">
|
<label class="form-check-label" for="chxlogenable"><?php echo _("Enable logging");
|
||||||
<?php echo _("Enable logging");
|
$checkedLogEnabled = '';
|
||||||
$checked = '';
|
|
||||||
if ($arrHostapdConf['LogEnable'] == 1) {
|
if ($arrHostapdConf['LogEnable'] == 1) {
|
||||||
$checked = ' checked="checked"';
|
$checkedLogEnabled = ' checked="checked"';
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<input id="logEnable" name ="logEnable" type="checkbox" class="form-check-input" value="1"<?php echo $checked; ?> />
|
</label>
|
||||||
</label>
|
<input id="chxlogenable" name="logEnable" type="checkbox" class="form-check-input" value="1"<?php echo $checkedLogEnabled; ?> />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4">
|
||||||
|
<div class="form-check">
|
||||||
|
<label class="form-check-label" for="chxhiddenssid"><?php echo _("Hide SSID in broadcast");
|
||||||
|
$checkedHiddenSSID = '';
|
||||||
|
if ($arrConfig['ignore_broadcast_ssid'] == 1 || $arrConfig['ignore_broadcast_ssid'] == 2) {
|
||||||
|
$checkedHiddenSSID = ' checked="checked"';
|
||||||
|
}
|
||||||
|
|
||||||
|
?> </label>
|
||||||
|
<input id="chxhiddenssid" name="hiddenSSID" type="checkbox" class="form-check-input" value="1"<?php echo $checkedHiddenSSID; ?> />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
<label for="code"><?php echo _("Country Code"); ?></label>
|
<label for="cbxcountries"><?php echo _("Country Code"); ?></label>
|
||||||
<input type="hidden" id="selected_country" value="<?php echo htmlspecialchars($arrConfig['country_code'], ENT_QUOTES); ?>">
|
<input type="hidden" id="selected_country" value="<?php echo htmlspecialchars($arrConfig['country_code'], ENT_QUOTES); ?>">
|
||||||
<select class="form-control" id="countries" name="country_code">
|
<select class="form-control" id="cbxcountries" name="country_code">
|
||||||
<option value="AF">Afghanistan</option>
|
<option value="AF">Afghanistan</option>
|
||||||
<option value="AX">Åland Islands</option>
|
<option value="AX">Åland Islands</option>
|
||||||
<option value="AL">Albania</option>
|
<option value="AL">Albania</option>
|
||||||
@ -424,7 +467,7 @@ if ($arrHostapdConf['LogEnable'] == 1) {
|
|||||||
</select>
|
</select>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var country = document.getElementById("selected_country").value;
|
var country = document.getElementById("selected_country").value;
|
||||||
var countries = document.getElementById("countries");
|
var countries = document.getElementById("cbxcountries");
|
||||||
var ops = countries.getElementsByTagName("option");
|
var ops = countries.getElementsByTagName("option");
|
||||||
for (var i = 0; i < ops.length; ++i) {
|
for (var i = 0; i < ops.length; ++i) {
|
||||||
if(ops[i].value == country){
|
if(ops[i].value == country){
|
||||||
@ -463,10 +506,13 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!filter_var($_POST['channel'], FILTER_VALIDATE_INT)) ||
|
if (!filter_var($_POST['channel'], FILTER_VALIDATE_INT)) {
|
||||||
intval($_POST['channel']) < 1 ||
|
error_log("Attempting to set channel to invalid number.");
|
||||||
intval($_POST['channel']) > 14) {
|
return false;
|
||||||
error_log("Attempting to set channel to '".$_POST['channel']."'"); // FIXME: log injection
|
}
|
||||||
|
|
||||||
|
if (intval($_POST['channel']) < 1 || intval($_POST['channel']) > 14) {
|
||||||
|
error_log("Attempting to set channel to '".$_POST['channel']."'");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -500,15 +546,30 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
|
|||||||
$good_input = false;
|
$good_input = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen($_POST['wpa_passphrase']) < 8 || strlen($_POST['wpa_passphrase']) > 63) {
|
if ($_POST['wpa'] !== 'none' &&
|
||||||
|
(strlen($_POST['wpa_passphrase']) < 8 || strlen($_POST['wpa_passphrase']) > 63)) {
|
||||||
$status->addMessage('WPA passphrase must be between 8 and 63 characters', 'danger');
|
$status->addMessage('WPA passphrase must be between 8 and 63 characters', 'danger');
|
||||||
$good_input = false;
|
$good_input = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($_POST['hiddenSSID'])) {
|
||||||
|
if (!is_int((int)$_POST['hiddenSSID'])) {
|
||||||
|
$status->addMessage('Parameter hiddenSSID not a number.', 'danger');
|
||||||
|
$good_input = false;
|
||||||
|
} elseif ((int)$_POST['hiddenSSID'] < 0 || (int)$_POST['hiddenSSID'] >= 3) {
|
||||||
|
$status->addMessage('Parameter hiddenSSID contains invalid configuratie value.', 'danger');
|
||||||
|
$good_input = false;
|
||||||
|
} else {
|
||||||
|
$ignore_broadcast_ssid = $_POST['hiddenSSID'];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$ignore_broadcast_ssid = '0';
|
||||||
|
}
|
||||||
|
|
||||||
if (! in_array($_POST['interface'], $interfaces)) {
|
if (! in_array($_POST['interface'], $interfaces)) {
|
||||||
// The user is probably up to something here but it may also be a
|
// The user is probably up to something here but it may also be a
|
||||||
// genuine error.
|
// genuine error.
|
||||||
$status->addMessage('Unknown interface '.$_POST['interface'], 'danger');
|
$status->addMessage('Unknown interface '.htmlspecialchars($_POST['interface'], ENT_QUOTES), 'danger');
|
||||||
$good_input = false;
|
$good_input = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -523,19 +584,28 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
|
|||||||
fwrite($tmp_file, 'driver=nl80211'.PHP_EOL);
|
fwrite($tmp_file, 'driver=nl80211'.PHP_EOL);
|
||||||
fwrite($tmp_file, 'ctrl_interface='.RASPI_HOSTAPD_CTRL_INTERFACE.PHP_EOL);
|
fwrite($tmp_file, 'ctrl_interface='.RASPI_HOSTAPD_CTRL_INTERFACE.PHP_EOL);
|
||||||
fwrite($tmp_file, 'ctrl_interface_group=0'.PHP_EOL);
|
fwrite($tmp_file, 'ctrl_interface_group=0'.PHP_EOL);
|
||||||
fwrite($tmp_file, 'beacon_int=100'.PHP_EOL);
|
|
||||||
fwrite($tmp_file, 'auth_algs=1'.PHP_EOL);
|
fwrite($tmp_file, 'auth_algs=1'.PHP_EOL);
|
||||||
fwrite($tmp_file, 'wpa_key_mgmt=WPA-PSK'.PHP_EOL);
|
fwrite($tmp_file, 'wpa_key_mgmt=WPA-PSK'.PHP_EOL);
|
||||||
|
fwrite($tmp_file, 'beacon_int=100'.PHP_EOL);
|
||||||
|
|
||||||
// TODO: deal with ini file value escaping. E.g. ssid=E=mc2 becomes ssid=E\=mc2
|
|
||||||
fwrite($tmp_file, 'ssid='.$_POST['ssid'].PHP_EOL);
|
fwrite($tmp_file, 'ssid='.$_POST['ssid'].PHP_EOL);
|
||||||
fwrite($tmp_file, 'channel='.$_POST['channel'].PHP_EOL);
|
fwrite($tmp_file, 'channel='.$_POST['channel'].PHP_EOL);
|
||||||
fwrite($tmp_file, 'hw_mode='.$_POST['hw_mode'].PHP_EOL);
|
if ($_POST['hw_mode'] === 'n') {
|
||||||
|
fwrite($tmp_file, 'hw_mode=g'.PHP_EOL);
|
||||||
|
fwrite($tmp_file, 'ieee80211n=1'.PHP_EOL);
|
||||||
|
// Enable basic Quality of service
|
||||||
|
fwrite($tmp_file, 'wme_enabled=1'.PHP_EOL);
|
||||||
|
} else {
|
||||||
|
fwrite($tmp_file, 'hw_mode='.$_POST['hw_mode'].PHP_EOL);
|
||||||
|
fwrite($tmp_file, 'ieee80211n=0'.PHP_EOL);
|
||||||
|
}
|
||||||
|
|
||||||
fwrite($tmp_file, 'wpa_passphrase='.$_POST['wpa_passphrase'].PHP_EOL);
|
fwrite($tmp_file, 'wpa_passphrase='.$_POST['wpa_passphrase'].PHP_EOL);
|
||||||
fwrite($tmp_file, 'interface='.$_POST['interface'].PHP_EOL);
|
fwrite($tmp_file, 'interface='.$_POST['interface'].PHP_EOL);
|
||||||
fwrite($tmp_file, 'wpa='.$_POST['wpa'].PHP_EOL);
|
fwrite($tmp_file, 'wpa='.$_POST['wpa'].PHP_EOL);
|
||||||
fwrite($tmp_file, 'wpa_pairwise='.$_POST['wpa_pairwise'].PHP_EOL);
|
fwrite($tmp_file, 'wpa_pairwise='.$_POST['wpa_pairwise'].PHP_EOL);
|
||||||
fwrite($tmp_file, 'country_code='.$_POST['country_code'].PHP_EOL);
|
fwrite($tmp_file, 'country_code='.$_POST['country_code'].PHP_EOL);
|
||||||
|
fwrite($tmp_file, 'ignore_broadcast_ssid='.$ignore_broadcast_ssid.PHP_EOL);
|
||||||
fclose($tmp_file);
|
fclose($tmp_file);
|
||||||
|
|
||||||
system( "sudo cp /tmp/hostapddata " . RASPI_HOSTAPD_CONFIG, $return );
|
system( "sudo cp /tmp/hostapddata " . RASPI_HOSTAPD_CONFIG, $return );
|
||||||
|
Loading…
Reference in New Issue
Block a user