本文整理汇总了PHP中Kernel::enterSystemMode方法的典型用法代码示例。如果您正苦于以下问题:PHP Kernel::enterSystemMode方法的具体用法?PHP Kernel::enterSystemMode怎么用?PHP Kernel::enterSystemMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kernel
的用法示例。
在下文中一共展示了Kernel::enterSystemMode方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processRequest
public function processRequest(MMapRequest $request, MMapResponse $response)
{
ob_start('mb_output_handler');
MMapManager::startSession();
MMapManager::checkSessionExpiration();
$username = $request->issetPOST('username') ? $request->getPOST('username') : '';
$password = $request->issetPOST('password') ? $request->getPOST('password') : '';
$loginPage = $request->issetPOST('loginPage') ? $request->getPOST('loginPage') : '';
$subject = new Subject();
$loginContext = new LoginContext('eyeos-login', $subject);
$cred = new EyeosPasswordCredential();
$cred->setUsername($username);
$cred->setPassword($password, true);
$subject->getPrivateCredentials()->append($cred);
try {
$loginContext->login();
$memoryManager = MemoryManager::getInstance();
Kernel::enterSystemMode();
$memoryManager->set('isExternLogin', 1);
$memoryManager->set('username', $username);
$memoryManager->set('password', $password);
$memoryManager->set('loginPage', $loginPage);
Kernel::exitSystemMode();
header("Location: index.php");
} catch (Exception $e) {
header("Location:" . $loginPage . "?errorLogin=1");
}
}
示例2: checkSessionExpiration
/**
* @throws EyeSessionExpiredException
*/
public static function checkSessionExpiration()
{
Kernel::enterSystemMode();
$regenerated = MemoryManager::getInstance()->get('regenerated', 1);
Kernel::exitSystemMode();
if ($regenerated == 1) {
MemoryManager::getInstance()->reset();
throw new EyeSessionExpiredException('Session expired.');
}
}
示例3: processRequest
public function processRequest(MMapRequest $request, MMapResponse $response)
{
$oauth_verifier = null;
$oauth_token = null;
if ($request->issetGET('oauth_verifier')) {
$oauth_verifier = $request->getGET('oauth_verifier');
}
if ($request->issetGET('oauth_token')) {
$oauth_token = $request->getGET('oauth_token');
}
if ($oauth_verifier && $oauth_token) {
$response->getHeaders()->append('Content-type: text/html');
$body = '<html>
<div id="logo_eyeos" style="margin: 0 auto;width:350"> <img src="eyeos/extern/images/logo-eyeos.jpg"/></div>
<div style="margin: 0 auto;width:350;text-align:center"><span style="font-family:Verdana;font-size:20px;">Successful authentication.<br>Back to Eyeos.</span></div>
</html>';
$response->getHeaders()->append('Content-Length: ' . strlen($body));
$response->getHeaders()->append('Accept-Ranges: bytes');
$response->getHeaders()->append('X-Pad: avoid browser bug');
$response->getHeaders()->append('Cache-Control: ');
$response->getHeaders()->append('pragma: ');
$response->setBody($body);
try {
$userRoot = UMManager::getInstance()->getUserByName('root');
} catch (EyeNoSuchUserException $e) {
throw new EyeFailedLoginException('Unknown user root"' . '". Cannot proceed to login.', 0, $e);
}
$subject = new Subject();
$loginContext = new LoginContext('eyeos-login', $subject);
$cred = new EyeosPasswordCredential();
$cred->setUsername('root');
$cred->setPassword($userRoot->getPassword(), false);
$subject->getPrivateCredentials()->append($cred);
$loginContext->login();
Kernel::enterSystemMode();
$appProcess = new Process('stacksync');
$appProcess->setPid('31338');
$mem = MemoryManager::getInstance();
$processTable = $mem->get('processTable', array());
$processTable[31338] = $appProcess;
$mem->set('processTable', $processTable);
$appProcess->setLoginContext($loginContext);
ProcManager::getInstance()->setCurrentProcess($appProcess);
kernel::exitSystemMode();
$token = new stdClass();
$token->oauth_verifier = $oauth_verifier;
$token->oauth_token = $oauth_token;
$group = UMManager::getInstance()->getGroupByName('users');
$users = UMManager::getInstance()->getAllUsersFromGroup($group);
foreach ($users as $user) {
$NetSyncMessage = new NetSyncMessage('cloud', 'token', $user->getId(), $token);
NetSyncController::getInstance()->send($NetSyncMessage);
}
}
}
示例4: __run
public static function __run(AppExecutionContext $context, MMapResponse $response)
{
$myMemoryManager = MemoryManager::getInstance();
Kernel::enterSystemMode();
$isExternLogin = $myMemoryManager->get('isExternLogin');
$loginPage = $myMemoryManager->get('loginPage');
Kernel::exitSystemMode();
$context->getArgs()->append($isExternLogin);
if ($isExternLogin) {
$context->getArgs()->append($loginPage);
}
}
示例5: processRequest
public function processRequest(MMapRequest $request, MMapResponse $response)
{
ob_start('mb_output_handler');
$return = null;
$dataManager = DataManager::getInstance();
$POST = $request->getPOST();
$params = array();
if (isset($POST['params'])) {
$params = $dataManager->doInput($POST['params']);
} else {
if ($request->issetGET('params')) {
$params = $request->getGET('params');
}
}
//login in the system and get a valid login context
$subject = new Subject();
$loginContext = new LoginContext('eyeos-login', $subject);
$cred = new EyeosPasswordCredential();
$cred->setUsername($_REQUEST['username']);
$cred->setPassword($_REQUEST['password'], true);
$subject->getPrivateCredentials()->append($cred);
$loginContext->login();
//now create fake process called api
Kernel::enterSystemMode();
$appProcess = new Process('api');
$appProcess->setPid('31337');
$mem = MemoryManager::getInstance();
$processTable = $mem->get('processTable', array());
$processTable[31337] = $appProcess;
$mem->set('processTable', $processTable);
$appProcess->setLoginContext($loginContext);
ProcManager::getInstance()->setCurrentProcess($appProcess);
kernel::exitSystemMode();
$return = call_user_func_array(array('EyeosApplicationExecutable', '__callModule'), array($request->getPOST('module'), $request->getPOST('name'), $params));
//try to force mime type. If there is a previous mime type defined at application level
//this have no effect
if (!headers_sent()) {
$response->getHeaders()->append('Content-type:text/plain');
}
if ($response->getBodyRenderer() === null && $response->getBody() == '') {
$response->setBodyRenderer(new DataManagerBodyRenderer($return));
}
}
示例6: __run
public static function __run(AppExecutionContext $context, MMapResponse $response)
{
$memoryManager = MemoryManager::getInstance();
Kernel::enterSystemMode();
$isExternLogin = $memoryManager->get('isExternLogin');
Kernel::exitSystemMode();
$list = new ArrayList();
$list->append($isExternLogin);
if ($isExternLogin) {
Kernel::enterSystemMode();
$username = $memoryManager->get('username');
$password = $memoryManager->get('password');
Kernel::exitSystemMode();
$list->append($username);
$list->append($password);
}
$context->setArgs($list);
$response->appendToBody('eyeos.isRegisterActive=' . self::isRegisterActive() . ';');
}
示例7: setProcessLoginContext
/**
* Change the LoginContext associated with an existing process
*
* @param int $pid
* @param LoginContext $loginContext
* @throws EyeInvalidArgumentException If the arguments are incorrect
* @throws EyeProcException If there is no such process with the given pid
*/
public function setProcessLoginContext($pid, LoginContext $loginContext)
{
$processTable = $this->getProcessesTable();
if (!isset($processTable[$pid])) {
throw new EyeProcException('Process $proc with PID ' . $pid . ' not found.');
}
$processTable[$pid]->setLoginContext($loginContext);
if ($this->currentProcess->getPid() == $pid) {
$this->currentProcess = $processTable[$pid];
}
Kernel::enterSystemMode();
$this->memoryManager->set('processTable', $processTable);
Kernel::exitSystemMode();
$this->fireEvent('loginContextChanged', new ProcEvent($processTable[$pid]));
}