Ejemplo n.º 1
0
 /**
  * Setup db
  *
  */
 public function setup(Zend_Config $config)
 {
     $sessionConfig = $config->get('config');
     $configArray = $sessionConfig->toArray();
     // save_path handler
     $configArray = $this->_prependSavePath($configArray);
     // name handler
     $configArray = $this->_parseName($configArray);
     // Setup config
     Zend_Session::setOptions($configArray);
     // Setup save handling?
     $saveHandlerConfig = $config->get('save_handler');
     if ($className = $saveHandlerConfig->get('class_name')) {
         if ($args = $saveHandlerConfig->get('constructor_args')) {
             if ($args instanceof Zend_Config) {
                 $args = $args->toArray();
             } else {
                 $args = (array) $args;
             }
         } else {
             $args = array();
         }
         require_once 'Zend/Loader.php';
         Zend_Loader::loadClass($className);
         $saveHandler = new ReflectionClass($className);
         $saveHandler = $saveHandler->newInstanceArgs($args);
         Zend_Session::setSaveHandler($saveHandler);
     }
     // Autostart session?
     if ($config->get('auto_start')) {
         // Start session
         Zend_Session::start();
     }
 }
Ejemplo n.º 2
0
 public function authenticate()
 {
     // clear any lingering session identities
     Zend_Auth::getInstance()->clearIdentity();
     $session = $this->initBootstrap()->getApplication()->getOption('session');
     $userModel = $this->_adapter->getUser();
     if (null === $userModel->user_email || null === $userModel->user_password) {
         throw new Zend_Auth_Adapter_Exception('must provide email and password');
     }
     if ($useremail = $userModel->authenticate($userModel->user_email, $userModel->user_password)) {
         $user = new stdClass();
         $user->useremail_email = $useremail->getUseremailEmail();
         $user->user_id = $useremail->getUser()->getUserId();
         $user->user_firstname = $useremail->getUser()->getUserFirstname();
         $user->user_lastname = $useremail->getUser()->getUserLastname();
         $user->user_admin = $useremail->getUser()->getUserAdmin();
         $user->profile_id = $useremail->getUser()->getProfile()->getProfileId();
         Zend_Session::setOptions($session);
         $auth = Zend_Auth::getInstance();
         $storage = $auth->getStorage();
         $storage->write($user);
         $user = $auth->getIdentity();
         return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $user, array('Authentication successful'));
     } else {
         throw new Zend_Auth_Adapter_Exception('Authentication failed');
     }
 }
Ejemplo n.º 3
0
 /**
  * @static
  * @return void
  */
 public static function initSession()
 {
     Zend_Session::setOptions(array("throw_startup_exceptions" => false, "gc_maxlifetime" => 7200, "name" => "pimcore_admin_sid", "strict" => false, "use_only_cookies" => false));
     try {
         // register session
         $front = Zend_Controller_Front::getInstance();
         if ($front->getRequest() != null && $front->getRequest()->getParam("pimcore_admin_sid")) {
             // hack to get zend_session work with session-id via get (since SwfUpload doesn't support cookies)
             $_REQUEST["pimcore_admin_sid"] = $front->getRequest()->getParam("pimcore_admin_sid");
             $_COOKIE["pimcore_admin_sid"] = $front->getRequest()->getParam("pimcore_admin_sid");
         }
         if (!empty($_GET["pimcore_admin_sid"])) {
             // hack to get zend_session work with session-id via get (since SwfUpload doesn't support cookies)
             $_REQUEST["pimcore_admin_sid"] = $_GET["pimcore_admin_sid"];
             $_COOKIE["pimcore_admin_sid"] = $_GET["pimcore_admin_sid"];
         }
         try {
             if (!Zend_Session::isStarted()) {
                 Zend_Session::start();
             }
         } catch (Exception $e) {
             Logger::error("Problem while starting session");
             Logger::error($e);
         }
     } catch (Exception $e) {
         Logger::emergency("there is a problem with admin session");
         die;
     }
 }
Ejemplo n.º 4
0
 protected function _initSession()
 {
     $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/sessions.ini', 'development');
     Zend_Session::setOptions($config->toArray());
     // start session
     Zend_Session::start();
 }
