@@ -477,8 +477,7 @@ discard block |
||
| 477 | 477 | if (mkdir($destination_directory, 0775, true)) { |
| 478 | 478 | $this->destination_directory = $destination_directory; |
| 479 | 479 | chdir($destination_directory); |
| 480 | - } |
|
| 481 | - else{ |
|
| 480 | + } else{ |
|
| 482 | 481 | $this->logger->warning('Can not create the upload directory [' .$destination_directory. ']'); |
| 483 | 482 | } |
| 484 | 483 | } |
@@ -630,8 +629,7 @@ discard block |
||
| 630 | 629 | // set original filename if not have a new name |
| 631 | 630 | if (empty($this->filename)) { |
| 632 | 631 | $this->filename = $this->file_array[$this->input]['name']; |
| 633 | - } |
|
| 634 | - else{ |
|
| 632 | + } else{ |
|
| 635 | 633 | // Replace %s for extension in filename |
| 636 | 634 | // Before: /[\w\d]*(.[\d\w]+)$/i |
| 637 | 635 | // After: /^[\s[:alnum:]\-\_\.]*\.([\d\w]+)$/iu |
@@ -225,8 +225,7 @@ discard block |
||
| 225 | 225 | } |
| 226 | 226 | if (empty($this->join)){ |
| 227 | 227 | $this->join = ' ' . $type . 'JOIN' . ' ' . $table . ' ON ' . $on; |
| 228 | - } |
|
| 229 | - else{ |
|
| 228 | + } else{ |
|
| 230 | 229 | $this->join = $this->join . ' ' . $type . 'JOIN' . ' ' . $table . ' ON ' . $on; |
| 231 | 230 | } |
| 232 | 231 | return $this; |
@@ -334,8 +333,7 @@ discard block |
||
| 334 | 333 | $whereStr = ''; |
| 335 | 334 | if (is_array($where)){ |
| 336 | 335 | $whereStr = $this->getWhereStrIfIsArray($where, $type, $andOr, $escape); |
| 337 | - } |
|
| 338 | - else{ |
|
| 336 | + } else{ |
|
| 339 | 337 | if (is_array($op)){ |
| 340 | 338 | $whereStr = $this->getWhereStrIfOperatorIsArray($where, $op, $type, $escape); |
| 341 | 339 | } else { |
@@ -585,8 +583,7 @@ discard block |
||
| 585 | 583 | } |
| 586 | 584 | if (! is_null($limitEnd)){ |
| 587 | 585 | $this->limit = $limit . ', ' . $limitEnd; |
| 588 | - } |
|
| 589 | - else{ |
|
| 586 | + } else{ |
|
| 590 | 587 | $this->limit = $limit; |
| 591 | 588 | } |
| 592 | 589 | return $this; |
@@ -601,8 +598,7 @@ discard block |
||
| 601 | 598 | public function orderBy($orderBy, $orderDir = ' ASC'){ |
| 602 | 599 | if (stristr($orderBy, ' ') || $orderBy == 'rand()'){ |
| 603 | 600 | $this->orderBy = empty($this->orderBy) ? $orderBy : $this->orderBy . ', ' . $orderBy; |
| 604 | - } |
|
| 605 | - else{ |
|
| 601 | + } else{ |
|
| 606 | 602 | $this->orderBy = empty($this->orderBy) |
| 607 | 603 | ? ($orderBy . ' ' . strtoupper($orderDir)) |
| 608 | 604 | : $this->orderBy . ', ' . $orderBy . ' ' . strtoupper($orderDir); |
@@ -618,8 +614,7 @@ discard block |
||
| 618 | 614 | public function groupBy($field){ |
| 619 | 615 | if (is_array($field)){ |
| 620 | 616 | $this->groupBy = implode(', ', $field); |
| 621 | - } |
|
| 622 | - else{ |
|
| 617 | + } else{ |
|
| 623 | 618 | $this->groupBy = $field; |
| 624 | 619 | } |
| 625 | 620 | return $this; |
@@ -636,14 +631,12 @@ discard block |
||
| 636 | 631 | public function having($field, $op = null, $val = null, $escape = true){ |
| 637 | 632 | if (is_array($op)){ |
| 638 | 633 | $this->having = $this->getHavingStrIfOperatorIsArray($field, $op, $escape); |
| 639 | - } |
|
| 640 | - else if (! in_array($op, $this->operatorList)){ |
|
| 634 | + } else if (! in_array($op, $this->operatorList)){ |
|
| 641 | 635 | if (is_null($op)){ |
| 642 | 636 | $op = ''; |
| 643 | 637 | } |
| 644 | 638 | $this->having = $field . ' > ' . ($this->escape($op, $escape)); |
| 645 | - } |
|
| 646 | - else{ |
|
| 639 | + } else{ |
|
| 647 | 640 | if (is_null($val)){ |
| 648 | 641 | $val = ''; |
| 649 | 642 | } |
@@ -149,8 +149,7 @@ discard block |
||
| 149 | 149 | $isSqlSELECTQuery = stristr($this->query, 'SELECT') !== false; |
| 150 | 150 | if($isSqlSELECTQuery){ |
| 151 | 151 | $this->setResultForSelect(); |
| 152 | - } |
|
| 153 | - else{ |
|
| 152 | + } else{ |
|
| 154 | 153 | $this->setResultForNonSelect(); |
| 155 | 154 | } |
| 156 | 155 | return $this->queryResult; |
@@ -172,15 +171,13 @@ discard block |
||
| 172 | 171 | } |
| 173 | 172 | if ($this->returnAsList){ |
| 174 | 173 | $result = $this->pdoStatment->fetchAll($fetchMode); |
| 175 | - } |
|
| 176 | - else{ |
|
| 174 | + } else{ |
|
| 177 | 175 | $result = $this->pdoStatment->fetch($fetchMode); |
| 178 | 176 | } |
| 179 | 177 | //Sqlite and pgsql always return 0 when using rowCount() |
| 180 | 178 | if (in_array($this->driver, array('sqlite', 'pgsql'))){ |
| 181 | 179 | $numRows = count($result); |
| 182 | - } |
|
| 183 | - else{ |
|
| 180 | + } else{ |
|
| 184 | 181 | $numRows = $this->pdoStatment->rowCount(); |
| 185 | 182 | } |
| 186 | 183 | if(! is_object($this->queryResult)){ |
@@ -201,8 +198,7 @@ discard block |
||
| 201 | 198 | if (in_array($this->driver, array('sqlite', 'pgsql'))){ |
| 202 | 199 | $result = true; //to test the result for the query like UPDATE, INSERT, DELETE |
| 203 | 200 | $numRows = 1; //TODO use the correct method to get the exact affected row |
| 204 | - } |
|
| 205 | - else{ |
|
| 201 | + } else{ |
|
| 206 | 202 | //to test the result for the query like UPDATE, INSERT, DELETE |
| 207 | 203 | $result = $this->pdoStatment->rowCount() >= 0; |
| 208 | 204 | $numRows = $this->pdoStatment->rowCount(); |
@@ -380,8 +376,7 @@ discard block |
||
| 380 | 376 | protected function setLoggerFromParamOrCreateNewInstance(Log $logger = null){ |
| 381 | 377 | if ($logger !== null){ |
| 382 | 378 | $this->logger = $logger; |
| 383 | - } |
|
| 384 | - else{ |
|
| 379 | + } else{ |
|
| 385 | 380 | $this->logger =& class_loader('Log', 'classes'); |
| 386 | 381 | $this->logger->setLogger('Library::DatabaseQueryRunner'); |
| 387 | 382 | } |
@@ -62,8 +62,7 @@ |
||
| 62 | 62 | $query[0] = rtrim($query[0], '/'); |
| 63 | 63 | $query[0] .= $suffix; |
| 64 | 64 | $path = implode('?', $query); |
| 65 | - } |
|
| 66 | - else{ |
|
| 65 | + } else{ |
|
| 67 | 66 | $path .= $suffix; |
| 68 | 67 | } |
| 69 | 68 | } |
@@ -128,8 +128,7 @@ discard block |
||
| 128 | 128 | $logger->info('Delete config item ['.$item.']'); |
| 129 | 129 | unset(self::$config[$item]); |
| 130 | 130 | return true; |
| 131 | - } |
|
| 132 | - else{ |
|
| 131 | + } else{ |
|
| 133 | 132 | $logger->warning('Config item ['.$item.'] to be deleted does not exists'); |
| 134 | 133 | return false; |
| 135 | 134 | } |
@@ -179,8 +178,7 @@ discard block |
||
| 179 | 178 | 0, |
| 180 | 179 | strpos($_SERVER['SCRIPT_NAME'], basename($_SERVER['SCRIPT_FILENAME'])) |
| 181 | 180 | ); |
| 182 | - } |
|
| 183 | - else{ |
|
| 181 | + } else{ |
|
| 184 | 182 | $logger->warning('Can not determine the application base URL automatically, use http://localhost as default'); |
| 185 | 183 | $baseUrl = 'http://localhost/'; |
| 186 | 184 | } |
@@ -234,8 +234,7 @@ discard block |
||
| 234 | 234 | //first check for CSRF |
| 235 | 235 | if (get_config('csrf_enable', false) && ! Security::validateCSRF()){ |
| 236 | 236 | show_error('Invalide data, Cross Site Request Forgery do his job, the data to validate is corrupted.'); |
| 237 | - } |
|
| 238 | - else{ |
|
| 237 | + } else{ |
|
| 239 | 238 | $this->logger->info('CSRF is not enabled in configuration or not set manully, no need to check it'); |
| 240 | 239 | } |
| 241 | 240 | } |
@@ -255,8 +254,7 @@ discard block |
||
| 255 | 254 | foreach ($this->getData() as $inputName => $inputVal) { |
| 256 | 255 | if(is_array($this->data[$inputName])){ |
| 257 | 256 | $this->data[$inputName] = array_map('trim', $this->data[$inputName]); |
| 258 | - } |
|
| 259 | - else{ |
|
| 257 | + } else{ |
|
| 260 | 258 | $this->data[$inputName] = trim($this->data[$inputName]); |
| 261 | 259 | } |
| 262 | 260 | |
@@ -624,8 +622,7 @@ discard block |
||
| 624 | 622 | if ($inputVal == '' && $callbackReturn == true) { |
| 625 | 623 | $this->_setError($inputName, $ruleName, $this->_getLabel($inputName)); |
| 626 | 624 | } |
| 627 | - } |
|
| 628 | - else if($inputVal == '') { |
|
| 625 | + } else if($inputVal == '') { |
|
| 629 | 626 | $this->_setError($inputName, $ruleName, $this->_getLabel($inputName)); |
| 630 | 627 | } |
| 631 | 628 | } |
@@ -684,8 +681,7 @@ discard block |
||
| 684 | 681 | $this->_setError($inputName, $ruleName . ',post:key', array($this->_getLabel($inputName), $this->_getLabel(str_replace('post:', '', $doNotEqual)))); |
| 685 | 682 | continue; |
| 686 | 683 | } |
| 687 | - } |
|
| 688 | - else{ |
|
| 684 | + } else{ |
|
| 689 | 685 | if ($inputVal == $doNotEqual) { |
| 690 | 686 | $this->_setError($inputName, $ruleName . ',string', array($this->_getLabel($inputName), $doNotEqual)); |
| 691 | 687 | continue; |
@@ -60,8 +60,7 @@ discard block |
||
| 60 | 60 | if(Session::exists($key) && Session::exists($keyExpire) && Session::get($keyExpire) > $currentTime){ |
| 61 | 61 | $logger->info('The CSRF token not yet expire just return it'); |
| 62 | 62 | return Session::get($key); |
| 63 | - } |
|
| 64 | - else{ |
|
| 63 | + } else{ |
|
| 65 | 64 | $newTime = $currentTime + $expire; |
| 66 | 65 | $token = sha1(uniqid()) . sha1(uniqid()); |
| 67 | 66 | $logger->info('The CSRF informations are listed below: key [' .$key. '], key expire [' .$keyExpire. '], expire time [' .$expire. '], token [' .$token. ']'); |
@@ -123,8 +122,7 @@ discard block |
||
| 123 | 122 | $logger->info('IP address ' . $ip . ' allowed using the wildcard "*" or the full IP'); |
| 124 | 123 | //wildcard to access all ip address |
| 125 | 124 | return; |
| 126 | - } |
|
| 127 | - else{ |
|
| 125 | + } else{ |
|
| 128 | 126 | // go through all whitelisted ips |
| 129 | 127 | foreach ($list as $ipaddr) { |
| 130 | 128 | // find the wild card * in whitelisted ip (f.e. find position in "127.0.*" or "127*") |
@@ -149,8 +147,7 @@ discard block |
||
| 149 | 147 | show_error('Access to this application is not allowed'); |
| 150 | 148 | } |
| 151 | 149 | } |
| 152 | - } |
|
| 153 | - else{ |
|
| 150 | + } else{ |
|
| 154 | 151 | $logger->info('Whitelist IP access is not enabled in the configuration, ignore checking'); |
| 155 | 152 | } |
| 156 | 153 | } |
@@ -107,8 +107,7 @@ discard block |
||
| 107 | 107 | if ($moduleModelFilePath){ |
| 108 | 108 | $logger->info('Found model [' . $class . '] from module [' .$module. '], the file path is [' .$moduleModelFilePath. '] we will used it'); |
| 109 | 109 | $classFilePath = $moduleModelFilePath; |
| 110 | - } |
|
| 111 | - else{ |
|
| 110 | + } else{ |
|
| 112 | 111 | $logger->info('Cannot find model [' . $class . '] from modules using the default location'); |
| 113 | 112 | } |
| 114 | 113 | $logger->info('The model file path to be loaded is [' . $classFilePath . ']'); |
@@ -120,12 +119,10 @@ discard block |
||
| 120 | 119 | $obj->{$instance} = $c; |
| 121 | 120 | static::$loaded[$instance] = $class; |
| 122 | 121 | $logger->info('Model [' . $class . '] --> ' . $classFilePath . ' loaded successfully.'); |
| 123 | - } |
|
| 124 | - else{ |
|
| 122 | + } else{ |
|
| 125 | 123 | show_error('The file '.$classFilePath.' exists but does not contain the class ['. $class . ']'); |
| 126 | 124 | } |
| 127 | - } |
|
| 128 | - else{ |
|
| 125 | + } else{ |
|
| 129 | 126 | show_error('Unable to find the model [' . $class . ']'); |
| 130 | 127 | } |
| 131 | 128 | } |
@@ -168,8 +165,7 @@ discard block |
||
| 168 | 165 | $libraryFilePath = CORE_LIBRARY_PATH . $file; |
| 169 | 166 | $class = ucfirst($class); |
| 170 | 167 | $logger->info('This library is a system library'); |
| 171 | - } |
|
| 172 | - else{ |
|
| 168 | + } else{ |
|
| 173 | 169 | $logger->info('This library is not a system library'); |
| 174 | 170 | //first check if this library is in the module |
| 175 | 171 | $libraryFilePath = self::getLibraryPathUsingModuleInfo($class); |
@@ -214,8 +210,7 @@ discard block |
||
| 214 | 210 | if ($moduleFunctionPath){ |
| 215 | 211 | $logger->info('Found helper [' . $function . '] from module [' .$module. '], the file path is [' .$moduleFunctionPath. '] we will used it'); |
| 216 | 212 | $functionFilePath = $moduleFunctionPath; |
| 217 | - } |
|
| 218 | - else{ |
|
| 213 | + } else{ |
|
| 219 | 214 | $logger->info('Cannot find helper [' . $function . '] from modules using the default location'); |
| 220 | 215 | } |
| 221 | 216 | if (! $functionFilePath){ |
@@ -234,8 +229,7 @@ discard block |
||
| 234 | 229 | require_once $functionFilePath; |
| 235 | 230 | static::$loaded['function_' . $function] = $functionFilePath; |
| 236 | 231 | $logger->info('Helper [' . $function . '] --> ' . $functionFilePath . ' loaded successfully.'); |
| 237 | - } |
|
| 238 | - else{ |
|
| 232 | + } else{ |
|
| 239 | 233 | show_error('Unable to find helper file [' . $file . ']'); |
| 240 | 234 | } |
| 241 | 235 | } |
@@ -268,8 +262,7 @@ discard block |
||
| 268 | 262 | if ($moduleConfigPath){ |
| 269 | 263 | $logger->info('Found config [' . $filename . '] from module [' .$module. '], the file path is [' .$moduleConfigPath. '] we will used it'); |
| 270 | 264 | $configFilePath = $moduleConfigPath; |
| 271 | - } |
|
| 272 | - else{ |
|
| 265 | + } else{ |
|
| 273 | 266 | $logger->info('Cannot find config [' . $filename . '] from modules using the default location'); |
| 274 | 267 | } |
| 275 | 268 | $logger->info('The config file path to be loaded is [' . $configFilePath . ']'); |
@@ -283,8 +276,7 @@ discard block |
||
| 283 | 276 | $logger->info('The custom application configuration loaded are listed below: ' . stringfy_vars($config)); |
| 284 | 277 | unset($config); |
| 285 | 278 | } |
| 286 | - } |
|
| 287 | - else{ |
|
| 279 | + } else{ |
|
| 288 | 280 | show_error('Unable to find config file ['. $configFilePath . ']'); |
| 289 | 281 | } |
| 290 | 282 | } |
@@ -323,8 +315,7 @@ discard block |
||
| 323 | 315 | if ($moduleLanguagePath){ |
| 324 | 316 | $logger->info('Found language [' . $language . '] from module [' .$module. '], the file path is [' .$moduleLanguagePath. '] we will used it'); |
| 325 | 317 | $languageFilePath = $moduleLanguagePath; |
| 326 | - } |
|
| 327 | - else{ |
|
| 318 | + } else{ |
|
| 328 | 319 | $logger->info('Cannot find language [' . $language . '] from modules using the default location'); |
| 329 | 320 | } |
| 330 | 321 | if (! $languageFilePath){ |
@@ -377,8 +368,7 @@ discard block |
||
| 377 | 368 | $module = $path[0]; |
| 378 | 369 | $class = ucfirst($path[1]); |
| 379 | 370 | } |
| 380 | - } |
|
| 381 | - else{ |
|
| 371 | + } else{ |
|
| 382 | 372 | $class = ucfirst($class); |
| 383 | 373 | } |
| 384 | 374 | if (! $module && !empty($obj->moduleName)){ |
@@ -499,8 +489,7 @@ discard block |
||
| 499 | 489 | if (isset($path[1])){ |
| 500 | 490 | $instance = strtolower($path[1]); |
| 501 | 491 | } |
| 502 | - } |
|
| 503 | - else{ |
|
| 492 | + } else{ |
|
| 504 | 493 | $instance = strtolower($class); |
| 505 | 494 | } |
| 506 | 495 | return $instance; |
@@ -522,8 +511,7 @@ discard block |
||
| 522 | 511 | if ($moduleLibraryPath){ |
| 523 | 512 | $logger->info('Found library [' . $class . '] from module [' .$module. '], the file path is [' .$moduleLibraryPath. '] we will used it'); |
| 524 | 513 | $libraryFilePath = $moduleLibraryPath; |
| 525 | - } |
|
| 526 | - else{ |
|
| 514 | + } else{ |
|
| 527 | 515 | $logger->info('Cannot find library [' . $class . '] from modules using the default location'); |
| 528 | 516 | } |
| 529 | 517 | return $libraryFilePath; |
@@ -547,12 +535,10 @@ discard block |
||
| 547 | 535 | $obj->{$instance} = $c; |
| 548 | 536 | static::$loaded[$instance] = $class; |
| 549 | 537 | $logger->info('Library [' . $class . '] --> ' . $libraryFilePath . ' loaded successfully.'); |
| 550 | - } |
|
| 551 | - else{ |
|
| 538 | + } else{ |
|
| 552 | 539 | show_error('The file '.$libraryFilePath.' exists but does not contain the class '.$class); |
| 553 | 540 | } |
| 554 | - } |
|
| 555 | - else{ |
|
| 541 | + } else{ |
|
| 556 | 542 | show_error('Unable to find library class [' . $class . ']'); |
| 557 | 543 | } |
| 558 | 544 | } |
@@ -578,8 +564,7 @@ discard block |
||
| 578 | 564 | } |
| 579 | 565 | static::$loaded['lang_' . $language] = $languageFilePath; |
| 580 | 566 | $logger->info('Language [' . $language . '] --> ' . $languageFilePath . ' loaded successfully.'); |
| 581 | - } |
|
| 582 | - else{ |
|
| 567 | + } else{ |
|
| 583 | 568 | show_error('Unable to find language [' . $language . ']'); |
| 584 | 569 | } |
| 585 | 570 | } |
@@ -156,8 +156,7 @@ |
||
| 156 | 156 | $this->updateQueryBuilderAndRunnerProperties(); |
| 157 | 157 | |
| 158 | 158 | return is_object($this->pdo); |
| 159 | - } |
|
| 160 | - catch (PDOException $e){ |
|
| 159 | + } catch (PDOException $e){ |
|
| 161 | 160 | $this->logger->fatal($e->getMessage()); |
| 162 | 161 | show_error('Cannot connect to Database.'); |
| 163 | 162 | return false; |