本文整理汇总了PHP中Stat::displayDown方法的典型用法代码示例。如果您正苦于以下问题:PHP Stat::displayDown方法的具体用法?PHP Stat::displayDown怎么用?PHP Stat::displayDown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stat
的用法示例。
在下文中一共展示了Stat::displayDown方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ValidateDisplays
/**
* Assess each Display to correctly set the logged in flag based on last accessed time
* @return
*/
public static function ValidateDisplays()
{
// Maintain an array of timed out displays
$timedOutDisplays = array();
try {
$dbh = PDOConnect::init();
$statObject = new Stat();
// Get a list of all displays and there last accessed / alert time out value
$sth = $dbh->prepare('SELECT displayid, display, lastaccessed, alert_timeout, client_type, displayprofileid, email_alert, loggedin FROM display');
$sthUpdate = $dbh->prepare('UPDATE display SET loggedin = 0 WHERE displayid = :displayid');
$sth->execute(array());
// Get the global time out (overrides the alert time out on the display if 0)
$globalTimeout = Config::GetSetting('MAINTENANCE_ALERT_TOUT') * 60;
$displays = $sth->fetchAll();
foreach ($displays as $row) {
$displayid = Kit::ValidateParam($row['displayid'], _INT);
$lastAccessed = Kit::ValidateParam($row['lastaccessed'], _INT);
$alertTimeout = Kit::ValidateParam($row['alert_timeout'], _INT);
$clientType = Kit::ValidateParam($row['client_type'], _WORD);
$loggedIn = Kit::ValidateParam($row['loggedin'], _INT);
// Get the config object
if ($alertTimeout == 0 && $clientType != '') {
$displayProfileId = empty($row['displayprofileid']) ? 0 : Kit::ValidateParam($row['displayprofileid'], _INT);
$display = new Display();
$display->displayId = $displayid;
$display->displayProfileId = $displayProfileId;
$display->clientType = $clientType;
$timeoutToTestAgainst = $display->GetSetting('collectInterval', $globalTimeout);
} else {
$timeoutToTestAgainst = $globalTimeout;
}
// Store the time out to test against
$row['timeout'] = $timeoutToTestAgainst;
$timeOut = $lastAccessed + $timeoutToTestAgainst;
// If the last time we accessed is less than now minus the time out
if ($timeOut < time()) {
Debug::Audit('Timed out display. Last Accessed: ' . date('Y-m-d h:i:s', $lastAccessed) . '. Time out: ' . date('Y-m-d h:i:s', $timeOut));
// If this is the first switch (i.e. the row was logged in before)
if ($loggedIn == 1) {
// Update the display and set it as logged out
$sthUpdate->execute(array('displayid' => $displayid));
// Log the down event
$statObject->displayDown($displayid, $lastAccessed);
}
// Store this row
$timedOutDisplays[] = $row;
}
}
return $timedOutDisplays;
} catch (Exception $e) {
Debug::LogEntry('error', $e->getMessage(), get_class(), __FUNCTION__);
return false;
}
}