Ejemplo n.º 5
0
 public function start()
 {
     Varien_Profiler::start(__METHOD__ . '/setOptions');
     $options = array('save_path' => Mage::getBaseDir('session'), 'use_only_cookies' => 'off', 'throw_startup_exceptions' => E_ALL ^ E_NOTICE);
     if ($this->getCookieDomain()) {
         $options['cookie_domain'] = $this->getCookieDomain();
     }
     if ($this->getCookiePath()) {
         $options['cookie_path'] = $this->getCookiePath();
     }
     if ($this->getCookieLifetime()) {
         $options['cookie_lifetime'] = $this->getCookieLifetime();
     }
     Zend_Session::setOptions($options);
     Varien_Profiler::stop(__METHOD__ . '/setOptions');
     /*
             Varien_Profiler::start(__METHOD__.'/setHandler');
             $sessionResource = Mage::getResourceSingleton('core/session');
             if ($sessionResource->hasConnection()) {
                 Zend_Session::setSaveHandler($sessionResource);
             }
             Varien_Profiler::stop(__METHOD__.'/setHandler');
     */
     Varien_Profiler::start(__METHOD__ . '/start');
     Zend_Session::start();
     Varien_Profiler::stop(__METHOD__ . '/start');
     return $this;
 }
Ejemplo n.º 6
0
 /**
  * 系统初始化
  */
 private static function init()
 {
     set_exception_handler(array('AWS_APP', 'exception_handle'));
     self::$config = load_class('core_config');
     self::$db = load_class('core_db');
     self::$plugins = load_class('core_plugins');
     self::$settings = self::model('setting')->get_settings();
     if ((!defined('G_SESSION_SAVE') or G_SESSION_SAVE == 'db') and get_setting('db_version') > 20121123) {
         Zend_Session::setSaveHandler(new Zend_Session_SaveHandler_DbTable(array('name' => get_table('sessions'), 'primary' => 'id', 'modifiedColumn' => 'modified', 'dataColumn' => 'data', 'lifetimeColumn' => 'lifetime')));
         self::$session_type = 'db';
     }
     Zend_Session::setOptions(array('name' => G_COOKIE_PREFIX . '_Session', 'cookie_domain' => G_COOKIE_DOMAIN));
     if (G_SESSION_SAVE == 'file' and G_SESSION_SAVE_PATH) {
         Zend_Session::setOptions(array('save_path' => G_SESSION_SAVE_PATH));
     }
     Zend_Session::start();
     self::$session = new Zend_Session_Namespace(G_COOKIE_PREFIX . '_Anwsion');
     if ($default_timezone = get_setting('default_timezone')) {
         date_default_timezone_set($default_timezone);
     }
     if ($img_url = get_setting('img_url')) {
         define('G_STATIC_URL', $img_url);
     } else {
         define('G_STATIC_URL', base_url() . '/static');
     }
     if (self::config()->get('system')->debug) {
         if ($cornd_timer = self::cache()->getGroup('crond')) {
             foreach ($cornd_timer as $cornd_tag) {
                 if ($cornd_runtime = self::cache()->get($cornd_tag)) {
                     AWS_APP::debug_log('crond', 0, 'Tag: ' . str_replace('crond_timer_', '', $cornd_tag) . ', Last run time: ' . date('Y-m-d H:i:s', $cornd_runtime));
                 }
             }
         }
     }
 }
Ejemplo n.º 7
0
 public function testSetOptions()
 {
     Zend_Session::setOptions(array('use_only_cookies' => false, 'remember_me_seconds' => 3600));
     $this->resource->setOptions(array('use_only_cookies' => true, 'remember_me_seconds' => 7200));
     $this->resource->init();
     $this->assertEquals(1, Zend_Session::getOptions('use_only_cookies'));
     $this->assertEquals(7200, Zend_Session::getOptions('remember_me_seconds'));
 }
Ejemplo n.º 8
0
 /**
  * This allow with a config file, to change the cookie_domain of the session.
  * Set "session.domain" directive in application.ini to change this.
  *
  * @param string $namespace
  * @param string $member
  */
 public function __construct($namespace = self::NAMESPACE_DEFAULT, $member = self::MEMBER_DEFAULT)
 {
     $cookieDomain = Centurion_Config_Manager::get('session.domain', $_SERVER['SERVER_NAME']);
     if ($cookieDomain !== null) {
         Zend_Session::setOptions(array('cookie_domain' => $cookieDomain));
     }
     parent::__construct($namespace, $member);
 }
