From 5f1abf31f333ce1e70af85cc85681468664d2d75 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 4 Dec 2017 18:25:09 +0100 Subject: [inc/Util] prettyTime: return '???' if given timestamp is 0 or not a number --- inc/util.inc.php | 3 +++ modules-available/dnbd3/hooks/main-warning.inc.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/inc/util.inc.php b/inc/util.inc.php index 1fb5b78e..ace879f4 100644 --- a/inc/util.inc.php +++ b/inc/util.inc.php @@ -476,6 +476,9 @@ SADFACE; */ public static function prettyTime($ts) { + settype($ts, 'int'); + if ($ts === 0) + return '???'; static $TODAY = false, $ETODAY = false, $YESTERDAY = false, $YEAR = false; if (!$ETODAY) $ETODAY = strtotime('today 23:59:59'); if ($ts > $ETODAY) // TODO: Do we need strings for future too? diff --git a/modules-available/dnbd3/hooks/main-warning.inc.php b/modules-available/dnbd3/hooks/main-warning.inc.php index 258d03d0..e38048e1 100644 --- a/modules-available/dnbd3/hooks/main-warning.inc.php +++ b/modules-available/dnbd3/hooks/main-warning.inc.php @@ -8,7 +8,7 @@ if (Dnbd3::isEnabled()) { while ($row = $res->fetch(PDO::FETCH_ASSOC)) { $error = $row['errormsg'] ? $row['errormsg'] : ''; - $lastSeen = date('d.m.Y H:i', $row['dnbd3lastseen']); + $lastSeen = Util::prettyTime($row['dnbd3lastseen']); if ($row['fixedip'] === '') { Message::addError('dnbd3.main-dnbd3-unreachable', true, $error, $lastSeen); continue; -- cgit v1.2.3-55-g7522