| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package VikWP - Libraries |
| 4 |
* @subpackage adapter.input |
| 5 |
* @author E4J s.r.l. |
| 6 |
* @copyright Copyright (C) 2023 E4J s.r.l. All Rights Reserved. |
| 7 |
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL |
| 8 |
* @link https://vikwp.com |
| 9 |
*/ |
| 10 |
|
| 11 |
// No direct access |
| 12 |
defined('ABSPATH') or die('No script kiddies please!'); |
| 13 |
|
| 14 |
JLoader::import('adapter.input.input'); |
| 15 |
|
| 16 |
/** |
| 17 |
* This is an abstracted input class used to handle retrieving data |
| 18 |
* from the FILES environment. |
| 19 |
* |
| 20 |
* @since 10.0 |
| 21 |
* |
| 22 |
* @property-read Input $get |
| 23 |
* @property-read Input $post |
| 24 |
* @property-read Input $request |
| 25 |
* @property-read Input $server |
| 26 |
* @property-read Files $files |
| 27 |
* @property-read Cookie $cookie |
| 28 |
* |
| 29 |
* @method integer getInt($name, $default = null) Get a signed integer. |
| 30 |
* @method integer getUint($name, $default = null) Get an unsigned integer. |
| 31 |
* @method float getFloat($name, $default = null) Get a floating-point number. |
| 32 |
* @method boolean getBool($name, $default = null) Get a boolean value. |
| 33 |
* @method string getWord($name, $default = null) Get a word. |
| 34 |
* @method string getAlnum($name, $default = null) Get an alphanumeric string. |
| 35 |
* @method string getCmd($name, $default = null) Get a CMD filtered string. |
| 36 |
* @method string getBase64($name, $default = null) Get a base64 encoded string. |
| 37 |
* @method string getString($name, $default = null) Get a string. |
| 38 |
* @method string getHtml($name, $default = null) Get a HTML string. |
| 39 |
* @method string getPath($name, $default = null) Get a file path. |
| 40 |
* @method string getUsername($name, $default = null) Get a username. |
| 41 |
*/ |
| 42 |
class JInputFiles extends JInput |
| 43 |
{ |
| 44 |
/** |
| 45 |
* Class constructor. |
| 46 |
* |
| 47 |
* @param array $source Optional source data. If omitted, a copy of the server variable '_REQUEST' is used. |
| 48 |
* @param array $options An optional associative array of configuration parameters. |
| 49 |
*/ |
| 50 |
public function __construct($source = null, array $options = array()) |
| 51 |
{ |
| 52 |
parent::__construct($_FILES, $options); |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* Gets a value from the input data. |
| 57 |
* |
| 58 |
* @param string $name The name of the input property (usually the name of the files INPUT tag) to get. |
| 59 |
* @param mixed $default The default value to return if the named property does not exist. |
| 60 |
* |
| 61 |
* @return mixed The filtered input value. |
| 62 |
*/ |
| 63 |
public function get($name, $default = null, $filter = 'array') |
| 64 |
{ |
| 65 |
if (isset($this->data[$name])) |
| 66 |
{ |
| 67 |
return $this->decodeData( |
| 68 |
array( |
| 69 |
$this->data[$name]['name'], |
| 70 |
$this->data[$name]['type'], |
| 71 |
$this->data[$name]['tmp_name'], |
| 72 |
$this->data[$name]['error'], |
| 73 |
$this->data[$name]['size'], |
| 74 |
) |
| 75 |
); |
| 76 |
} |
| 77 |
|
| 78 |
return $default; |
| 79 |
} |
| 80 |
|
| 81 |
/** |
| 82 |
* Method to decode a data array. |
| 83 |
* |
| 84 |
* @param array $data The data array to decode. |
| 85 |
* |
| 86 |
* @return array |
| 87 |
* |
| 88 |
* @since 10.1.16 |
| 89 |
*/ |
| 90 |
protected function decodeData(array $data) |
| 91 |
{ |
| 92 |
$result = array(); |
| 93 |
|
| 94 |
if (is_array($data[0])) |
| 95 |
{ |
| 96 |
foreach ($data[0] as $k => $v) |
| 97 |
{ |
| 98 |
$result[$k] = $this->decodeData(array($data[0][$k], $data[1][$k], $data[2][$k], $data[3][$k], $data[4][$k])); |
| 99 |
} |
| 100 |
|
| 101 |
return $result; |
| 102 |
} |
| 103 |
|
| 104 |
return array('name' => $data[0], 'type' => $data[1], 'tmp_name' => $data[2], 'error' => $data[3], 'size' => $data[4]); |
| 105 |
} |
| 106 |
|
| 107 |
/** |
| 108 |
* Sets a value. |
| 109 |
* |
| 110 |
* @param string $name The name of the input property to set. |
| 111 |
* @param mixed $value The value to assign to the input property. |
| 112 |
* |
| 113 |
* @return void |
| 114 |
*/ |
| 115 |
public function set($name, $value) |
| 116 |
{ |
| 117 |
// restricts the usage of parent's set method |
| 118 |
} |
| 119 |
} |
| 120 |
|