@@ -68,11 +68,11 @@ discard block |
||
| 68 | 68 | { |
| 69 | 69 | $this->sUploadSubdir = uniqid() . DIRECTORY_SEPARATOR; |
| 70 | 70 | |
| 71 | - if(array_key_exists('jxnupl', $_POST)) |
|
| 71 | + if (array_key_exists('jxnupl', $_POST)) |
|
| 72 | 72 | { |
| 73 | 73 | $this->sTempFile = $_POST['jxnupl']; |
| 74 | 74 | } |
| 75 | - elseif(array_key_exists('jxnupl', $_GET)) |
|
| 75 | + elseif (array_key_exists('jxnupl', $_GET)) |
|
| 76 | 76 | { |
| 77 | 77 | $this->sTempFile = $_GET['jxnupl']; |
| 78 | 78 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | protected function filterFilename($sFilename, $sVarName) |
| 102 | 102 | { |
| 103 | - if(($this->cFileFilter)) |
|
| 103 | + if (($this->cFileFilter)) |
|
| 104 | 104 | { |
| 105 | 105 | $cFileFilter = $this->cFileFilter; |
| 106 | 106 | $sFilename = (string)$cFileFilter($sFilename, $sVarName); |
@@ -120,12 +120,12 @@ discard block |
||
| 120 | 120 | { |
| 121 | 121 | $sUploadDir = rtrim(trim($sUploadDir), '/\\') . DIRECTORY_SEPARATOR; |
| 122 | 122 | // Verify that the upload dir exists and is writable |
| 123 | - if(!is_writable($sUploadDir)) |
|
| 123 | + if (!is_writable($sUploadDir)) |
|
| 124 | 124 | { |
| 125 | 125 | throw new \Jaxon\Exception\Error($this->trans('errors.upload.access')); |
| 126 | 126 | } |
| 127 | 127 | $sUploadDir .= $sUploadSubDir; |
| 128 | - if(!file_exists($sUploadDir) && !@mkdir($sUploadDir)) |
|
| 128 | + if (!file_exists($sUploadDir) && !@mkdir($sUploadDir)) |
|
| 129 | 129 | { |
| 130 | 130 | throw new \Jaxon\Exception\Error($this->trans('errors.upload.access')); |
| 131 | 131 | } |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | $sUploadDir = rtrim(trim($sUploadDir), '/\\') . DIRECTORY_SEPARATOR; |
| 173 | 173 | $sUploadDir .= 'tmp' . DIRECTORY_SEPARATOR; |
| 174 | 174 | $sUploadTempFile = $sUploadDir . $this->sTempFile . '.json'; |
| 175 | - if(!is_readable($sUploadTempFile)) |
|
| 175 | + if (!is_readable($sUploadTempFile)) |
|
| 176 | 176 | { |
| 177 | 177 | throw new \Jaxon\Exception\Error($this->trans('errors.upload.access')); |
| 178 | 178 | } |
@@ -188,18 +188,18 @@ discard block |
||
| 188 | 188 | { |
| 189 | 189 | // Check validity of the uploaded files |
| 190 | 190 | $aTempFiles = []; |
| 191 | - foreach($_FILES as $sVarName => $aFile) |
|
| 191 | + foreach ($_FILES as $sVarName => $aFile) |
|
| 192 | 192 | { |
| 193 | - if(is_array($aFile['name'])) |
|
| 193 | + if (is_array($aFile['name'])) |
|
| 194 | 194 | { |
| 195 | 195 | $nFileCount = count($aFile['name']); |
| 196 | - for($i = 0; $i < $nFileCount; $i++) |
|
| 196 | + for ($i = 0; $i < $nFileCount; $i++) |
|
| 197 | 197 | { |
| 198 | - if(!$aFile['name'][$i]) |
|
| 198 | + if (!$aFile['name'][$i]) |
|
| 199 | 199 | { |
| 200 | 200 | continue; |
| 201 | 201 | } |
| 202 | - if(!array_key_exists($sVarName, $aTempFiles)) |
|
| 202 | + if (!array_key_exists($sVarName, $aTempFiles)) |
|
| 203 | 203 | { |
| 204 | 204 | $aTempFiles[$sVarName] = []; |
| 205 | 205 | } |
@@ -219,11 +219,11 @@ discard block |
||
| 219 | 219 | } |
| 220 | 220 | else |
| 221 | 221 | { |
| 222 | - if(!$aFile['name']) |
|
| 222 | + if (!$aFile['name']) |
|
| 223 | 223 | { |
| 224 | 224 | continue; |
| 225 | 225 | } |
| 226 | - if(!array_key_exists($sVarName, $aTempFiles)) |
|
| 226 | + if (!array_key_exists($sVarName, $aTempFiles)) |
|
| 227 | 227 | { |
| 228 | 228 | $aTempFiles[$sVarName] = []; |
| 229 | 229 | } |
@@ -243,17 +243,17 @@ discard block |
||
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | // Check uploaded files validity |
| 246 | - foreach($aTempFiles as $sVarName => $aFiles) |
|
| 246 | + foreach ($aTempFiles as $sVarName => $aFiles) |
|
| 247 | 247 | { |
| 248 | - foreach($aFiles as $aFile) |
|
| 248 | + foreach ($aFiles as $aFile) |
|
| 249 | 249 | { |
| 250 | 250 | // Verify upload result |
| 251 | - if($aFile['error'] != 0) |
|
| 251 | + if ($aFile['error'] != 0) |
|
| 252 | 252 | { |
| 253 | 253 | throw new \Jaxon\Exception\Error($this->trans('errors.upload.failed', $aFile)); |
| 254 | 254 | } |
| 255 | 255 | // Verify file validity (format, size) |
| 256 | - if(!$this->validateUploadedFile($sVarName, $aFile)) |
|
| 256 | + if (!$this->validateUploadedFile($sVarName, $aFile)) |
|
| 257 | 257 | { |
| 258 | 258 | throw new \Jaxon\Exception\Error($this->getValidatorMessage()); |
| 259 | 259 | } |
@@ -263,10 +263,10 @@ discard block |
||
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | // Copy the uploaded files from the temp dir to the user dir |
| 266 | - foreach($aTempFiles as $sVarName => $_aTempFiles) |
|
| 266 | + foreach ($aTempFiles as $sVarName => $_aTempFiles) |
|
| 267 | 267 | { |
| 268 | 268 | $this->aUserFiles[$sVarName] = []; |
| 269 | - foreach($_aTempFiles as $aFile) |
|
| 269 | + foreach ($_aTempFiles as $aFile) |
|
| 270 | 270 | { |
| 271 | 271 | // Get the path to the upload dir |
| 272 | 272 | $sUploadDir = $this->getUploadDir($sVarName); |
@@ -288,10 +288,10 @@ discard block |
||
| 288 | 288 | { |
| 289 | 289 | // Convert uploaded file to an array |
| 290 | 290 | $aFiles = []; |
| 291 | - foreach($this->aUserFiles as $sVarName => $aUserFiles) |
|
| 291 | + foreach ($this->aUserFiles as $sVarName => $aUserFiles) |
|
| 292 | 292 | { |
| 293 | 293 | $aFiles[$sVarName] = []; |
| 294 | - foreach($aUserFiles as $aUserFile) |
|
| 294 | + foreach ($aUserFiles as $aUserFile) |
|
| 295 | 295 | { |
| 296 | 296 | $aFiles[$sVarName][] = $aUserFile->toTempData(); |
| 297 | 297 | } |
@@ -312,10 +312,10 @@ discard block |
||
| 312 | 312 | // Upload temp file |
| 313 | 313 | $sUploadTempFile = $this->getUploadTempFile(); |
| 314 | 314 | $aFiles = json_decode(file_get_contents($sUploadTempFile), true); |
| 315 | - foreach($aFiles as $sVarName => $aUserFiles) |
|
| 315 | + foreach ($aFiles as $sVarName => $aUserFiles) |
|
| 316 | 316 | { |
| 317 | 317 | $this->aUserFiles[$sVarName] = []; |
| 318 | - foreach($aUserFiles as $aUserFile) |
|
| 318 | + foreach ($aUserFiles as $aUserFile) |
|
| 319 | 319 | { |
| 320 | 320 | $this->aUserFiles[$sVarName][] = UploadedFile::fromTempData($aUserFile); |
| 321 | 321 | } |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | */ |
| 383 | 383 | public function noRequestPluginFound() |
| 384 | 384 | { |
| 385 | - if(count($_FILES) > 0) |
|
| 385 | + if (count($_FILES) > 0) |
|
| 386 | 386 | { |
| 387 | 387 | $this->bRequestIsHttpUpload = true; |
| 388 | 388 | } |
@@ -405,17 +405,17 @@ discard block |
||
| 405 | 405 | */ |
| 406 | 406 | public function processRequest() |
| 407 | 407 | { |
| 408 | - if(!$this->canProcessRequest()) |
|
| 408 | + if (!$this->canProcessRequest()) |
|
| 409 | 409 | { |
| 410 | 410 | return false; |
| 411 | 411 | } |
| 412 | 412 | |
| 413 | - if(count($_FILES) > 0) |
|
| 413 | + if (count($_FILES) > 0) |
|
| 414 | 414 | { |
| 415 | 415 | // Ajax request with upload |
| 416 | 416 | $this->readFromHttpData(); |
| 417 | 417 | |
| 418 | - if($this->bRequestIsHttpUpload) |
|
| 418 | + if ($this->bRequestIsHttpUpload) |
|
| 419 | 419 | { |
| 420 | 420 | // Process an HTTP upload request |
| 421 | 421 | // This requires to set the response to be returned. |
@@ -425,14 +425,14 @@ discard block |
||
| 425 | 425 | $this->saveToTempFile(); |
| 426 | 426 | $xResponse->setUploadedFile($this->sTempFile); |
| 427 | 427 | } |
| 428 | - catch(Exception $e) |
|
| 428 | + catch (Exception $e) |
|
| 429 | 429 | { |
| 430 | 430 | $xResponse->setErrorMessage($e->getMessage()); |
| 431 | 431 | } |
| 432 | 432 | jaxon()->di()->getResponseManager()->append($xResponse); |
| 433 | 433 | } |
| 434 | 434 | } |
| 435 | - elseif(($this->sTempFile)) |
|
| 435 | + elseif (($this->sTempFile)) |
|
| 436 | 436 | { |
| 437 | 437 | // Ajax request following and HTTP upload |
| 438 | 438 | $this->readFromTempFile(); |