summaryrefslogtreecommitdiffstats
path: root/usr/local/www/status_dhcp_leases.php
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@inf.org>2015-03-13 14:18:15 +0545
committerPhil Davis <phil.davis@inf.org>2015-03-13 14:18:15 +0545
commit39894ed4b4710d2d26412b4206b36f4cb424a765 (patch)
treeee048abc3f4298a5edf5a01669fefb7648143201 /usr/local/www/status_dhcp_leases.php
parentf2f34088ace895b0113b468b856ceb02301585d1 (diff)
downloadpfsense-39894ed4b4710d2d26412b4206b36f4cb424a765.zip
pfsense-39894ed4b4710d2d26412b4206b36f4cb424a765.tar.gz
Status DHCP Leases handle expire never
Note: We can let the code pass "never" (or any other unexpected stuff) to adjust_gmt() adjust_gmt() should anyway handle the case when strtotime() cannot understand the input string and thus returns false. In that case we return the input string as-is so it will be displayed as the time. That way the user will see it and can report easily whatever other unexpected char data was in the leases file. It also prevents "false" (zero) being converted to the date-time string and thus becoming the Unix epoch 1 Jan 1970 on the display. Latest forum report of this kind of thing: https://forum.pfsense.org/index.php?topic=90083.0
Diffstat (limited to 'usr/local/www/status_dhcp_leases.php')
-rw-r--r--usr/local/www/status_dhcp_leases.php22
1 files changed, 16 insertions, 6 deletions
diff --git a/usr/local/www/status_dhcp_leases.php b/usr/local/www/status_dhcp_leases.php
index 191d9f5..24c41b8 100644
--- a/usr/local/www/status_dhcp_leases.php
+++ b/usr/local/www/status_dhcp_leases.php
@@ -107,9 +107,12 @@ function adjust_gmt($dt) {
}
if ($dhcpleaseinlocaltime == "yes") {
$ts = strtotime($dt . " GMT");
- return strftime("%Y/%m/%d %I:%M:%S%p", $ts);
- } else
- return $dt;
+ if ($ts !== false) {
+ return strftime("%Y/%m/%d %I:%M:%S%p", $ts);
+ }
+ }
+ /* If we did not need to convert to local time or the conversion failed, just return the input. */
+ return $dt;
}
function remove_duplicate($array, $field)
@@ -186,9 +189,16 @@ foreach($leases_content as $lease) {
$f = $f+3;
break;
case "ends":
- $leases[$l]['end'] = $data[$f+2];
- $leases[$l]['end'] .= " " . $data[$f+3];
- $f = $f+3;
+ if ($data[$f+1] == "never") {
+ // Quote from dhcpd.leases(5) man page:
+ // If a lease will never expire, date is never instead of an actual date.
+ $leases[$l]['end'] = gettext("Never");
+ $f = $f+1;
+ } else {
+ $leases[$l]['end'] = $data[$f+2];
+ $leases[$l]['end'] .= " " . $data[$f+3];
+ $f = $f+3;
+ }
break;
case "tstp":
$f = $f+3;
OpenPOWER on IntegriCloud