Пример #1
0
 /**
  * This method to set request data
  *
  * @param boolean $includeQueryParameters.
  *
  * @access public
  * @author Brayan Pereyra (Cochalo) <*****@*****.**>
  * @copyright Colosa - Bolivia
  *
  * @return void
  */
 public function getRequestData($includeQueryParameters = true)
 {
     $get = UrlEncodedFormat::decoderTypeFix($_GET);
     if ($this->requestMethod == 'PUT' || $this->requestMethod == 'PATCH' || $this->requestMethod == 'POST') {
         if (!empty($this->requestData)) {
             return $includeQueryParameters ? $this->requestData + $get : $this->requestData;
         }
         if ($this->flagMultipart === false) {
             $r = file_get_contents('php://input');
             if (is_null($r)) {
                 return array();
                 //no body
             }
         } else {
             $r = $this->inputExecute;
         }
         if (!empty($r) || !$this->requestFormat instanceof JsonFormat) {
             $r = $this->requestFormat->decode($r);
         }
         $r = is_array($r) ? array_merge($r, array(Defaults::$fullRequestDataName => $r)) : array(Defaults::$fullRequestDataName => $r);
         return $includeQueryParameters ? $r + $get : $r;
     }
     return $includeQueryParameters ? $get : array();
     //no body
 }
Пример #2
0
 /**
  * Parses the request data and returns it
  *
  * @param bool $includeQueryParameters
  *
  * @return array php data
  */
 public function getRequestData($includeQueryParameters = true)
 {
     $get = UrlEncodedFormat::decoderTypeFix($_GET);
     if ($this->requestMethod == 'PUT' || $this->requestMethod == 'PATCH' || $this->requestMethod == 'POST') {
         if (!empty($this->requestData)) {
             return $includeQueryParameters ? $this->requestData + $get : $this->requestData;
         }
         $stream = $this->getRequestStream();
         if ($stream === FALSE) {
             return array();
         }
         $r = $this->requestFormat instanceof iDecodeStream ? $this->requestFormat->decodeStream($stream) : $this->requestFormat->decode(stream_get_contents($stream));
         $r = is_array($r) ? array_merge($r, array(Defaults::$fullRequestDataName => $r)) : array(Defaults::$fullRequestDataName => $r);
         return $includeQueryParameters ? $r + $get : $r;
     }
     return $includeQueryParameters ? $get : array();
     //no body
 }
Пример #3
0
 public function decode($data)
 {
     $doMimeCheck = !empty(self::$allowedMimeTypes);
     $doSizeCheck = self::$maximumFileSize ? TRUE : FALSE;
     //validate
     foreach ($_FILES as &$file) {
         if (is_array($file['error'])) {
             foreach ($file['error'] as $i => $error) {
                 $innerFile = array();
                 foreach ($file as $property => $value) {
                     $innerFile[$property] = $value[$i];
                 }
                 if ($innerFile['name']) {
                     static::checkFile($innerFile, $doMimeCheck, $doSizeCheck);
                 }
                 if (isset($innerFile['exception'])) {
                     $file['error'][$i] = $innerFile['error'];
                     $file['exception'] = $innerFile['exception'];
                     break;
                 }
             }
         } else {
             if ($file['name']) {
                 static::checkFile($file, $doMimeCheck, $doSizeCheck);
             }
             if (isset($innerFile['exception'])) {
                 break;
             }
         }
     }
     //sort file order if needed;
     return UrlEncodedFormat::decoderTypeFix($_FILES + $_POST);
 }