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 128... Zeile 128...
128
	 */
128
	 */
129
	public function open($save_path, $name)
129
	public function open($save_path, $name)
130
	{
130
	{
131
		if (empty($this->_db->conn_id) && ! $this->_db->db_connect())
131
		if (empty($this->_db->conn_id) && ! $this->_db->db_connect())
132
		{
132
		{
133
			return $this->_fail();
133
			return $this->_failure;
134
		}
134
		}
Zeile -... Zeile 135...
-
 
135
 
-
 
136
		$this->php5_validate_id();
135
 
137
 
136
		return $this->_success;
138
		return $this->_success;
Zeile 137... Zeile 139...
137
	}
139
	}
Zeile 146... Zeile 148...
146
	 * @param	string	$session_id	Session ID
148
	 * @param	string	$session_id	Session ID
147
	 * @return	string	Serialized session data
149
	 * @return	string	Serialized session data
148
	 */
150
	 */
149
	public function read($session_id)
151
	public function read($session_id)
150
	{
152
	{
151
		if ($this->_get_lock($session_id) !== FALSE)
153
		if ($this->_get_lock($session_id) === FALSE)
152
		{
154
		{
153
			// Prevent previous QB calls from messing with our queries
-
 
154
			$this->_db->reset_query();
155
			return $this->_failure;
-
 
156
		}
Zeile 155... Zeile 157...
155
 
157
 
156
			// Needed by write() to detect session_regenerate_id() calls
158
		// Prevent previous QB calls from messing with our queries
Zeile 157... Zeile -...
157
			$this->_session_id = $session_id;
-
 
158
 
-
 
159
			$this->_db
159
		$this->_db->reset_query();
160
				->select('data')
160
 
Zeile -... Zeile 161...
-
 
161
		// Needed by write() to detect session_regenerate_id() calls
-
 
162
		$this->_session_id = $session_id;
161
				->from($this->_config['save_path'])
163
 
162
				->where('id', $session_id);
-
 
163
 
164
		$this->_db
164
			if ($this->_config['match_ip'])
-
 
Zeile 165... Zeile 165...
165
			{
165
			->select('data')
166
				$this->_db->where('ip_address', $_SERVER['REMOTE_ADDR']);
166
			->from($this->_config['save_path'])
167
			}
-
 
168
 
-
 
169
			if ( ! ($result = $this->_db->get()) OR ($result = $result->row()) === NULL)
-
 
170
			{
-
 
171
				// PHP7 will reuse the same SessionHandler object after
167
			->where('id', $session_id);
172
				// ID regeneration, so we need to explicitly set this to
-
 
173
				// FALSE instead of relying on the default ...
168
 
Zeile 174... Zeile 169...
174
				$this->_row_exists = FALSE;
169
		if ($this->_config['match_ip'])
-
 
170
		{
175
				$this->_fingerprint = md5('');
171
			$this->_db->where('ip_address', $_SERVER['REMOTE_ADDR']);
176
				return '';
-
 
177
			}
172
		}
178
 
173
 
179
			// PostgreSQL's variant of a BLOB datatype is Bytea, which is a
174
		if ( ! ($result = $this->_db->get()) OR ($result = $result->row()) === NULL)
180
			// PITA to work with, so we use base64-encoded data in a TEXT
-
 
181
			// field instead.
175
		{
182
			$result = ($this->_platform === 'postgre')
-
 
183
				? base64_decode(rtrim($result->data))
176
			// PHP7 will reuse the same SessionHandler object after
184
				: $result->data;
177
			// ID regeneration, so we need to explicitly set this to
Zeile -... Zeile 178...
-
 
178
			// FALSE instead of relying on the default ...
-
 
179
			$this->_row_exists = FALSE;
-
 
180
			$this->_fingerprint = md5('');
-
 
181
			return '';
-
 
182
		}
-
 
183
 
-
 
184
		// PostgreSQL's variant of a BLOB datatype is Bytea, which is a
185
 
185
		// PITA to work with, so we use base64-encoded data in a TEXT
-
 
186
		// field instead.
186
			$this->_fingerprint = md5($result);
187
		$result = ($this->_platform === 'postgre')
187
			$this->_row_exists = TRUE;
188
			? base64_decode(rtrim($result->data))
Zeile 188... Zeile 189...
188
			return $result;
189
			: $result->data;
Zeile 189... Zeile 190...
189
		}
190
 
Zeile 211... Zeile 212...
211
		// Was the ID regenerated?
212
		// Was the ID regenerated?
212
		if (isset($this->_session_id) && $session_id !== $this->_session_id)
213
		if (isset($this->_session_id) && $session_id !== $this->_session_id)
213
		{
214
		{
214
			if ( ! $this->_release_lock() OR ! $this->_get_lock($session_id))
215
			if ( ! $this->_release_lock() OR ! $this->_get_lock($session_id))
215
			{
216
			{
216
				return $this->_fail();
217
				return $this->_failure;
217
			}
218
			}
Zeile 218... Zeile 219...
218
 
219
 
219
			$this->_row_exists = FALSE;
220
			$this->_row_exists = FALSE;
220
			$this->_session_id = $session_id;
221
			$this->_session_id = $session_id;
221
		}
222
		}
222
		elseif ($this->_lock === FALSE)
223
		elseif ($this->_lock === FALSE)
223
		{
224
		{
224
			return $this->_fail();
225
			return $this->_failure;
Zeile 225... Zeile 226...
225
		}
226
		}
226
 
227
 
227
		if ($this->_row_exists === FALSE)
228
		if ($this->_row_exists === FALSE)
Zeile 238... Zeile 239...
238
				$this->_fingerprint = md5($session_data);
239
				$this->_fingerprint = md5($session_data);
239
				$this->_row_exists = TRUE;
240
				$this->_row_exists = TRUE;
240
				return $this->_success;
241
				return $this->_success;
241
			}
242
			}
