예제 #1
0
 /**
  * start() - Start the session.
  *
  * @param bool|array $options  OPTIONAL Either user supplied options, or flag indicating if start initiated automatically
  * @throws Zend_Session_Exception
  * @return void
  */
 public static function start($options = false)
 {
     if (self::$_sessionStarted && self::$_destroyed) {
         // require_once 'Zend/Session/Exception.php';
         throw new Zend_Session_Exception('The session was explicitly destroyed during this request, attempting to re-start is not allowed.');
     }
     if (self::$_sessionStarted) {
         return;
         // already started
     }
     // make sure our default options (at the least) have been set
     if (!self::$_defaultOptionsSet) {
         self::setOptions(is_array($options) ? $options : array());
     }
     // In strict mode, do not allow auto-starting Zend_Session, such as via "new Zend_Session_Namespace()"
     if (self::$_strict && $options === true) {
         /** @see Zend_Session_Exception */
         // require_once 'Zend/Session/Exception.php';
         throw new Zend_Session_Exception('You must explicitly start the session with Zend_Session::start() when session options are set to strict.');
     }
     $filename = $linenum = null;
     if (!self::$_unitTestEnabled && headers_sent($filename, $linenum)) {
         /** @see Zend_Session_Exception */
         // require_once 'Zend/Session/Exception.php';
         throw new Zend_Session_Exception("Session must be started before any output has been sent to the browser;" . " output started in {$filename}/{$linenum}");
     }
     // See http://www.php.net/manual/en/ref.session.php for explanation
     if (!self::$_unitTestEnabled && defined('SID')) {
         /** @see Zend_Session_Exception */
         // require_once 'Zend/Session/Exception.php';
         throw new Zend_Session_Exception('session has already been started by session.auto-start or session_start()');
     }
     /**
      * Hack to throw exceptions on start instead of php errors
      * @see http://framework.zend.com/issues/browse/ZF-1325
      */
     $errorLevel = is_int(self::$_throwStartupExceptions) ? self::$_throwStartupExceptions : E_ALL;
     /** @see Zend_Session_Exception */
     if (!self::$_unitTestEnabled) {
         if (self::$_throwStartupExceptions) {
             // require_once 'Zend/Session/Exception.php';
             set_error_handler(array('Zend_Session_Exception', 'handleSessionStartError'), $errorLevel);
         }
         $startedCleanly = session_start();
         if (self::$_throwStartupExceptions) {
             restore_error_handler();
         }
         if (!$startedCleanly || Zend_Session_Exception::$sessionStartError != null) {
             if (self::$_throwStartupExceptions) {
                 set_error_handler(array('Zend_Session_Exception', 'handleSilentWriteClose'), $errorLevel);
             }
             session_write_close();
             if (self::$_throwStartupExceptions) {
                 restore_error_handler();
                 throw new Zend_Session_Exception(__CLASS__ . '::' . __FUNCTION__ . '() - ' . Zend_Session_Exception::$sessionStartError);
             }
         }
     }
     parent::$_readable = true;
     parent::$_writable = true;
     self::$_sessionStarted = true;
     if (self::$_regenerateIdState === -1) {
         self::regenerateId();
     }
     // run validators if they exist
     if (isset($_SESSION['__ZF']['VALID'])) {
         self::_processValidators();
     }
     self::_processStartupMetadataGlobal();
 }
