From 2113ea5a3e1999788075ec8eb8eccc2309ee3cd5 Mon Sep 17 00:00:00 2001 From: Daniel Kerr Date: Thu, 1 Aug 2024 15:58:03 +0800 Subject: [PATCH] Update request.php --- upload/system/library/request.php | 56 +++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/upload/system/library/request.php b/upload/system/library/request.php index 13b204288e6..d8f17ee1dc5 100644 --- a/upload/system/library/request.php +++ b/upload/system/library/request.php @@ -45,6 +45,62 @@ public function __construct() { $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 *