1
0
mirror of https://github.com/billz/raspap-webgui.git synced 2023-10-10 13:37:24 +02:00

Merge pull request #1282 from RaspAP/fix/dhcp-leasetime

Fix handling of infinite lease time
This commit is contained in:
Bill Zimmerman 2023-01-17 09:30:48 -08:00 committed by GitHub
commit ca5164c3a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View File

@ -143,10 +143,10 @@ function validateDHCPInput()
if (!filter_var($_POST['RangeEnd'], FILTER_VALIDATE_IP) && !empty($_POST['RangeEnd'])) {
$errors .= _('Invalid DHCP range end.').'<br />'.PHP_EOL;
}
if (!ctype_digit($_POST['RangeLeaseTime']) && $_POST['RangeLeaseTimeUnits'] !== 'infinite') {
if (!ctype_digit($_POST['RangeLeaseTime']) && $_POST['RangeLeaseTimeUnits'] !== 'i') {
$errors .= _('Invalid DHCP lease time, not a number.').'<br />'.PHP_EOL;
}
if (!in_array($_POST['RangeLeaseTimeUnits'], array('m', 'h', 'd', 'infinite'))) {
if (!in_array($_POST['RangeLeaseTimeUnits'], array('m', 'h', 'd', 'i'))) {
$errors .= _('Unknown DHCP lease time unit.').'<br />'.PHP_EOL;
}
if ($_POST['Metric'] !== '' && !ctype_digit($_POST['Metric'])) {
@ -181,10 +181,12 @@ function updateDnsmasqConfig($iface,$status)
{
$config = '# RaspAP '.$iface.' configuration'.PHP_EOL;
$config .= 'interface='.$iface.PHP_EOL.'dhcp-range='.$_POST['RangeStart'].','.$_POST['RangeEnd'].','.$_POST['SubnetMask'].',';
if ($_POST['RangeLeaseTimeUnits'] !== 'infinite') {
if ($_POST['RangeLeaseTimeUnits'] !== 'i') {
$config .= $_POST['RangeLeaseTime'];
$config .= $_POST['RangeLeaseTimeUnits'].PHP_EOL;
} else {
$config .= 'infinite'.PHP_EOL;
}
$config .= $_POST['RangeLeaseTimeUnits'].PHP_EOL;
// Static leases
$staticLeases = array();
for ($i=0; $i < count($_POST["static_leases"]["mac"]); $i++) {

View File

@ -107,7 +107,7 @@
<option value="m"><?php echo _("Minute(s)"); ?></option>
<option value="h"><?php echo _("Hour(s)"); ?></option>
<option value="d"><?php echo _("Day(s)"); ?></option>
<option value="infinite"><?php echo _("Infinite"); ?></option>
<option value="i"><?php echo _("Infinite"); ?></option>
</select>
</div>
</div>