Ejemplo n.º 9
0
 protected function _initConfig()
 {
     $config = new Zend_Config($this->getOptions(), true);
     Zend_Registry::set('config', $config);
     // TODO faut-il utiliser les sessions ou les registres ?
     $configSession = new Zend_Config_Ini(__DIR__ . '/configs/session.ini', APPLICATION_ENV);
     Zend_Session::setOptions($configSession->toArray());
     return $config;
 }
Ejemplo n.º 10
0
 public static function initSessionConfig()
 {
     if (false == self::$sessionInited) {
         $dir = APP_PATH . '/runtime/session';
         \Zend_Session::setOptions(array('name' => 'sid', 'use_only_cookies' => true, 'use_cookies' => true, 'cookie_lifetime' => 90 * 86400, 'gc_maxlifetime' => 30 * 86400, 'save_path' => $dir, 'save_handler' => 'files', 'cookie_domain' => Dispatcher::getInstance()->getRequest()->getServer('HTTP_HOST')));
         ini_set('session.use_strict_mode', false);
         self::$sessionInited = true;
     }
 }
 /**
  * Defined by Zend_Application_Resource_Resource
  *
  * @return void
  */
 public function init()
 {
     $options = array_change_key_case($this->getOptions(), CASE_LOWER);
     if (isset($options['savehandler'])) {
         unset($options['savehandler']);
     }
     if (count($options) > 0) {
         Zend_Session::setOptions($options);
     }
     if ($this->_saveHandler !== null) {
         Zend_Session::setSaveHandler($this->_saveHandler);
     }
 }
Ejemplo n.º 12
0
 private function getSession()
 {
     static $session;
     if (!isset($session)) {
         $dir = APP_PATH . '/runtime/session';
         if (!is_dir($dir)) {
             mkdir($dir, 0755, true);
         }
         Zend_Session::setOptions(array('cookie_lifetime' => 90 * 86400, 'gc_maxlifetime' => 30 * 86400, 'save_path' => $dir));
         Zend_Session::start();
         $session = new Zend_Session_Namespace(__METHOD__, Zend_Session_Namespace::SINGLE_INSTANCE);
     }
     return $session;
 }
Ejemplo n.º 13
0
 protected function _initSession()
 {
     $options = $this->getOptions();
     if (!empty($options['session'])) {
         Zend_Session::setOptions($options['session']);
     }
     Zend_Session::start();
     foreach ($_COOKIE as $name => $value) {
         // remove unused cookies
         if ($name[0] == 'w' && strrpos('_height', $name) !== FALSE) {
             setcookie($name, '', time() - 3600);
         }
     }
 }
Ejemplo n.º 14
0
 /**
  * Setup db
  *
  */
 public function setup(Zend_Config $config)
 {
     $sessionConfig = $config->get('config');
     $configArray = $sessionConfig->toArray();
     // save_path handler
     $configArray = $this->_prependSavePath($configArray);
     // name handler
     $configArray = $this->_parseName($configArray);
     // Setup config
     Zend_Session::setOptions($configArray);
     // Autostart session?
     if ($config->get('auto_start')) {
         // Start session
         Zend_Session::start();
     }
 }
Ejemplo n.º 15
0
 protected function _initSiteBootstrap()
 {
     $config = $this->getOption('site');
     $bootstrapClass = $this->_formatModuleName($config['name']) . '_Bootstrap';
     $bootstrapPath = $config['path'] . '/Bootstrap.php';
     $siteBootstrap = null;
     if (file_exists($bootstrapPath)) {
         include_once $bootstrapPath;
         if (class_exists($bootstrapClass, false)) {
             $siteBootstrap = new $bootstrapClass($this);
             $siteBootstrap->bootstrap();
         }
     }
     Zend_Session::setOptions(array('cookie_domain' => '.' . $config['host']));
     return $siteBootstrap;
 }
