| [ Index ] |
PHP Cross Reference of Joomla 1.5.26 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @version $Id:sessionstorage.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 * Custom session storage handler for PHP 20 * 21 * @abstract 22 * @package Joomla.Framework 23 * @subpackage Session 24 * @since 1.5 25 * @see http://www.php.net/manual/en/function.session-set-save-handler.php 26 */ 27 class JSessionStorage extends JObject 28 { 29 /** 30 * Constructor 31 * 32 * @access protected 33 * @param array $options optional parameters 34 */ 35 function __construct( $options = array() ) 36 { 37 $this->register($options); 38 } 39 40 /** 41 * Returns a reference to a session storage handler object, only creating it 42 * if it doesn't already exist. 43 * 44 * @access public 45 * @param name $name The session store to instantiate 46 * @return database A JSessionStorage object 47 * @since 1.5 48 */ 49 function &getInstance($name = 'none', $options = array()) 50 { 51 static $instances; 52 53 if (!isset ($instances)) { 54 $instances = array (); 55 } 56 57 $name = strtolower(JFilterInput::clean($name, 'word')); 58 if (empty ($instances[$name])) 59 { 60 $class = 'JSessionStorage'.ucfirst($name); 61 if(!class_exists($class)) 62 { 63 $path = dirname(__FILE__).DS.'storage'.DS.$name.'.php'; 64 if (file_exists($path)) { 65 require_once($path); 66 } else { 67 // No call to JError::raiseError here, as it tries to close the non-existing session 68 jexit('Unable to load session storage class: '.$name); 69 } 70 } 71 72 $instances[$name] = new $class($options); 73 } 74 75 return $instances[$name]; 76 } 77 78 /** 79 * Register the functions of this class with PHP's session handler 80 * 81 * @access public 82 * @param array $options optional parameters 83 */ 84 function register( $options = array() ) 85 { 86 // use this object as the session handler 87 session_set_save_handler( 88 array($this, 'open'), 89 array($this, 'close'), 90 array($this, 'read'), 91 array($this, 'write'), 92 array($this, 'destroy'), 93 array($this, 'gc') 94 ); 95 } 96 97 /** 98 * Open the SessionHandler backend. 99 * 100 * @abstract 101 * @access public 102 * @param string $save_path The path to the session object. 103 * @param string $session_name The name of the session. 104 * @return boolean True on success, false otherwise. 105 */ 106 function open($save_path, $session_name) 107 { 108 return true; 109 } 110 111 /** 112 * Close the SessionHandler backend. 113 * 114 * @abstract 115 * @access public 116 * @return boolean True on success, false otherwise. 117 */ 118 function close() 119 { 120 return true; 121 } 122 123 /** 124 * Read the data for a particular session identifier from the 125 * SessionHandler backend. 126 * 127 * @abstract 128 * @access public 129 * @param string $id The session identifier. 130 * @return string The session data. 131 */ 132 function read($id) 133 { 134 return; 135 } 136 137 /** 138 * Write session data to the SessionHandler backend. 139 * 140 * @abstract 141 * @access public 142 * @param string $id The session identifier. 143 * @param string $session_data The session data. 144 * @return boolean True on success, false otherwise. 145 */ 146 function write($id, $session_data) 147 { 148 return true; 149 } 150 151 /** 152 * Destroy the data for a particular session identifier in the 153 * SessionHandler backend. 154 * 155 * @abstract 156 * @access public 157 * @param string $id The session identifier. 158 * @return boolean True on success, false otherwise. 159 */ 160 function destroy($id) 161 { 162 return true; 163 } 164 165 /** 166 * Garbage collect stale sessions from the SessionHandler backend. 167 * 168 * @abstract 169 * @access public 170 * @param integer $maxlifetime The maximum age of a session. 171 * @return boolean True on success, false otherwise. 172 */ 173 function gc($maxlifetime) 174 { 175 return true; 176 } 177 178 /** 179 * Test to see if the SessionHandler is available. 180 * 181 * @abstract 182 * @static 183 * @access public 184 * @return boolean True on success, false otherwise. 185 */ 186 function test() 187 { 188 return true; 189 } 190 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Mar 28 15:54:07 2012 | Cross-referenced by PHPXref 0.7.1 |