Subversion-Projekte lars-tiefland.ci

Revision

Revision 2257 | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 2257 Revision 2414
Zeile 4... Zeile 4...
4
 *
4
 *
5
 * An open source application development framework for PHP
5
 * An open source application development framework for PHP
6
 *
6
 *
7
 * This content is released under the MIT License (MIT)
7
 * This content is released under the MIT License (MIT)
8
 *
8
 *
9
 * Copyright (c) 2014 - 2018, British Columbia Institute of Technology
9
 * Copyright (c) 2014 - 2019, British Columbia Institute of Technology
10
 *
10
 *
11
 * Permission is hereby granted, free of charge, to any person obtaining a copy
11
 * Permission is hereby granted, free of charge, to any person obtaining a copy
12
 * of this software and associated documentation files (the "Software"), to deal
12
 * of this software and associated documentation files (the "Software"), to deal
13
 * in the Software without restriction, including without limitation the rights
13
 * in the Software without restriction, including without limitation the rights
14
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
Zeile 27... Zeile 27...
27
 * THE SOFTWARE.
27
 * THE SOFTWARE.
28
 *
28
 *
29
 * @package	CodeIgniter
29
 * @package	CodeIgniter
30
 * @author	EllisLab Dev Team
30
 * @author	EllisLab Dev Team
31
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
31
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
 * @copyright	Copyright (c) 2014 - 2018, British Columbia Institute of Technology (http://bcit.ca/)
32
 * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33
 * @license	http://opensource.org/licenses/MIT	MIT License
33
 * @license	https://opensource.org/licenses/MIT	MIT License
34
 * @link	https://codeigniter.com
34
 * @link	https://codeigniter.com
35
 * @since	Version 3.0.0
35
 * @since	Version 3.0.0
36
 * @filesource
36
 * @filesource
37
 */
37
 */
38
defined('BASEPATH') OR exit('No direct script access allowed');
38
defined('BASEPATH') OR exit('No direct script access allowed');
Zeile 115... Zeile 115...
115
 
115
 
116
		if ( ! preg_match_all('#,?([^,:]+)\:(\d{1,5})(?:\:(\d+))?#', $this->_config['save_path'], $matches, PREG_SET_ORDER))
116
		if ( ! preg_match_all('#,?([^,:]+)\:(\d{1,5})(?:\:(\d+))?#', $this->_config['save_path'], $matches, PREG_SET_ORDER))
117
		{
117
		{
118
			$this->_memcached = NULL;
118
			$this->_memcached = NULL;
119
			log_message('error', 'Session: Invalid Memcached save path format: '.$this->_config['save_path']);
119
			log_message('error', 'Session: Invalid Memcached save path format: '.$this->_config['save_path']);
120
			return $this->_fail();
120
			return $this->_failure;
Zeile 121... Zeile 121...
121
		}
121
		}
122
 
122
 
123
		foreach ($matches as $match)
123
		foreach ($matches as $match)
Zeile 140... Zeile 140...
140
		}
140
		}
Zeile 141... Zeile 141...
141
 
141
 
142
		if (empty($server_list))
142
		if (empty($server_list))
143
		{
143
		{
144
			log_message('error', 'Session: Memcached server pool is empty.');
144
			log_message('error', 'Session: Memcached server pool is empty.');
145
			return $this->_fail();
145
			return $this->_failure;
Zeile -... Zeile 146...
-
 
146
		}
-
 
147
 
146
		}
148
		$this->php5_validate_id();
147
 
149
 
Zeile 148... Zeile 150...
148
		return $this->_success;
150
		return $this->_success;
Zeile 168... Zeile 170...
168
			$session_data = (string) $this->_memcached->get($this->_key_prefix.$session_id);
170
			$session_data = (string) $this->_memcached->get($this->_key_prefix.$session_id);
169
			$this->_fingerprint = md5($session_data);
171
			$this->_fingerprint = md5($session_data);
170
			return $session_data;
172
			return $session_data;
171
		}
173
		}
Zeile 172... Zeile 174...
172
 
174
 
173
		return $this->_fail();
175
		return $this->_failure;
Zeile 174... Zeile 176...
174
	}
176
	}
Zeile 175... Zeile 177...
175
 
177
 
Zeile 186... Zeile 188...
186
	 */
188
	 */
187
	public function write($session_id, $session_data)
189
	public function write($session_id, $session_data)