Ejemplo n.º 16
0
 public function _ZF_expireAll($args)
 {
     Zend_Session::setOptions(array('remember_me_seconds' => 15, 'gc_probability' => 2));
     session_id($args[0]);
     if (isset($args[1]) && !empty($args[1])) {
         $s = new Zend_Session_Namespace($args[1]);
     } else {
         $s = new Zend_Session_Namespace();
     }
     $result = '';
     foreach ($s->getIterator() as $key => $val) {
         $result .= "{$key} === {$val};";
     }
     Zend_Session::expireSessionCookie();
     Zend_Session::writeClose();
     echo $result;
 }
 protected function _initApp()
 {
     $front = Zend_Controller_Front::getInstance();
     $plugins = $this->getOption('plugins');
     foreach ($plugins as $plugin) {
         $path = isset($plugin['path']) ? $plugin['path'] : '';
         $class = isset($plugin['class']) ? $plugin['class'] : '';
         $index = isset($plugin['index']) ? $plugin['index'] : '';
         $params = isset($plugin['params']) ? $plugin['params'] : array();
         if ($class) {
             if ($path) {
                 require_once $path;
             }
             $front->registerPlugin(new $class($params), $index);
         }
     }
     Zend_Session::setOptions(array('name' => sha1(preg_match('/^\\/+(admin|base)\\/?/', $_SERVER['REQUEST_URI'])), 'cookie_domain' => PROJECT_HOST));
     Zend_Session::start();
 }
Ejemplo n.º 18
0
 public function _initSession()
 {
     $config = new Zend_Config_Ini(realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'session.ini', 'development');
     // Flash has problems with cookies so we pass the PHPSESSID variable via get
     if (substr_count($_SERVER['REQUEST_URI'], 'sessionid/') != 0) {
         $start = stripos($_SERVER['REQUEST_URI'], 'sessionid/') + 10;
         $end = strpos($_SERVER['REQUEST_URI'], '/', $start);
         if ($end > $start) {
             $sid = substr($_SERVER['REQUEST_URI'], $start, $end);
         } else {
             $sid = substr($_SERVER['REQUEST_URI'], $start);
         }
         $prefix = '';
         if (!empty($_SERVER["HTTP_COOKIE"])) {
             $prefix = '; ';
         }
         $_SERVER["HTTP_COOKIE"] = $prefix . $config->name . '=' . $sid;
         $_COOKIE[$config->name] = $sid;
         Zend_Session::setId($sid);
     }
     Zend_Session::setOptions($config->toArray());
 }
Ejemplo n.º 19
0
 /**
  * Bootstrap sessions
  * 
  * For Non-MVC
  */
 protected function _initSession()
 {
     $options = $this->getOptions();
     // Get session options
     $session_options = $options['resources']['session'];
     if (!empty($session_options)) {
         Zend_Session::setOptions($session_options);
     }
     $session = $this->getPluginResource('session');
     $session->init();
     Zend_Session::start();
     $auth_session = new Zend_Session_Namespace('Zend_Auth');
     // Default to 30 minutes
     $lifetime = 1800;
     if (isset($session_options['remember_me_seconds'])) {
         if ($session_options['remember_me_seconds'] > 0) {
             $lifetime = $session_options['remember_me_seconds'];
         }
     }
     $auth_session->setExpirationSeconds($lifetime);
     // store in registry for backward compatibility
     Zend_Registry::set('auth_session', $auth_session);
 }
Ejemplo n.º 20
0
 /**
  * Start the session, using the session settings from application.ini and dots.xml
  * @access public
  * @static
  * @return void
  */
 public static function start()
 {
     $option = Zend_Registry::get('option');
     $config = Zend_Registry::get('configuration');
     //check is a session exists for the current module
     if (isset($option->session)) {
         $namespaceName = $option->session->name;
         //if session is not registered, create it
         if (!Zend_Registry::isRegistered('session')) {
             $session = new Zend_Session_Namespace($namespaceName);
             // set session options
             Zend_Session::setOptions($config->resources->session->toArray());
             if (!isset($session->initialized)) {
                 $session->initialized = true;
                 // use only session cookie and regenerate session in the same time
                 Zend_Session::rememberMe($config->resources->session->remember_me_seconds);
             }
             Zend_Registry::set('session', $session);
         }
     } else {
         Zend_Registry::set('session', null);
     }
 }
