Spade
Mini Shell
Cli.php000064400000010277151170226260005775 0ustar00<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Input;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Filter\InputFilter;
/**
* Joomla! Input CLI Class
*
* @since 1.7.0
* @deprecated 5.0 Use Joomla\Input\Cli instead
*/
class Cli extends Input
{
/**
* The executable that was called to run the CLI script.
*
* @var string
* @since 1.7.0
* @deprecated 5.0 Use Joomla\Input\Cli instead
*/
public $executable;
/**
* The additional arguments passed to the script that are not associated
* with a specific argument name.
*
* @var array
* @since 1.7.0
* @deprecated 5.0 Use Joomla\Input\Cli instead
*/
public $args = array();
/**
* Constructor.
*
* @param array $source Source data (Optional, default is $_REQUEST)
* @param array $options Array of configuration parameters (Optional)
*
* @since 1.7.0
* @deprecated 5.0 Use Joomla\Input\Cli instead
*/
public function __construct(array $source = null, array $options =
array())
{
if (isset($options['filter']))
{
$this->filter = $options['filter'];
}
else
{
$this->filter = InputFilter::getInstance();
}
// Get the command line options
$this->parseArguments();
// Set the options for the class.
$this->options = $options;
}
/**
* Method to serialize the input.
*
* @return string The serialized input.
*
* @since 3.0.0
* @deprecated 5.0 Use Joomla\Input\Cli instead
*/
public function serialize()
{
// Load all of the inputs.
$this->loadAllInputs();
// Remove $_ENV and $_SERVER from the inputs.
$inputs = $this->inputs;
unset($inputs['env']);
unset($inputs['server']);
// Serialize the executable, args, options, data, and inputs.
return serialize(array($this->executable, $this->args,
$this->options, $this->data, $inputs));
}
/**
* Method to unserialize the input.
*
* @param string $input The serialized input.
*
* @return Input The input object.
*
* @since 3.0.0
* @deprecated 5.0 Use Joomla\Input\Cli instead
*/
public function unserialize($input)
{
// Unserialize the executable, args, options, data, and inputs.
list($this->executable, $this->args, $this->options,
$this->data, $this->inputs) = unserialize($input);
// Load the filter.
if (isset($this->options['filter']))
{
$this->filter = $this->options['filter'];
}
else
{
$this->filter = InputFilter::getInstance();
}
}
/**
* Initialise the options and arguments
*
* Not supported: -abc c-value
*
* @return void
*
* @since 1.7.0
* @deprecated 5.0 Use Joomla\Input\Cli instead
*/
protected function parseArguments()
{
$argv = $_SERVER['argv'];
$this->executable = array_shift($argv);
$out = array();
for ($i = 0, $j = count($argv); $i < $j; $i++)
{
$arg = $argv[$i];
// --foo --bar=baz
if (substr($arg, 0, 2) === '--')
{
$eqPos = strpos($arg, '=');
// --foo
if ($eqPos === false)
{
$key = substr($arg, 2);
// --foo value
if ($i + 1 < $j && $argv[$i + 1][0] !== '-')
{
$value = $argv[$i + 1];
$i++;
}
else
{
$value = isset($out[$key]) ? $out[$key] : true;
}
$out[$key] = $value;
}
// --bar=baz
else
{
$key = substr($arg, 2, $eqPos - 2);
$value = substr($arg, $eqPos + 1);
$out[$key] = $value;
}
}
elseif (substr($arg, 0, 1) === '-')
// -k=value -abc
{
// -k=value
if (substr($arg, 2, 1) === '=')
{
$key = substr($arg, 1, 1);
$value = substr($arg, 3);
$out[$key] = $value;
}
else
// -abc
{
$chars = str_split(substr($arg, 1));
foreach ($chars as $char)
{
$key = $char;
$value = isset($out[$key]) ? $out[$key] : true;
$out[$key] = $value;
}
// -a a-value
if ((count($chars) === 1) && ($i + 1 < $j) &&
($argv[$i + 1][0] !== '-'))
{
$out[$key] = $argv[$i + 1];
$i++;
}
}
}
else
{
// Plain-arg
$this->args[] = $arg;
}
}
$this->data = $out;
}
}
Cookie.php000064400000010443151170226260006472 0ustar00<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Input;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Filter\InputFilter;
/**
* Joomla! Input Cookie Class
*
* @since 1.7.0
* @deprecated 5.0 Use Joomla\Input\Cookie instead
*/
class Cookie extends Input
{
/**
* Constructor.
*
* @param array $source Ignored.
* @param array $options Array of configuration parameters (Optional)
*
* @since 1.7.0
* @deprecated 5.0 Use Joomla\Input\Cookie instead
*/
public function __construct(array $source = null, array $options =
array())
{
if (isset($options['filter']))
{
$this->filter = $options['filter'];
}
else
{
$this->filter = InputFilter::getInstance();
}
// Set the data source.
$this->data = & $_COOKIE;
// Set the options for the class.
$this->options = $options;
}
/**
* Sets a value
*
* @param string $name Name of the value to set.
* @param mixed $value Value to assign to the input.
* @param integer $expire The time the cookie expires. This is a
Unix timestamp so is in number
* of seconds since the epoch. In other
words, you'll most likely set this
* with the time() function plus the number
of seconds before you want it
* to expire. Or you might use mktime().
time()+60*60*24*30 will set the
* cookie to expire in 30 days. If set to 0,
or omitted, the cookie will
* expire at the end of the session (when the
browser closes).
* @param string $path The path on the server in which the cookie
will be available on. If set
* to '/', the cookie will be
available within the entire domain. If set to
* '/foo/', the cookie will only be
available within the /foo/ directory and
* all sub-directories such as /foo/bar/ of
domain. The default value is the
* current directory that the cookie is being
set in.
* @param string $domain The domain that the cookie is available
to. To make the cookie available
* on all subdomains of example.com
(including example.com itself) then you'd
* set it to '.example.com'.
Although some browsers will accept cookies without
* the initial ., RFC 2109 requires it to be
included. Setting the domain to
* 'www.example.com' or
'.www.example.com' will make the cookie only available
* in the www subdomain.
* @param boolean $secure Indicates that the cookie should only be
transmitted over a secure HTTPS
* connection from the client. When set to
TRUE, the cookie will only be set
* if a secure connection exists. On the
server-side, it's on the programmer
* to send this kind of cookie only on secure
connection (e.g. with respect
* to $_SERVER["HTTPS"]).
* @param boolean $httpOnly When TRUE the cookie will be made
accessible only through the HTTP protocol.
* This means that the cookie won't be
accessible by scripting languages, such
* as JavaScript. This setting can
effectively help to reduce identity theft
* through XSS attacks (although it is not
supported by all browsers).
*
* @return void
*
* @link http://www.ietf.org/rfc/rfc2109.txt
* @see setcookie()
* @since 1.7.0
* @deprecated 5.0 Use Joomla\Input\Cookie instead
*/
public function set($name, $value, $expire = 0, $path = '',
$domain = '', $secure = false, $httpOnly = false)
{
if (is_array($value))
{
foreach ($value as $key => $val)
{
setcookie($name . "[$key]", $val, $expire, $path, $domain,
$secure, $httpOnly);
}
}
else
{
setcookie($name, $value, $expire, $path, $domain, $secure, $httpOnly);
}
$this->data[$name] = $value;
}
}
Files.php000064400000006435151170226260006331 0ustar00<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Input;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Filter\InputFilter;
/**
* Joomla! Input Files Class
*
* @since 1.7.0
* @deprecated 5.0 Use Joomla\Input\Files instead
*/
class Files extends Input
{
/**
* The pivoted data from a $_FILES or compatible array.
*
* @var array
* @since 1.7.0
* @deprecated 5.0 Use Joomla\Input\Files instead
*/
protected $decodedData = array();
/**
* The class constructor.
*
* @param array $source The source argument is ignored. $_FILES is
always used.
* @param array $options An optional array of configuration options:
* filter : a custom JFilterInput object.
*
* @since 3.0.0
* @deprecated 5.0 Use Joomla\Input\Files instead
*/
public function __construct(array $source = null, array $options =
array())
{
if (isset($options['filter']))
{
$this->filter = $options['filter'];
}
else
{
$this->filter = InputFilter::getInstance();
}
// Set the data source.
$this->data = & $_FILES;
// Set the options for the class.
$this->options = $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 JFilterInput::clean()
* @since 1.7.0
* @deprecated 5.0 Use Joomla\Input\Files instead
*/
public function get($name, $default = null, $filter = 'cmd')
{
if (isset($this->data[$name]))
{
$results = $this->decodeData(
array(
$this->data[$name]['name'],
$this->data[$name]['type'],
$this->data[$name]['tmp_name'],
$this->data[$name]['error'],
$this->data[$name]['size'],
)
);
// Prevent returning an unsafe file unless specifically requested
if (strtoupper($filter) !== 'RAW')
{
$isSafe = InputFilter::isSafeFile($results);
if (!$isSafe)
{
return $default;
}
}
return $results;
}
return $default;
}
/**
* Method to decode a data array.
*
* @param array $data The data array to decode.
*
* @return array
*
* @since 1.7.0
* @deprecated 5.0 Use Joomla\Input\Files instead
*/
protected function decodeData(array $data)
{
$result = array();
if (is_array($data[0]))
{
foreach ($data[0] as $k => $v)
{
$result[$k] = $this->decodeData(array($data[0][$k], $data[1][$k],
$data[2][$k], $data[3][$k], $data[4][$k]));
}
return $result;
}
return array('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.7.0
* @deprecated 5.0 Use Joomla\Input\Files instead
*/
public function set($name, $value)
{
}
}
Input.php000064400000014024151170226260006357 0ustar00<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Input;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Filter\InputFilter;
/**
* Joomla! Input Base Class
*
* This is an abstracted input class used to manage retrieving data from
the application environment.
*
* @since 1.7.0
* @deprecated 5.0 Use Joomla\Input\Input instead
*
* @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
*/
class Input extends \Joomla\Input\Input
{
/**
* Container with allowed superglobals
*
* @var array
* @since 3.8.9
* @deprecated 5.0 Use Joomla\Input\Input instead
*/
private static $allowedGlobals = array('REQUEST',
'GET', 'POST', 'FILES', 'SERVER',
'ENV');
/**
* Input objects
*
* @var Input[]
* @since 1.7.0
* @deprecated 5.0 Use Joomla\Input\Input instead
*/
protected $inputs = array();
/**
* Constructor.
*
* @param array $source Source data (Optional, default is $_REQUEST)
* @param array $options Array of configuration parameters (Optional)
*
* @since 1.7.0
* @deprecated 5.0 Use Joomla\Input\Input instead
*/
public function __construct($source = null, array $options = array())
{
if (!isset($options['filter']))
{
$this->filter = InputFilter::getInstance();
}
parent::__construct($source, $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.7.0
* @deprecated 5.0 Use Joomla\Input\Input instead
*/
public function __get($name)
{
if (isset($this->inputs[$name]))
{
return $this->inputs[$name];
}
$className = '\\Joomla\\CMS\\Input\\' . 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::$allowedGlobals, true) &&
isset($GLOBALS[$superGlobal]))
{
$this->inputs[$name] = new Input($GLOBALS[$superGlobal],
$this->options);
return $this->inputs[$name];
}
// Try using the parent class
return parent::__get($name);
}
/**
* 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 filter given by
the parameter defaultFilter in
* JFilterInput::clean.
* @param mixed $datasource Array to retrieve data from, or null.
* @param string $defaultFilter Default filter used in
JFilterInput::clean if vars is empty and
* datasource is null. If
'unknown', the default case is used in
* JFilterInput::clean.
*
* @return mixed The filtered input data.
*
* @since 1.7.0
* @deprecated 5.0 Use Joomla\Input\Input instead
*/
public function getArray(array $vars = array(), $datasource = null,
$defaultFilter = 'unknown')
{
return $this->getArrayRecursive($vars, $datasource, $defaultFilter,
false);
}
/**
* 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 filter given by
the parameter defaultFilter in
* JFilterInput::clean.
* @param mixed $datasource Array to retrieve data from, or null.
* @param string $defaultFilter Default filter used in
JFilterInput::clean if vars is empty and
* datasource is null. If
'unknown', the default case is used in
* JFilterInput::clean.
* @param bool $recursion Flag to indicate a recursive function
call.
*
* @return mixed The filtered input data.
*
* @since 3.4.2
* @deprecated 5.0 Use Joomla\Input\Input instead
*/
protected function getArrayRecursive(array $vars = array(), $datasource =
null, $defaultFilter = 'unknown', $recursion = false)
{
if (empty($vars) && is_null($datasource))
{
$vars = $this->data;
}
else
{
if (!$recursion)
{
$defaultFilter = null;
}
}
$results = array();
foreach ($vars as $k => $v)
{
if (is_array($v))
{
if (is_null($datasource))
{
$results[$k] = $this->getArrayRecursive($v, $this->get($k, null,
'array'), $defaultFilter, true);
}
else
{
$results[$k] = $this->getArrayRecursive($v, $datasource[$k],
$defaultFilter, true);
}
}
else
{
$filter = isset($defaultFilter) ? $defaultFilter : $v;
if (is_null($datasource))
{
$results[$k] = $this->get($k, null, $filter);
}
elseif (isset($datasource[$k]))
{
$results[$k] = $this->filter->clean($datasource[$k], $filter);
}
else
{
$results[$k] = $this->filter->clean(null, $filter);
}
}
}
return $results;
}
/**
* Method to unserialize the input.
*
* @param string $input The serialized input.
*
* @return Input The input object.
*
* @since 3.0.0
* @deprecated 5.0 Use Joomla\Input\Input instead
*/
public function unserialize($input)
{
// Unserialize the options, data, and inputs.
list($this->options, $this->data, $this->inputs) =
unserialize($input);
// Load the filter.
if (isset($this->options['filter']))
{
$this->filter = $this->options['filter'];
}
else
{
$this->filter = InputFilter::getInstance();
}
}
}
Json.php000064400000003357151170226260006200 0ustar00<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Input;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Filter\InputFilter;
/**
* Joomla! Input JSON Class
*
* This class decodes a JSON string from the raw request data and makes it
available via
* the standard JInput interface.
*
* @since 3.0.1
* @deprecated 5.0 Use Joomla\Input\Json instead
*/
class Json extends Input
{
/**
* @var string The raw JSON string from the request.
* @since 3.0.1
* @deprecated 5.0 Use Joomla\Input\Json instead
*/
private $_raw;
/**
* Constructor.
*
* @param array $source Source data (Optional, default is the raw
HTTP input decoded from JSON)
* @param array $options Array of configuration parameters (Optional)
*
* @since 3.0.1
* @deprecated 5.0 Use Joomla\Input\Json instead
*/
public function __construct(array $source = null, array $options =
array())
{
if (isset($options['filter']))
{
$this->filter = $options['filter'];
}
else
{
$this->filter = InputFilter::getInstance();
}
if (is_null($source))
{
$this->_raw = file_get_contents('php://input');
$this->data = json_decode($this->_raw, true);
if (!is_array($this->data))
{
$this->data = array();
}
}
else
{
$this->data = &$source;
}
$this->options = $options;
}
/**
* Gets the raw JSON string from the request.
*
* @return string The raw JSON string from the request.
*
* @since 3.0.1
* @deprecated 5.0 Use Joomla\Input\Json instead
*/
public function getRaw()
{
return $this->_raw;
}
}