PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 4.3.0
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v4.3.0
5.11.1 5.11.0 5.10.2 5.10.1 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.3.2 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.2 4.1.3 4.10.0 4.11.0 4.12.0 4.13.0 4.13.2 4.13.3 4.13.4 4.13.5 4.14.0 4.14.1 4.14.2 4.15.0 4.15.1 4.15.2 4.15.3 4.2.0 4.3.0 4.3.1 4.4.1 4.4.2 4.5.0 4.6.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.10.0 5.2.0 5.2.1 5.2.2 5.3.0 5.3.1 5.3.2 5.3.3 5.6.0 5.6.1 5.7.0 5.7.1 5.8.0 5.8.1 5.8.2
matomo / app / libs / Zend / Session / Abstract.php
matomo / app / libs / Zend / Session Last commit date
SaveHandler 6 years ago Validator 6 years ago Abstract.php 6 years ago Exception.php 5 years ago Namespace.php 6 years ago
Abstract.php
186 lines
1 <?php
2
3 /**
4 * Zend Framework
5 *
6 * LICENSE
7 *
8 * This source file is subject to the new BSD license that is bundled
9 * with this package in the file LICENSE.txt.
10 * It is also available through the world-wide-web at this URL:
11 * http://framework.zend.com/license/new-bsd
12 * If you did not receive a copy of the license and are unable to
13 * obtain it through the world-wide-web, please send an email
14 * to license@zend.com so we can send you a copy immediately.
15 *
16 * @category Zend
17 * @package Zend_Session
18 * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
20 * @version $Id: Abstract.php 23775 2011-03-01 17:25:24Z ralph $
21 * @since Preview Release 0.2
22 */
23
24
25 /**
26 * Zend_Session_Abstract
27 *
28 * @category Zend
29 * @package Zend_Session
30 * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
31 * @license http://framework.zend.com/license/new-bsd New BSD License
32 */
33 abstract class Zend_Session_Abstract
34 {
35 /**
36 * Whether or not session permits writing (modification of $_SESSION[])
37 *
38 * @var bool
39 */
40 protected static $_writable = false;
41
42 /**
43 * Whether or not session permits reading (reading data in $_SESSION[])
44 *
45 * @var bool
46 */
47 protected static $_readable = false;
48
49 /**
50 * Since expiring data is handled at startup to avoid __destruct difficulties,
51 * the data that will be expiring at end of this request is held here
52 *
53 * @var array
54 */
55 protected static $_expiringData = array();
56
57
58 /**
59 * Error message thrown when an action requires modification,
60 * but current Zend_Session has been marked as read-only.
61 */
62 const _THROW_NOT_WRITABLE_MSG = 'Zend_Session is currently marked as read-only.';
63
64
65 /**
66 * Error message thrown when an action requires reading session data,
67 * but current Zend_Session is not marked as readable.
68 */
69 const _THROW_NOT_READABLE_MSG = 'Zend_Session is not marked as readable.';
70
71
72 /**
73 * namespaceIsset() - check to see if a namespace or a variable within a namespace is set
74 *
75 * @param string $namespace
76 * @param string $name
77 * @return bool
78 */
79 protected static function _namespaceIsset($namespace, $name = null)
80 {
81 if (self::$_readable === false) {
82 /**
83 * @see Zend_Session_Exception
84 */
85 // require_once 'Zend/Session/Exception.php';
86 throw new Zend_Session_Exception(self::_THROW_NOT_READABLE_MSG);
87 }
88
89 if ($name === null) {
90 return ( isset($_SESSION[$namespace]) || isset(self::$_expiringData[$namespace]) );
91 } else {
92 return ( isset($_SESSION[$namespace][$name]) || isset(self::$_expiringData[$namespace][$name]) );
93 }
94 }
95
96
97 /**
98 * namespaceUnset() - unset a namespace or a variable within a namespace
99 *
100 * @param string $namespace
101 * @param string $name
102 * @throws Zend_Session_Exception
103 * @return void
104 */
105 protected static function _namespaceUnset($namespace, $name = null)
106 {
107 if (self::$_writable === false) {
108 /**
109 * @see Zend_Session_Exception
110 */
111 // require_once 'Zend/Session/Exception.php';
112 throw new Zend_Session_Exception(self::_THROW_NOT_WRITABLE_MSG);
113 }
114
115 $name = (string) $name;
116
117 // check to see if the api wanted to remove a var from a namespace or a namespace
118 if ($name === '') {
119 unset($_SESSION[$namespace]);
120 unset(self::$_expiringData[$namespace]);
121 } else {
122 unset($_SESSION[$namespace][$name]);
123 unset(self::$_expiringData[$namespace]);
124 }
125
126 // if we remove the last value, remove namespace.
127 if (empty($_SESSION[$namespace])) {
128 unset($_SESSION[$namespace]);
129 }
130 }
131
132
133 /**
134 * namespaceGet() - Get $name variable from $namespace, returning by reference.
135 *
136 * @param string $namespace
137 * @param string $name
138 * @return mixed
139 */
140 protected static function & _namespaceGet($namespace, $name = null)
141 {
142 if (self::$_readable === false) {
143 /**
144 * @see Zend_Session_Exception
145 */
146 // require_once 'Zend/Session/Exception.php';
147 throw new Zend_Session_Exception(self::_THROW_NOT_READABLE_MSG);
148 }
149
150 if ($name === null) {
151 if (isset($_SESSION[$namespace])) { // check session first for data requested
152 return $_SESSION[$namespace];
153 } elseif (isset(self::$_expiringData[$namespace])) { // check expiring data for data reqeusted
154 return self::$_expiringData[$namespace];
155 } else {
156 return $_SESSION[$namespace]; // satisfy return by reference
157 }
158 } else {
159 if (isset($_SESSION[$namespace][$name])) { // check session first
160 return $_SESSION[$namespace][$name];
161 } elseif (isset(self::$_expiringData[$namespace][$name])) { // check expiring data
162 return self::$_expiringData[$namespace][$name];
163 } else {
164 return $_SESSION[$namespace][$name]; // satisfy return by reference
165 }
166 }
167 }
168
169
170 /**
171 * namespaceGetAll() - Get an array containing $namespace, including expiring data.
172 *
173 * @param string $namespace
174 * @param string $name
175 * @return mixed
176 */
177 protected static function _namespaceGetAll($namespace)
178 {
179 $currentData = (isset($_SESSION[$namespace]) && is_array($_SESSION[$namespace])) ?
180 $_SESSION[$namespace] : array();
181 $expiringData = (isset(self::$_expiringData[$namespace]) && is_array(self::$_expiringData[$namespace])) ?
182 self::$_expiringData[$namespace] : array();
183 return array_merge($currentData, $expiringData);
184 }
185 }
186