[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/src/Input/ -> Files.php (source)

   1  <?php
   2  
   3  /**
   4   * Joomla! Content Management System
   5   *
   6   * @copyright  (C) 2011 Open Source Matters, Inc. <https://www.joomla.org>
   7   * @license    GNU General Public License version 2 or later; see LICENSE.txt
   8   */
   9  
  10  namespace Joomla\CMS\Input;
  11  
  12  use Joomla\CMS\Filter\InputFilter;
  13  
  14  // phpcs:disable PSR1.Files.SideEffects
  15  \defined('JPATH_PLATFORM') or die;
  16  // phpcs:enable PSR1.Files.SideEffects
  17  
  18  /**
  19   * Joomla! Input Files Class
  20   *
  21   * @since       1.7.0
  22   * @deprecated  5.0  Use Joomla\Input\Files instead
  23   */
  24  class Files extends Input
  25  {
  26      /**
  27       * The pivoted data from a $_FILES or compatible array.
  28       *
  29       * @var    array
  30       * @since  1.7.0
  31       * @deprecated  5.0  Use Joomla\Input\Files instead
  32       */
  33      protected $decodedData = array();
  34  
  35      /**
  36       * The class constructor.
  37       *
  38       * @param   array  $source   The source argument is ignored. $_FILES is always used.
  39       * @param   array  $options  An optional array of configuration options:
  40       *                           filter : a custom InputFilter object.
  41       *
  42       * @since   3.0.0
  43       * @deprecated  5.0  Use Joomla\Input\Files instead
  44       */
  45      public function __construct(array $source = null, array $options = array())
  46      {
  47          if (isset($options['filter'])) {
  48              $this->filter = $options['filter'];
  49          } else {
  50              $this->filter = InputFilter::getInstance();
  51          }
  52  
  53          // Set the data source.
  54          $this->data = & $_FILES;
  55  
  56          // Set the options for the class.
  57          $this->options = $options;
  58      }
  59  
  60      /**
  61       * Gets a value from the input data.
  62       *
  63       * @param   string  $name     The name of the input property (usually the name of the files INPUT tag) to get.
  64       * @param   mixed   $default  The default value to return if the named property does not exist.
  65       * @param   string  $filter   The filter to apply to the value.
  66       *
  67       * @return  mixed  The filtered input value.
  68       *
  69       * @see     InputFilter::clean()
  70       * @since   1.7.0
  71       * @deprecated  5.0  Use Joomla\Input\Files instead
  72       */
  73      public function get($name, $default = null, $filter = 'cmd')
  74      {
  75          if (isset($this->data[$name])) {
  76              $results = $this->decodeData(
  77                  array(
  78                      $this->data[$name]['name'],
  79                      $this->data[$name]['type'],
  80                      $this->data[$name]['tmp_name'],
  81                      $this->data[$name]['error'],
  82                      $this->data[$name]['size'],
  83                  )
  84              );
  85  
  86              // Prevent returning an unsafe file unless specifically requested
  87              if (strtoupper($filter) !== 'RAW') {
  88                  $isSafe = InputFilter::isSafeFile($results);
  89  
  90                  if (!$isSafe) {
  91                      return $default;
  92                  }
  93              }
  94  
  95              return $results;
  96          }
  97  
  98          return $default;
  99      }
 100  
 101      /**
 102       * Method to decode a data array.
 103       *
 104       * @param   array  $data  The data array to decode.
 105       *
 106       * @return  array
 107       *
 108       * @since   1.7.0
 109       * @deprecated  5.0  Use Joomla\Input\Files instead
 110       */
 111      protected function decodeData(array $data)
 112      {
 113          $result = array();
 114  
 115          if (\is_array($data[0])) {
 116              foreach ($data[0] as $k => $v) {
 117                  $result[$k] = $this->decodeData(array($data[0][$k], $data[1][$k], $data[2][$k], $data[3][$k], $data[4][$k]));
 118              }
 119  
 120              return $result;
 121          }
 122  
 123          return array('name' => $data[0], 'type' => $data[1], 'tmp_name' => $data[2], 'error' => $data[3], 'size' => $data[4]);
 124      }
 125  
 126      /**
 127       * Sets a value.
 128       *
 129       * @param   string  $name   The name of the input property to set.
 130       * @param   mixed   $value  The value to assign to the input property.
 131       *
 132       * @return  void
 133       *
 134       * @since   1.7.0
 135       * @deprecated  5.0  Use Joomla\Input\Files instead
 136       */
 137      public function set($name, $value)
 138      {
 139      }
 140  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer