示例#1
0
 /**
  * Public constructor. Overriden to allow specifying the global input array
  * to use as a string and instantiate from an objetc holding variables.
  *
  * @param   array|string|object|null  $source   Source data; set null to use $_REQUEST
  * @param   array                     $options  Filter options
  */
 public function __construct($source = null, array $options = array())
 {
     $hash = null;
     if (is_string($source)) {
         $hash = strtoupper($source);
         switch ($hash) {
             case 'GET':
                 $source = $_GET;
                 break;
             case 'POST':
                 $source = $_POST;
                 break;
             case 'FILES':
                 $source = $_FILES;
                 break;
             case 'COOKIE':
                 $source = $_COOKIE;
                 break;
             case 'ENV':
                 $source = $_ENV;
                 break;
             case 'SERVER':
                 $source = $_SERVER;
                 break;
             default:
                 $source = $_REQUEST;
                 $hash = 'REQUEST';
                 break;
         }
     } elseif (is_object($source)) {
         try {
             $source = (array) $source;
         } catch (Exception $exc) {
             $source = null;
         }
     } elseif (is_array($source)) {
         // Nothing, it's already an array
     } else {
         // Any other case
         $source = $_REQUEST;
         $hash = 'REQUEST';
     }
     // Magic quotes GPC handling (something JInput simply can't handle at all)
     if ($hash == 'REQUEST' && get_magic_quotes_gpc() && class_exists('JRequest', true)) {
         $source = JRequest::get('REQUEST', 2);
     }
     parent::__construct($source, $options);
 }
示例#2
0
文件: Input.php 项目: akeeba/fof
 /**
  * Public constructor. Overridden to allow specifying the global input array
  * to use as a string and instantiate from an object holding variables.
  *
  * @param   array|string|object|null  $source   Source data; set null to use $_REQUEST
  * @param   array                     $options  Filter options
  */
 public function __construct($source = null, array $options = array())
 {
     $hash = null;
     if (is_string($source)) {
         $hash = strtoupper($source);
         switch ($hash) {
             case 'GET':
                 $source = $_GET;
                 break;
             case 'POST':
                 $source = $_POST;
                 break;
             case 'FILES':
                 $source = $_FILES;
                 break;
             case 'COOKIE':
                 $source = $_COOKIE;
                 break;
             case 'ENV':
                 $source = $_ENV;
                 break;
             case 'SERVER':
                 $source = $_SERVER;
                 break;
             default:
                 $source = $_REQUEST;
                 $hash = 'REQUEST';
                 break;
         }
     } elseif (is_object($source) && $source instanceof Input) {
         $source = $source->getData();
     } elseif (is_object($source) && $source instanceof \JInput) {
         $serialised = $source->serialize();
         list($xOptions, $xData, $xInput) = unserialize($serialised);
         unset($xOptions);
         unset($xInput);
         unset($source);
         $source = $xData;
         unset($xData);
     } elseif (is_object($source)) {
         try {
             $source = (array) $source;
         } catch (\Exception $exc) {
             $source = null;
         }
     } elseif (is_array($source)) {
         // Nothing, it's already an array
     } else {
         // Any other case
         $source = null;
     }
     // If we are not sure use the REQUEST array
     if (empty($source)) {
         $source = $_REQUEST;
         $hash = 'REQUEST';
     }
     // Magic quotes GPC handling (something JInput simply can't handle at all)
     // @codeCoverageIgnoreStart
     if ($hash == 'REQUEST' && get_magic_quotes_gpc() && class_exists('\\JRequest', true)) {
         $source = \JRequest::get('REQUEST', 2);
     }
     // @codeCoverageIgnoreEnd
     parent::__construct($source, $options);
 }