Request::__set()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 2
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * EGroupware - eTemplate request object storing request-data directly in the form itself
4
 *
5
 * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
6
 * @package api
7
 * @subpackage etemplate
8
 * @link http://www.egroupware.org
9
 * @author Ralf Becker <[email protected]>
10
 * @copyright (c) 2007-16 by Ralf Becker <[email protected]>
11
 * @version $Id$
12
 */
13
14
namespace EGroupware\Api\Etemplate;
15
16
use EGroupware\Api;
17
18
/**
19
 * Class to represent the persitent information of an eTemplate request
20
 *
21
 * Current default for etemplate_request is to store request-data in egw_cache by
22
 * setting a not set etemplate_request::$request_class to 'etemplate_request_cache'.
23
 *
24
 * This class stores the request-data direct in a hidden var in the form.
25
 * As this would allow an evil user to manipulate it and therefore compromise the security
26
 * of an EGroupware instance, this class should only be used, if mcrypt is available
27
 * to encrypt that data. The factory method etemplate_request::read() ensures that,
28
 * by using etemplate_request_session instead.
29
 *
30
 * The key used to encrypt the request can be set in header.inc.php by setting
31
 *
32
 *		$GLOBALS['egw_info']['server']['etemplate_form_key'] = 'something secret';
33
 *
34
 * if this var is not set, the db_pass and EGW_SERVER_ROOT is used instead.
35
 *
36
 * The request object should be instancated only via the factory method etemplate_request::read($id=null)
37
 *
38
 * $request = Api\Etemplate\Request::read();
39
 *
40
 * // add request data
41
 *
42
 * $id = $request->id();
43
 *
44
 * b) open or modify an existing request:
45
 *
46
 * if (!($request = Api\Etemplate\Request::read($id)))
47
 * {
48
 * 		// request not found
49
 * }
50
 *
51
 * Ajax requests can use this object to open the original request by using the id, they have to transmitt back,
52
 * and register further variables, modify the registered ones or delete them AND then update the id, if it changed:
53
 *
54
 * eTemplate2:
55
 *
56
 *	if (($new_id = $request->id()) != $exec_id)
57
 *	{
58
 *		Api\Json\Response::get()->generic('assign', array(
59
 *			'etemplate_exec_id' => $id,
60
 *			'id' => '',
61
 *			'key' => 'etemplate_exec_id',
62
 *			'value' => $new_id,
63
 *		));
64
 *	}
65
 *
66
 * old eTemplate:
67
 *
68
 *	if (($new_id = $request->id()) != $exec_id)
69
 *	{
70
 *		Api\Json\Response::get()->assign('etemplate_exec_id','value',$new_id);
71
 *	}
72
 *
73
 * For an example look in link_widget::ajax_search()
74
 *
75
 * @property-read boolean $data_modified true if data was modified and therefore needs saving
76
 * @property int $output_mode
77
 * @property array $content
78
 * @property array $changes
79
 * @property array $sel_options
80
 * @property array $readonlys
81
 * @property array $preserv
82
 * @property string $method
83
 * @property array $ignore_validation
84
 * @property array $template
85
 * @property string $app_header
86
 */
