primo commit
This commit is contained in:
110
libraries/vendor/joomla/input/src/Cookie.php
vendored
Normal file
110
libraries/vendor/joomla/input/src/Cookie.php
vendored
Normal file
@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Part of the Joomla Framework Input Package
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2022 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
namespace Joomla\Input;
|
||||
|
||||
/**
|
||||
* Joomla! Input Cookie Class
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class Cookie extends Input
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array|null $source Source data (Optional, default is $_COOKIE)
|
||||
* @param array $options Array of configuration parameters (Optional)
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
public function __construct($source = null, array $options = [])
|
||||
{
|
||||
$source = $source ?? $_COOKIE;
|
||||
parent::__construct($source, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a value
|
||||
*
|
||||
* @param string $name Name of the value to set.
|
||||
* @param mixed $value Value to assign to the input.
|
||||
* @param array $options An associative array which may have any of the keys expires, path, domain,
|
||||
* secure, httponly and samesite. The values have the same meaning as described
|
||||
* for the parameters with the same name. The value of the samesite element
|
||||
* should be either Lax or Strict. If any of the allowed options are not given,
|
||||
* their default values are the same as the default values of the explicit
|
||||
* parameters. If the samesite element is omitted, no SameSite cookie attribute
|
||||
* is set.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @link https://www.ietf.org/rfc/rfc2109.txt
|
||||
* @link https://php.net/manual/en/function.setcookie.php
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @note As of 1.4.0, the (name, value, expire, path, domain, secure, httpOnly) signature is deprecated and will not be supported
|
||||
* when support for PHP 7.2 and earlier is dropped
|
||||
*/
|
||||
public function set($name, $value, $options = [])
|
||||
{
|
||||
// BC layer to convert old method parameters.
|
||||
if (is_array($options) === false) {
|
||||
trigger_deprecation(
|
||||
'joomla/input',
|
||||
'1.4.0',
|
||||
'The %s($name, $value, $expire, $path, $domain, $secure, $httpOnly) signature is deprecated and will not be supported once support'
|
||||
. ' for PHP 7.2 and earlier is dropped, use the %s($name, $value, $options) signature instead',
|
||||
__METHOD__,
|
||||
__METHOD__
|
||||
);
|
||||
|
||||
$argList = func_get_args();
|
||||
|
||||
$options = [
|
||||
'expires' => $argList[2] ?? 0,
|
||||
'path' => $argList[3] ?? '',
|
||||
'domain' => $argList[4] ?? '',
|
||||
'secure' => $argList[5] ?? false,
|
||||
'httponly' => $argList[6] ?? false,
|
||||
];
|
||||
}
|
||||
|
||||
// Set the cookie
|
||||
if (version_compare(PHP_VERSION, '7.3', '>=')) {
|
||||
setcookie($name, $value, $options);
|
||||
} else {
|
||||
// Using the setcookie function before php 7.3, make sure we have default values.
|
||||
if (array_key_exists('expires', $options) === false) {
|
||||
$options['expires'] = 0;
|
||||
}
|
||||
|
||||
if (array_key_exists('path', $options) === false) {
|
||||
$options['path'] = '';
|
||||
}
|
||||
|
||||
if (array_key_exists('domain', $options) === false) {
|
||||
$options['domain'] = '';
|
||||
}
|
||||
|
||||
if (array_key_exists('secure', $options) === false) {
|
||||
$options['secure'] = false;
|
||||
}
|
||||
|
||||
if (array_key_exists('httponly', $options) === false) {
|
||||
$options['httponly'] = false;
|
||||
}
|
||||
|
||||
setcookie($name, $value, $options['expires'], $options['path'], $options['domain'], $options['secure'], $options['httponly']);
|
||||
}
|
||||
|
||||
$this->data[$name] = $value;
|
||||
}
|
||||
}
|
||||
110
libraries/vendor/joomla/input/src/Files.php
vendored
Normal file
110
libraries/vendor/joomla/input/src/Files.php
vendored
Normal file
@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Part of the Joomla Framework Input Package
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2022 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
namespace Joomla\Input;
|
||||
|
||||
/**
|
||||
* Joomla! Input Files Class
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class Files extends Input
|
||||
{
|
||||
/**
|
||||
* The pivoted data from a $_FILES or compatible array.
|
||||
*
|
||||
* @var array
|
||||
* @since 1.0
|
||||
*/
|
||||
protected $decodedData = [];
|
||||
|
||||
/**
|
||||
* The class constructor.
|
||||
*
|
||||
* @param array|null $source Source data (Optional, default is $_FILES)
|
||||
* @param array $options Array of configuration parameters (Optional)
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
public function __construct($source = null, array $options = [])
|
||||
{
|
||||
$source = $source ?? $_FILES;
|
||||
parent::__construct($source, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a value from the input data.
|
||||
*
|
||||
* @param string $name The name of the input property (usually the name of the files INPUT tag) to get.
|
||||
* @param mixed $default The default value to return if the named property does not exist.
|
||||
* @param string $filter The filter to apply to the value.
|
||||
*
|
||||
* @return mixed The filtered input value.
|
||||
*
|
||||
* @see \Joomla\Filter\InputFilter::clean()
|
||||
* @since 1.0
|
||||
*/
|
||||
public function get($name, $default = null, $filter = 'cmd')
|
||||
{
|
||||
if (isset($this->data[$name])) {
|
||||
$results = $this->decodeData(
|
||||
[
|
||||
$this->data[$name]['name'],
|
||||
$this->data[$name]['type'],
|
||||
$this->data[$name]['tmp_name'],
|
||||
$this->data[$name]['error'],
|
||||
$this->data[$name]['size'],
|
||||
]
|
||||
);
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to decode a data array.
|
||||
*
|
||||
* @param array $data The data array to decode.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
protected function decodeData(array $data)
|
||||
{
|
||||
$result = [];
|
||||
|
||||
if (\is_array($data[0])) {
|
||||
foreach ($data[0] as $k => $v) {
|
||||
$result[$k] = $this->decodeData([$data[0][$k], $data[1][$k], $data[2][$k], $data[3][$k], $data[4][$k]]);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
return ['name' => $data[0], 'type' => $data[1], 'tmp_name' => $data[2], 'error' => $data[3], 'size' => $data[4]];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a value.
|
||||
*
|
||||
* @param string $name The name of the input property to set.
|
||||
* @param mixed $value The value to assign to the input property.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
public function set($name, $value)
|
||||
{
|
||||
// Restricts the usage of parent's set method.
|
||||
}
|
||||
}
|
||||
328
libraries/vendor/joomla/input/src/Input.php
vendored
Normal file
328
libraries/vendor/joomla/input/src/Input.php
vendored
Normal file
@ -0,0 +1,328 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Part of the Joomla Framework Input Package
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2022 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
namespace Joomla\Input;
|
||||
|
||||
use Joomla\Filter;
|
||||
|
||||
/**
|
||||
* Joomla! Input Base Class
|
||||
*
|
||||
* This is an abstracted input class used to manage retrieving data from the application environment.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @property-read Input $get
|
||||
* @property-read Input $post
|
||||
* @property-read Input $request
|
||||
* @property-read Input $server
|
||||
* @property-read Input $env
|
||||
* @property-read Files $files
|
||||
* @property-read Cookie $cookie
|
||||
* @property-read Json $json
|
||||
*
|
||||
* @method integer getInt($name, $default = null) Get a signed integer.
|
||||
* @method integer getUint($name, $default = null) Get an unsigned integer.
|
||||
* @method float getFloat($name, $default = null) Get a floating-point number.
|
||||
* @method boolean getBool($name, $default = null) Get a boolean value.
|
||||
* @method string getWord($name, $default = null) Get a word.
|
||||
* @method string getAlnum($name, $default = null) Get an alphanumeric string.
|
||||
* @method string getCmd($name, $default = null) Get a CMD filtered string.
|
||||
* @method string getBase64($name, $default = null) Get a base64 encoded string.
|
||||
* @method string getString($name, $default = null) Get a string.
|
||||
* @method string getHtml($name, $default = null) Get a HTML string.
|
||||
* @method string getPath($name, $default = null) Get a file path.
|
||||
* @method string getUsername($name, $default = null) Get a username.
|
||||
* @method mixed getRaw($name, $default = null) Get an unfiltered value.
|
||||
*/
|
||||
class Input implements \Countable
|
||||
{
|
||||
/**
|
||||
* Container with allowed superglobals
|
||||
*
|
||||
* @var array
|
||||
* @since 1.3.0
|
||||
*/
|
||||
private const ALLOWED_GLOBALS = ['REQUEST', 'GET', 'POST', 'FILES', 'SERVER', 'ENV'];
|
||||
|
||||
/**
|
||||
* Options array for the Input instance.
|
||||
*
|
||||
* @var array
|
||||
* @since 1.0
|
||||
*/
|
||||
protected $options = [];
|
||||
|
||||
/**
|
||||
* Filter object to use.
|
||||
*
|
||||
* @var Filter\InputFilter
|
||||
* @since 1.0
|
||||
*/
|
||||
protected $filter;
|
||||
|
||||
/**
|
||||
* Input data.
|
||||
*
|
||||
* @var array
|
||||
* @since 1.0
|
||||
*/
|
||||
protected $data = [];
|
||||
|
||||
/**
|
||||
* Input objects
|
||||
*
|
||||
* @var Input[]
|
||||
* @since 1.0
|
||||
*/
|
||||
protected $inputs = [];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array|null $source Optional source data. If omitted, a copy of the server variable '_REQUEST' is used.
|
||||
* @param array $options An optional associative array of configuration parameters:
|
||||
* filter: An instance of Filter\Input. If omitted, a default filter is initialised.
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
public function __construct($source = null, array $options = [])
|
||||
{
|
||||
$this->data = $source ?? $_REQUEST;
|
||||
$this->filter = $options['filter'] ?? new Filter\InputFilter();
|
||||
$this->options = $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic method to get an input object
|
||||
*
|
||||
* @param mixed $name Name of the input object to retrieve.
|
||||
*
|
||||
* @return Input The request input object
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
if (isset($this->inputs[$name])) {
|
||||
return $this->inputs[$name];
|
||||
}
|
||||
|
||||
$className = __NAMESPACE__ . '\\' . ucfirst($name);
|
||||
|
||||
if (class_exists($className)) {
|
||||
$this->inputs[$name] = new $className(null, $this->options);
|
||||
|
||||
return $this->inputs[$name];
|
||||
}
|
||||
|
||||
$superGlobal = '_' . strtoupper($name);
|
||||
|
||||
if (\in_array(strtoupper($name), self::ALLOWED_GLOBALS, true) && isset($GLOBALS[$superGlobal])) {
|
||||
$this->inputs[$name] = new self($GLOBALS[$superGlobal], $this->options);
|
||||
|
||||
return $this->inputs[$name];
|
||||
}
|
||||
|
||||
$trace = debug_backtrace();
|
||||
trigger_error(
|
||||
'Undefined property via __get(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'],
|
||||
E_USER_NOTICE
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of variables.
|
||||
*
|
||||
* @return integer The number of variables in the input.
|
||||
*
|
||||
* @since 1.0
|
||||
* @see Countable::count()
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function count()
|
||||
{
|
||||
return \count($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a value from the input data.
|
||||
*
|
||||
* @param string $name Name of the value to get.
|
||||
* @param mixed $default Default value to return if variable does not exist.
|
||||
* @param string $filter Filter to apply to the value.
|
||||
*
|
||||
* @return mixed The filtered input value.
|
||||
*
|
||||
* @see \Joomla\Filter\InputFilter::clean()
|
||||
* @since 1.0
|
||||
*/
|
||||
public function get($name, $default = null, $filter = 'cmd')
|
||||
{
|
||||
if ($this->exists($name)) {
|
||||
return $this->filter->clean($this->data[$name], $filter);
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an array of values from the request.
|
||||
*
|
||||
* @param array $vars Associative array of keys and filter types to apply.
|
||||
* If empty and datasource is null, all the input data will be returned
|
||||
* but filtered using the default case in InputFilter::clean.
|
||||
* @param mixed $datasource Array to retrieve data from, or null
|
||||
*
|
||||
* @return mixed The filtered input data.
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
public function getArray(array $vars = [], $datasource = null)
|
||||
{
|
||||
if (empty($vars) && $datasource === null) {
|
||||
$vars = $this->data;
|
||||
}
|
||||
|
||||
$results = [];
|
||||
|
||||
foreach ($vars as $k => $v) {
|
||||
if (\is_array($v)) {
|
||||
if ($datasource === null) {
|
||||
$results[$k] = $this->getArray($v, $this->get($k, null, 'array'));
|
||||
} else {
|
||||
$results[$k] = $this->getArray($v, $datasource[$k]);
|
||||
}
|
||||
} else {
|
||||
if ($datasource === null) {
|
||||
$results[$k] = $this->get($k, null, $v);
|
||||
} elseif (isset($datasource[$k])) {
|
||||
$results[$k] = $this->filter->clean($datasource[$k], $v);
|
||||
} else {
|
||||
$results[$k] = $this->filter->clean(null, $v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Input instance holding the data for the current request method
|
||||
*
|
||||
* @return Input
|
||||
*
|
||||
* @since 1.3.0
|
||||
*/
|
||||
public function getInputForRequestMethod()
|
||||
{
|
||||
switch (strtoupper($this->getMethod())) {
|
||||
case 'GET':
|
||||
return $this->get;
|
||||
|
||||
case 'POST':
|
||||
return $this->post;
|
||||
|
||||
default:
|
||||
// PUT, PATCH, etc. don't have superglobals
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a value
|
||||
*
|
||||
* @param string $name Name of the value to set.
|
||||
* @param mixed $value Value to assign to the input.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
public function set($name, $value)
|
||||
{
|
||||
$this->data[$name] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define a value. The value will only be set if there's no value for the name or if it is null.
|
||||
*
|
||||
* @param string $name Name of the value to define.
|
||||
* @param mixed $value Value to assign to the input.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
public function def($name, $value)
|
||||
{
|
||||
if (isset($this->data[$name])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->data[$name] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a value name exists.
|
||||
*
|
||||
* @param string $name Value name
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @since 1.2.0
|
||||
*/
|
||||
public function exists($name)
|
||||
{
|
||||
return isset($this->data[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic method to get filtered input data.
|
||||
*
|
||||
* @param string $name Name of the filter type prefixed with 'get'.
|
||||
* @param array $arguments [0] The name of the variable [1] The default value.
|
||||
*
|
||||
* @return mixed The filtered input value.
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
public function __call($name, $arguments)
|
||||
{
|
||||
if (substr($name, 0, 3) == 'get') {
|
||||
$filter = substr($name, 3);
|
||||
|
||||
$default = null;
|
||||
|
||||
if (isset($arguments[1])) {
|
||||
$default = $arguments[1];
|
||||
}
|
||||
|
||||
return $this->get($arguments[0], $default, $filter);
|
||||
}
|
||||
|
||||
$trace = debug_backtrace();
|
||||
trigger_error(
|
||||
'Call to undefined method via call(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'],
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the request method.
|
||||
*
|
||||
* @return string The request method.
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
public function getMethod()
|
||||
{
|
||||
return strtoupper($this->server->getCmd('REQUEST_METHOD'));
|
||||
}
|
||||
}
|
||||
69
libraries/vendor/joomla/input/src/Json.php
vendored
Normal file
69
libraries/vendor/joomla/input/src/Json.php
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Part of the Joomla Framework Input Package
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2022 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
namespace Joomla\Input;
|
||||
|
||||
/**
|
||||
* Joomla! Input JSON Class
|
||||
*
|
||||
* This class decodes a JSON string from the raw request data and makes it available via the standard Input interface.
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class Json extends Input
|
||||
{
|
||||
/**
|
||||
* The raw JSON string from the request.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0
|
||||
*/
|
||||
private $raw;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array|null $source Source data (Optional, default is the raw HTTP input decoded from JSON)
|
||||
* @param array $options Array of configuration parameters (Optional)
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
public function __construct($source = null, array $options = [])
|
||||
{
|
||||
if ($source === null) {
|
||||
$this->raw = file_get_contents('php://input');
|
||||
|
||||
// This is a workaround for where php://input has already been read.
|
||||
// See note under php://input on https://www.php.net/manual/en/wrappers.php.php
|
||||
if (empty($this->raw) && isset($GLOBALS['HTTP_RAW_POST_DATA'])) {
|
||||
$this->raw = $GLOBALS['HTTP_RAW_POST_DATA'];
|
||||
}
|
||||
|
||||
$source = json_decode($this->raw, true);
|
||||
|
||||
if (!\is_array($source)) {
|
||||
$source = [];
|
||||
}
|
||||
}
|
||||
|
||||
parent::__construct($source, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the raw JSON string from the request.
|
||||
*
|
||||
* @return string The raw JSON string from the request.
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
public function getRaw()
|
||||
{
|
||||
return $this->raw;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user