mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 09:48:40 +00:00
Supporting uploaded files and removing http verbs for security reasons
This commit is contained in:
parent
a626c0d0f0
commit
8c95184780
|
|
@ -61,6 +61,14 @@ class Request extends RequestAbstract
|
|||
*/
|
||||
protected $path = null;
|
||||
|
||||
/**
|
||||
* Uploaded files.
|
||||
*
|
||||
* @var array
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $files = [];
|
||||
|
||||
/**
|
||||
* Request information.
|
||||
*
|
||||
|
|
@ -93,6 +101,8 @@ class Request extends RequestAbstract
|
|||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
|
|
@ -103,10 +113,16 @@ class Request extends RequestAbstract
|
|||
|
||||
if (isset($_SERVER['CONTENT_TYPE'])) {
|
||||
if (strpos($_SERVER['CONTENT_TYPE'], 'application/json') !== false) {
|
||||
$this->data += json_decode(file_get_contents('php://input'), true);
|
||||
if(($json = json_decode(($input = file_get_contents('php://input')), true)) === false || $json === null) {
|
||||
throw new \Exception('Is not valid json ' . $input);
|
||||
}
|
||||
|
||||
$this->data += $json;
|
||||
} elseif (strpos($_SERVER['CONTENT_TYPE'], 'application/x-www-form-urlencoded') !== false) {
|
||||
parse_str(file_get_contents('php://input'), $temp);
|
||||
$this->data += $temp;
|
||||
} elseif (strpos($_SERVER['CONTENT_TYPE'], 'multipart/form-data') !== false) {
|
||||
$this->files = $_FILES;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -370,6 +386,11 @@ class Request extends RequestAbstract
|
|||
return '/';
|
||||
}
|
||||
|
||||
public function getFiles() : array
|
||||
{
|
||||
return $this->files;
|
||||
}
|
||||
|
||||
public function setHeader($key, \string $header, \bool $overwrite = true)
|
||||
{
|
||||
// NOT Required for Http request
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user