Ejemplo n.º 21
0
 public function routeStartup()
 {
     $this->initAcl();
     $config = Zend_Registry::get('config');
     try {
         $lifetime = $config->system->duree_connexion;
         Zend_Session::setOptions(array('cookie_path' => '/', 'cookie_lifetime' => $lifetime, 'cache_expire' => $lifetime));
     } catch (Exception $e) {
         error_log((string) $e);
     }
     // models formulaire
     $m = new Wtk_Form_Model('login');
     $i = $m->addString('username', "Courriel");
     $m->addConstraintRequired($i);
     $i = $m->addString('password', "Mot de passe");
     $m->addConstraintRequired($i);
     $m->addNewSubmission('login', "Identifier");
     Zend_Registry::set('login_model', $m);
     $m = new Wtk_Form_Model('logout');
     $m->addNewSubmission('logout', "Déconnecter");
     Zend_Registry::set('logout_model', $m);
     $db = Zend_Registry::get('db');
     // initialise les méthodes d'authentifications.
     $auth = Zend_Auth::getInstance();
     // DB AUTH
     $this->db = new Strass_Auth_Adapter_DbTable($db, 'user', 'username', 'password');
     // HTTP_AUTH
     $config = array('accept_schemes' => 'digest', 'realm' => $config->system->realm, 'digest_domains' => '/', 'nonce_timeout' => $config->system->duree_connexion);
     $this->http = new Zend_Auth_Adapter_Http($config);
     $resolver = new Strass_Auth_Adapter_Http_Resolver_DbTable($db, 'user', 'username', 'password');
     $this->http->setDigestResolver($resolver);
     // SUDO AUTH
     $this->sudo = new Strass_Auth_Adapter_Sudo();
     $this->sudo();
     $this->form();
     $this->getUser();
 }
Ejemplo n.º 22
0
 public function authenticate()
 {
     $session = $this->initBootstrap()->getApplication()->getOption('session');
     $singlesignon = $this->_adapter->getUser();
     if (null === $singlesignon) {
         throw new Zend_Auth_Adapter_Exception('SingleSignon object cannot be null');
     }
     $userentity = $singlesignon->getUser();
     $ues = $userentity->getUseremail();
     if (count($ues) === 0) {
         throw new Zend_Auth_Adapter_Exception('User has no email addresses');
     }
     $useremail = null;
     foreach ($ues as $ue) {
         if ($ue->getUseremailIsprimary() === true) {
             $useremail = $ue;
             continue;
         }
     }
     if ($useremail === null) {
         throw new Zend_Auth_Adapter_Exception('User has no primary email address');
     }
     $user = new stdClass();
     $user->useremail_email = $useremail->getUseremailEmail();
     $user->user_id = $userentity->getUserId();
     $user->user_firstname = $userentity->getUserFirstname();
     $user->user_lastname = $userentity->getUserLastname();
     $user->user_admin = $userentity->getUserAdmin();
     $user->profile_id = $userentity->getProfile()->getProfileId();
     Zend_Session::setOptions($session);
     $auth = Zend_Auth::getInstance();
     $storage = $auth->getStorage();
     $storage->write($user);
     $user = $auth->getIdentity();
     return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $user, array('Authentication successful'));
 }
Ejemplo n.º 23
0
 /**
  * @static
  * @return void
  */
 public static function initSession()
 {
     Zend_Session::setOptions(array("throw_startup_exceptions" => false, "gc_maxlifetime" => 7200, "name" => "pimcore_admin_sid", "strict" => false, "use_only_cookies" => false));
     try {
         try {
             if (!Zend_Session::isStarted()) {
                 $sName = Zend_Session::getOptions("name");
                 // only set the session id if the cookie isn't present, otherwise Set-Cookie is always in the headers
                 if (array_key_exists($sName, $_REQUEST) && !empty($_REQUEST[$sName]) && (!array_key_exists($sName, $_COOKIE) || empty($_COOKIE[$sName]))) {
                     // get zend_session work with session-id via get (since SwfUpload doesn't support cookies)
                     Zend_Session::setId($_REQUEST[$sName]);
                 }
                 // register session
                 Zend_Session::start();
             }
         } catch (Exception $e) {
             Logger::error("Problem while starting session");
             Logger::error($e);
         }
     } catch (Exception $e) {
         Logger::emergency("there is a problem with admin session");
         die;
     }
 }
