-
Notifications
You must be signed in to change notification settings - Fork 4.8k
/
request.php
53 lines (48 loc) · 1.1 KB
/
request.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
/**
* @package OpenCart
* @author Daniel Kerr
* @copyright Copyright (c) 2005 - 2022, OpenCart, Ltd. (https://www.opencart.com/)
* @license https://opensource.org/licenses/GPL-3.0
* @link https://www.opencart.com
*/
/**
* Request class
*/
namespace Opencart\System\Library;
class Request {
public array $get = [];
public array $post = [];
protected array $request = [];
public array $cookie = [];
public array $files = [];
public array $server = [];
/**
* Constructor
*/
public function __construct() {
$this->get = $this->clean($_GET);
$this->post = $this->clean($_POST);
$this->request = $this->clean($_REQUEST);
$this->cookie = $this->clean($_COOKIE);
$this->files = $this->clean($_FILES);
$this->server = $this->clean($_SERVER);
}
/**
*
* @param array $data
*
* @return array
*/
public function clean(mixed $data): mixed {
if (is_array($data)) {
foreach ($data as $key => $value) {
unset($data[$key]);
$data[$this->clean($key)] = $this->clean($value);
}
} else {
$data = trim(htmlspecialchars($data, ENT_COMPAT, 'UTF-8'));
}
return $data;
}
}