diff --git a/includes/dhcp.php b/includes/dhcp.php
index 0ffb096b..5c7752a1 100755
--- a/includes/dhcp.php
+++ b/includes/dhcp.php
@@ -29,7 +29,7 @@ function DisplayDHCPConfig() {
$errors .= _('Invalid DHCP range end.').'
'.PHP_EOL;
}
- if (!ctype_digit($_POST['RangeLeaseTime'])) {
+ if (!ctype_digit($_POST['RangeLeaseTime']) && $_POST['RangeLeaseTimeUnits'] !== 'infinite') {
$errors .= _('Invalid DHCP lease time, not a number.').'
'.PHP_EOL;
}
@@ -41,7 +41,12 @@ function DisplayDHCPConfig() {
if (empty($errors)) {
$config = 'interface='.$_POST['interface'].PHP_EOL.
'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);
system('sudo cp /tmp/dhcpddata '.RASPI_DNSMASQ_CONFIG, $return);
} else {
@@ -107,25 +112,30 @@ function DisplayDHCPConfig() {
$RangeStart = $arrRange[0];
$RangeEnd = $arrRange[1];
$RangeMask = $arrRange[2];
- preg_match( '/([0-9]*)([a-z])/i', $arrRange[3], $arrRangeLeaseTime );
+ $leaseTime = $arrRange[3];
$hselected = '';
$mselected = '';
$dselected = '';
-
- switch( $arrRangeLeaseTime[2] ) {
- case 'h':
- $hselected = ' selected="selected"';
- break;
- case 'm':
- $mselected = ' selected="selected"';
- break;
- case 'd':
- $dselected = ' selected="selected"';
- break;
+ $infiniteselected = '';
+ preg_match( '/([0-9]*)([a-z])/i', $leaseTime, $arrRangeLeaseTime );
+ if ($leaseTime === 'infinite') {
+ $infiniteselected = ' selected="selected"';
+ } else {
+ switch( $arrRangeLeaseTime[2] ) {
+ case 'h':
+ $hselected = ' selected="selected"';
+ break;
+ case 'm':
+ $mselected = ' selected="selected"';
+ break;
+ case 'd':
+ $dselected = ' selected="selected"';
+ break;
+ }
}
- ?>
+?>