188
	{
190
	{
189
		if ( ! isset($this->_memcached, $this->_lock_key))
191
		if ( ! isset($this->_memcached, $this->_lock_key))
190
		{
192
		{
191
			return $this->_fail();
193
			return $this->_failure;
192
		}
194
		}
193
		// Was the ID regenerated?
195
		// Was the ID regenerated?
194
		elseif ($session_id !== $this->_session_id)
196
		elseif ($session_id !== $this->_session_id)
195
		{
197
		{
196
			if ( ! $this->_release_lock() OR ! $this->_get_lock($session_id))
198
			if ( ! $this->_release_lock() OR ! $this->_get_lock($session_id))
197
			{
199
			{
198
				return $this->_fail();
200
				return $this->_failure;
199
			}
201
			}
Zeile 200... Zeile 202...
200
 
202
 
201
			$this->_fingerprint = md5('');
203
			$this->_fingerprint = md5('');
202
			$this->_session_id = $session_id;
204
			$this->_session_id = $session_id;
Zeile 211... Zeile 213...
211
			{
213
			{
212
				$this->_fingerprint = $fingerprint;
214
				$this->_fingerprint = $fingerprint;
213
				return $this->_success;
215
				return $this->_success;
214
			}
216
			}
Zeile 215... Zeile 217...
215
 
217
 
216
			return $this->_fail();
218
			return $this->_failure;
217
		}
219
		}
218
		elseif (
220
		elseif (
219
			$this->_memcached->touch($key, $this->_config['expiration'])
221
			$this->_memcached->touch($key, $this->_config['expiration'])
220
			OR ($this->_memcached->getResultCode() === Memcached::RES_NOTFOUND && $this->_memcached->set($key, $session_data, $this->_config['expiration']))
222
			OR ($this->_memcached->getResultCode() === Memcached::RES_NOTFOUND && $this->_memcached->set($key, $session_data, $this->_config['expiration']))
221
		)
223
		)
222
		{
224
		{
223
			return $this->_success;
225
			return $this->_success;
Zeile 224... Zeile 226...
224
		}
226
		}
225
 
227
 
Zeile 226... Zeile 228...
226
		return $this->_fail();
228
		return $this->_failure;
Zeile 227... Zeile 229...
227
	}
229
	}
Zeile 240... Zeile 242...
240
		if (isset($this->_memcached))
242
		if (isset($this->_memcached))
241
		{
243
		{
242
			$this->_release_lock();
244
			$this->_release_lock();
243
			if ( ! $this->_memcached->quit())
245
			if ( ! $this->_memcached->quit())
244
			{
246
			{
245
				return $this->_fail();
247
				return $this->_failure;
246
			}
248
			}
Zeile 247... Zeile 249...
247
 
249
 
248
			$this->_memcached = NULL;
250
			$this->_memcached = NULL;
249
			return $this->_success;
251
			return $this->_success;
Zeile 250... Zeile 252...
250
		}
252
		}
251
 
253
 
Zeile 252... Zeile 254...
252
		return $this->_fail();
254
		return $this->_failure;
Zeile 253... Zeile 255...
253
	}
255
	}
Zeile 269... Zeile 271...
269
			$this->_memcached->delete($this->_key_prefix.$session_id);
271
			$this->_memcached->delete($this->_key_prefix.$session_id);
270
			$this->_cookie_destroy();
272
			$this->_cookie_destroy();
271
			return $this->_success;
273
			return $this->_success;
272
		}
274
		}
Zeile 273... Zeile 275...
273
 
275
 
274
		return $this->_fail();
276
		return $this->_failure;
Zeile 275... Zeile 277...
275
	}
277
	}
Zeile 276... Zeile 278...
276
 
278
 
Zeile 288... Zeile 290...
288
	{
290
	{
289
		// Not necessary, Memcached takes care of that.
291
		// Not necessary, Memcached takes care of that.
290
		return $this->_success;
292
		return $this->_success;
291
	}
293
	}
Zeile -... Zeile 294...
-
 
294
 
-
 
295
	// --------------------------------------------------------------------
-
 
296
 
-
 
297
	/**
-
 
298
	 * Validate ID
-
 
299
	 *
-
 
300
	 * Checks whether a session ID record exists server-side,
-
 
301
	 * to enforce session.use_strict_mode.
-
 
302
	 *
-
 
303
	 * @param	string	$id
-
 
304
	 * @return	bool
-
 
305
	 */
-
 
306
	public function validateSessionId($id)
-
 
307
	{
-
 
308
		$this->_memcached->get($this->_key_prefix.$id);
-
 
309
		return ($this->_memcached->getResultCode() === Memcached::RES_SUCCESS);
-
 
310
	}
292
 
311
 
Zeile 293... Zeile 312...
293
	// ------------------------------------------------------------------------
312
	// ------------------------------------------------------------------------
294
 
313
 
295
	/**
314
	/**