summaryrefslogtreecommitdiffstats
path: root/usr
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@inf.org>2015-03-13 14:18:15 +0545
committerRenato Botelho <garga@FreeBSD.org>2015-03-26 11:08:45 -0300
commit6eb5191b7c92186e242481699f51cc8b4e55646c (patch)
treeba71c425f9048af036df70e33b5043c4458d7b01 /usr
parent3c3a3bf9c5a691786d65afa78914d5e498530663 (diff)
downloadpfsense-6eb5191b7c92186e242481699f51cc8b4e55646c.zip
pfsense-6eb5191b7c92186e242481699f51cc8b4e55646c.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')
-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