1: <?php
2: /**
3: * @package OpenCart
4: *
5: * @author Daniel Kerr
6: * @copyright Copyright (c) 2005 - 2022, OpenCart, Ltd. (https://www.opencart.com/)
7: * @license https://opensource.org/licenses/GPL-3.0
8: *
9: * @see https://www.opencart.com
10: */
11: namespace Opencart\System\Library;
12: /**
13: * Class Request
14: */
15: class Request {
16: /**
17: * @var array<string, mixed>
18: */
19: public array $get = [];
20: /**
21: * @var array<string, mixed>
22: */
23: public array $post = [];
24: /**
25: * @var array<string, mixed>
26: */
27: public array $cookie = [];
28: /**
29: * @var array<string, mixed>
30: */
31: public array $files = [];
32: /**
33: * @var array<string, mixed>
34: */
35: public array $server = [];
36:
37: /**
38: * Constructor
39: */
40: public function __construct() {
41: $this->get = $this->clean($_GET);
42: $this->post = $this->clean($_POST);
43: $this->cookie = $this->clean($_COOKIE);
44: $this->files = $this->clean($_FILES);
45: $this->server = $this->clean($_SERVER);
46: }
47:
48: /**
49: * Clean
50: *
51: * @param mixed $data
52: *
53: * @return mixed
54: */
55: public function clean($data) {
56: if (is_array($data)) {
57: foreach ($data as $key => $value) {
58: unset($data[$key]);
59:
60: $data[$this->clean($key)] = $this->clean($value);
61: }
62: } else {
63: $data = trim(htmlspecialchars($data, ENT_COMPAT, 'UTF-8'));
64: }
65:
66: return $data;
67: }
68: }
69: