本文整理汇总了PHP中Kurogo::getSession方法的典型用法代码示例。如果您正苦于以下问题:PHP Kurogo::getSession方法的具体用法?PHP Kurogo::getSession怎么用?PHP Kurogo::getSession使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kurogo
的用法示例。
在下文中一共展示了Kurogo::getSession方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: cacheFilename
/**
* Returns a base filename for the cache file that will be used. The default implementation uses
* a hash of the value returned from the url
* @return string
*/
protected function cacheFilename($url = null)
{
$url = $url ? $url : $this->url();
// Add the user's id to the cache-key for a per-user cache.
$session = Kurogo::getSession();
$user = $session->getUser();
return md5($url . $user->getUserID());
}
示例3: isLoggedIn
public function isLoggedIn()
{
$session = Kurogo::getSession();
return $session->isLoggedIn($this);
}
示例4: getCurrentUser
protected function getCurrentUser()
{
if ($this->authority) {
return $this->authority->getCurrentUser();
} else {
$session = Kurogo::getSession();
return $session->getUser();
}
}
示例5: getSession
/**
* Returns the current login session
*/
protected function getSession()
{
return Kurogo::getSession();
}
示例6: 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;
}