本文整理汇总了PHP中Kurogo::getElapsed方法的典型用法代码示例。如果您正苦于以下问题:PHP Kurogo::getElapsed方法的具体用法?PHP Kurogo::getElapsed怎么用?PHP Kurogo::getElapsed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kurogo
的用法示例。
在下文中一共展示了Kurogo::getElapsed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: logView
public static function logView($service, $id, $page, $data, $dataLabel, $size = 0)
{
switch ($service) {
case 'web':
case 'api':
break;
default:
throw new Exception("Invalid service {$service}");
break;
}
$deviceClassifier = Kurogo::deviceClassifier();
$ip = Kurogo::determineIP();
$requestURI = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
$referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
$userAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
$visitID = self::getVisitID($service);
if (Kurogo::getSiteVar('AUTHENTICATION_ENABLED')) {
$session = Kurogo::getSession();
$user = $session->getUser();
} else {
$user = false;
}
$logData = array('timestamp' => time(), 'date' => date('Y-m-d H:i:s'), 'site' => SITE_KEY, 'service' => $service, 'requestURI' => $requestURI, 'referrer' => $referrer, 'referredSite' => intval(self::isFromThisSite($referrer)), 'referredModule' => intval(self::isFromModule($referrer, $id)), 'userAgent' => $userAgent, 'ip' => $ip, 'user' => $user ? $user->getUserID() : '', 'authority' => $user ? $user->getAuthenticationAuthorityIndex() : '', 'visitID' => $visitID, 'pagetype' => $deviceClassifier->getPageType(), 'platform' => $deviceClassifier->getPlatform(), 'moduleID' => $id, 'page' => $page, 'data' => $data, 'dataLabel' => $dataLabel, 'size' => $size, 'elapsed' => Kurogo::getElapsed());
try {
$conn = self::connection();
} catch (KurogoDataServerException $e) {
throw new KurogoConfigurationException("Database not configured for statistics. To disable stats, set STATS_ENABLED=0 in site.ini");
}
$sql = sprintf("INSERT INTO %s (%s) VALUES (%s)", Kurogo::getOptionalSiteVar("KUROGO_STATS_TABLE", "kurogo_stats_v1"), implode(",", array_keys($logData)), implode(",", array_fill(0, count($logData), '?')));
if (!($result = $conn->query($sql, array_values($logData), db::IGNORE_ERRORS))) {
self::createStatsTables();
$result = $conn->query($sql, array_values($logData));
}
return $result;
}
示例2: logView
public static function logView($service, $id, $page, $data, $dataLabel, $size = 0)
{
switch ($service) {
case 'web':
case 'api':
break;
default:
throw new Exception("Invalid service {$service}");
break;
}
$deviceClassifier = Kurogo::deviceClassifier();
$ip = Kurogo::determineIP();
$requestURI = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
$referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
$userAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
$visitID = self::getVisitID($service);
if (Kurogo::getSiteVar('AUTHENTICATION_ENABLED')) {
$session = Kurogo::getSession();
$user = $session->getUser();
} else {
$user = false;
}
$statsLogFilename = Kurogo::getOptionalSiteVar('KUROGO_STATS_LOG_FILENAME', "kurogo_stats_log_v1");
$statsLogFile = LOG_DIR . DIRECTORY_SEPARATOR . $statsLogFilename;
$current = time();
$logData = array('timestamp' => time(), 'date' => date('Y-m-d H:i:s', $current), 'service' => $service, 'site' => SITE_KEY, 'requestURI' => $requestURI, 'referrer' => $referrer, 'referredSite' => intval(self::isFromThisSite($referrer)), 'referredModule' => intval(self::isFromModule($referrer, $id)), 'userAgent' => $userAgent, 'ip' => $ip, 'user' => $user ? $user->getUserID() : '', 'authority' => $user ? $user->getAuthenticationAuthorityIndex() : '', 'visitID' => $visitID, 'pagetype' => $deviceClassifier->getPageType(), 'platform' => $deviceClassifier->getPlatform(), 'moduleID' => $id, 'page' => $page, 'data' => $data, 'dataLabel' => $dataLabel, 'size' => $size, 'elapsed' => Kurogo::getElapsed());
$fields = array_fill(0, count($logData), '%s');
$data = array_merge(array(implode("\t", $fields)), array_values($logData));
$content = call_user_func_array('sprintf', $data) . PHP_EOL;
self::fileAppend($statsLogFile, $content);
return true;
}