@@ -28,9 +28,9 @@ discard block |
||
| 28 | 28 | // Fetch content and determine boundary |
| 29 | 29 | $boundary = substr($raw_data, 0, strpos($raw_data, "\r\n")); |
| 30 | 30 | |
| 31 | - if(empty($boundary)){ |
|
| 32 | - parse_str($raw_data,$data); |
|
| 33 | - $GLOBALS[ '_PUT' ] = $data; |
|
| 31 | + if (empty($boundary)) { |
|
| 32 | + parse_str($raw_data, $data); |
|
| 33 | + $GLOBALS['_PUT'] = $data; |
|
| 34 | 34 | return; |
| 35 | 35 | } |
| 36 | 36 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | foreach ($parts as $part) { |
| 42 | 42 | // If this is the last part, break |
| 43 | - if ($part == "--\r\n") break; |
|
| 43 | + if ($part=="--\r\n") break; |
|
| 44 | 44 | |
| 45 | 45 | // Separate content from headers |
| 46 | 46 | $part = ltrim($part, "\r\n"); |
@@ -67,10 +67,10 @@ discard block |
||
| 67 | 67 | list(, $type, $name) = $matches; |
| 68 | 68 | |
| 69 | 69 | //Parse File |
| 70 | - if( isset($matches[4]) ) |
|
| 70 | + if (isset($matches[4])) |
|
| 71 | 71 | { |
| 72 | 72 | //if labeled the same as previous, skip |
| 73 | - if( isset( $_FILES[ $matches[ 2 ] ] ) ) |
|
| 73 | + if (isset($_FILES[$matches[2]])) |
|
| 74 | 74 | { |
| 75 | 75 | continue; |
| 76 | 76 | } |
@@ -79,16 +79,16 @@ discard block |
||
| 79 | 79 | $filename = $matches[4]; |
| 80 | 80 | |
| 81 | 81 | //get tmp name |
| 82 | - $filename_parts = pathinfo( $filename ); |
|
| 83 | - $tmp_name = tempnam( ini_get('upload_tmp_dir'), $filename_parts['filename']); |
|
| 82 | + $filename_parts = pathinfo($filename); |
|
| 83 | + $tmp_name = tempnam(ini_get('upload_tmp_dir'), $filename_parts['filename']); |
|
| 84 | 84 | |
| 85 | 85 | //populate $_FILES with information, size may be off in multibyte situation |
| 86 | 86 | /** @noinspection PhpUndefinedVariableInspection */ |
| 87 | - $_FILES[ $matches[ 2 ] ] = array( |
|
| 87 | + $_FILES[$matches[2]] = array( |
|
| 88 | 88 | 'error'=>0, |
| 89 | 89 | 'name'=>$filename, |
| 90 | 90 | 'tmp_name'=>$tmp_name, |
| 91 | - 'size'=>strlen( $body ), |
|
| 91 | + 'size'=>strlen($body), |
|
| 92 | 92 | 'type'=>$value |
| 93 | 93 | ); |
| 94 | 94 | |
@@ -98,12 +98,12 @@ discard block |
||
| 98 | 98 | //Parse Field |
| 99 | 99 | else |
| 100 | 100 | { |
| 101 | - $data[$name] = substr($body, 0, strlen($body) - 2); |
|
| 101 | + $data[$name] = substr($body, 0, strlen($body)-2); |
|
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | } |
| 106 | - $GLOBALS[ '_PUT' ] = $data; |
|
| 106 | + $GLOBALS['_PUT'] = $data; |
|
| 107 | 107 | return $data; |
| 108 | 108 | } |
| 109 | 109 | |
@@ -111,34 +111,34 @@ discard block |
||
| 111 | 111 | * @param string $method |
| 112 | 112 | * @return array |
| 113 | 113 | */ |
| 114 | - public function httpMethodData($method='get') |
|
| 114 | + public function httpMethodData($method = 'get') |
|
| 115 | 115 | { |
| 116 | 116 | $body = []; |
| 117 | 117 | |
| 118 | - if(httpMethod()==$method){ |
|
| 119 | - $rawData = json_decode(request()->getContent(),1); |
|
| 118 | + if (httpMethod()==$method) { |
|
| 119 | + $rawData = json_decode(request()->getContent(), 1); |
|
| 120 | 120 | |
| 121 | 121 | $get = get(); |
| 122 | - if(is_array($get) && count($get)){ |
|
| 122 | + if (is_array($get) && count($get)) { |
|
| 123 | 123 | $body['params'] = get(); |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - if(is_null($rawData)){ |
|
| 126 | + if (is_null($rawData)) { |
|
| 127 | 127 | |
| 128 | 128 | $containerMethod = app()->get(httpMethod()); |
| 129 | 129 | |
| 130 | - if(is_array($containerMethod) && count($containerMethod)){ |
|
| 130 | + if (is_array($containerMethod) && count($containerMethod)) { |
|
| 131 | 131 | $inputData = $containerMethod; |
| 132 | 132 | } |
| 133 | - else{ |
|
| 133 | + else { |
|
| 134 | 134 | $inputData = $this->getInputData(); |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - if(!is_null($inputData)){ |
|
| 137 | + if (!is_null($inputData)) { |
|
| 138 | 138 | $body['body']['form-data'] = $inputData; |
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | - else{ |
|
| 141 | + else { |
|
| 142 | 142 | $body['body']['raw-data'] = $rawData; |
| 143 | 143 | } |
| 144 | 144 | } |
@@ -19,8 +19,9 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | /* Read the data 1 KB at a time |
| 21 | 21 | and write to the file */ |
| 22 | - while ($chunk = fread($putdata, 1024)) |
|
| 23 | - $raw_data .= $chunk; |
|
| 22 | + while ($chunk = fread($putdata, 1024)) {
|
|
| 23 | + $raw_data .= $chunk; |
|
| 24 | + } |
|
| 24 | 25 | |
| 25 | 26 | /* Close the streams */ |
| 26 | 27 | fclose($putdata); |
@@ -40,7 +41,9 @@ discard block |
||
| 40 | 41 | |
| 41 | 42 | foreach ($parts as $part) { |
| 42 | 43 | // If this is the last part, break |
| 43 | - if ($part == "--\r\n") break; |
|
| 44 | + if ($part == "--\r\n") {
|
|
| 45 | + break; |
|
| 46 | + } |
|
| 44 | 47 | |
| 45 | 48 | // Separate content from headers |
| 46 | 49 | $part = ltrim($part, "\r\n"); |
@@ -129,16 +132,14 @@ discard block |
||
| 129 | 132 | |
| 130 | 133 | if(is_array($containerMethod) && count($containerMethod)){ |
| 131 | 134 | $inputData = $containerMethod; |
| 132 | - } |
|
| 133 | - else{ |
|
| 135 | + } else{ |
|
| 134 | 136 | $inputData = $this->getInputData(); |
| 135 | 137 | } |
| 136 | 138 | |
| 137 | 139 | if(!is_null($inputData)){ |
| 138 | 140 | $body['body']['form-data'] = $inputData; |
| 139 | 141 | } |
| 140 | - } |
|
| 141 | - else{ |
|
| 142 | + } else{ |
|
| 142 | 143 | $body['body']['raw-data'] = $rawData; |
| 143 | 144 | } |
| 144 | 145 | } |