87
class Request
88
{
89
	/**
90
	 * here is the request data stored
91
	 *
92
	 * @var array
93
	 */
94
	protected $data=[
95
		'content' => [],
96
		'readonlys' => [],
97
	];
98
	/**
99
	 * Flag if data has been modified and therefor need to be stored again in the session
100
	 *
101
	 * @var boolean
102
	 */
103
	protected $data_modified=false;
104
	/**
105
	 * Flag that stored data should be removed by destructor, if not modified.
106
	 *
107
	 * @var boolean
108
	 */
109
	protected $remove_if_not_modified=false;
110
	/**
111
	 * mcrypt resource
112
	 *
113
	 * @var resource
114
	 */
115
	static protected $mcrypt;
116
117
	/**
118
	 * See gzcompress, set it to 0 to not compress
119
	 *
120
	 * @var int
121
	 */
122
	static public $compression_level = 6;
123
124
	/**
125
	 * Name of request class used
126
	 *
127
	 * Can be set here to force a certain class, otherwise the factory method chooses one
128
	 *
129
	 * @var string
130
	 */
131
	static public $request_class; // = 'EGroupware\Api\Etemplate\Request\Session';
132
133
	/**
134
	 * Factory method to get a new request object or the one for an existing request
135
	 *
136
	 * New default is to use egw_cache to store requests and no longer request or
137
	 * session documented below:
138
	 *
139
	 * If mcrypt AND gzcompress is available this factory method chooses etemplate_request,
140
	 * which stores the request data encrypted in a hidden var directly in the form,
141
	 * over etemplate_request_session, which stores the data in the session (and causing
142
	 * the sesison to constantly grow).
143
	 *
144
	 * @param string $id =null
145
	 * @param bool $handle_not_found =true true: handle not found by trying to redirect, false: just return null
146
	 * @return Request|null null if Request not found and $handle_not_found === false
147
	 */
148
	public static function read($id=null, $handle_not_found=true)
149
	{
150
		if (is_null(self::$request_class))
0 ignored issues
show
introduced by
The condition is_null(self::request_class) is always false.
Loading history...
151
		{
152
			// new default to use egw_cache to store requests
153
			self::$request_class = __CLASS__.'\\Cache';
154
			/* old default to use request if mcrypt and gzcompress are available and session if not
155
			self::$request_class = check_load_extension('mcrypt') && function_exists('gzcompress') &&
156
				self::init_crypt() ? __CLASS__ : 'EGroupware\Api\Etemplate\Request\Session';
157
			 */
158
		}
159
		if (self::$request_class != __CLASS__)
160
		{
161
			$request = call_user_func(self::$request_class.'::read', $id);
162
		}
163
		else
164
		{
165
			$request = new Request();
166
167
			if (!is_null($id))
168
			{
169
				$id = base64_decode($id);
170
171
				// decrypt the data if available
172
				if (self::init_crypt())
173
				{
174
					$id = mdecrypt_generic(self::$mcrypt,$id);
0 ignored issues
show
Deprecated Code introduced by
The function mdecrypt_generic() has been deprecated: 7.1 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

174
					$id = /** @scrutinizer ignore-deprecated */ mdecrypt_generic(self::$mcrypt,$id);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
175
				}
176
				// uncompress the data if available
177
				if (self::$compression_level && function_exists('gzcompress'))
178
				{
179
					//$len_compressed = bytes($id);
180
					//$time = microtime(true);
181
					$id = gzuncompress($id);
182
					//$time = number_format(1000.0 * (microtime(true) - $time),1);
183
					//$len_uncompressed = bytes($id);
184
					//error_log(__METHOD__."() uncompressed from $len_compressed to $len_uncompressed bytes $time ms");
185
				}
186
				$request->data = unserialize($id);
187
188
				if (!$request->data)
189
				{
190
					error_log(__METHOD__."() id not valid!");
191
					$request = false;
192
				}
193
				//error_log(__METHOD__."() size of request = ".bytes($id));
194
			}
195
		}
196
		if (!$request && $handle_not_found)	// eT2 request/session expired
197
		{
198
			list($app) = explode('.', $_GET['menuaction']);
199
			$global = false;
200
			if(isset($GLOBALS['egw_info']['apps'][$app]))
201
			{
202
				$index_url = isset($GLOBALS['egw_info']['apps'][$app]['index']) ?
203
					'/index.php?menuaction='.$GLOBALS['egw_info']['apps'][$app]['index'] : '/'.$app.'/index.php';
204
			}
205
			else
206
			{
207
				$index_url = Api\Framework::link('/index.php');
208
				$global = true;
209
				$app = null;
210
			}
211
			// add a unique token to redirect to avoid client-side framework tries refreshing via nextmatch
212
			$index_url .= (strpos($index_url, '?') ? '&' : '?').'redirect='.microtime(true);
213
			error_log(__METHOD__."('$id', ...) eT2 request not found / expired --> redirecting app $app to $index_url (_GET[menuaction]=$_GET[menuaction], isJSONRequest()=".array2string(Api\Json\Request::isJSONRequest()).')');
214
			if (Api\Json\Request::isJSONRequest())
215
			{
216
				// we must not redirect ajax_destroy_session calls, as they might originate from our own redirect!
217
				if (strpos($_GET['menuaction'], '.ajax_destroy_session.etemplate') === false)
218
				{
219
					$response = Api\Json\Response::get();
220
					$response->redirect($index_url, $global, $app);
221
					exit;
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
222
				}
223
			}
224
			else
225
			{
226
				Api\Framework::redirect_link($index_url);
227
			}
228
		}
229
		return $request;
230
	}
231
232
	/**
233
	 * CSRF check using an etemplate-exec-id
234
	 *
235
	 * If eTemplate request object could not be read, the function will NOT return,
236
	 * but send an Ajax error response and exit or die with the error-message!
237
	 *
238
	 * @param string $id etemplate-exec-id
239
	 * @param string $caller calling method to log
240
	 * @param array $args =[] arguments to log
241
	 * @throws Api\Json\Exception
242
	 */
243
	public static function csrfCheck($id, $caller, $args=[])
244
	{
245
		if (!self::read($id, false))		// false: do NOT handle not found, but return null
246
		{
247
			error_log(__METHOD__."('$id', $caller, ".json_encode($args).") called with invalid/expired etemplate_exec_id: possible CSRF detected from IP ".$_SERVER['REMOTE_ADDR'].' to '.$_SERVER['REQUEST_METHOD'].' '.$_SERVER['REQUEST_URI']);
248
			$msg = lang('Request could not be processed, please reload your window (press F5 or Cmd R)!');
249
250
			if (Api\Json\Request::isJSONRequest())
251
			{
252
				Api\Json\Response::get()->message($msg, 'error');
253
				exit;
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
254
			}
255
			die($msg);
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
256
		}
257
	}
258
259
	/**
260
	 * Private constructor to force the instancation of this class only via it's static factory method read
261
	 *
262
	 * @param string $id =null
263
	 */
264
	private function __construct($id=null)
265
	{
266
		unset($id);
267
	}
268
269
	/**
270
	 * return the id of this request
271
	 *
272
	 * @return string
273
	 */
274
	public function &id()
275
	{
276
		$this->cleanup();
277
		$data = serialize($this->data);
278
279
		// compress the data if available
280
		if (self::$compression_level && function_exists('gzcompress'))
281
		{
282
			//$len_uncompressed = bytes($id);
283
			//$time = microtime(true);
284
			$data = gzcompress($data, self::$compression_level);
285
			//$time = number_format(1000.0 * (microtime(true) - $time),1);
286
			//$len_compressed = bytes($id);
287
			//error_log(__METHOD__."() compressed from $len_uncompressed to $len_compressed bytes in $time ms");
288
		}
289
		// encrypt the data if available
290
		if (self::init_crypt())
291
		{
292
			$data = mcrypt_generic(self::$mcrypt, $data);
0 ignored issues
show
Deprecated Code introduced by
The function mcrypt_generic() has been deprecated: 7.1 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

292
			$data = /** @scrutinizer ignore-deprecated */ mcrypt_generic(self::$mcrypt, $data);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
293
		}
294
		$id = base64_encode($data);
295
296
		//error_log(__METHOD__."() #$this->id: size of request = ".bytes($id));//.", id='$id'");
297
		//self::debug();
298
		return $id;
299
	}
300
301
	/**
302
	 * Clean up data before storing it: currently only removes "real" nextmatch rows
303
	 */
304
	protected function cleanup()
305
	{
306
		if (isset($this->data['content']['nm']))
307
		{
308
			if (is_array($this->data['content']['nm']['rows']))
309
			{
310
				foreach(array_keys($this->data['content']['nm']['rows']) as $n)
311
				{
312
					if (is_int($n))
313
					{
314
						unset($this->data['content']['nm']['rows'][$n]);
315
					}
316
				}
317
				//error_log(__METHOD__."() content[nm][rows]=".array2string($this->data['content']['nm']['rows']));
318
			}
319
			// do not store actions
320
			unset($this->data['content']['nm']['actions'], $this->data['content']['nm']['action_links']);
321
		}
322
	}
323
324
	/**
325
	 * Register a form-variable to be processed
326
	 *
327
	 * @param string $_form_name form-name
328
	 * @param string $type etemplate type
329
	 * @param array $data =array() optional extra data
330
	 */
331
	public function set_to_process($_form_name, $type, $data=array())
332
	{
333
		if (!$_form_name || !$type) return;
334
335
		//echo '<p>'.__METHOD__."($form_name,$type,".array2string($data).")</p>\n";
336
		$data['type'] = $type;
337
338
		// unquote single and double quotes, as this is how they get returned in $_POST
339
		$form_name = str_replace(array('\\\'','&quot;'), array('\'','"'), $_form_name);
340
341
		$this->data['to_process'][$form_name] = $data;
342
		$this->data_modified = true;
0 ignored issues
show
Bug introduced by
The property data_modified is declared read-only in EGroupware\Api\Etemplate\Request.
Loading history...
343
	}
344
345
	/**
346
	 * Set an attribute of a to-process record
347
	 *
348
	 * @param string $_form_name form-name
349
	 * @param string $attribute etemplate type
350
	 * @param array $value
351
	 * @param boolean $add_to_array =false should $value be added to the attribute array
352
	 */
353
	public function set_to_process_attribute($_form_name, $attribute, $value, $add_to_array=false)
354
	{
355
		//echo '<p>'.__METHOD__."($form_name,$attribute,$value,$add_to_array)</p>\n";
356
		if (!$_form_name) return;
357
358
		// unquote single and double quotes, as this is how they get returned in $_POST
359
		$form_name = str_replace(array('\\\'','&quot;'), array('\'','"'), $_form_name);
360
361
		if ($add_to_array)
362
		{
363
			$this->data['to_process'][$form_name][$attribute][] = $value;
364
		}
365
		else
366
		{
367
			$this->data['to_process'][$form_name][$attribute] = $value;
368
		}
369
		$this->data_modified = true;
0 ignored issues
show
Bug introduced by
The property data_modified is declared read-only in EGroupware\Api\Etemplate\Request.
Loading history...
370
	}
371
372
	/**
373
	 * Unregister a form-variable to be no longer processed
374
	 *
375
	 * @param string $form_name form-name
376
	 */
377
	public function unset_to_process($form_name)
378
	{
379
		//echo '<p>'.__METHOD__."($form_name) isset_to_process($form_name)=".$this->isset_to_process($form_name)."</p>\n";
380
		unset($this->data['to_process'][$form_name]);
381
		$this->data_modified = true;
0 ignored issues
show
Bug introduced by
The property data_modified is declared read-only in EGroupware\Api\Etemplate\Request.
Loading history...
382
	}
383
384
	/**
385
	 * return the data of a form-var to process or the whole array
386
	 *
387
	 * @param string $form_name =null
388
	 * @return array
389
	 */
390
	public function get_to_process($form_name=null)
391
	{
392
		//echo '<p>'.__METHOD__."($form_name)</p>\n";
393
		return $form_name ? $this->data['to_process'][$form_name] : $this->data['to_process'];
394
	}
395
396
	/**
397
	 * check if something set for a given $form_name
398
	 *
399
	 * @param string $form_name
400
	 * @return boolean
401
	 */
402
	public function isset_to_process($form_name)
403
	{
404
		//echo '<p>'.__METHOD__."($form_name) = ".array2string(isset($this->data['to_process'][$form_name]))."</p>\n";
405
		return isset($this->data['to_process'][$form_name]);
406
	}
407
408
	/**
409
	 * creates a new unique request-id
410
	 *
411
	 * @return string
412
	 * @throws \Exception if it was not possible to gather sufficient entropy.
413
	 */
414
	static function request_id()
415
	{
416
		// replace url-unsafe chars with _ to not run into url-encoding issues when used in a url
417
		$userID = preg_replace('/[^a-z0-9_\\.@-]/i', '_', $GLOBALS['egw_info']['user']['account_lid']);
418
419
		// replace + with _ to not run into url-encoding issues when used in a url
420
		$token = str_replace('+', '_', base64_encode(random_bytes(32)));
421
422
		return $GLOBALS['egw_info']['flags']['currentapp'].'_'.$userID.'_'.$token;
423
	}
424
425
	/**
426
	 * magic function to set all request-vars, used eg. as $request->method = 'app.class.method';
427
	 *
428
	 * @param string $var
429
	 * @param mixed $val
430
	 */
431
	public function __set($var,$val)
432
	{
433
		if ($this->data[$var] !== $val)
434
		{
435
			$this->data[$var] = $val;
436
			//error_log(__METHOD__."('$var', ...) data of id=$this->id changed ...");
437
			$this->data_modified = true;
0 ignored issues
show
Bug introduced by
The property data_modified is declared read-only in EGroupware\Api\Etemplate\Request.
Loading history...
438
		}
439
	}
440
441
	/**
442
	 * magic function to access the request-vars, used eg. as $method = $request->method;
443
	 *
444
	 * @param string $var
445
	 * @return mixed
446
	 */
447
	public function &__get($var)
448
	{
449
		if ($var == 'data_modified') return $this->data_modified;
450
451
		return $this->data[$var];
452
	}
453
454
455
	/**
456
	 * magic function to see if a request-var has been set
457
	 *
458
	 * @param string $var
459
	 * @return boolean
460
	 */
461
	public function __isset($var)
462
	{
463
		return array_key_exists($var, $this->data);
464
	}
465
466
	/**
467
	 * Get the names / keys of existing variables
468
	 *
469
	 * @return array
470
	 */
471
	public function names()
472
	{
473
		return array_keys($this->data);
474
	}
475
476
	/**
477
	 * Output the size-wise important parts of a request
478
	 *
479
	 * @param double $min_share minimum share to be reported (in percent of the whole request)
480
	 * @param double $dump_share minimum share from which on a variable get output
481
	 */
482
	public function debug($min_share=1.0,$dump_share=25.0)
483
	{
484
		echo "<p><b>total size request data = ".($total=strlen(serialize($this->data)))."</b></p>\n";
485
		echo "<p>shares bigger then $min_share% percent of it:</p>\n";
486
		foreach($this->data as $key => $val)
487
		{
488
			$len = strlen(is_array($val) ? serialize($val) : $val);
489
			$len .= ' ('.sprintf('%2.1lf',($percent = 100.0 * $len / $total)).'%)';
490
			if ($percent < $min_share) continue;
491
			echo "<p><b>$key</b>: strlen(\$val)=$len</p>\n";
492
			if ($percent >= $dump_share) _debug_array($val);
493
			if (is_array($val) && $len > 2000)
494
			{
495
				foreach($val as $k => $v)
496
				{
497
					$l = strlen(is_array($v) ? serialize($v) : $v);
498
					$l .= ' ('.sprintf('%2.1lf',($p = 100.0 * $l / $total)).'%)';
499
					if ($p < $min_share) continue;
500
					echo "<p>&nbsp;- {$key}[$k]: strlen(\$v)=$l</p>\n";
501
				}
502
			}
503
		}
504
	}
505
506
	/**
507
	 * Check if session encryption is configured, possible and initialise it
508
	 *
509
	 * @param string $algo ='tripledes'
510
	 * @param string $mode ='ecb'
511
	 * @return boolean true if encryption is used, false otherwise
512
	 */
513
	static public function init_crypt($algo='tripledes',$mode='ecb')
514
	{
515
		if (is_null(self::$mcrypt))
0 ignored issues
show
introduced by
The condition is_null(self::mcrypt) is always false.
Loading history...
516
		{
517
			if (isset($GLOBALS['egw_info']['server']['etemplate_form_key']))
518
			{
519
				$key = $GLOBALS['egw_info']['server']['etemplate_form_key'];
520
			}
521
			else
522
			{
523
				$key = $GLOBALS['egw_info']['server']['db_pass'].EGW_SERVER_ROOT;
524
			}
525
			if (!check_load_extension('mcrypt'))
526
			{
527
				error_log(__METHOD__."() required PHP extension mcrypt not loaded and can not be loaded, eTemplate requests get NOT encrypted!");
528
				return false;
529
			}
530
			if (!(self::$mcrypt = mcrypt_module_open($algo, '', $mode, '')))
0 ignored issues
show
Deprecated Code introduced by
The function mcrypt_module_open() has been deprecated: 7.1 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

530
			if (!(self::$mcrypt = /** @scrutinizer ignore-deprecated */ mcrypt_module_open($algo, '', $mode, '')))

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
531
			{
532
				error_log(__METHOD__."() could not mcrypt_module_open(algo='$algo','',mode='$mode',''), eTemplate requests get NOT encrypted!");
533
				return false;
534
			}
535
			$iv_size = mcrypt_enc_get_iv_size(self::$mcrypt);
0 ignored issues
show
Deprecated Code introduced by
The function mcrypt_enc_get_iv_size() has been deprecated: 7.1 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

535
			$iv_size = /** @scrutinizer ignore-deprecated */ mcrypt_enc_get_iv_size(self::$mcrypt);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
536
			$iv = !isset($GLOBALS['egw_info']['server']['mcrypt_iv']) || strlen($GLOBALS['egw_info']['server']['mcrypt_iv']) < $iv_size ?
537
				mcrypt_create_iv ($iv_size, MCRYPT_RAND) : substr($GLOBALS['egw_info']['server']['mcrypt_iv'],0,$iv_size);
0 ignored issues
show
Deprecated Code introduced by
The function mcrypt_create_iv() has been deprecated: 7.1 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

537
				/** @scrutinizer ignore-deprecated */ mcrypt_create_iv ($iv_size, MCRYPT_RAND) : substr($GLOBALS['egw_info']['server']['mcrypt_iv'],0,$iv_size);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
538
539
			$key_size = mcrypt_enc_get_key_size(self::$mcrypt);
0 ignored issues
show
Deprecated Code introduced by
The function mcrypt_enc_get_key_size() has been deprecated: 7.1 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

539
			$key_size = /** @scrutinizer ignore-deprecated */ mcrypt_enc_get_key_size(self::$mcrypt);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
540
			if (bytes($key) > $key_size) $key = cut_bytes($key,0,$key_size-1);
541
542
			if (mcrypt_generic_init(self::$mcrypt,$key, $iv) < 0)
0 ignored issues
show
Deprecated Code introduced by
The function mcrypt_generic_init() has been deprecated: 7.1 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

542
			if (/** @scrutinizer ignore-deprecated */ mcrypt_generic_init(self::$mcrypt,$key, $iv) < 0)

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
543
			{
544
				error_log(__METHOD__."() could not initialise mcrypt, sessions get NOT encrypted!");
545
				return self::$mcrypt = false;
546
			}
547
		}
548
		return is_resource(self::$mcrypt);
549
	}
550
551
	/**
552
	 * Destructor
553
	 */
554
	function __destruct()
555
	{
556
		if (self::$mcrypt)
557
		{
558
			mcrypt_generic_deinit(self::$mcrypt);
0 ignored issues
show
Deprecated Code introduced by
The function mcrypt_generic_deinit() has been deprecated: 7.1 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

558
			/** @scrutinizer ignore-deprecated */ mcrypt_generic_deinit(self::$mcrypt);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
559
			self::$mcrypt = null;
560
		}
561
	}
562
563
	/**
564
	 * Mark request as to destroy, if it does not get modified before destructor is called
565
	 *
566
	 * If that function is called, request is removed from storage, further modification will work!
567
	 */
568
	public function remove_if_not_modified()
569
	{
570
		$this->remove_if_not_modified = true;
571
	}
572
}
573