[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/libraries/joomla/session/storage/ -> eaccelerator.php (source)

   1  <?php
   2  /**
   3  * @version        $Id:eaccelerator.php 6961 2007-03-15 16:06:53Z tcp $
   4  * @package        Joomla.Framework
   5  * @subpackage    Session
   6  * @copyright    Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
   7  * @license        GNU/GPL, see LICENSE.php
   8  * Joomla! is free software. This version may have been modified pursuant
   9  * to the GNU General Public License, and as distributed it includes or
  10  * is derivative of works licensed under the GNU General Public License or
  11  * other free or open source software licenses.
  12  * See COPYRIGHT.php for copyright notices and details.
  13  */
  14  
  15  // Check to ensure this file is within the rest of the framework
  16  defined('JPATH_BASE') or die();
  17  
  18  /**
  19  * eAccelerator session storage handler for PHP
  20  *
  21  * @package        Joomla.Framework
  22  * @subpackage    Session
  23  * @since        1.5
  24  * @see http://www.php.net/manual/en/function.session-set-save-handler.php
  25  */
  26  class JSessionStorageEaccelerator extends JSessionStorage
  27  {
  28      /**
  29      * Constructor
  30      *
  31      * @access protected
  32      * @param array $options optional parameters
  33      */
  34  	function __construct( $options = array() )
  35      {
  36          if (!$this->test()) {
  37              return JError::raiseError(404, "The eaccelerator extension is not available");
  38          }
  39  
  40          parent::__construct($options);
  41      }
  42  
  43      /**
  44       * Open the SessionHandler backend.
  45       *
  46       * @access public
  47       * @param string $save_path     The path to the session object.
  48       * @param string $session_name  The name of the session.
  49       * @return boolean  True on success, false otherwise.
  50       */
  51  	function open($save_path, $session_name)
  52      {
  53          return true;
  54      }
  55  
  56      /**
  57       * Close the SessionHandler backend.
  58       *
  59       * @access public
  60       * @return boolean  True on success, false otherwise.
  61       */
  62  	function close()
  63      {
  64          return true;
  65      }
  66  
  67       /**
  68        * Read the data for a particular session identifier from the
  69        * SessionHandler backend.
  70        *
  71        * @access public
  72        * @param string $id  The session identifier.
  73        * @return string  The session data.
  74        */
  75  	function read($id)
  76      {
  77          $sess_id = 'sess_'.$id;
  78          return (string) eaccelerator_get($sess_id);
  79      }
  80  
  81      /**
  82       * Write session data to the SessionHandler backend.
  83       *
  84       * @access public
  85       * @param string $id            The session identifier.
  86       * @param string $session_data  The session data.
  87       * @return boolean  True on success, false otherwise.
  88       */
  89  	function write($id, $session_data)
  90      {
  91          $sess_id = 'sess_'.$id;
  92          return eaccelerator_put($sess_id, $session_data, ini_get("session.gc_maxlifetime"));
  93      }
  94  
  95      /**
  96        * Destroy the data for a particular session identifier in the
  97        * SessionHandler backend.
  98        *
  99        * @access public
 100        * @param string $id  The session identifier.
 101        * @return boolean  True on success, false otherwise.
 102        */
 103  	function destroy($id)
 104      {
 105          $sess_id = 'sess_'.$id;
 106          return eaccelerator_rm($sess_id);
 107      }
 108  
 109      /**
 110       * Garbage collect stale sessions from the SessionHandler backend.
 111       *
 112       * @access public
 113       * @param integer $maxlifetime  The maximum age of a session.
 114       * @return boolean  True on success, false otherwise.
 115       */
 116      function gc($maxlifetime)
 117      {
 118          eaccelerator_gc();
 119          return true;
 120      }
 121  
 122      /**
 123       * Test to see if the SessionHandler is available.
 124       *
 125       * @static
 126       * @access public
 127       * @return boolean  True on success, false otherwise.
 128       */
 129  	function test() {
 130          return (extension_loaded('eaccelerator') && function_exists('eaccelerator_get'));
 131      }
 132  }


Generated: Wed Mar 28 15:54:07 2012 Cross-referenced by PHPXref 0.7.1