本文整理汇总了PHP中Zend_Session::sessionExists方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Session::sessionExists方法的具体用法?PHP Zend_Session::sessionExists怎么用?PHP Zend_Session::sessionExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Session
的用法示例。
在下文中一共展示了Zend_Session::sessionExists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
$this->bootstrap = $this->getInvokeArg('bootstrap');
$this->options = $this->bootstrap->getOptions();
$this->_host = $this->_request->getServer('HTTP_HOST');
if (Zend_Session::sessionExists()) {
if (!$this->session) {
$singleton = !empty($this->options['unittest']) ? false : true;
$this->session = new Zend_Session_Namespace(self::SESSION_NAMESPACE, $singleton);
}
$this->_sessionId = Zend_Session::getId();
do {
// 登陆信息验证
$names = $this->options['cookies'];
if (!isset($this->session->auth) || !$this->_request->getCookie($names['username'])) {
break;
}
//var_dump($this->_request->getCookie($names['email']));exit();
if ($this->session->auth['username'] != $this->_request->getCookie($names['username'])) {
break;
}
$this->session->auth['lasttime'] = time();
$this->_user = Tudu_User::getInstance();
$this->_user->init($this->session->auth);
} while (false);
} else {
$authId = $this->_request->getCookie($this->options['cookies']['auth']);
if (!empty($authId)) {
$referer = PROTOCOL . '//' . $this->_request->getServer('HTTP_HOST') . '/frame';
return $this->_redirect($this->options['sites']['www'] . '/login/auto?referer=' . urlencode($referer));
}
}
}
示例2: uploadAction
/**
*Upload File
*
*/
public function uploadAction()
{
$this->_loadParams();
$dir = $this->_fields[$this->_request->getParam('field_id')]['params']['dir'];
if (!Zend_Session::sessionExists() || !Zend_Session::isStarted()) {
Zend_Session::start();
}
$uniqueName = Zend_Session::getId();
$this->_genericFileHelper->createFieldDir($dir . DIRECTORY_SEPARATOR . stripcslashes($uniqueName), true);
$destination = $dir . DIRECTORY_SEPARATOR . stripcslashes($uniqueName);
$uploadSettings = $this->getParams($this->_request->getParam('field_id'));
if (!isset($uploadSettings)) {
//do something bcs there is no file types
}
$uploadSettings = array_merge($uploadSettings, array('dir' => $destination, 'field' => $this->_request->getParam('field_id')));
$result = $this->_genericFileHelper->upload($uploadSettings);
if ($result === false) {
$result = array('success' => false, 'files' => array());
$lastError = $this->_genericFileHelper->getLastErrorMessage();
if ($lastError != '') {
$result['error'] = $this->translate($lastError);
}
echo json_encode($result);
} else {
$result = array('success' => true, 'files' => array($result), 'path' => $result['path']);
$lastError = $this->_genericFileHelper->getLastErrorMessage();
if ($lastError != '') {
$result['error'] = $this->translate($lastError);
}
echo json_encode($result);
}
die;
}
示例3: read
/**
* Defined by Zend_Auth_Storage_Interface
*
* @return mixed
*/
public function read()
{
if (!Zend_Session::isStarted() && !Zend_Session::sessionExists()) {
return array();
}
return $this->_getSession()->{$this->_member};
}
示例4: indexAction
public function indexAction()
{
if ($this->getRequest()->getParam('garbage')) {
$this->redirect('');
}
$translator = Zend_Registry::get('Zend_Translate');
if (!$this->getRequest()->isPost()) {
if (Zend_Session::sessionExists()) {
$namespace = $this->_session->getNamespace();
if (isset($_SESSION[$namespace])) {
unset($_SESSION[$namespace]);
}
$translator->setLocale('en');
Zend_Registry::set('Zend_Translate', $translator);
Zend_Session::regenerateId();
}
} else {
$lang = $this->getRequest()->getParam('lang');
if ($lang && Zend_Locale::isLocale($lang)) {
$this->_session->locale->setLocale($lang);
if ($translator->getLocale() !== $lang) {
$translator->setLocale($lang);
Zend_Registry::set('Zend_Translate', $translator);
}
$this->_session->nextStep = 1;
}
if ($this->_session->nextStep !== null) {
return $this->forward('step' . $this->_session->nextStep);
}
}
$this->forward('step1');
}
示例5: logoutAction
/**
* logout
*/
public function logoutAction()
{
if (Zend_Session::sessionExists()) {
Zend_Session::destroy(true, true);
$this->_redirect('/index/login');
}
}
示例6: _getTypeConnected
public function _getTypeConnected($type)
{
$isconnected = false;
$defaultNamespace = new Zend_Session_Namespace();
if (Zend_Session::sessionExists() && $defaultNamespace->type == $type) {
$isconnected = true;
}
return $isconnected;
}
示例7: __construct
/**
* Sets session storage options and initializes session namespace object
*
* @param mixed $namespace
* @param mixed $member
* @param string $sessionId
* @return void
*/
public function __construct($namespace = self::NAMESPACE_DEFAULT, $member = self::MEMBER_DEFAULT, $sessionId = null)
{
$this->_namespace = $namespace;
$this->_member = $member;
if (null !== $sessionId && !Zend_Session::sessionExists()) {
Zend_Session::setId($sessionId);
}
$this->_session = new Zend_Session_Namespace($this->_namespace);
}
示例8: loginAction
public function loginAction()
{
$this->view->translate()->setLocale(isset($_GET['locale']) ? $_GET['locale'] : 'ru');
$this->view->resource = $this->_request->getParam('resource');
$this->view->headTitle($this->view->translate('Login page'));
$this->view->headLink()->appendStylesheet(array('rel' => 'shortcut icon', 'type' => 'image/x-icon', 'href' => '/img/favicon.ico'));
$this->view->headLink()->appendStylesheet('/modules/auth/css/login.css');
if ($this->_request->isPost()) {
// file_put_contents('d:\\temp\\auth.txt', var_export($this->_request->getParams(), true));
$filter = new Zend_Filter_StripTags();
$username = $filter->filter($this->_request->getParam('username'));
$password = $filter->filter($this->_request->getParam('password'));
$woredir = $this->_request->getParam('woredir');
if ($woredir) {
$this->getHelper('viewRenderer')->setNoRender();
$this->getHelper('layout')->disableLayout();
}
if (empty($username)) {
$this->_response->setHttpResponseCode(401);
// Unauthorized
if ($woredir) {
echo 'Please, provide a username.';
} else {
$this->view->message = 'Please, provide a username.';
}
//$this->view->translate('Please provide a username.');
} else {
Zend_Session::start();
if (Uman_Auth::login($username, $password)) {
Zend_Session::rememberMe();
$auth = Zend_Auth::getInstance();
$identity = $auth->getIdentity();
$ns = new Zend_Session_Namespace('acl');
$ns->acl = new Uman_Acl($identity->NODEID, $identity->PATH);
if ($woredir) {
echo 'OK';
} else {
$this->_redirect($this->_request->getParam('resource', '/'));
}
} else {
$this->_response->setHttpResponseCode(401);
// Unauthorized
Zend_Session::destroy();
if ($woredir) {
echo 'Authorization error. Please, try again.';
} else {
$this->view->message = $this->view->translate('Authorization error. Please, try again.');
}
}
}
} else {
if (Zend_Session::sessionExists()) {
Zend_Session::start();
Zend_Session::destroy();
}
}
}
示例9: _initSession
protected function _initSession()
{
Zend_Session::start(true);
if (Zend_Session::sessionExists()) {
$phpSettings = $this->getOption('phpSettings');
$sessionConfig = $phpSettings['session'];
// Prorrogando o tempo de vida do cookie ;)
setcookie($sessionConfig['name'], Zend_Session::getId(), $sessionConfig['cookie_lifetime'] + time(), $sessionConfig['cookie_path'], $sessionConfig['cookie_domain'], $sessionConfig['cookie_secure'], $sessionConfig['cookie_httponly']);
}
}
示例10: init
/**
* Initialization session namespace
*
* @param string $namespace
*/
public function init($namespace)
{
if (!Zend_Session::sessionExists()) {
$this->start();
}
Varien_Profiler::start(__METHOD__ . '/init');
$this->_namespace = new Zend_Session_Namespace($namespace, Zend_Session_Namespace::SINGLE_INSTANCE);
Varien_Profiler::stop(__METHOD__ . '/init');
return $this;
}
示例11: sendContent
public function sendContent($includeMaster)
{
$benchmarkEnabled = Kwf_Benchmark::isEnabled();
if (Kwf_Util_Https::supportsHttps()) {
$foundRequestHttps = Kwf_Util_Https::doesComponentRequestHttps($this->_data);
if (isset($_SERVER['HTTPS'])) {
//we are on https
if (!$foundRequestHttps && isset($_COOKIE['kwcAutoHttps']) && !Zend_Session::sessionExists() && !Zend_Session::isStarted()) {
//we where auto-redirected to https but don't need https anymore
setcookie('kwcAutoHttps', '', 0, '/');
//delete cookie
Kwf_Util_Https::ensureHttp();
}
} else {
//we are on http
if ($foundRequestHttps) {
setcookie('kwcAutoHttps', '1', 0, '/');
Kwf_Util_Https::ensureHttps();
}
}
if ($benchmarkEnabled) {
Kwf_Benchmark::checkpoint('check requestHttps');
}
}
if ($benchmarkEnabled) {
$startTime = microtime(true);
}
$process = $this->_getProcessInputComponents($includeMaster);
if ($benchmarkEnabled) {
Kwf_Benchmark::subCheckpoint('getProcessInputComponents', microtime(true) - $startTime);
}
self::_callProcessInput($process);
if ($benchmarkEnabled) {
Kwf_Benchmark::checkpoint('processInput');
}
$hasDynamicParts = false;
$out = $this->_render($includeMaster, $hasDynamicParts);
if ($benchmarkEnabled) {
Kwf_Benchmark::checkpoint('render');
}
header('Content-Type: text/html; charset=utf-8');
if (!$hasDynamicParts) {
$lifetime = 60 * 60;
header('Cache-Control: public, max-age=' . $lifetime);
header('Expires: ' . gmdate("D, d M Y H:i:s \\G\\M\\T", time() + $lifetime));
header('Pragma: public');
}
echo $out;
self::_callPostProcessInput($process);
if ($benchmarkEnabled) {
Kwf_Benchmark::checkpoint('postProcessInput');
}
}
示例12: dispatchLoopShutdown
public function dispatchLoopShutdown()
{
if (Zend_Session::sessionExists() && Zend_Auth::getInstance()->hasIdentity()) {
$ident = Zend_Auth::getInstance()->getIdentity();
$isVaporLogin = in_array($ident['authType'], array(App_Controller_Plugin_Auth::AUTH_TYPE_LOST_PASSWORD, App_Controller_Plugin_Auth::AUTH_TYPE_ASYNC, App_Controller_Plugin_Auth::AUTH_TYPE_EXTERNAL, App_Controller_Plugin_Auth::AUTH_TYPE_THIRD_PARTY, App_Controller_Plugin_Auth::AUTH_TYPE_DOWNLOAD_TOKEN));
if (!$isVaporLogin) {
Zend_Session::writeClose(true);
} else {
Zend_Session::destroy(false);
$_SESSION = array();
}
}
}
示例13: start
function start()
{
$saveHandlerManager = new Kutu_Session_SaveHandler_Manager();
$saveHandlerManager->setSaveHandler();
$flagSessionIdSent = false;
if (Zend_Session::sessionExists()) {
Zend_Session::start();
} else {
echo "session has not been started";
$sReturn = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
$sReturn = urlencode($sReturn);
header(KUTU_ROOT_URL . '/helper/sso/syncsession/?returnTo=' . $sReturn);
}
}
示例14: errorAction
/**
* The errorAction handles errors and exceptions.
*
* @return null
*/
public function errorAction()
{
$this->getResponse()->clearBody();
$errors = $this->_getParam('error_handler');
switch ($errors->type) {
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
// 404 error -- controller or action not found
$this->getResponse()->setHttpResponseCode(404);
$this->view->message = 'The page requested was not found.';
break;
default:
// Log exceptions. EnterpriseSecurityException were automagically logged
// so they are not logged here.
if ($errors->exception instanceof EnterpriseSecurityException === false) {
ESAPI::getIntrusionDetector()->addException($errors->exception);
}
// application error - if display_errors is off then the client
// is redirected to the index controller error action where a
// generic error message will be rendered.
$bootstrap = $this->getInvokeArg('bootstrap');
if ($bootstrap->hasOption('phpsettings')) {
$o = $bootstrap->getOption('phpsettings');
if (array_key_exists('display_errors', $o) && $o['display_errors'] !== '1') {
if (Zend_Session::sessionExists()) {
$ns = new Zend_Session_Namespace('Contact');
$ns->error = true;
}
$this->_helper->getHelper('redirector')->setCode(303)->gotoSimple('error', 'index', null, $this->_request->getParams());
return;
}
}
$this->getResponse()->setHttpResponseCode(500);
$this->view->message = 'Application error';
}
// conditionally display exceptions
if ($this->getInvokeArg('displayExceptions') == true) {
$this->view->exception = $errors->exception;
}
$this->view->request = $errors->request;
}
示例15: inscriptionAction
public function inscriptionAction()
{
$log = new SessionLAG();
if ($log->_getTypeConnected('joueur')) {
return $this->_helper->redirector('inscriptionlan', 'inscription');
} else {
$smarty = Zend_Registry::get('view');
$request = $this->getRequest();
$smarty->assign('title', 'Connexion');
$defaultNamespace = new Zend_Session_Namespace();
if (Zend_Session::sessionExists() && empty($defaultNamespace->userid)) {
$form = $this->_getLogForm();
$model = $this->_getModelCompte();
$modelFonctionCompte = $this->_getModelFonctionCompte();
if ($this->getRequest()->isPost()) {
if ($form->isValid($request->getPost())) {
$dataform = $form->getValues();
$dataform['password'] = sha1('l@g8?' . $dataform['password'] . 'pe6r!e8');
$existlog = $model->existLog($dataform);
if ($existlog != NULL) {
$userid = 'idCompte';
$fonction = $modelFonctionCompte->fetchFonction($existlog[$userid]);
$min = 200;
foreach ($fonction as $f) {
if ($f['ordre'] < $min) {
$min = $f['ordre'];
$nom = $f['nom'];
}
}
$this->connexion($existlog[$userid], $nom);
return $this->_redirect('/inscription/inscriptionlan');
} else {
$form = "Erreur de connexion : votre login ou mot de passe n'est pas valide. Votre compte n'est peut �tre pas encore activ� par un administrateur.";
}
}
}
$smarty->assign('creer_compte', $request->getBaseUrl() . '/inscription/inscriptionmembre');
$smarty->assign('form', $form);
$smarty->display('inscription/inscription.tpl');
}
}
}