Bad Status last online value.

pull/30/head
jerome 2014-03-22 03:48:26 +01:00
parent f376f374b4
commit ae2b4700a7
3 changed files with 19 additions and 3 deletions

View File

@ -248,11 +248,13 @@ function psm_curl_get($href, $header = false, $body = true, $timeout = 10, $add_
* Get a "nice" timespan message * Get a "nice" timespan message
* *
* Source: http://www.interactivetools.com/forum/forum-posts.php?postNum=2208966 * Source: http://www.interactivetools.com/forum/forum-posts.php?postNum=2208966
* @param int $time * @param string $time
* @return string * @return string
* @todo add translation to timespan messages * @todo add translation to timespan messages
*/ */
function psm_timespan($time) { function psm_timespan($time) {
if(empty($time) || $time == '0000-00-00 00:00:00')
return 'never';
if ($time !== intval($time)) { $time = strtotime($time); } if ($time !== intval($time)) { $time = strtotime($time); }
$d = time() - $time; $d = time() - $time;
if ($time < strtotime(date('Y-m-d 00:00:00')) - 60*60*24*3) { 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"; 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 * Check if an update is available for PHP Server Monitor
* *

View File

@ -62,8 +62,8 @@ abstract class AbstractServerController extends AbstractController {
`s`.`status`, `s`.`status`,
`s`.`error`, `s`.`error`,
`s`.`rtime`, `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`, `s`.`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_online`,
`s`.`active`, `s`.`active`,
`s`.`email`, `s`.`email`,
`s`.`sms` `s`.`sms`

View File

@ -79,6 +79,7 @@ class ServerController extends AbstractServerController {
$servers[$x] = $html_actions + $servers[$x]; $servers[$x] = $html_actions + $servers[$x];
$servers[$x]['class'] = ($x & 1) ? 'odd' : 'even'; $servers[$x]['class'] = ($x & 1) ? 'odd' : 'even';
$servers[$x]['rtime'] = round((float) $servers[$x]['rtime'], 4); $servers[$x]['rtime'] = round((float) $servers[$x]['rtime'], 4);
$servers[$x]['last_online'] = psm_date($servers[$x]['last_online']);
if($servers[$x]['type'] == 'website') { if($servers[$x]['type'] == 'website') {
// add link to label // add link to label