@@ -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 | } |
@@ -151,8 +151,7 @@ discard block |
||
| 151 | 151 | $this->pdo->exec("SET CHARACTER SET '" . $config['charset'] . "'"); |
| 152 | 152 | $this->pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ); |
| 153 | 153 | return true; |
| 154 | - } |
|
| 155 | - catch (PDOException $e){ |
|
| 154 | + } catch (PDOException $e){ |
|
| 156 | 155 | $this->logger->fatal($e->getMessage()); |
| 157 | 156 | show_error('Cannot connect to Database.'); |
| 158 | 157 | return false; |
@@ -671,8 +670,7 @@ discard block |
||
| 671 | 670 | protected function setLoggerFromParamOrCreateNewInstance(Log $logger = null){ |
| 672 | 671 | if ($logger !== null){ |
| 673 | 672 | $this->logger = $logger; |
| 674 | - } |
|
| 675 | - else{ |
|
| 673 | + } else{ |
|
| 676 | 674 | $this->logger =& class_loader('Log', 'classes'); |
| 677 | 675 | $this->logger->setLogger('Library::Database'); |
| 678 | 676 | } |
@@ -685,8 +683,7 @@ discard block |
||
| 685 | 683 | protected function setQueryBuilderFromParamOrCreateNewInstance(DatabaseQueryBuilder $queryBuilder = null){ |
| 686 | 684 | if ($queryBuilder !== null){ |
| 687 | 685 | $this->queryBuilder = $queryBuilder; |
| 688 | - } |
|
| 689 | - else{ |
|
| 686 | + } else{ |
|
| 690 | 687 | $this->queryBuilder =& class_loader('DatabaseQueryBuilder', 'classes/database'); |
| 691 | 688 | } |
| 692 | 689 | } |
@@ -698,8 +695,7 @@ discard block |
||
| 698 | 695 | protected function setQueryRunnerFromParamOrCreateNewInstance(DatabaseQueryRunner $queryRunner = null){ |
| 699 | 696 | if ($queryRunner !== null){ |
| 700 | 697 | $this->queryRunner = $queryRunner; |
| 701 | - } |
|
| 702 | - else{ |
|
| 698 | + } else{ |
|
| 703 | 699 | $this->queryRunner =& class_loader('DatabaseQueryRunner', 'classes/database'); |
| 704 | 700 | } |
| 705 | 701 | } |
@@ -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; |
@@ -48,8 +48,7 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | if(is_object($logger)){ |
| 50 | 50 | $this->logger = $logger; |
| 51 | - } |
|
| 52 | - else{ |
|
| 51 | + } else{ |
|
| 53 | 52 | $this->logger =& class_loader('Log', 'classes'); |
| 54 | 53 | $this->logger->setLogger('Library::FileCache'); |
| 55 | 54 | } |
@@ -95,8 +94,7 @@ discard block |
||
| 95 | 94 | // Unlinking when the file was expired |
| 96 | 95 | unlink($filePath); |
| 97 | 96 | return false; |
| 98 | - } |
|
| 99 | - else{ |
|
| 97 | + } else{ |
|
| 100 | 98 | $this->logger->info('The cache not yet expire, now return the cache data for key ['. $key .'], the cache will expire at [' . date('Y-m-d H:i:s', $data['expire']) . ']'); |
| 101 | 99 | return $data['data']; |
| 102 | 100 | } |
@@ -133,8 +131,7 @@ discard block |
||
| 133 | 131 | $this->logger->error('Can not write cache data into file [' .$filePath. '] for the key ['. $key .'], return false'); |
| 134 | 132 | fclose($handle); |
| 135 | 133 | return false; |
| 136 | - } |
|
| 137 | - else{ |
|
| 134 | + } else{ |
|
| 138 | 135 | $this->logger->info('Cache data saved into file [' .$filePath. '] for the key ['. $key .']'); |
| 139 | 136 | fclose($handle); |
| 140 | 137 | chmod($filePath, 0640); |
@@ -156,8 +153,7 @@ discard block |
||
| 156 | 153 | if(! file_exists($filePath)){ |
| 157 | 154 | $this->logger->info('This cache file does not exists skipping'); |
| 158 | 155 | return false; |
| 159 | - } |
|
| 160 | - else{ |
|
| 156 | + } else{ |
|
| 161 | 157 | $this->logger->info('Found cache file [' .$filePath. '] remove it'); |
| 162 | 158 | unlink($filePath); |
| 163 | 159 | return true; |
@@ -210,8 +206,7 @@ discard block |
||
| 210 | 206 | $list = glob(CACHE_PATH . '*.cache'); |
| 211 | 207 | if(! $list){ |
| 212 | 208 | $this->logger->info('No cache files were found skipping'); |
| 213 | - } |
|
| 214 | - else{ |
|
| 209 | + } else{ |
|
| 215 | 210 | $this->logger->info('Found [' . count($list) . '] cache files to remove if expired'); |
| 216 | 211 | foreach ($list as $file) { |
| 217 | 212 | $this->logger->debug('Processing the cache file [' . $file . ']'); |
@@ -219,12 +214,10 @@ discard block |
||
| 219 | 214 | $data = @unserialize($this->compressCacheData ? gzinflate($data) : $data); |
| 220 | 215 | if(! $data){ |
| 221 | 216 | $this->logger->warning('Can not unserialize the cache data for file [' . $file . ']'); |
| 222 | - } |
|
| 223 | - else if(time() > $data['expire']){ |
|
| 217 | + } else if(time() > $data['expire']){ |
|
| 224 | 218 | $this->logger->info('The cache data for file [' . $file . '] already expired remove it'); |
| 225 | 219 | unlink($file); |
| 226 | - } |
|
| 227 | - else{ |
|
| 220 | + } else{ |
|
| 228 | 221 | $this->logger->info('The cache data for file [' . $file . '] not yet expired skip it'); |
| 229 | 222 | } |
| 230 | 223 | } |
@@ -239,8 +232,7 @@ discard block |
||
| 239 | 232 | $list = glob(CACHE_PATH . '*.cache'); |
| 240 | 233 | if(! $list){ |
| 241 | 234 | $this->logger->info('No cache files were found skipping'); |
| 242 | - } |
|
| 243 | - else{ |
|
| 235 | + } else{ |
|
| 244 | 236 | $this->logger->info('Found [' . count($list) . '] cache files to remove'); |
| 245 | 237 | foreach ($list as $file) { |
| 246 | 238 | $this->logger->debug('Processing the cache file [' . $file . ']'); |
@@ -267,8 +259,7 @@ discard block |
||
| 267 | 259 | |
| 268 | 260 | $this->logger->warning('The zlib extension is not loaded set cache compress data to FALSE'); |
| 269 | 261 | $this->compressCacheData = false; |
| 270 | - } |
|
| 271 | - else{ |
|
| 262 | + } else{ |
|
| 272 | 263 | $this->compressCacheData = $status; |
| 273 | 264 | } |
| 274 | 265 | return $this; |
@@ -266,8 +266,7 @@ discard block |
||
| 266 | 266 | //if the application is running in CLI mode use the first argument |
| 267 | 267 | else if(IS_CLI && isset($_SERVER['argv'][1])){ |
| 268 | 268 | $routeUri = $_SERVER['argv'][1]; |
| 269 | - } |
|
| 270 | - else if(isset($_SERVER['REQUEST_URI'])){ |
|
| 269 | + } else if(isset($_SERVER['REQUEST_URI'])){ |
|
| 271 | 270 | $routeUri = $_SERVER['REQUEST_URI']; |
| 272 | 271 | } |
| 273 | 272 | $this->logger->debug('Check if URL suffix is enabled in the configuration'); |
@@ -363,15 +362,13 @@ discard block |
||
| 363 | 362 | if(! class_exists($controller, false)){ |
| 364 | 363 | $e404 = true; |
| 365 | 364 | $this->logger->warning('The controller file [' .$classFilePath. '] exists but does not contain the class [' . $controller . ']'); |
| 366 | - } |
|
| 367 | - else{ |
|
| 365 | + } else{ |
|
| 368 | 366 | $controllerInstance = new $controller(); |
| 369 | 367 | $controllerMethod = $this->getMethod(); |
| 370 | 368 | if(! method_exists($controllerInstance, $controllerMethod)){ |
| 371 | 369 | $e404 = true; |
| 372 | 370 | $this->logger->warning('The controller [' . $controller . '] exist but does not contain the method [' . $controllerMethod . ']'); |
| 373 | - } |
|
| 374 | - else{ |
|
| 371 | + } else{ |
|
| 375 | 372 | $this->logger->info('Routing data is set correctly now GO!'); |
| 376 | 373 | call_user_func_array(array($controllerInstance, $controllerMethod), $this->args); |
| 377 | 374 | //render the final page to user |
@@ -379,8 +376,7 @@ discard block |
||
| 379 | 376 | get_instance()->response->renderFinalPage(); |
| 380 | 377 | } |
| 381 | 378 | } |
| 382 | - } |
|
| 383 | - else{ |
|
| 379 | + } else{ |
|
| 384 | 380 | $this->logger->info('The controller file path [' . $classFilePath . '] does not exist'); |
| 385 | 381 | $e404 = true; |
| 386 | 382 | } |
@@ -486,8 +482,7 @@ discard block |
||
| 486 | 482 | $this->logger->info('The current request use the module [' . $moduleControllerMethod[0] . ']'); |
| 487 | 483 | $this->module = $moduleControllerMethod[0]; |
| 488 | 484 | $moduleControllerMethod = explode('@', $moduleControllerMethod[1]); |
| 489 | - } |
|
| 490 | - else{ |
|
| 485 | + } else{ |
|
| 491 | 486 | $this->logger->info('The current request does not use the module'); |
| 492 | 487 | $moduleControllerMethod = explode('@', $this->callback[$index]); |
| 493 | 488 | } |
@@ -543,8 +538,7 @@ discard block |
||
| 543 | 538 | } |
| 544 | 539 | //args |
| 545 | 540 | $this->args = $segment; |
| 546 | - } |
|
| 547 | - else{ |
|
| 541 | + } else{ |
|
| 548 | 542 | $this->logger->info('The application contains a loaded module will check if the current request is found in the module list'); |
| 549 | 543 | if(in_array($segment[0], $modules)){ |
| 550 | 544 | $this->logger->info('Found, the current request use the module [' . $segment[0] . ']'); |
@@ -558,8 +552,7 @@ discard block |
||
| 558 | 552 | if(! $path){ |
| 559 | 553 | $this->logger->info('The controller [' . $this->controller . '] not found in the module, may be will use the module [' . $this->module . '] as controller'); |
| 560 | 554 | $this->controller = $this->module; |
| 561 | - } |
|
| 562 | - else{ |
|
| 555 | + } else{ |
|
| 563 | 556 | $this->controllerPath = $path; |
| 564 | 557 | array_shift($segment); |
| 565 | 558 | } |
@@ -571,8 +564,7 @@ discard block |
||
| 571 | 564 | } |
| 572 | 565 | //the remaining is for args |
| 573 | 566 | $this->args = $segment; |
| 574 | - } |
|
| 575 | - else{ |
|
| 567 | + } else{ |
|
| 576 | 568 | $this->logger->info('The current request information is not found in the module list'); |
| 577 | 569 | //controller |
| 578 | 570 | if(isset($segment[0])){ |
@@ -615,8 +607,7 @@ discard block |
||
| 615 | 607 | protected function setLoggerFromParamOrCreateNewInstance(Log $logger = null){ |
| 616 | 608 | if ($logger !== null){ |
| 617 | 609 | $this->logger = $logger; |
| 618 | - } |
|
| 619 | - else{ |
|
| 610 | + } else{ |
|
| 620 | 611 | $this->logger =& class_loader('Log', 'classes'); |
| 621 | 612 | $this->logger->setLogger('Library::Router'); |
| 622 | 613 | } |