@@ -43,8 +43,7 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | if(is_object($logger)){ |
| 45 | 45 | $this->logger = $logger; |
| 46 | - } |
|
| 47 | - else{ |
|
| 46 | + } else{ |
|
| 48 | 47 | $this->logger =& class_loader('Log', 'classes'); |
| 49 | 48 | $this->logger->setLogger('Library::ApcCache'); |
| 50 | 49 | } |
@@ -62,8 +61,7 @@ discard block |
||
| 62 | 61 | if($success === false){ |
| 63 | 62 | $this->logger->info('No cache found for the key ['. $key .'], return false'); |
| 64 | 63 | return false; |
| 65 | - } |
|
| 66 | - else{ |
|
| 64 | + } else{ |
|
| 67 | 65 | $cacheInfo = $this->_getCacheInfo($key); |
| 68 | 66 | $expire = time(); |
| 69 | 67 | if($cacheInfo){ |
@@ -89,8 +87,7 @@ discard block |
||
| 89 | 87 | if($result === false){ |
| 90 | 88 | $this->logger->error('Can not write cache data for the key ['. $key .'], return false'); |
| 91 | 89 | return false; |
| 92 | - } |
|
| 93 | - else{ |
|
| 90 | + } else{ |
|
| 94 | 91 | $this->logger->info('Cache data saved for the key ['. $key .']'); |
| 95 | 92 | return true; |
| 96 | 93 | } |
@@ -109,8 +106,7 @@ discard block |
||
| 109 | 106 | if($cacheInfo === false){ |
| 110 | 107 | $this->logger->info('This cache data does not exists skipping'); |
| 111 | 108 | return false; |
| 112 | - } |
|
| 113 | - else{ |
|
| 109 | + } else{ |
|
| 114 | 110 | $this->logger->info('Found cache data for the key [' .$key. '] remove it'); |
| 115 | 111 | return apc_delete($key) === true; |
| 116 | 112 | } |
@@ -134,8 +130,7 @@ discard block |
||
| 134 | 130 | 'ttl' => $cacheInfos['ttl'] |
| 135 | 131 | ); |
| 136 | 132 | return $data; |
| 137 | - } |
|
| 138 | - else{ |
|
| 133 | + } else{ |
|
| 139 | 134 | $this->logger->info('This cache does not exists skipping'); |
| 140 | 135 | return false; |
| 141 | 136 | } |
@@ -159,8 +154,7 @@ discard block |
||
| 159 | 154 | if(empty($cacheInfos['cache_list'])){ |
| 160 | 155 | $this->logger->info('No cache data were found skipping'); |
| 161 | 156 | return false; |
| 162 | - } |
|
| 163 | - else{ |
|
| 157 | + } else{ |
|
| 164 | 158 | $this->logger->info('Found [' . count($cacheInfos) . '] cache data to remove'); |
| 165 | 159 | return apc_clear_cache('user'); |
| 166 | 160 | } |
@@ -59,8 +59,7 @@ discard block |
||
| 59 | 59 | if(! isset($this->listeners[$eventName])){ |
| 60 | 60 | $this->logger->info('This event does not have the registered event listener before, adding new one'); |
| 61 | 61 | $this->listeners[$eventName] = array(); |
| 62 | - } |
|
| 63 | - else{ |
|
| 62 | + } else{ |
|
| 64 | 63 | $this->logger->info('This event already have the registered listener, add this listener to the list'); |
| 65 | 64 | } |
| 66 | 65 | $this->listeners[$eventName][] = $listener; |
@@ -78,12 +77,10 @@ discard block |
||
| 78 | 77 | if(false !== $index = array_search($listener, $this->listeners[$eventName], true)){ |
| 79 | 78 | $this->logger->info('Found the listener at index [' .$index. '] remove it'); |
| 80 | 79 | unset($this->listeners[$eventName][$index]); |
| 81 | - } |
|
| 82 | - else{ |
|
| 80 | + } else{ |
|
| 83 | 81 | $this->logger->info('Cannot found this listener in the event listener list'); |
| 84 | 82 | } |
| 85 | - } |
|
| 86 | - else{ |
|
| 83 | + } else{ |
|
| 87 | 84 | $this->logger->info('This event does not have this listener ignore remove'); |
| 88 | 85 | } |
| 89 | 86 | } |
@@ -98,8 +95,7 @@ discard block |
||
| 98 | 95 | if($eventName !== null && isset($this->listeners[$eventName])){ |
| 99 | 96 | $this->logger->info('The event name is set of exist in the listener just remove all event listener for this event'); |
| 100 | 97 | unset($this->listeners[$eventName]); |
| 101 | - } |
|
| 102 | - else{ |
|
| 98 | + } else{ |
|
| 103 | 99 | $this->logger->info('The event name is not set or does not exist in the listener, so remove all event listener'); |
| 104 | 100 | $this->listeners = array(); |
| 105 | 101 | } |
@@ -132,8 +128,7 @@ discard block |
||
| 132 | 128 | if($event->returnBack){ |
| 133 | 129 | $this->logger->info('This event need return back, return the result for future use'); |
| 134 | 130 | return $this->dispatchToListerners($event); |
| 135 | - } |
|
| 136 | - else{ |
|
| 131 | + } else{ |
|
| 137 | 132 | $this->logger->info('This event no need return back the result, just dispatch it'); |
| 138 | 133 | $this->dispatchToListerners($event); |
| 139 | 134 | } |
@@ -153,8 +148,7 @@ discard block |
||
| 153 | 148 | return $event; |
| 154 | 149 | } |
| 155 | 150 | return; |
| 156 | - } |
|
| 157 | - else{ |
|
| 151 | + } else{ |
|
| 158 | 152 | $this->logger->info('Found the registered event listener for the event [' .$event->name. '] the list are: ' . stringfy_vars($list)); |
| 159 | 153 | } |
| 160 | 154 | foreach($list as $listener){ |
@@ -162,12 +156,10 @@ discard block |
||
| 162 | 156 | $returnedEvent = call_user_func_array($listener, array($event)); |
| 163 | 157 | if($returnedEvent instanceof EventInfo){ |
| 164 | 158 | $event = $returnedEvent; |
| 165 | - } |
|
| 166 | - else{ |
|
| 159 | + } else{ |
|
| 167 | 160 | show_error('This event [' .$event->name. '] need you return the event object after processing'); |
| 168 | 161 | } |
| 169 | - } |
|
| 170 | - else{ |
|
| 162 | + } else{ |
|
| 171 | 163 | call_user_func_array($listener, array($event)); |
| 172 | 164 | } |
| 173 | 165 | if($event->stop){ |
@@ -115,8 +115,7 @@ |
||
| 115 | 115 | protected function setLoggerFromParamOrCreateNewInstance(Log $logger = null){ |
| 116 | 116 | if($logger !== null){ |
| 117 | 117 | $this->logger = $logger; |
| 118 | - } |
|
| 119 | - else{ |
|
| 118 | + } else{ |
|
| 120 | 119 | $this->logger =& class_loader('Log', 'classes'); |
| 121 | 120 | $this->logger->setLogger('MainController'); |
| 122 | 121 | } |
@@ -226,16 +226,14 @@ discard block |
||
| 226 | 226 | ); |
| 227 | 227 | if (isset($http_status[$code])){ |
| 228 | 228 | $text = $http_status[$code]; |
| 229 | - } |
|
| 230 | - else{ |
|
| 229 | + } else{ |
|
| 231 | 230 | show_error('No HTTP status text found for your code please check it.'); |
| 232 | 231 | } |
| 233 | 232 | } |
| 234 | 233 | |
| 235 | 234 | if (strpos(php_sapi_name(), 'cgi') === 0){ |
| 236 | 235 | header('Status: ' . $code . ' ' . $text, TRUE); |
| 237 | - } |
|
| 238 | - else{ |
|
| 236 | + } else{ |
|
| 239 | 237 | $proto = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1'; |
| 240 | 238 | header($proto . ' ' . $code . ' ' . $text, TRUE, $code); |
| 241 | 239 | } |
@@ -277,11 +275,9 @@ discard block |
||
| 277 | 275 | */ |
| 278 | 276 | if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off'){ |
| 279 | 277 | return true; |
| 280 | - } |
|
| 281 | - else if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https'){ |
|
| 278 | + } else if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https'){ |
|
| 282 | 279 | return true; |
| 283 | - } |
|
| 284 | - else if (isset($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off'){ |
|
| 280 | + } else if (isset($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off'){ |
|
| 285 | 281 | return true; |
| 286 | 282 | } |
| 287 | 283 | return false; |
@@ -324,8 +320,7 @@ discard block |
||
| 324 | 320 | function php_exception_handler($ex){ |
| 325 | 321 | if (str_ireplace(array('off', 'none', 'no', 'false', 'null'), '', ini_get('display_errors'))){ |
| 326 | 322 | show_error('An exception is occured in file '. $ex->getFile() .' at line ' . $ex->getLine() . ' raison : ' . $ex->getMessage(), 'PHP Exception #' . $ex->getCode()); |
| 327 | - } |
|
| 328 | - else{ |
|
| 323 | + } else{ |
|
| 329 | 324 | save_to_log('error', 'An exception is occured in file ' . $ex->getFile() . ' at line ' . $ex->getLine() . ' raison : ' . $ex->getMessage(), 'PHP Exception'); |
| 330 | 325 | } |
| 331 | 326 | return true; |
@@ -447,15 +442,13 @@ discard block |
||
| 447 | 442 | function clean_input($str){ |
| 448 | 443 | if (is_array($str)){ |
| 449 | 444 | $str = array_map('clean_input', $str); |
| 450 | - } |
|
| 451 | - else if (is_object($str)){ |
|
| 445 | + } else if (is_object($str)){ |
|
| 452 | 446 | $obj = $str; |
| 453 | 447 | foreach ($str as $var => $value) { |
| 454 | 448 | $obj->$var = clean_input($value); |
| 455 | 449 | } |
| 456 | 450 | $str = $obj; |
| 457 | - } |
|
| 458 | - else{ |
|
| 451 | + } else{ |
|
| 459 | 452 | $str = htmlspecialchars(strip_tags($str), ENT_QUOTES, 'UTF-8'); |
| 460 | 453 | } |
| 461 | 454 | return $str; |
@@ -528,8 +521,7 @@ discard block |
||
| 528 | 521 | session_save_path($sessionSavePath); |
| 529 | 522 | $logger->info('Session save path: ' . $sessionSavePath); |
| 530 | 523 | } |
| 531 | - } |
|
| 532 | - else if ($sessionHandler == 'database'){ |
|
| 524 | + } else if ($sessionHandler == 'database'){ |
|
| 533 | 525 | //load database session handle library |
| 534 | 526 | //Database Session handler Model |
| 535 | 527 | require_once CORE_CLASSES_MODEL_PATH . 'DBSessionHandlerModel.php'; |
@@ -537,8 +529,7 @@ discard block |
||
| 537 | 529 | $DBS =& class_loader('DBSessionHandler', 'classes'); |
| 538 | 530 | session_set_save_handler($DBS, true); |
| 539 | 531 | $logger->info('session save path: ' . get_config('session_save_path')); |
| 540 | - } |
|
| 541 | - else{ |
|
| 532 | + } else{ |
|
| 542 | 533 | show_error('Invalid session handler configuration'); |
| 543 | 534 | } |
| 544 | 535 | $lifetime = get_config('session_cookie_lifetime', 0); |
@@ -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 | } |