Zeile 242... Zeile 243...
242
 
243
 
243
			return $this->_fail();
244
			return $this->_failure;
Zeile 244... Zeile 245...
244
		}
245
		}
245
 
246
 
246
		$this->_db->where('id', $session_id);
247
		$this->_db->where('id', $session_id);
Zeile 261... Zeile 262...
261
		{
262
		{
262
			$this->_fingerprint = md5($session_data);
263
			$this->_fingerprint = md5($session_data);
263
			return $this->_success;
264
			return $this->_success;
264
		}
265
		}
Zeile 265... Zeile 266...
265
 
266
 
266
		return $this->_fail();
267
		return $this->_failure;
Zeile 267... Zeile 268...
267
	}
268
	}
Zeile 268... Zeile 269...
268
 
269
 
Zeile 276... Zeile 277...
276
	 * @return	bool
277
	 * @return	bool
277
	 */
278
	 */
278
	public function close()
279
	public function close()
279
	{
280
	{
280
		return ($this->_lock && ! $this->_release_lock())
281
		return ($this->_lock && ! $this->_release_lock())
281
			? $this->_fail()
282
			? $this->_failure
282
			: $this->_success;
283
			: $this->_success;
283
	}
284
	}
Zeile 284... Zeile 285...
284
 
285
 
Zeile 305... Zeile 306...
305
				$this->_db->where('ip_address', $_SERVER['REMOTE_ADDR']);
306
				$this->_db->where('ip_address', $_SERVER['REMOTE_ADDR']);
306
			}
307
			}
Zeile 307... Zeile 308...
307
 
308
 
308
			if ( ! $this->_db->delete($this->_config['save_path']))
309
			if ( ! $this->_db->delete($this->_config['save_path']))
309
			{
310
			{
310
				return $this->_fail();
311
				return $this->_failure;
311
			}
312
			}
Zeile 312... Zeile 313...
312
		}
313
		}
313
 
314
 
314
		if ($this->close() === $this->_success)
315
		if ($this->close() === $this->_success)
315
		{
316
		{
316
			$this->_cookie_destroy();
317
			$this->_cookie_destroy();
Zeile 317... Zeile 318...
317
			return $this->_success;
318
			return $this->_success;
318
		}
319
		}
Zeile 319... Zeile 320...
319
 
320
 
Zeile 320... Zeile 321...
320
		return $this->_fail();
321
		return $this->_failure;
Zeile 335... Zeile 336...
335
		// Prevent previous QB calls from messing with our queries
336
		// Prevent previous QB calls from messing with our queries
336
		$this->_db->reset_query();
337
		$this->_db->reset_query();
Zeile 337... Zeile 338...
337
 
338
 
338
		return ($this->_db->delete($this->_config['save_path'], 'timestamp < '.(time() - $maxlifetime)))
339
		return ($this->_db->delete($this->_config['save_path'], 'timestamp < '.(time() - $maxlifetime)))
339
			? $this->_success
340
			? $this->_success
-
 
341
			: $this->_failure;
-
 
342
	}
-
 
343
 
-
 
344
	// --------------------------------------------------------------------
-
 
345
 
-
 
346
	/**
-
 
347
	 * Validate ID
-
 
348
	 *
-
 
349
	 * Checks whether a session ID record exists server-side,
-
 
350
	 * to enforce session.use_strict_mode.
-
 
351
	 *
-
 
352
	 * @param	string	$id
-
 
353
	 * @return	bool
-
 
354
	 */
-
 
355
	public function validateSessionId($id)
-
 
356
	{
-
 
357
		// Prevent previous QB calls from messing with our queries
-
 
358
		$this->_db->reset_query();
-
 
359
 
-
 
360
		$this->_db->select('1')->from($this->_config['save_path'])->where('id', $id);
-
 
361
		empty($this->_config['match_ip']) OR $this->_db->where('ip_address', $_SERVER['REMOTE_ADDR']);
-
 
362
		$result = $this->_db->get();
-
 
363
		empty($result) OR $result = $result->row();
-
 
364
 
340
			: $this->_fail();
365
		return ! empty($result);
Zeile 341... Zeile 366...
341
	}
366
	}
Zeile 342... Zeile 367...
342
 
367