[ Index ] |
PHP Cross Reference of vtigercrm-6.1.0 |
[Summary view] [Print] [Text view]
1 <?php 2 3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ 4 5 /** 6 * Container class for storing session data 7 * 8 * PHP version 4 9 * 10 * LICENSE: This source file is subject to version 3.0 of the PHP license 11 * that is available through the world-wide-web at the following URI: 12 * http://www.php.net/license/3_0.txt. If you did not receive a copy of 13 * the PHP License and are unable to obtain it through the web, please 14 * send a note to [email protected] so we can mail you a copy immediately. 15 * 16 * @category HTTP 17 * @package HTTP_Session 18 * @author Alexander Radivanovich <[email protected]> 19 * @author David Costa <[email protected]> 20 * @author Michael Metz <[email protected]> 21 * @author Stefan Neufeind <[email protected]> 22 * @author Torsten Roehr <[email protected]> 23 * @copyright 1997-2005 The PHP Group 24 * @license http://www.php.net/license/3_0.txt PHP License 3.0 25 * @version CVS: $Id: Container.php,v 1.8 2007/07/14 12:11:54 troehr Exp $ 26 * @link http://pear.php.net/package/HTTP_Session 27 * @since File available since Release 0.4.0 28 */ 29 30 /** 31 * Container class for storing session data 32 * 33 * @category HTTP 34 * @package HTTP_Session 35 * @author David Costa <[email protected]> 36 * @author Michael Metz <[email protected]> 37 * @author Stefan Neufeind <[email protected]> 38 * @author Torsten Roehr <[email protected]> 39 * @copyright 1997-2005 The PHP Group 40 * @license http://www.php.net/license/3_0.txt PHP License 3.0 41 * @version Release: @package_version@ 42 * @link http://pear.php.net/package/HTTP_Session 43 * @since Class available since Release 0.4.0 44 */ 45 class HTTP_Session_Container 46 { 47 /** 48 * Additional options for the container object 49 * 50 * @var array 51 * @access private 52 */ 53 var $options = array(); 54 55 /** 56 * Constrtuctor method 57 * 58 * @param array $options Additional options for the container object 59 * 60 * @access public 61 * @return object 62 */ 63 function HTTP_Session_Container($options = null) 64 { 65 $this->_setDefaults(); 66 if (is_array($options)) { 67 $this->_parseOptions(); 68 } 69 } 70 71 /** 72 * Set some default options 73 * 74 * @access private 75 * @return void 76 */ 77 function _setDefaults() 78 { 79 } 80 81 /** 82 * Parse options passed to the container class 83 * 84 * @param array $options Options 85 * 86 * @access private 87 * @return void 88 */ 89 function _parseOptions($options) 90 { 91 foreach ($options as $option => $value) { 92 if (in_array($option, array_keys($this->options))) { 93 $this->options[$option] = $value; 94 } 95 } 96 } 97 98 /** 99 * This function is called by the session handler to initialize things 100 * 101 * @param string $save_path Save path 102 * @param string $session_name Session name 103 * 104 * @access public 105 * @return bool 106 */ 107 function open($save_path, $session_name) 108 { 109 return true; 110 } 111 112 /** 113 * This function is called when the page is finished 114 * executing and the session handler needs to close things off 115 * 116 * Has to be overwritten by each container class 117 * 118 * @access public 119 * @return bool 120 */ 121 function close() 122 { 123 return true; 124 } 125 126 /** 127 * This function is called by the session handler 128 * to read the data associated with a given session ID. 129 * This function must retrieve and return the session data 130 * for the session identified by $id. 131 * 132 * Has to be overwritten by each container class 133 * 134 * @param string $id ID of the session 135 * 136 * @access public 137 * @return string 138 */ 139 function read($id) 140 { 141 return ''; 142 } 143 144 /** 145 * This function is called when the session handler 146 * has session data to save, which usually happens 147 * at the end of your script 148 * 149 * Has to be overwritten by each container class 150 * 151 * @param string $id ID of the session 152 * @param mixed $data The data associated with a given session ID 153 * 154 * @access public 155 * @return bool 156 */ 157 function write($id, $data) 158 { 159 return true; 160 } 161 162 /** 163 * This function is called when a session is destroyed. 164 * It is responsible for deleting the session and cleaning things up. 165 * 166 * Has to be overwritten by each container class 167 * 168 * @param string $id ID of the session 169 * 170 * @access public 171 * @return bool 172 */ 173 function destroy($id) 174 { 175 return true; 176 } 177 178 /** 179 * This function copies session data of specified id to specified table 180 * 181 * Has to be overwritten by each container class 182 * 183 * @param string $targetTable Table to replicate data to 184 * @param string $id ID of the session 185 * 186 * @access public 187 * @return bool 188 */ 189 function replicate($targetTable, $id = null) 190 { 191 return true; 192 } 193 194 /** 195 * This function is responsible for garbage collection. 196 * In the case of session handling, it is responsible 197 * for deleting old, stale sessions that are hanging around. 198 * The session handler will call this every now and then. 199 * 200 * Has to be overwritten by each container class 201 * 202 * @param integer $maxlifetime Maximum lifetime 203 * 204 * @access public 205 * @return bool 206 */ 207 function gc($maxlifetime) 208 { 209 return true; 210 } 211 212 /** 213 * Set session save handler 214 * 215 * @access public 216 * @return void 217 */ 218 function set() 219 { 220 $GLOBALS['HTTP_Session_Container'] =& $this; 221 session_module_name('user'); 222 session_set_save_handler('HTTP_Session_Open', 223 'HTTP_Session_Close', 224 'HTTP_Session_Read', 225 'HTTP_Session_Write', 226 'HTTP_Session_Destroy', 227 'HTTP_Session_GC'); 228 } 229 230 /** 231 * Destructor for compatibility with PHP >= 5.0.5 232 * 233 * @access private 234 * @return void 235 */ 236 function __destruct() 237 { 238 $GLOBALS['HTTP_Session_Container'] =& $this; 239 session_write_close(); 240 } 241 } 242 243 // Delegate function calls to the object's methods 244 /** @ignore */ 245 function HTTP_Session_Open($save_path, $session_name) 246 { 247 return (isset($GLOBALS['HTTP_Session_Container'])) ? $GLOBALS['HTTP_Session_Container']->open($save_path, $session_name) 248 : false; 249 } 250 /** @ignore */ 251 function HTTP_Session_Close() 252 { 253 return (isset($GLOBALS['HTTP_Session_Container'])) ? $GLOBALS['HTTP_Session_Container']->close() 254 : false; 255 } 256 /** @ignore */ 257 function HTTP_Session_Read($id) 258 { 259 return (isset($GLOBALS['HTTP_Session_Container'])) ? $GLOBALS['HTTP_Session_Container']->read($id) 260 : false; 261 } 262 /** @ignore */ 263 function HTTP_Session_Write($id, $data) 264 { 265 return (isset($GLOBALS['HTTP_Session_Container'])) ? $GLOBALS['HTTP_Session_Container']->write($id, $data) 266 : false; 267 } 268 /** @ignore */ 269 function HTTP_Session_Destroy($id) 270 { 271 return (isset($GLOBALS['HTTP_Session_Container'])) ? $GLOBALS['HTTP_Session_Container']->destroy($id) 272 : false; 273 } 274 /** @ignore */ 275 function HTTP_Session_GC($maxlifetime) 276 { 277 return (isset($GLOBALS['HTTP_Session_Container'])) ? $GLOBALS['HTTP_Session_Container']->gc($maxlifetime) 278 : false; 279 } 280 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:08:37 2014 | Cross-referenced by PHPXref 0.7.1 |