Fix dhcp leasetime ( timezone ) display

Config for dhcpleaseinlocaltime was not being wrtten to the config. Corrected leasetine display routine.
This commit is contained in:
Martin Wasley 2019-01-08 07:03:53 +00:00 committed by Franco Fichtner
parent 03d06437b3
commit 6ecee71a6b
2 changed files with 22 additions and 7 deletions

View File

@ -427,6 +427,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if (!empty($pconfig['ntp2'])) {
$dhcpdconf['ntpserver'][] = $pconfig['ntp2'];
}
if (!empty($pconfig['dhcpleaseinlocaltime'])) {
$dhcpdconf['ntpserver'][] = $pconfig['dhcpleaseinlocaltime'];
}
// handle changes
if (!isset($pool) && $act != "newpool") {

View File

@ -37,18 +37,30 @@ function adjust_gmt($dt)
{
global $config;
$dhcpleaseinlocaltime = 'no';
$dhcpd = array();
if (isset($config['dhcpd'])) {
if (is_array($config['dhcpd'])) {
$dhcpd = $config['dhcpd'];
}
foreach ($dhcpd as $dhcpditem) {
if (isset($dhcpditem['dhcpleaseinlocaltime']) && $dhcpleaseinlocaltime == "yes") {
$ts = strtotime($dt . " GMT");
return strftime("%Y/%m/%d %I:%M:%S%p", $ts);
foreach ($dhcpd as $dhcpleaseinlocaltime) {
$dhcpleaseinlocaltime = $dhcpleaseinlocaltime['dhcpleaseinlocaltime'];
if ($dhcpleaseinlocaltime == "yes") {
break;
}
}
}
$timezone = $config['system']['timezone'];
$ts = strtotime($dt . " GMT");
if ($dhcpleaseinlocaltime != "yes") {
$this_tz = new DateTimeZone($timezone);
$dhcp_lt = new DateTime(strftime("%I:%M:%S%p", $ts), $this_tz);
$offset = $this_tz->getOffset($dhcp_lt);
$ts = $ts - $offset;
return strftime("%Y/%m/%d %I:%M:%S%p", $ts);
} else {
return strftime("%Y/%m/%d %H:%M:%S", $ts);
}
return $dt;
}