2014-08-30 18:11:32 +02:00
|
|
|
<?php
|
|
|
|
namespace Szurubooru\Helpers;
|
|
|
|
|
2014-09-09 12:34:57 +02:00
|
|
|
final class InputReader extends \ArrayObject
|
2014-08-30 18:11:32 +02:00
|
|
|
{
|
|
|
|
public function __construct()
|
|
|
|
{
|
2014-09-09 12:34:57 +02:00
|
|
|
parent::setFlags(parent::ARRAY_AS_PROPS | parent::STD_PROP_LIST);
|
|
|
|
|
2014-08-30 23:17:54 +02:00
|
|
|
$_PUT = [];
|
2014-11-10 19:14:58 +01:00
|
|
|
if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'PUT')
|
2014-08-30 23:17:54 +02:00
|
|
|
parse_str(file_get_contents('php://input'), $_PUT);
|
|
|
|
|
|
|
|
foreach ([$_GET, $_POST, $_PUT] as $source)
|
|
|
|
{
|
|
|
|
foreach ($source as $key => $value)
|
2014-09-09 12:34:57 +02:00
|
|
|
$this->offsetSet($key, $value);
|
2014-08-30 23:17:54 +02:00
|
|
|
}
|
2014-08-30 18:11:32 +02:00
|
|
|
}
|
|
|
|
|
2014-09-09 12:34:57 +02:00
|
|
|
public function offsetGet($index)
|
2014-08-30 18:11:32 +02:00
|
|
|
{
|
2014-09-09 12:34:57 +02:00
|
|
|
if (!parent::offsetExists($index))
|
|
|
|
return null;
|
|
|
|
return parent::offsetGet($index);
|
2014-08-30 18:11:32 +02:00
|
|
|
}
|
2014-09-15 17:09:42 +02:00
|
|
|
|
2014-11-22 14:32:47 +01:00
|
|
|
public function readFile($fileName)
|
|
|
|
{
|
|
|
|
if (!isset($_FILES[$fileName]))
|
|
|
|
return null;
|
|
|
|
|
|
|
|
return file_get_contents($_FILES[$fileName]['tmp_name']);
|
|
|
|
}
|
2014-08-30 18:11:32 +02:00
|
|
|
}
|