JOOMLA中国
  • Joomla中国首页
  • 社区
  • 教程
  • 应用市场
  • B计划
Joomla! Framework TM
  • Namespace
  • Class
  • Tree
  • Deprecated

Namespaces

  • Composer
    • Autoload
  • Joomla
    • Application
      • Cli
        • Output
          • Processor
      • Web
    • Data
    • DI
      • Exception
    • Event
    • Filter
    • Input
    • Ldap
    • Registry
      • Format
    • Session
      • Storage
    • String
    • Uri
    • Utilities
  • None
  • PasswordCompat
    • binary
  • PHP
  • Psr
    • Log
  • Symfony
    • Component
      • Yaml
        • Exception
    • Polyfill
      • Util

Classes

  • Session
  • Storage
  1 <?php
  2 /**
  3  * Part of the Joomla Framework Session Package
  4  *
  5  * @copyright  Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
  6  * @license    GNU General Public License version 2 or later; see LICENSE
  7  */
  8 
  9 namespace Joomla\Session;
 10 
 11 use Joomla\Filter\InputFilter;
 12 
 13 /**
 14  * Custom session storage handler for PHP
 15  *
 16  * @see         http://www.php.net/manual/en/function.session-set-save-handler.php
 17  * @since       1.0
 18  * @deprecated  2.0  The Storage class chain will be removed.
 19  */
 20 abstract class Storage
 21 {
 22     /**
 23      * @var    Storage[]  Storage instances container.
 24      * @since  1.0
 25      * @deprecated  2.0
 26      */
 27     protected static $instances = array();
 28 
 29     /**
 30      * Constructor
 31      *
 32      * @param   array  $options  Optional parameters.
 33      *
 34      * @since   1.0
 35      * @deprecated  2.0
 36      */
 37     public function __construct($options = array())
 38     {
 39         $this->register($options);
 40     }
 41 
 42     /**
 43      * Returns a session storage handler object, only creating it if it doesn't already exist.
 44      *
 45      * @param   string  $name     The session store to instantiate
 46      * @param   array   $options  Array of options
 47      *
 48      * @return  Storage
 49      *
 50      * @since   1.0
 51      * @deprecated  2.0
 52      */
 53     public static function getInstance($name = 'none', $options = array())
 54     {
 55         $filter = new InputFilter;
 56         $name = strtolower($filter->clean($name, 'word'));
 57 
 58         if (empty(self::$instances[$name]))
 59         {
 60             $class = '\\Joomla\\Session\\Storage\\' . ucfirst($name);
 61 
 62             if (!class_exists($class))
 63             {
 64                 $path = __DIR__ . '/storage/' . $name . '.php';
 65 
 66                 if (file_exists($path))
 67                 {
 68                     require_once $path;
 69                 }
 70                 else
 71                 {
 72                     // No attempt to die gracefully here, as it tries to close the non-existing session
 73                     exit('Unable to load session storage class: ' . $name);
 74                 }
 75             }
 76 
 77             self::$instances[$name] = new $class($options);
 78         }
 79 
 80         return self::$instances[$name];
 81     }
 82 
 83     /**
 84      * Register the functions of this class with PHP's session handler
 85      *
 86      * @return  void
 87      *
 88      * @since   1.0
 89      * @deprecated  2.0
 90      */
 91     public function register()
 92     {
 93         // Use this object as the session handler
 94         session_set_save_handler(
 95             array($this, 'open'), array($this, 'close'), array($this, 'read'), array($this, 'write'),
 96             array($this, 'destroy'), array($this, 'gc')
 97         );
 98     }
 99 
100     /**
101      * Open the SessionHandler backend.
102      *
103      * @param   string  $save_path     The path to the session object.
104      * @param   string  $session_name  The name of the session.
105      *
106      * @return  boolean  True on success, false otherwise.
107      *
108      * @since   1.0
109      * @deprecated  2.0
110      */
111     public function open($save_path, $session_name)
112     {
113         return true;
114     }
115 
116     /**
117      * Close the SessionHandler backend.
118      *
119      * @return  boolean  True on success, false otherwise.
120      *
121      * @since   1.0
122      * @deprecated  2.0
123      */
124     public function close()
125     {
126         return true;
127     }
128 
129     /**
130      * Read the data for a particular session identifier from the
131      * SessionHandler backend.
132      *
133      * @param   string  $id  The session identifier.
134      *
135      * @return  string  The session data.
136      *
137      * @since   1.0
138      * @deprecated  2.0
139      */
140     public function read($id)
141     {
142         return;
143     }
144 
145     /**
146      * Write session data to the SessionHandler backend.
147      *
148      * @param   string  $id            The session identifier.
149      * @param   string  $session_data  The session data.
150      *
151      * @return  boolean  True on success, false otherwise.
152      *
153      * @since   1.0
154      * @deprecated  2.0
155      */
156     public function write($id, $session_data)
157     {
158         return true;
159     }
160 
161     /**
162      * Destroy the data for a particular session identifier in the
163      * SessionHandler backend.
164      *
165      * @param   string  $id  The session identifier.
166      *
167      * @return  boolean  True on success, false otherwise.
168      *
169      * @since   1.0
170      * @deprecated  2.0
171      */
172     public function destroy($id)
173     {
174         return true;
175     }
176 
177     /**
178      * Garbage collect stale sessions from the SessionHandler backend.
179      *
180      * @param   integer  $maxlifetime  The maximum age of a session.
181      *
182      * @return  boolean  True on success, false otherwise.
183      *
184      * @since   1.0
185      * @deprecated  2.0
186      */
187     public function gc($maxlifetime = null)
188     {
189         return true;
190     }
191 
192     /**
193      * Test to see if the SessionHandler is available.
194      *
195      * @return  boolean  True on success, false otherwise.
196      *
197      * @since   1.0
198      * @deprecated  2.0
199      */
200     public static function isSupported()
201     {
202         return true;
203     }
204 }
205 
Joomla! Framework TM API documentation generated by ApiGen 2.8.0
Joomla!® and Joomla! Framework™ are trademarks of Open Source Matters, Inc. in the United States and other countries.