| Linux hosting5.siteguarding.com 3.10.0-962.3.2.lve1.5.88.el7.x86_64 #1 SMP Fri Sep 26 14:06:42 UTC 2025 x86_64 Path : /home/devsafetybis/op4103.dev.safetybis.com/system/library/ |
| Current File : /home/devsafetybis/op4103.dev.safetybis.com/system/library/request.php |
<?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
*
* @see https://www.opencart.com
*/
namespace Opencart\System\Library;
/**
* Class Request
*/
class Request {
/**
* @var array<string, mixed>
*/
public array $get = [];
/**
* @var array<string, mixed>
*/
public array $post = [];
/**
* @var array<string, mixed>
*/
public array $cookie = [];
/**
* @var array<string, mixed>
*/
public array $files = [];
/**
* @var array<string, mixed>
*/
public array $server = [];
/**
* Constructor
*/
public function __construct() {
$this->get = $this->clean($_GET);
$this->post = $this->clean($_POST);
$this->cookie = $this->clean($_COOKIE);
$this->files = $this->clean($_FILES);
$this->server = $this->clean($_SERVER);
}
public function get(string $key, string $type = ''): mixed {
if (isset($this->get[$key])) {
$value = $this->get[$key];
} else {
$value = null;
}
switch ($type) {
case 'string':
return (string)$value;
break;
case 'int':
return (int)$value;
break;
case 'float':
return (float)$value;
break;
case 'bool':
return (bool)$value;
break;
case 'array':
return (array)$value;
break;
default:
return $value;
}
}
public function post(string $key, string $type = ''): mixed {
if (isset($this->post[$key])) {
$value = $this->post[$key];
} else {
$value = null;
}
switch ($type) {
case 'string':
return (string)$value;
break;
case 'int':
return (int)$value;
break;
case 'float':
return (float)$value;
break;
case 'bool':
return (bool)$value;
break;
case 'array':
return (array)$value;
break;
default:
return $value;
}
}
/**
* Clean
*
* @param mixed $data
*
* @return mixed
*/
public function clean($data) {
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;
}
}