本文整理汇总了PHP中UserSession::getFromRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP UserSession::getFromRequest方法的具体用法?PHP UserSession::getFromRequest怎么用?PHP UserSession::getFromRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserSession
的用法示例。
在下文中一共展示了UserSession::getFromRequest方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleRequest
public static function handleRequest()
{
if (extension_loaded('newrelic')) {
newrelic_disable_autorum();
}
if (!Site::getConfig('inheritance_key')) {
Site::respondUnauthorized('Remote emergence access is disabled');
} elseif (empty($_REQUEST['accessKey']) || $_REQUEST['accessKey'] != Site::getConfig('inheritance_key')) {
// attempt to authenticate via developer session
if (!UserSession::getFromRequest()->hasAccountLevel('Developer')) {
Site::respondUnauthorized('Remote emergence access denied');
}
}
if ($_REQUEST['remote'] == 'parent') {
set_time_limit(1800);
$remoteParams = array();
if (!empty($_REQUEST['exclude'])) {
$remoteParams['exclude'] = $_REQUEST['exclude'];
}
HttpProxy::relayRequest(array('url' => static::buildUrl(Site::$pathStack, $remoteParams), 'autoAppend' => false, 'autoQuery' => false, 'timeout' => 500));
}
if (empty(Site::$pathStack[0])) {
return static::handleTreeRequest();
} elseif ($node = Site::resolvePath(Site::$pathStack)) {
if (method_exists($node, 'outputAsResponse')) {
$node->outputAsResponse(true);
} elseif (is_a($node, 'SiteCollection')) {
return static::handleTreeRequest($node);
} else {
Site::respondBadRequest();
}
} else {
header('HTTP/1.0 404 Not Found');
die('File not found');
}
}
示例2: executeScript
public static function executeScript(SiteFile $_SCRIPT_NODE, $_SCRIPT_EXIT = true)
{
// create session
if (empty($GLOBALS['Session']) && static::$autoCreateSession && !in_array(implode('/', static::$resolvedPath), static::$skipSessionPaths)) {
$GLOBALS['Session'] = UserSession::getFromRequest();
}
if (is_callable(static::$onBeforeScriptExecute)) {
call_user_func(static::$onBeforeScriptExecute, $_SCRIPT_NODE);
}
require $_SCRIPT_NODE->RealPath;
if ($_SCRIPT_EXIT) {
exit;
}
}
示例3: executeScript
public static function executeScript(SiteFile $_SCRIPT_NODE, $_SCRIPT_EXIT = true)
{
// create session
if (empty($GLOBALS['Session']) && static::$autoCreateSession && !in_array(implode('/', static::$resolvedPath), static::$skipSessionPaths)) {
$GLOBALS['Session'] = UserSession::getFromRequest();
}
if (extension_loaded('newrelic')) {
if (!empty($GLOBALS['Session'])) {
newrelic_add_custom_parameter('session_id', $GLOBALS['Session']->Handle);
newrelic_add_custom_parameter('person_id', $GLOBALS['Session']->PersonID);
}
newrelic_add_custom_parameter('script_path', $_SCRIPT_NODE->FullPath);
}
if (is_callable(static::$onBeforeScriptExecute)) {
call_user_func(static::$onBeforeScriptExecute, $_SCRIPT_NODE);
}
if (class_exists('Emergence\\EventBus')) {
Emergence\EventBus::fireEvent('beforeScriptExecute', 'Site', array('node' => $_SCRIPT_NODE, 'exit' => $_SCRIPT_EXIT));
}
require $_SCRIPT_NODE->RealPath;
if ($_SCRIPT_EXIT) {
exit;
}
}
示例4: handleRequest
public static function handleRequest()
{
// TODO: try global handle lookup?
// resolve URL in root
$resolvedNode = false;
$rootNode = static::getRootCollection('site-root');
// handle root request - default page
if (empty(static::$pathStack[0]) && static::$defaultPage) {
static::$pathStack[0] = static::$defaultPage;
}
// route request
if (static::$pathStack[0] == 'emergence') {
array_shift(static::$pathStack);
return Emergence::handleRequest();
} elseif (static::$pathStack[0] == 'parent-refresh' && $_REQUEST['key'] == static::$controlKey) {
DB::nonQuery('DELETE FROM `%s` WHERE CollectionID IN (SELECT ID FROM `%s` WHERE SiteID != %u)', array(SiteFile::$tableName, SiteCollection::$tableName, Site::getSiteID()));
die('Cleared ' . DB::affectedRows() . ' cached files');
} else {
$resolvedNode = $rootNode;
$resolvedPath = array();
while ($handle = array_shift(static::$pathStack)) {
$scriptHandle = substr($handle, -4) == '.php' ? $handle : $handle . '.php';
//printf('%s: (%s)/(%s) - %s<br>', $resolvedNode->Handle, $handle, implode('/',static::$pathStack), $scriptHandle);
if ($resolvedNode && method_exists($resolvedNode, 'getChild') && (($childNode = $resolvedNode->getChild($handle)) || $scriptHandle && ($childNode = $resolvedNode->getChild($scriptHandle))) || ($childNode = Emergence::resolveFileFromParent('site-root', array_merge($resolvedPath, array($handle)))) || $scriptHandle && ($childNode = Emergence::resolveFileFromParent('site-root', array_merge($resolvedPath, array($scriptHandle))))) {
$resolvedNode = $childNode;
if (is_a($resolvedNode, 'SiteFile')) {
break;
}
} else {
$resolvedNode = false;
//break;
}
$resolvedPath[] = $handle;
}
}
if ($resolvedNode) {
// create session
if (static::$autoCreateSession && $resolvedNode->MIMEType == 'application/php') {
$GLOBALS['Session'] = UserSession::getFromRequest();
}
if (is_callable(static::$onRequestMapped)) {
call_user_func(static::$onRequestMapped, $resolvedNode);
}
if ($resolvedNode->MIMEType == 'application/php') {
require $resolvedNode->RealPath;
exit;
} elseif (!is_callable(array($resolvedNode, 'outputAsResponse'))) {
//throw new Exception('Node does not support rendering');
static::respondNotFound();
} else {
$resolvedNode->outputAsResponse();
}
} else {
static::respondNotFound();
}
}
示例5: executeScript
public static function executeScript(SiteFile $_SCRIPT_NODE, $_SCRIPT_EXIT = true)
{
// create session
if (empty($GLOBALS['Session']) && static::$autoCreateSession && !in_array(implode('/', static::$resolvedPath), static::$skipSessionPaths)) {
$GLOBALS['Session'] = UserSession::getFromRequest();
}
if (is_callable(static::$onBeforeScriptExecute)) {
call_user_func(static::$onBeforeScriptExecute, $_SCRIPT_NODE);
}
if (class_exists('Emergence\\EventBus')) {
Emergence\EventBus::fireEvent('beforeScriptExecute', 'Site', array('node' => $_SCRIPT_NODE, 'exit' => $_SCRIPT_EXIT));
}
require $_SCRIPT_NODE->RealPath;
if ($_SCRIPT_EXIT) {
exit;
}
}