1
0
mirror of https://github.com/billz/raspap-webgui.git synced 2023-10-10 13:37:24 +02:00
This commit is contained in:
D9ping 2018-10-02 01:05:34 +02:00
commit 34f2926317
2 changed files with 32 additions and 21 deletions

View File

@ -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.

View File

@ -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,12 +112,16 @@ 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 = '';
preg_match( '/([0-9]*)([a-z])/i', $leaseTime, $arrRangeLeaseTime );
if ($leaseTime === 'infinite') {
$infiniteselected = ' selected="selected"';
} else {
switch( $arrRangeLeaseTime[2] ) { switch( $arrRangeLeaseTime[2] ) {
case 'h': case 'h':
$hselected = ' selected="selected"'; $hselected = ' selected="selected"';
@ -124,8 +133,9 @@ function DisplayDHCPConfig() {
$dselected = ' selected="selected"'; $dselected = ' selected="selected"';
break; 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>