예제 #2
0
 /**
  * start() - Start the session.
  *
  * @param bool|array $options  OPTIONAL Either user supplied options, or flag indicating if start initiated automatically
  * @throws \Micro\Session\Exception
  * @return void
  */
 public static function start($options = false)
 {
     // Check to see if we've been passed an invalid session ID
     if (self::getId() && !self::_checkId(self::getId())) {
         // Generate a valid, temporary replacement
         self::setId(md5(self::getId()));
         // Force a regenerate after session is started
         self::$_regenerateIdState = -1;
     }
     if (self::$_sessionStarted && self::$_destroyed) {
         throw new Exception('The session was explicitly destroyed during this request, attempting to re-start is not allowed.');
     }
     if (self::$_sessionStarted) {
         return;
         // already started
     }
     // make sure our default options (at the least) have been set
     if (!self::$_defaultOptionsSet) {
         self::setOptions(is_array($options) ? $options : array());
     }
     // In strict mode, do not allow auto-starting \Micro\Session\Session, such as via "new \Micro\Session\SessionNamespace()"
     if (self::$_strict && $options === true) {
         throw new Exception('You must explicitly start the session with \\Micro\\Session\\Session::start() when session options are set to strict.');
     }
     $filename = $linenum = null;
     if (!self::$_unitTestEnabled && headers_sent($filename, $linenum)) {
         throw new Exception("Session must be started before any output has been sent to the browser;" . " output started in {$filename}/{$linenum}");
     }
     // See http://www.php.net/manual/en/ref.session.php for explanation
     if (!self::$_unitTestEnabled && defined('SID')) {
         throw new Exception('session has already been started by session.auto-start or session_start()');
     }
     $errorLevel = is_int(self::$_throwStartupExceptions) ? self::$_throwStartupExceptions : E_ALL;
     /** @see \Micro\Session\Exception */
     if (!self::$_unitTestEnabled) {
         if (self::$_throwStartupExceptions) {
             set_error_handler(array('Micro\\Session\\Exception', 'handleSessionStartError'), $errorLevel);
         }
         $startedCleanly = session_start();
         if (self::$_throwStartupExceptions) {
             restore_error_handler();
         }
         if (!$startedCleanly || Exception::$sessionStartError != null) {
             if (self::$_throwStartupExceptions) {
                 set_error_handler(array('Micro\\Session\\Exception', 'handleSilentWriteClose'), $errorLevel);
             }
             session_write_close();
             if (self::$_throwStartupExceptions) {
                 restore_error_handler();
                 throw new Exception(__CLASS__ . '::' . __FUNCTION__ . '() - ' . Exception::$sessionStartError);
             }
         }
     }
     parent::$_readable = true;
     parent::$_writable = true;
     self::$_sessionStarted = true;
     if (self::$_regenerateIdState === -1) {
         self::regenerateId();
     }
     // run validators if they exist
     if (isset($_SESSION['__MICRO']['VALID'])) {
         self::_processValidators();
     }
     self::_processStartupMetadataGlobal();
 }
예제 #3
0
파일: Session.php 프로젝트: jasmun/Noco100
 /**
  * Ifw Hack for using Zend_Session in WordPress context if session is already started
  * @param $started
  */
 public static function setStarted($started)
 {
     if ($started === true) {
         self::$_sessionStarted = true;
         parent::$_readable = true;
         parent::$_writable = true;
     }
 }
예제 #4
0
 /**
  * start() - Start the session.
  *
  * @param bool|array $options  OPTIONAL Either user supplied options, or flag indicating if start initiated automatically
  * @throws Zend_Session_Exception
  * @return void
  */
 public static function start($options = false)
 {
     if (self::$_sessionStarted) {
         return;
         // already started
     }
     // make sure our default options (at the least) have been set
     if (!self::$_defaultOptionsSet) {
         self::setOptions(is_array($options) ? $options : array());
     }
     // In strict mode, do not allow auto-starting Zend_Session, such as via "new Zend_Session_Namespace()"
     if (self::$_strict && $options === true) {
         throw new Zend_Session_Exception('You must explicitly start the session with Zend_Session::start() when session options are set to strict.');
     }
     if (headers_sent($filename, $linenum)) {
         throw new Zend_Session_Exception("Session must be started before any output has been sent to the browser;" . " output started in {$filename}/{$linenum}");
     }
     // See http://www.php.net/manual/en/ref.session.php for explanation
     if (defined('SID')) {
         throw new Zend_Session_Exception('session has already been started by session.auto-start or session_start()');
     }
     session_start();
     parent::$_readable = true;
     parent::$_writable = true;
     self::$_sessionStarted = true;
     if (self::$_regenerateIdState === -1) {
         self::regenerateId();
     }
     // run validators if they exist
     if (isset($_SESSION['__ZF']['VALID'])) {
         self::_processValidators();
     }
     self::_processStartupMetadataGlobal();
 }