Ejemplo n.º 24
0
 public function start()
 {
     if (VPROF) {
         Varien_Profiler::start(__METHOD__ . '/setOptions');
     }
     $options = array('save_path' => AO::getBaseDir('session'), 'use_only_cookies' => 'off');
     if ($this->getCookieDomain()) {
         $options['cookie_domain'] = $this->getCookieDomain();
     }
     if ($this->getCookiePath()) {
         $options['cookie_path'] = $this->getCookiePath();
     }
     if ($this->getCookieLifetime()) {
         $options['cookie_lifetime'] = $this->getCookieLifetime();
     }
     Zend_Session::setOptions($options);
     if (VPROF) {
         Varien_Profiler::stop(__METHOD__ . '/setOptions');
     }
     /*
             if (VPROF) Varien_Profiler::start(__METHOD__.'/setHandler');
             $sessionResource = AO::getResourceSingleton('core/session');
             if ($sessionResource->hasConnection()) {
             	Zend_Session::setSaveHandler($sessionResource);
             }
             if (VPROF) Varien_Profiler::stop(__METHOD__.'/setHandler');
     */
     if (VPROF) {
         Varien_Profiler::start(__METHOD__ . '/start');
     }
     Zend_Session::start();
     if (VPROF) {
         Varien_Profiler::stop(__METHOD__ . '/start');
     }
     return $this;
 }
Ejemplo n.º 25
0
 /**
  * Sets up view
  * Alters response content type headers
  * Starts session
  *
  * @param Zend_Controller_Request_Abstract $request
  */
 public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
 {
     $this->setupView();
     parent::dispatchLoopStartup($request);
     // Since we're not using the cli sapi, instanciate the http protocol items
     if (!Zend_Session::isStarted() && !Zend_Session::sessionExists()) {
         if ($config = Zoo::getConfig('session', 'plugin')) {
             $options = $config->toArray();
             if (isset($options['save_path'])) {
                 $options['save_path'] = ZfApplication::$_data_path . $options['save_path'];
                 if (!file_exists($options['save_path'])) {
                     mkdir($options['save_path']);
                 }
             }
             Zend_Session::setOptions($options);
             if ($config->save_handler) {
                 $savehandlerClass = $config->save_handler;
                 Zend_Session::setSaveHandler(new $savehandlerClass());
                 // Not ready yet
             }
         }
         Zend_Session::start();
     }
 }
Ejemplo n.º 26
0
 /**
  * @static
  * @return void
  */
 public static function initSession()
 {
     if (!\Zend_Session::isStarted()) {
         \Zend_Session::setOptions(self::$options);
     }
     try {
         try {
             if (!\Zend_Session::isStarted()) {
                 $sName = self::getOption("name");
                 // only set the session id if the cookie isn't present, otherwise Set-Cookie is always in the headers
                 if (array_key_exists($sName, $_REQUEST) && !empty($_REQUEST[$sName]) && (!array_key_exists($sName, $_COOKIE) || empty($_COOKIE[$sName]))) {
                     // get zend_session work with session-id via get (since SwfUpload doesn't support cookies)
                     \Zend_Session::setId($_REQUEST[$sName]);
                 }
             }
         } catch (\Exception $e) {
             \Logger::error("Problem while starting session");
             \Logger::error($e);
         }
     } catch (\Exception $e) {
         \Logger::emergency("there is a problem with admin session");
         die;
     }
 }
