Subversion-Projekte lars-tiefland.ci

Revision

Revision 68 | Revision 2049 | Zur aktuellen Revision | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 68 Revision 1257
Zeile 74... Zeile 74...
74
	 *
74
	 *
75
	 * @var	bool
75
	 * @var	bool
76
	 */
76
	 */
77
	protected $_file_new;
77
	protected $_file_new;
Zeile -... Zeile 78...
-
 
78
 
-
 
79
	/**
-
 
80
	 * Validate SID regular expression
-
 
81
	 *
-
 
82
	 * @var	string
-
 
83
	 */
-
 
84
	protected $_sid_regexp;
-
 
85
 
-
 
86
	/**
-
 
87
	 * mbstring.func_override flag
-
 
88
	 *
-
 
89
	 * @var	bool
-
 
90
	 */
-
 
91
	protected static $func_override;
78
 
92
 
Zeile 79... Zeile 93...
79
	// ------------------------------------------------------------------------
93
	// ------------------------------------------------------------------------
80
 
94
 
81
	/**
95
	/**
Zeile 96... Zeile 110...
96
		else
110
		else
97
		{
111
		{
98
			log_message('debug', 'Session: "sess_save_path" is empty; using "session.save_path" value from php.ini.');
112
			log_message('debug', 'Session: "sess_save_path" is empty; using "session.save_path" value from php.ini.');
99
			$this->_config['save_path'] = rtrim(ini_get('session.save_path'), '/\\');
113
			$this->_config['save_path'] = rtrim(ini_get('session.save_path'), '/\\');
100
		}
114
		}
-
 
115
 
-
 
116
		$this->_sid_regexp = $this->_config['_sid_regexp'];
-
 
117
 
-
 
118
		isset(self::$func_override) OR self::$func_override = (extension_loaded('mbstring') && ini_get('mbstring.func_override'));
101
	}
119
	}
Zeile 102... Zeile 120...
102
 
120
 
Zeile 103... Zeile 121...
103
	// ------------------------------------------------------------------------
121
	// ------------------------------------------------------------------------
Zeile 147... Zeile 165...
147
	{
165
	{
148
		// This might seem weird, but PHP 5.6 introduces session_reset(),
166
		// This might seem weird, but PHP 5.6 introduces session_reset(),
149
		// which re-reads session data
167
		// which re-reads session data
150
		if ($this->_file_handle === NULL)
168
		if ($this->_file_handle === NULL)
151
		{
169
		{
152
			// Just using fopen() with 'c+b' mode would be perfect, but it is only
-
 
153
			// available since PHP 5.2.6 and we have to set permissions for new files,
-
 
154
			// so we'd have to hack around this ...
-
 
155
			if (($this->_file_new = ! file_exists($this->_file_path.$session_id)) === TRUE)
170
			$this->_file_new = ! file_exists($this->_file_path.$session_id);
156
			{
171
 
157
				if (($this->_file_handle = fopen($this->_file_path.$session_id, 'w+b')) === FALSE)
172
			if (($this->_file_handle = fopen($this->_file_path.$session_id, 'c+b')) === FALSE)
158
				{
-
 
159
					log_message('error', "Session: File '".$this->_file_path.$session_id."' doesn't exist and cannot be created.");
-
 
160
					return $this->_failure;
-
 
161
				}
-
 
162
			}
-
 
163
			elseif (($this->_file_handle = fopen($this->_file_path.$session_id, 'r+b')) === FALSE)
-
 
164
			{
173
			{
165
				log_message('error', "Session: Unable to open file '".$this->_file_path.$session_id."'.");
174
				log_message('error', "Session: Unable to open file '".$this->_file_path.$session_id."'.");
166
				return $this->_failure;
175
				return $this->_failure;
167
			}
176
			}
Zeile 194... Zeile 203...
194
		{
203
		{
195
			rewind($this->_file_handle);
204
			rewind($this->_file_handle);
196
		}
205
		}
Zeile 197... Zeile 206...
197
 
206
 
198
		$session_data = '';
207
		$session_data = '';
199
		for ($read = 0, $length = filesize($this->_file_path.$session_id); $read < $length; $read += strlen($buffer))
208
		for ($read = 0, $length = filesize($this->_file_path.$session_id); $read < $length; $read += self::strlen($buffer))
200
		{
209
		{
201
			if (($buffer = fread($this->_file_handle, $length - $read)) === FALSE)
210
			if (($buffer = fread($this->_file_handle, $length - $read)) === FALSE)
202
			{
211
			{
203
				break;
212
				break;
Zeile 350... Zeile 359...
350
			return $this->_failure;
359
			return $this->_failure;
351
		}
360
		}
Zeile 352... Zeile 361...
352
 
361
 
Zeile -... Zeile 362...
-
 
362
		$ts = time() - $maxlifetime;
-
 
363
 
-
 
364
		$pattern = ($this->_config['match_ip'] === TRUE)
-
 
365
			? '[0-9a-f]{32}'
353
		$ts = time() - $maxlifetime;
366
			: '';
354
 
367
 
355
		$pattern = sprintf(
368
		$pattern = sprintf(
356
			'/^%s[0-9a-f]{%d}$/',
-
 
357
			preg_quote($this->_config['cookie_name'], '/'),
369
			'#\A%s'.$pattern.$this->_sid_regexp.'\z#',
Zeile 358... Zeile 370...
358
			($this->_config['match_ip'] === TRUE ? 72 : 40)
370
			preg_quote($this->_config['cookie_name'])
359
		);
371
		);
360
 
372
 
Zeile 375... Zeile 387...
375
		closedir($directory);
387
		closedir($directory);
Zeile 376... Zeile 388...
376
 
388
 
377
		return $this->_success;
389
		return $this->_success;
Zeile 378... Zeile -...
378
	}
-
 
379
 
390
	}
-
 
391
 
-
 
392
	// --------------------------------------------------------------------
-
 
393
 
-
 
394
	/**
-
 
395
	 * Byte-safe strlen()
-
 
396
	 *
-
 
397
	 * @param	string	$str
-
 
398
	 * @return	int
-
 
399
	 */
-
 
400
	protected static function strlen($str)
-
 
401
	{
-
 
402
		return (self::$func_override)
-
 
403
			? mb_strlen($str, '8bit')
-
 
404
			: strlen($str);
-
 
405
	}