diff --git a/src/includes/functions.inc.php b/src/includes/functions.inc.php index 2849b9b3..cac65528 100755 --- a/src/includes/functions.inc.php +++ b/src/includes/functions.inc.php @@ -248,11 +248,13 @@ function psm_curl_get($href, $header = false, $body = true, $timeout = 10, $add_ * Get a "nice" timespan message * * Source: http://www.interactivetools.com/forum/forum-posts.php?postNum=2208966 - * @param int $time + * @param string $time * @return string * @todo add translation to timespan messages */ function psm_timespan($time) { + if(empty($time) || $time == '0000-00-00 00:00:00') + return 'never'; if ($time !== intval($time)) { $time = strtotime($time); } $d = time() - $time; if ($time < strtotime(date('Y-m-d 00:00:00')) - 60*60*24*3) { @@ -276,6 +278,19 @@ function psm_timespan($time) { return "a few seconds ago"; } +/** + * Get a localised date from MySQL date format + * @param string $time + * @return string + * @todo add translation + */ +function psm_date($time) +{ + if(empty($time) || $time == '0000-00-00 00:00:00') + return 'never'; + return date('d/m/Y H:i:s', strtotime($time)); +} + /** * Check if an update is available for PHP Server Monitor * diff --git a/src/psm/Module/Server/Controller/AbstractServerController.class.php b/src/psm/Module/Server/Controller/AbstractServerController.class.php index 8eb4207e..55e94870 100644 --- a/src/psm/Module/Server/Controller/AbstractServerController.class.php +++ b/src/psm/Module/Server/Controller/AbstractServerController.class.php @@ -62,8 +62,8 @@ abstract class AbstractServerController extends AbstractController { `s`.`status`, `s`.`error`, `s`.`rtime`, - IF(`s`.`last_check`='0000-00-00 00:00:00', 'never', DATE_FORMAT(`s`.`last_check`, '%d-%m-%y %H:%i')) AS `last_check`, - IF(`s`.`last_online`='0000-00-00 00:00:00', 'never', DATE_FORMAT(`s`.`last_online`, '%d-%m-%y %H:%i')) AS `last_online`, + `s`.`last_check`, + `s`.`last_online`, `s`.`active`, `s`.`email`, `s`.`sms` diff --git a/src/psm/Module/Server/Controller/ServerController.class.php b/src/psm/Module/Server/Controller/ServerController.class.php index f79a127c..f7bdedca 100755 --- a/src/psm/Module/Server/Controller/ServerController.class.php +++ b/src/psm/Module/Server/Controller/ServerController.class.php @@ -79,6 +79,7 @@ class ServerController extends AbstractServerController { $servers[$x] = $html_actions + $servers[$x]; $servers[$x]['class'] = ($x & 1) ? 'odd' : 'even'; $servers[$x]['rtime'] = round((float) $servers[$x]['rtime'], 4); + $servers[$x]['last_online'] = psm_date($servers[$x]['last_online']); if($servers[$x]['type'] == 'website') { // add link to label