예제 #5
0
 /**
  * start() - Start the session.
  *
  * @param bool|array $options  OPTIONAL Either user supplied options, or flag indicating if start initiated automatically
  * @throws Zend_Session_Exception
  * @return void
  */
 public static function start($options = false)
 {
     // Check to see if we've been passed an invalid session ID
     if (self::getId() && !self::_checkId(self::getId())) {
         // Generate a valid, temporary replacement
         self::setId(md5(self::getId()));
         // Force a regenerate after session is started
         self::$_regenerateIdState = -1;
     }
     if (self::$_sessionStarted && self::$_destroyed) {
         require_once 'Zend/Session/Exception.php';
         throw new Zend_Session_Exception('The session was explicitly destroyed during this request, attempting to re-start is not allowed.');
     }
     if (self::$_sessionStarted) {
         return;
         // already started
     }
     // make sure our default options (at the least) have been set
     if (!self::$_defaultOptionsSet) {
         self::setOptions(is_array($options) ? $options : array());
     }
     // In strict mode, do not allow auto-starting Zend_Session, such as via "new Zend_Session_Namespace()"
     if (self::$_strict && $options === true) {
         /** @see Zend_Session_Exception */
         require_once 'Zend/Session/Exception.php';
         throw new Zend_Session_Exception('You must explicitly start the session with Zend_Session::start() when session options are set to strict.');
     }
     $filename = $linenum = null;
     if (!self::$_unitTestEnabled && headers_sent($filename, $linenum)) {
         /** @see Zend_Session_Exception */
         require_once 'Zend/Session/Exception.php';
         throw new Zend_Session_Exception("Session must be started before any output has been sent to the browser;" . " output started in {$filename}/{$linenum}");
     }
     // See http://www.php.net/manual/en/ref.session.php for explanation
     if (!self::$_unitTestEnabled && defined('SID')) {
         /** @see Zend_Session_Exception */
         require_once 'Zend/Session/Exception.php';
         throw new Zend_Session_Exception('session has already been started by session.auto-start or session_start()');
     }
     /**
      * Hack to throw exceptions on start instead of php errors
      * @see http://framework.zend.com/issues/browse/ZF-1325
      */
     $errorLevel = is_int(self::$_throwStartupExceptions) ? self::$_throwStartupExceptions : E_ALL;
     // alcalbg - do not start session for robots
     $is_human = true;
     $robots = array('googlebot' => 'Googlebot', 'msnbot' => 'MSNBot', 'baiduspider' => 'Baiduspider', 'bingbot' => 'Bing', 'slurp' => 'Inktomi Slurp', 'yahoo' => 'Yahoo', 'askjeeves' => 'AskJeeves', 'fastcrawler' => 'FastCrawler', 'infoseek' => 'InfoSeek Robot 1.0', 'lycos' => 'Lycos', 'yandex' => 'YandexBot', 'newrelic' => 'NewRelicPinger');
     foreach ($robots as $key => $value) {
         if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], $value) !== false) {
             $is_human = false;
             break;
         }
     }
     /** @see Zend_Session_Exception */
     if ($is_human && !self::$_unitTestEnabled) {
         if (self::$_throwStartupExceptions) {
             require_once 'Zend/Session/Exception.php';
             set_error_handler(array('Zend_Session_Exception', 'handleSessionStartError'), $errorLevel);
         }
         $startedCleanly = session_start();
         if (self::$_throwStartupExceptions) {
             restore_error_handler();
         }
         if (!$startedCleanly || Zend_Session_Exception::$sessionStartError != null) {
             if (self::$_throwStartupExceptions) {
                 set_error_handler(array('Zend_Session_Exception', 'handleSilentWriteClose'), $errorLevel);
             }
             session_write_close();
             if (self::$_throwStartupExceptions) {
                 restore_error_handler();
                 throw new Zend_Session_Exception(__CLASS__ . '::' . __FUNCTION__ . '() - ' . Zend_Session_Exception::$sessionStartError);
             }
         }
     }
     parent::$_readable = true;
     parent::$_writable = true;
     self::$_sessionStarted = true;
     if (self::$_regenerateIdState === -1) {
         self::regenerateId();
     }
     // run validators if they exist
     if (isset($_SESSION['__ZF']['VALID'])) {
         self::_processValidators();
     }
     self::_processStartupMetadataGlobal();
 }