Ejemplo n.º 27
0
 protected function _initSession()
 {
     $name = 'en4_install';
     Zend_Session::setOptions(array('name' => $name, 'cookie_path' => substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], '/') + 1), 'cookie_lifetime' => 0, 'gc_maxlifetime' => 86400, 'remember_me_seconds' => 86400, 'cookie_httponly' => false));
     session_name($name);
     // Check for bad session config
     if (function_exists('ini_get') && in_array(strtolower(ini_get('session.save_handler')), array('user', 'users', 'files'))) {
         $flag = true;
         if ('files' !== ini_get('session.save_handler') && function_exists('ini_set')) {
             $flag = false !== ini_set('session.save_handler', 'files');
         }
         if (function_exists('ini_set') && $flag && false !== ini_set('session.save_path', APPLICATION_PATH . '/temporary/session/')) {
             if (!is_writable(APPLICATION_PATH . '/temporary/session/')) {
                 throw new Exception('Please set full permissions on temporary/session (chmod 0777).');
             }
         } else {
             throw new Exception('Your session configuration is incorrect and ' . 'could not be automatically corrected. Please set ' . 'session.save_handler=files and session.save_path=/tmp (or your ' . 'temporary directory on non-Linux OSes.');
         }
     }
     // Session hack for fancy upload
     if (isset($_POST[session_name()])) {
         Zend_Session::setId($_POST[session_name()]);
     } else {
         if (isset($_COOKIE[session_name()])) {
             Zend_Session::setId($_COOKIE[session_name()]);
         }
     }
     // Start
     try {
         Zend_Session::start();
     } catch (Exception $e) {
         // This will generally happen when weird data is saved during the install process
         if (Zend_Session::isStarted()) {
             Zend_Session::destroy();
         }
         throw $e;
     }
     // Session binding
     $fixed = true;
     $namespace = new Zend_Session_Namespace('ZendSession');
     if (empty($namespace->ip)) {
         $namespace->ip = $_SERVER['REMOTE_ADDR'];
         $namespace->ua = @$_SERVER['HTTP_USER_AGENT'];
     } else {
         if ($namespace->ip != $_SERVER['REMOTE_ADDR']) {
             $fixed = false;
         }
     }
     // Occaisonally regenerate the id if requesting with the original user agent
     /*
     if( empty($namespace->count) ) {
       $namespace->count = 1;
     } else if( $namespace->count < 10 ) {
       $namespace->count++;
     } else if( $namespace->ua == $_SERVER['HTTP_USER_AGENT'] ) {
       Zend_Session::regenerateId();
     }
     */
     if (!$fixed) {
         Zend_Session::destroy();
         header('Location: ' . $_SERVER['REQUEST_URI']);
         exit;
     }
 }
 /**
  * init tine framework
  */
 public static function initFramework()
 {
     // avoid autostart of sessions
     Zend_Session::setOptions(array('strict' => true));
     Tinebase_Core::setupTempDir();
     Tinebase_Core::setupStreamWrapper();
     //Cache must be setup before User Locale because otherwise Zend_Locale tries to setup
     //its own cache handler which might result in a open_basedir restriction depending on the php.ini settings
     Tinebase_Core::setupCache();
     Tinebase_Core::setupBuildConstants();
     // setup a temporary user locale. This will be overwritten later but we
     // need to handle exceptions during initialisation process such as session timeout
     // @todo add fallback locale to config file
     Tinebase_Core::set('locale', new Zend_Locale('en_US'));
     Tinebase_Core::setupUserLocale();
     Tinebase_Core::enableProfiling();
     if (PHP_SAPI !== 'cli') {
         header('X-API: http://www.tine20.org/apidocs/tine20/');
         if (isset($_SERVER['HTTP_X_TRANSACTIONID'])) {
             header('X-TransactionID: ' . substr($_SERVER['HTTP_X_TRANSACTIONID'], 1, -1) . ';' . $_SERVER['SERVER_NAME'] . ';16.4.5009.816;' . date('Y-m-d H:i:s') . ' UTC;265.1558 ms');
         }
     }
 }
Ejemplo n.º 29
0
 /** Configure the session. */
 protected function _initSession()
 {
     $this->bootstrap('Config');
     $config = Zend_Registry::get('configGlobal');
     $options = array('cookie_httponly' => true, 'cookie_secure' => (int) $config->get('cookie_secure', 1) === 1, 'gc_maxlifetime' => 600);
     Zend_Session::setOptions($options);
 }
Ejemplo n.º 30
0
 public function routeStartup(Zend_Controller_Request_Abstract $request)
 {
     Zend_Session::setOptions(Zend_Registry::getInstance()->get('Zend_Config')->get('session')->get('params')->toArray());
 }