@@ -49,11 +49,11 @@ discard block |
||
49 | 49 | { |
50 | 50 | $this->aUserFiles = []; |
51 | 51 | |
52 | - if(array_key_exists('jxnupl', $_POST)) |
|
52 | + if (array_key_exists('jxnupl', $_POST)) |
|
53 | 53 | { |
54 | 54 | $this->sTempFile = $_POST['jxnupl']; |
55 | 55 | } |
56 | - elseif(array_key_exists('jxnupl', $_GET)) |
|
56 | + elseif (array_key_exists('jxnupl', $_GET)) |
|
57 | 57 | { |
58 | 58 | $this->sTempFile = $_GET['jxnupl']; |
59 | 59 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | protected function filterFilename($sFilename, $sVarName) |
83 | 83 | { |
84 | - if(($this->fFileFilter)) |
|
84 | + if (($this->fFileFilter)) |
|
85 | 85 | { |
86 | 86 | $fFileFilter = $this->fFileFilter; |
87 | 87 | $sFilename = (string)$fFileFilter($sFilename, $sVarName); |
@@ -98,17 +98,17 @@ discard block |
||
98 | 98 | { |
99 | 99 | // Check validity of the uploaded files |
100 | 100 | $aTempFiles = []; |
101 | - foreach($_FILES as $sVarName => $aFile) |
|
101 | + foreach ($_FILES as $sVarName => $aFile) |
|
102 | 102 | { |
103 | - if(is_array($aFile['name'])) |
|
103 | + if (is_array($aFile['name'])) |
|
104 | 104 | { |
105 | - for($i = 0; $i < count($aFile['name']); $i++) |
|
105 | + for ($i = 0; $i < count($aFile['name']); $i++) |
|
106 | 106 | { |
107 | - if(!$aFile['name'][$i]) |
|
107 | + if (!$aFile['name'][$i]) |
|
108 | 108 | { |
109 | 109 | continue; |
110 | 110 | } |
111 | - if(!array_key_exists($sVarName, $aTempFiles)) |
|
111 | + if (!array_key_exists($sVarName, $aTempFiles)) |
|
112 | 112 | { |
113 | 113 | $aTempFiles[$sVarName] = []; |
114 | 114 | } |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | } |
129 | 129 | else |
130 | 130 | { |
131 | - if(!$aFile['name']) |
|
131 | + if (!$aFile['name']) |
|
132 | 132 | { |
133 | 133 | continue; |
134 | 134 | } |
135 | - if(!array_key_exists($sVarName, $aTempFiles)) |
|
135 | + if (!array_key_exists($sVarName, $aTempFiles)) |
|
136 | 136 | { |
137 | 137 | $aTempFiles[$sVarName] = []; |
138 | 138 | } |
@@ -155,24 +155,24 @@ discard block |
||
155 | 155 | $sDefaultUploadDir = $this->getOption('upload.default.dir'); |
156 | 156 | |
157 | 157 | // Check uploaded files validity |
158 | - foreach($aTempFiles as $sVarName => $aFiles) |
|
158 | + foreach ($aTempFiles as $sVarName => $aFiles) |
|
159 | 159 | { |
160 | - foreach($aFiles as $aFile) |
|
160 | + foreach ($aFiles as $aFile) |
|
161 | 161 | { |
162 | 162 | // Verify upload result |
163 | - if($aFile['error'] != 0) |
|
163 | + if ($aFile['error'] != 0) |
|
164 | 164 | { |
165 | 165 | throw new \Jaxon\Exception\Error($this->trans('errors.upload.failed', $aFile)); |
166 | 166 | } |
167 | 167 | // Verify file validity (format, size) |
168 | - if(!$this->validateUploadedFile($sVarName, $aFile)) |
|
168 | + if (!$this->validateUploadedFile($sVarName, $aFile)) |
|
169 | 169 | { |
170 | 170 | throw new \Jaxon\Exception\Error($this->getValidatorMessage()); |
171 | 171 | } |
172 | 172 | // Verify that the upload dir exists and is writable |
173 | 173 | $sUploadDir = $this->getOption('upload.files.' . $sVarName . '.dir', $sDefaultUploadDir); |
174 | 174 | $sUploadDir = rtrim(trim($sUploadDir), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; |
175 | - if(!is_writable($sUploadDir)) |
|
175 | + if (!is_writable($sUploadDir)) |
|
176 | 176 | { |
177 | 177 | throw new \Jaxon\Exception\Error($this->trans('errors.upload.access')); |
178 | 178 | } |
@@ -180,10 +180,10 @@ discard block |
||
180 | 180 | } |
181 | 181 | |
182 | 182 | // Copy the uploaded files from the temp dir to the user dir |
183 | - foreach($aTempFiles as $sVarName => $aTempFiles) |
|
183 | + foreach ($aTempFiles as $sVarName => $aTempFiles) |
|
184 | 184 | { |
185 | 185 | $this->aUserFiles[$sVarName] = []; |
186 | - foreach($aTempFiles as $aFile) |
|
186 | + foreach ($aTempFiles as $aFile) |
|
187 | 187 | { |
188 | 188 | // Set the user file data |
189 | 189 | $sUploadDir = $this->getOption('upload.files.' . $sVarName . '.dir', $sDefaultUploadDir); |
@@ -206,16 +206,16 @@ discard block |
||
206 | 206 | // Default upload dir |
207 | 207 | $sUploadDir = $this->getOption('upload.default.dir'); |
208 | 208 | $sUploadDir = rtrim(trim($sUploadDir), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; |
209 | - if(!is_writable($sUploadDir)) |
|
209 | + if (!is_writable($sUploadDir)) |
|
210 | 210 | { |
211 | 211 | throw new \Jaxon\Exception\Error($this->trans('errors.upload.access')); |
212 | 212 | } |
213 | 213 | // Convert uploaded file to an array |
214 | 214 | $aFiles = []; |
215 | - foreach($this->aUserFiles as $sVarName => $aUserFiles) |
|
215 | + foreach ($this->aUserFiles as $sVarName => $aUserFiles) |
|
216 | 216 | { |
217 | 217 | $aFiles[$sVarName] = []; |
218 | - foreach($aUserFiles as $aUserFile) |
|
218 | + foreach ($aUserFiles as $aUserFile) |
|
219 | 219 | { |
220 | 220 | $aFiles[$sVarName][] = $aUserFile->toTempData(); |
221 | 221 | } |
@@ -238,16 +238,16 @@ discard block |
||
238 | 238 | $sUploadDir = $this->getOption('upload.default.dir'); |
239 | 239 | $sUploadDir = rtrim(trim($sUploadDir), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; |
240 | 240 | $sUploadDir .= 'tmp' . DIRECTORY_SEPARATOR; |
241 | - if(!is_readable($sUploadDir . $this->sTempFile . '.json')) |
|
241 | + if (!is_readable($sUploadDir . $this->sTempFile . '.json')) |
|
242 | 242 | { |
243 | 243 | throw new \Jaxon\Exception\Error($this->trans('errors.upload.access')); |
244 | 244 | } |
245 | 245 | $aFiles = file_get_contents($sUploadDir . $this->sTempFile . '.json'); |
246 | 246 | $aFiles = json_decode($aFiles, true); |
247 | - foreach($aFiles as $sVarName => $aUserFiles) |
|
247 | + foreach ($aFiles as $sVarName => $aUserFiles) |
|
248 | 248 | { |
249 | 249 | $this->aUserFiles[$sVarName] = []; |
250 | - foreach($aUserFiles as $aUserFile) |
|
250 | + foreach ($aUserFiles as $aUserFile) |
|
251 | 251 | { |
252 | 252 | $this->aUserFiles[$sVarName][] = UploadedFile::fromTempData($aUserFile); |
253 | 253 | } |
@@ -324,15 +324,15 @@ discard block |
||
324 | 324 | */ |
325 | 325 | public function processRequest() |
326 | 326 | { |
327 | - if(!$this->canProcessRequest()) |
|
327 | + if (!$this->canProcessRequest()) |
|
328 | 328 | { |
329 | 329 | return false; |
330 | 330 | } |
331 | - if(count($_FILES) > 0) |
|
331 | + if (count($_FILES) > 0) |
|
332 | 332 | { |
333 | 333 | $this->readFromHttpData(); |
334 | 334 | } |
335 | - elseif(($this->sTempFile)) |
|
335 | + elseif (($this->sTempFile)) |
|
336 | 336 | { |
337 | 337 | $this->readFromTempFile(); |
338 | 338 | } |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | public function saveUploadedFiles() |
348 | 348 | { |
349 | 349 | // Process uploaded files |
350 | - if(!$this->processRequest()) |
|
350 | + if (!$this->processRequest()) |
|
351 | 351 | { |
352 | 352 | return ''; |
353 | 353 | } |
@@ -52,8 +52,7 @@ discard block |
||
52 | 52 | if(array_key_exists('jxnupl', $_POST)) |
53 | 53 | { |
54 | 54 | $this->sTempFile = $_POST['jxnupl']; |
55 | - } |
|
56 | - elseif(array_key_exists('jxnupl', $_GET)) |
|
55 | + } elseif(array_key_exists('jxnupl', $_GET)) |
|
57 | 56 | { |
58 | 57 | $this->sTempFile = $_GET['jxnupl']; |
59 | 58 | } |
@@ -125,8 +124,7 @@ discard block |
||
125 | 124 | 'extension' => pathinfo($aFile['name'][$i], PATHINFO_EXTENSION), |
126 | 125 | ]; |
127 | 126 | } |
128 | - } |
|
129 | - else |
|
127 | + } else |
|
130 | 128 | { |
131 | 129 | if(!$aFile['name']) |
132 | 130 | { |
@@ -331,8 +329,7 @@ discard block |
||
331 | 329 | if(count($_FILES) > 0) |
332 | 330 | { |
333 | 331 | $this->readFromHttpData(); |
334 | - } |
|
335 | - elseif(($this->sTempFile)) |
|
332 | + } elseif(($this->sTempFile)) |
|
336 | 333 | { |
337 | 334 | $this->readFromTempFile(); |
338 | 335 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | 'core.prefix.event' => 'jaxon_event_', |
132 | 132 | // 'core.request.uri' => '', |
133 | 133 | 'core.request.mode' => 'asynchronous', |
134 | - 'core.request.method' => 'POST', // W3C: Method is case sensitive |
|
134 | + 'core.request.method' => 'POST', // W3C: Method is case sensitive |
|
135 | 135 | 'core.debug.on' => false, |
136 | 136 | 'core.debug.verbose' => false, |
137 | 137 | 'core.process.exit' => true, |
@@ -208,13 +208,13 @@ discard block |
||
208 | 208 | $aArgs = func_get_args(); |
209 | 209 | $nArgs = func_num_args(); |
210 | 210 | |
211 | - if(self::PROCESSING_EVENT == $sType) |
|
211 | + if (self::PROCESSING_EVENT == $sType) |
|
212 | 212 | { |
213 | - if($nArgs > 2) |
|
213 | + if ($nArgs > 2) |
|
214 | 214 | { |
215 | 215 | $sEvent = $xArgs; |
216 | 216 | $xUserFunction = $aArgs[2]; |
217 | - if(!is_a($xUserFunction, 'Request\\Support\\UserFunction')) |
|
217 | + if (!is_a($xUserFunction, 'Request\\Support\\UserFunction')) |
|
218 | 218 | $xUserFunction = new Request\Support\UserFunction($xUserFunction); |
219 | 219 | $this->aProcessingEvents[$sEvent] = $xUserFunction; |
220 | 220 | } |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | public function processRequest() |
301 | 301 | { |
302 | 302 | // Check to see if headers have already been sent out, in which case we can't do our job |
303 | - if(headers_sent($filename, $linenumber)) |
|
303 | + if (headers_sent($filename, $linenumber)) |
|
304 | 304 | { |
305 | 305 | echo $this->trans('errors.output.already-sent', array( |
306 | 306 | 'location' => $filename . ':' . $linenumber |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | } |
310 | 310 | |
311 | 311 | // Check if there is a plugin to process this request |
312 | - if(!$this->canProcessRequest()) |
|
312 | + if (!$this->canProcessRequest()) |
|
313 | 313 | { |
314 | 314 | return; |
315 | 315 | } |
@@ -318,18 +318,18 @@ discard block |
||
318 | 318 | $mResult = true; |
319 | 319 | |
320 | 320 | // Handle before processing event |
321 | - if(isset($this->aProcessingEvents[self::PROCESSING_EVENT_BEFORE])) |
|
321 | + if (isset($this->aProcessingEvents[self::PROCESSING_EVENT_BEFORE])) |
|
322 | 322 | { |
323 | 323 | $this->aProcessingEvents[self::PROCESSING_EVENT_BEFORE]->call(array(&$bEndRequest)); |
324 | 324 | } |
325 | 325 | |
326 | - if(!$bEndRequest) |
|
326 | + if (!$bEndRequest) |
|
327 | 327 | { |
328 | 328 | try |
329 | 329 | { |
330 | 330 | $mResult = $this->getPluginManager()->processRequest(); |
331 | 331 | } |
332 | - catch(Exception $e) |
|
332 | + catch (Exception $e) |
|
333 | 333 | { |
334 | 334 | // An exception was thrown while processing the request. |
335 | 335 | // The request missed the corresponding handler function, |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | $xResponseManager->debug($e->getMessage()); |
343 | 343 | $mResult = false; |
344 | 344 | |
345 | - if($e instanceof \Jaxon\Exception\Error) |
|
345 | + if ($e instanceof \Jaxon\Exception\Error) |
|
346 | 346 | { |
347 | 347 | $sEvent = self::PROCESSING_EVENT_INVALID; |
348 | 348 | $aParams = array($e->getMessage()); |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | $aParams = array($e); |
354 | 354 | } |
355 | 355 | |
356 | - if(isset($this->aProcessingEvents[$sEvent])) |
|
356 | + if (isset($this->aProcessingEvents[$sEvent])) |
|
357 | 357 | { |
358 | 358 | // Call the processing event |
359 | 359 | $this->aProcessingEvents[$sEvent]->call($aParams); |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | } |
367 | 367 | } |
368 | 368 | // Clean the processing buffer |
369 | - if(($this->getOption('core.process.clean'))) |
|
369 | + if (($this->getOption('core.process.clean'))) |
|
370 | 370 | { |
371 | 371 | $er = error_reporting(0); |
372 | 372 | while (ob_get_level() > 0) |
@@ -376,10 +376,10 @@ discard block |
||
376 | 376 | error_reporting($er); |
377 | 377 | } |
378 | 378 | |
379 | - if($mResult === true) |
|
379 | + if ($mResult === true) |
|
380 | 380 | { |
381 | 381 | // Handle after processing event |
382 | - if(isset($this->aProcessingEvents[self::PROCESSING_EVENT_AFTER])) |
|
382 | + if (isset($this->aProcessingEvents[self::PROCESSING_EVENT_AFTER])) |
|
383 | 383 | { |
384 | 384 | $bEndRequest = false; |
385 | 385 | $this->aProcessingEvents[self::PROCESSING_EVENT_AFTER]->call(array($bEndRequest)); |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | |
389 | 389 | $this->getResponseManager()->printDebug(); |
390 | 390 | |
391 | - if(($this->getOption('core.process.exit'))) |
|
391 | + if (($this->getOption('core.process.exit'))) |
|
392 | 392 | { |
393 | 393 | $this->getResponseManager()->sendOutput(); |
394 | 394 | exit(); |
@@ -438,16 +438,16 @@ discard block |
||
438 | 438 | */ |
439 | 439 | public function getScript($bIncludeJs = false, $bIncludeCss = false) |
440 | 440 | { |
441 | - if(!$this->getOption('core.request.uri')) |
|
441 | + if (!$this->getOption('core.request.uri')) |
|
442 | 442 | { |
443 | 443 | $this->setOption('core.request.uri', URI::detect()); |
444 | 444 | } |
445 | 445 | $sCode = ''; |
446 | - if(($bIncludeCss)) |
|
446 | + if (($bIncludeCss)) |
|
447 | 447 | { |
448 | 448 | $sCode .= $this->getPluginManager()->getCss() . "\n"; |
449 | 449 | } |
450 | - if(($bIncludeJs)) |
|
450 | + if (($bIncludeJs)) |
|
451 | 451 | { |
452 | 452 | $sCode .= $this->getPluginManager()->getJs() . "\n"; |
453 | 453 | } |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | public function readConfigFile($sConfigFile, $sLibKey = '', $sAppKey = null) |
546 | 546 | { |
547 | 547 | $sExt = pathinfo($sConfigFile, PATHINFO_EXTENSION); |
548 | - switch($sExt) |
|
548 | + switch ($sExt) |
|
549 | 549 | { |
550 | 550 | case 'php': |
551 | 551 | return $this->readPhpConfigFile($sConfigFile, $sLibKey, $sAppKey); |
@@ -621,7 +621,7 @@ discard block |
||
621 | 621 | */ |
622 | 622 | public function hasUploadedFiles() |
623 | 623 | { |
624 | - if(($xUploadPlugin = $this->getPluginManager()->getRequestPlugin(self::FILE_UPLOAD)) == null) |
|
624 | + if (($xUploadPlugin = $this->getPluginManager()->getRequestPlugin(self::FILE_UPLOAD)) == null) |
|
625 | 625 | { |
626 | 626 | return false; |
627 | 627 | } |
@@ -637,11 +637,11 @@ discard block |
||
637 | 637 | { |
638 | 638 | try |
639 | 639 | { |
640 | - if(($xUploadPlugin = $this->getPluginManager()->getRequestPlugin(self::FILE_UPLOAD)) == null) |
|
640 | + if (($xUploadPlugin = $this->getPluginManager()->getRequestPlugin(self::FILE_UPLOAD)) == null) |
|
641 | 641 | { |
642 | 642 | throw new Exception($this->trans('errors.upload.plugin')); |
643 | 643 | } |
644 | - elseif(!$xUploadPlugin->canProcessRequest()) |
|
644 | + elseif (!$xUploadPlugin->canProcessRequest()) |
|
645 | 645 | { |
646 | 646 | throw new Exception($this->trans('errors.upload.request')); |
647 | 647 | } |
@@ -650,14 +650,14 @@ discard block |
||
650 | 650 | $sResponse = '{"code": "success", "upl": "' . $sKey . '"}'; |
651 | 651 | $return = true; |
652 | 652 | } |
653 | - catch(Exception $e) |
|
653 | + catch (Exception $e) |
|
654 | 654 | { |
655 | 655 | $sResponse = '{"code": "error", "msg": "' . addslashes($e->getMessage()) . '"}'; |
656 | 656 | $return = false; |
657 | 657 | } |
658 | 658 | // Send the response back to the browser |
659 | 659 | echo '<script>var res = ', $sResponse, '; </script>'; |
660 | - if(($this->getOption('core.process.exit'))) |
|
660 | + if (($this->getOption('core.process.exit'))) |
|
661 | 661 | { |
662 | 662 | exit(); |
663 | 663 | } |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | */ |
672 | 672 | public function getUploadedFiles() |
673 | 673 | { |
674 | - if(($xUploadPlugin = $this->getPluginManager()->getRequestPlugin(self::FILE_UPLOAD)) == null) |
|
674 | + if (($xUploadPlugin = $this->getPluginManager()->getRequestPlugin(self::FILE_UPLOAD)) == null) |
|
675 | 675 | { |
676 | 676 | return []; |
677 | 677 | } |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | */ |
688 | 688 | public function setUploadFileFilter($fFileFilter) |
689 | 689 | { |
690 | - if(($xUploadPlugin = $this->getPluginManager()->getRequestPlugin(self::FILE_UPLOAD)) == null) |
|
690 | + if (($xUploadPlugin = $this->getPluginManager()->getRequestPlugin(self::FILE_UPLOAD)) == null) |
|
691 | 691 | { |
692 | 692 | return; |
693 | 693 | } |
@@ -214,8 +214,9 @@ discard block |
||
214 | 214 | { |
215 | 215 | $sEvent = $xArgs; |
216 | 216 | $xUserFunction = $aArgs[2]; |
217 | - if(!is_a($xUserFunction, 'Request\\Support\\UserFunction')) |
|
218 | - $xUserFunction = new Request\Support\UserFunction($xUserFunction); |
|
217 | + if(!is_a($xUserFunction, 'Request\\Support\\UserFunction')) { |
|
218 | + $xUserFunction = new Request\Support\UserFunction($xUserFunction); |
|
219 | + } |
|
219 | 220 | $this->aProcessingEvents[$sEvent] = $xUserFunction; |
220 | 221 | } |
221 | 222 | /*else |
@@ -328,8 +329,7 @@ discard block |
||
328 | 329 | try |
329 | 330 | { |
330 | 331 | $mResult = $this->getPluginManager()->processRequest(); |
331 | - } |
|
332 | - catch(Exception $e) |
|
332 | + } catch(Exception $e) |
|
333 | 333 | { |
334 | 334 | // An exception was thrown while processing the request. |
335 | 335 | // The request missed the corresponding handler function, |
@@ -346,8 +346,7 @@ discard block |
||
346 | 346 | { |
347 | 347 | $sEvent = self::PROCESSING_EVENT_INVALID; |
348 | 348 | $aParams = array($e->getMessage()); |
349 | - } |
|
350 | - else |
|
349 | + } else |
|
351 | 350 | { |
352 | 351 | $sEvent = self::PROCESSING_EVENT_ERROR; |
353 | 352 | $aParams = array($e); |
@@ -357,8 +356,7 @@ discard block |
||
357 | 356 | { |
358 | 357 | // Call the processing event |
359 | 358 | $this->aProcessingEvents[$sEvent]->call($aParams); |
360 | - } |
|
361 | - else |
|
359 | + } else |
|
362 | 360 | { |
363 | 361 | // The exception is not to be processed here. |
364 | 362 | throw $e; |
@@ -640,8 +638,7 @@ discard block |
||
640 | 638 | if(($xUploadPlugin = $this->getPluginManager()->getRequestPlugin(self::FILE_UPLOAD)) == null) |
641 | 639 | { |
642 | 640 | throw new Exception($this->trans('errors.upload.plugin')); |
643 | - } |
|
644 | - elseif(!$xUploadPlugin->canProcessRequest()) |
|
641 | + } elseif(!$xUploadPlugin->canProcessRequest()) |
|
645 | 642 | { |
646 | 643 | throw new Exception($this->trans('errors.upload.request')); |
647 | 644 | } |
@@ -649,8 +646,7 @@ discard block |
||
649 | 646 | $sKey = $xUploadPlugin->saveUploadedFiles(); |
650 | 647 | $sResponse = '{"code": "success", "upl": "' . $sKey . '"}'; |
651 | 648 | $return = true; |
652 | - } |
|
653 | - catch(Exception $e) |
|
649 | + } catch(Exception $e) |
|
654 | 650 | { |
655 | 651 | $sResponse = '{"code": "error", "msg": "' . addslashes($e->getMessage()) . '"}'; |
656 | 652 | $return = false; |