@@ -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; |
@@ -48,16 +48,14 @@ discard block |
||
| 48 | 48 | require_once CONFIG_PATH . 'config_pagination.php'; |
| 49 | 49 | if (empty($config) || ! is_array($config)){ |
| 50 | 50 | show_error('No configuration found in ' . CONFIG_PATH . 'config_pagination.php'); |
| 51 | - } |
|
| 52 | - else{ |
|
| 51 | + } else{ |
|
| 53 | 52 | $config = array_merge($config, $overwriteConfig); |
| 54 | 53 | $this->config = $config; |
| 55 | 54 | //put it gobally |
| 56 | 55 | Config::setAll($config); |
| 57 | 56 | unset($config); |
| 58 | 57 | } |
| 59 | - } |
|
| 60 | - else{ |
|
| 58 | + } else{ |
|
| 61 | 59 | show_error('Unable to find the pagination configuration file'); |
| 62 | 60 | } |
| 63 | 61 | } |
@@ -115,18 +113,15 @@ discard block |
||
| 115 | 113 | $query = ''; |
| 116 | 114 | if ($queryString == ''){ |
| 117 | 115 | $query = '?' . $pageQueryName . '='; |
| 118 | - } |
|
| 119 | - else{ |
|
| 116 | + } else{ |
|
| 120 | 117 | $tab = explode($pageQueryName . '=', $queryString); |
| 121 | 118 | $nb = count($tab); |
| 122 | 119 | if ($nb == 1){ |
| 123 | 120 | $query = '?' . $queryString . '&' . $pageQueryName . '='; |
| 124 | - } |
|
| 125 | - else{ |
|
| 121 | + } else{ |
|
| 126 | 122 | if ($tab[0] == ''){ |
| 127 | 123 | $query = '?' . $pageQueryName . '='; |
| 128 | - } |
|
| 129 | - else{ |
|
| 124 | + } else{ |
|
| 130 | 125 | $query = '?' . $tab[0] . '' . $pageQueryName . '='; |
| 131 | 126 | } |
| 132 | 127 | } |
@@ -180,11 +175,9 @@ discard block |
||
| 180 | 175 | $navbar = null; |
| 181 | 176 | if ($currentPageNumber == 1){ |
| 182 | 177 | $navbar .= $this->buildPaginationLinkForFirstPage($begin, $end, $currentPageNumber); |
| 183 | - } |
|
| 184 | - else if ($currentPageNumber > 1 && $currentPageNumber < $numberOfPage){ |
|
| 178 | + } else if ($currentPageNumber > 1 && $currentPageNumber < $numberOfPage){ |
|
| 185 | 179 | $navbar .= $this->buildPaginationLinkForMiddlePage($begin, $end, $currentPageNumber); |
| 186 | - } |
|
| 187 | - else if ($currentPageNumber == $numberOfPage){ |
|
| 180 | + } else if ($currentPageNumber == $numberOfPage){ |
|
| 188 | 181 | $navbar .= $this->buildPaginationLinkForLastPage($begin, $end, $currentPageNumber); |
| 189 | 182 | } |
| 190 | 183 | $navbar = $this->config['pagination_open'] . $navbar . $this->config['pagination_close']; |
@@ -205,20 +198,17 @@ discard block |
||
| 205 | 198 | if ($numberOfLink % 2 == 0){ |
| 206 | 199 | $start = $currentPageNumber - ($numberOfLink / 2) + 1; |
| 207 | 200 | $end = $currentPageNumber + ($numberOfLink / 2); |
| 208 | - } |
|
| 209 | - else{ |
|
| 201 | + } else{ |
|
| 210 | 202 | $start = $currentPageNumber - floor($numberOfLink / 2); |
| 211 | 203 | $end = $currentPageNumber + floor($numberOfLink / 2); |
| 212 | 204 | } |
| 213 | 205 | if ($start <= 1){ |
| 214 | 206 | $begin = 1; |
| 215 | 207 | $end = $numberOfLink; |
| 216 | - } |
|
| 217 | - else if ($start > 1 && $end < $numberOfPage){ |
|
| 208 | + } else if ($start > 1 && $end < $numberOfPage){ |
|
| 218 | 209 | $begin = $start; |
| 219 | 210 | $end = $end; |
| 220 | - } |
|
| 221 | - else{ |
|
| 211 | + } else{ |
|
| 222 | 212 | $begin = ($numberOfPage - $numberOfLink) + 1; |
| 223 | 213 | $end = $numberOfPage; |
| 224 | 214 | } |
@@ -245,8 +235,7 @@ discard block |
||
| 245 | 235 | for($i = $begin; $i <= $end; $i++){ |
| 246 | 236 | if ($i == $currentPageNumber){ |
| 247 | 237 | $navbar .= $this->config['active_link_open'] . $currentPageNumber . $this->config['active_link_close']; |
| 248 | - } |
|
| 249 | - else{ |
|
| 238 | + } else{ |
|
| 250 | 239 | $navbar .= $this->config['digit_open'] |
| 251 | 240 | . '<a href="' . $query . $i . '" ' . attributes_to_string($this->config['attributes']) . '>' . $i . '</a>' |
| 252 | 241 | . $this->config['digit_close']; |
@@ -274,8 +263,7 @@ discard block |
||
| 274 | 263 | for($i = $begin; $i <= $end; $i++){ |
| 275 | 264 | if ($i == $currentPageNumber){ |
| 276 | 265 | $navbar .= $this->config['active_link_open'] . $currentPageNumber . $this->config['active_link_close']; |
| 277 | - } |
|
| 278 | - else{ |
|
| 266 | + } else{ |
|
| 279 | 267 | $navbar .= $this->config['digit_open'] |
| 280 | 268 | . '<a href="' . $query . $i . '"' . attributes_to_string($this->config['attributes']) . '>' . $i .'</a>' |
| 281 | 269 | . $this->config['digit_close']; |
@@ -303,8 +291,7 @@ discard block |
||
| 303 | 291 | $navbar .= $this->config['active_link_open'] |
| 304 | 292 | . $currentPageNumber |
| 305 | 293 | . $this->config['active_link_close']; |
| 306 | - } |
|
| 307 | - else{ |
|
| 294 | + } else{ |
|
| 308 | 295 | $navbar .= $this->config['digit_open'] |
| 309 | 296 | . '<a href="' . $query . $i . '"' . attributes_to_string($this->config['attributes']) . '>' . $i . '</a>' |
| 310 | 297 | . $this->config['digit_close']; |
@@ -210,8 +210,7 @@ discard block |
||
| 210 | 210 | if($moduleViewPath){ |
| 211 | 211 | $path = $moduleViewPath; |
| 212 | 212 | $logger->info('Found view [' . $view . '] in module [' .$module. '], the file path is [' .$moduleViewPath. '] we will used it'); |
| 213 | - } |
|
| 214 | - else{ |
|
| 213 | + } else{ |
|
| 215 | 214 | $logger->info('Cannot find view [' . $view . '] in module [' .$module. '] using the default location'); |
| 216 | 215 | } |
| 217 | 216 | |
@@ -335,8 +334,7 @@ discard block |
||
| 335 | 334 | $output = ob_get_clean(); |
| 336 | 335 | self::sendHeaders(404); |
| 337 | 336 | echo $output; |
| 338 | - } |
|
| 339 | - else{ |
|
| 337 | + } else{ |
|
| 340 | 338 | show_error('The 404 view [' .$path. '] does not exist'); |
| 341 | 339 | } |
| 342 | 340 | } |
@@ -359,8 +357,7 @@ discard block |
||
| 359 | 357 | $output = ob_get_clean(); |
| 360 | 358 | self::sendHeaders(503); |
| 361 | 359 | echo $output; |
| 362 | - } |
|
| 363 | - else{ |
|
| 360 | + } else{ |
|
| 364 | 361 | //can't use show_error() at this time because some dependencies not yet loaded and to prevent loop |
| 365 | 362 | set_http_status_header(503); |
| 366 | 363 | echo 'The error view [' . $path . '] does not exist'; |
@@ -148,8 +148,7 @@ discard block |
||
| 148 | 148 | public function __construct(Database $db = null){ |
| 149 | 149 | if (is_object($db)){ |
| 150 | 150 | $this->setDatabaseInstance($db); |
| 151 | - } |
|
| 152 | - else{ |
|
| 151 | + } else{ |
|
| 153 | 152 | $obj = & get_instance(); |
| 154 | 153 | if (isset($obj->database) && is_object($obj->database)){ |
| 155 | 154 | /** |
@@ -265,8 +264,7 @@ discard block |
||
| 265 | 264 | $this->trigger('after_create', $insert_id); |
| 266 | 265 | //if the table doesn't have the auto increment field or sequence, the value of 0 will be returned |
| 267 | 266 | return ! $insert_id ? true : $insert_id; |
| 268 | - } |
|
| 269 | - else |
|
| 267 | + } else |
|
| 270 | 268 | { |
| 271 | 269 | return FALSE; |
| 272 | 270 | } |
@@ -303,8 +301,7 @@ discard block |
||
| 303 | 301 | $result = $this->_database->update($data, $escape); |
| 304 | 302 | $this->trigger('after_update', array($data, $result)); |
| 305 | 303 | return $result; |
| 306 | - } |
|
| 307 | - else |
|
| 304 | + } else |
|
| 308 | 305 | { |
| 309 | 306 | return FALSE; |
| 310 | 307 | } |
@@ -327,8 +324,7 @@ discard block |
||
| 327 | 324 | $result = $this->_database->update($data, $escape); |
| 328 | 325 | $this->trigger('after_update', array($data, $result)); |
| 329 | 326 | return $result; |
| 330 | - } |
|
| 331 | - else |
|
| 327 | + } else |
|
| 332 | 328 | { |
| 333 | 329 | return FALSE; |
| 334 | 330 | } |
@@ -345,8 +341,7 @@ discard block |
||
| 345 | 341 | if (is_array($args[1])){ |
| 346 | 342 | $data = array_pop($args); |
| 347 | 343 | } |
| 348 | - } |
|
| 349 | - else if (count($args) == 3){ |
|
| 344 | + } else if (count($args) == 3){ |
|
| 350 | 345 | if (is_array($args[2])){ |
| 351 | 346 | $data = array_pop($args); |
| 352 | 347 | } |
@@ -387,8 +382,7 @@ discard block |
||
| 387 | 382 | { |
| 388 | 383 | $this->getQueryBuilder()->from($this->_table); |
| 389 | 384 | $result = $this->_database->update(array( $this->soft_delete_key => TRUE )); |
| 390 | - } |
|
| 391 | - else |
|
| 385 | + } else |
|
| 392 | 386 | { |
| 393 | 387 | $this->getQueryBuilder()->from($this->_table); |
| 394 | 388 | $result = $this->_database->delete(); |
@@ -411,8 +405,7 @@ discard block |
||
| 411 | 405 | { |
| 412 | 406 | $this->getQueryBuilder()->from($this->_table); |
| 413 | 407 | $result = $this->_database->update(array( $this->soft_delete_key => TRUE )); |
| 414 | - } |
|
| 415 | - else |
|
| 408 | + } else |
|
| 416 | 409 | { |
| 417 | 410 | $this->getQueryBuilder()->from($this->_table); |
| 418 | 411 | $result = $this->_database->delete(); |
@@ -433,8 +426,7 @@ discard block |
||
| 433 | 426 | { |
| 434 | 427 | $this->getQueryBuilder()->from($this->_table); |
| 435 | 428 | $result = $this->_database->update(array( $this->soft_delete_key => TRUE )); |
| 436 | - } |
|
| 437 | - else |
|
| 429 | + } else |
|
| 438 | 430 | { |
| 439 | 431 | $this->getQueryBuilder()->from($this->_table); |
| 440 | 432 | $result = $this->_database->delete(); |
@@ -496,8 +488,7 @@ discard block |
||
| 496 | 488 | if (count($args) == 2) |
| 497 | 489 | { |
| 498 | 490 | list($key, $value) = $args; |
| 499 | - } |
|
| 500 | - else |
|
| 491 | + } else |
|
| 501 | 492 | { |
| 502 | 493 | $key = $this->primary_key; |
| 503 | 494 | $value = $args[0]; |
@@ -649,8 +640,7 @@ discard block |
||
| 649 | 640 | if (is_object($row)) |
| 650 | 641 | { |
| 651 | 642 | $row->created_at = date('Y-m-d H:i:s'); |
| 652 | - } |
|
| 653 | - else |
|
| 643 | + } else |
|
| 654 | 644 | { |
| 655 | 645 | $row['created_at'] = date('Y-m-d H:i:s'); |
| 656 | 646 | } |
@@ -662,8 +652,7 @@ discard block |
||
| 662 | 652 | if (is_object($row)) |
| 663 | 653 | { |
| 664 | 654 | $row->updated_at = date('Y-m-d H:i:s'); |
| 665 | - } |
|
| 666 | - else |
|
| 655 | + } else |
|
| 667 | 656 | { |
| 668 | 657 | $row['updated_at'] = date('Y-m-d H:i:s'); |
| 669 | 658 | } |
@@ -690,8 +679,7 @@ discard block |
||
| 690 | 679 | if (is_array($row)) |
| 691 | 680 | { |
| 692 | 681 | $row[$column] = unserialize($row[$column]); |
| 693 | - } |
|
| 694 | - else |
|
| 682 | + } else |
|
| 695 | 683 | { |
| 696 | 684 | $row->$column = unserialize($row->$column); |
| 697 | 685 | } |
@@ -711,8 +699,7 @@ discard block |
||
| 711 | 699 | if (isset($row->$attr)){ |
| 712 | 700 | unset($row->$attr); |
| 713 | 701 | } |
| 714 | - } |
|
| 715 | - else |
|
| 702 | + } else |
|
| 716 | 703 | { |
| 717 | 704 | if (isset($row[$attr])){ |
| 718 | 705 | unset($row[$attr]); |
@@ -812,8 +799,7 @@ discard block |
||
| 812 | 799 | { |
| 813 | 800 | $this->getQueryBuilder()->orderBy($key, $value); |
| 814 | 801 | } |
| 815 | - } |
|
| 816 | - else |
|
| 802 | + } else |
|
| 817 | 803 | { |
| 818 | 804 | $this->getQueryBuilder()->orderBy($criteria, $order); |
| 819 | 805 | } |
@@ -844,8 +830,7 @@ discard block |
||
| 844 | 830 | { |
| 845 | 831 | $relationship = $value; |
| 846 | 832 | $options = array( 'primary_key' => $value . '_id', 'model' => $value . '_model' ); |
| 847 | - } |
|
| 848 | - else |
|
| 833 | + } else |
|
| 849 | 834 | { |
| 850 | 835 | $relationship = $key; |
| 851 | 836 | $options = $value; |
@@ -855,15 +840,13 @@ discard block |
||
| 855 | 840 | { |
| 856 | 841 | if (is_object($this->loaderInstance)){ |
| 857 | 842 | $this->loaderInstance->model($options['model'], $relationship . '_model'); |
| 858 | - } |
|
| 859 | - else{ |
|
| 843 | + } else{ |
|
| 860 | 844 | Loader::model($options['model'], $relationship . '_model'); |
| 861 | 845 | } |
| 862 | 846 | if (is_object($row)) |
| 863 | 847 | { |
| 864 | 848 | $row->{$relationship} = $this->{$relationship . '_model'}->get($row->{$options['primary_key']}); |
| 865 | - } |
|
| 866 | - else |
|
| 849 | + } else |
|
| 867 | 850 | { |
| 868 | 851 | $row[$relationship] = $this->{$relationship . '_model'}->get($row[$options['primary_key']]); |
| 869 | 852 | } |
@@ -883,8 +866,7 @@ discard block |
||
| 883 | 866 | { |
| 884 | 867 | $relationship = $value; |
| 885 | 868 | $options = array( 'primary_key' => $this->_table . '_id', 'model' => $value . '_model' ); |
| 886 | - } |
|
| 887 | - else |
|
| 869 | + } else |
|
| 888 | 870 | { |
| 889 | 871 | $relationship = $key; |
| 890 | 872 | $options = $value; |
@@ -894,15 +876,13 @@ discard block |
||
| 894 | 876 | { |
| 895 | 877 | if (is_object($this->loaderInstance)){ |
| 896 | 878 | $this->loaderInstance->model($options['model'], $relationship . '_model'); |
| 897 | - } |
|
| 898 | - else{ |
|
| 879 | + } else{ |
|
| 899 | 880 | Loader::model($options['model'], $relationship . '_model'); |
| 900 | 881 | } |
| 901 | 882 | if (is_object($row)) |
| 902 | 883 | { |
| 903 | 884 | $row->{$relationship} = $this->{$relationship . '_model'}->get_many_by($options['primary_key'], $row->{$this->primary_key}); |
| 904 | - } |
|
| 905 | - else |
|
| 885 | + } else |
|
| 906 | 886 | { |
| 907 | 887 | $row[$relationship] = $this->{$relationship . '_model'}->get_many_by($options['primary_key'], $row[$this->primary_key]); |
| 908 | 888 | } |
@@ -970,14 +950,12 @@ discard block |
||
| 970 | 950 | if (is_array($filter)) |
| 971 | 951 | { |
| 972 | 952 | $this->getQueryBuilder()->in($field, $filter); |
| 973 | - } |
|
| 974 | - else |
|
| 953 | + } else |
|
| 975 | 954 | { |
| 976 | 955 | if (is_int($field)) |
| 977 | 956 | { |
| 978 | 957 | $this->getQueryBuilder()->where($filter); |
| 979 | - } |
|
| 980 | - else |
|
| 958 | + } else |
|
| 981 | 959 | { |
| 982 | 960 | $this->getQueryBuilder()->where($field, $filter); |
| 983 | 961 | } |
@@ -994,33 +972,27 @@ discard block |
||
| 994 | 972 | if (count($params) == 1 && is_array($params[0])) |
| 995 | 973 | { |
| 996 | 974 | $this->_set_where_array($params[0]); |
| 997 | - } |
|
| 998 | - else if (count($params) == 1) |
|
| 975 | + } else if (count($params) == 1) |
|
| 999 | 976 | { |
| 1000 | 977 | $this->getQueryBuilder()->where($params[0]); |
| 1001 | - } |
|
| 1002 | - else if (count($params) == 2) |
|
| 978 | + } else if (count($params) == 2) |
|
| 1003 | 979 | { |
| 1004 | 980 | if (is_array($params[1])) |
| 1005 | 981 | { |
| 1006 | 982 | $this->getQueryBuilder()->in($params[0], $params[1]); |
| 1007 | - } |
|
| 1008 | - else |
|
| 983 | + } else |
|
| 1009 | 984 | { |
| 1010 | 985 | $this->getQueryBuilder()->where($params[0], $params[1]); |
| 1011 | 986 | } |
| 1012 | - } |
|
| 1013 | - else if (count($params) == 3) |
|
| 987 | + } else if (count($params) == 3) |
|
| 1014 | 988 | { |
| 1015 | 989 | $this->getQueryBuilder()->where($params[0], $params[1], $params[2]); |
| 1016 | - } |
|
| 1017 | - else |
|
| 990 | + } else |
|
| 1018 | 991 | { |
| 1019 | 992 | if (is_array($params[1])) |
| 1020 | 993 | { |
| 1021 | 994 | $this->getQueryBuilder()->in($params[0], $params[1]); |
| 1022 | - } |
|
| 1023 | - else |
|
| 995 | + } else |
|
| 1024 | 996 | { |
| 1025 | 997 | $this->getQueryBuilder()->where($params[0], $params[1]); |
| 1026 | 998 | } |
@@ -222,16 +222,14 @@ discard block |
||
| 222 | 222 | ); |
| 223 | 223 | if (isset($http_status[$code])){ |
| 224 | 224 | $text = $http_status[$code]; |
| 225 | - } |
|
| 226 | - else{ |
|
| 225 | + } else{ |
|
| 227 | 226 | show_error('No HTTP status text found for your code please check it.'); |
| 228 | 227 | } |
| 229 | 228 | } |
| 230 | 229 | |
| 231 | 230 | if (strpos(php_sapi_name(), 'cgi') === 0){ |
| 232 | 231 | header('Status: ' . $code . ' ' . $text, TRUE); |
| 233 | - } |
|
| 234 | - else{ |
|
| 232 | + } else{ |
|
| 235 | 233 | $proto = 'HTTP/1.1'; |
| 236 | 234 | if(isset($_SERVER['SERVER_PROTOCOL'])){ |
| 237 | 235 | $proto = $_SERVER['SERVER_PROTOCOL']; |
@@ -323,8 +321,7 @@ discard block |
||
| 323 | 321 | function php_exception_handler($ex){ |
| 324 | 322 | if (str_ireplace(array('off', 'none', 'no', 'false', 'null'), '', ini_get('display_errors'))){ |
| 325 | 323 | show_error('An exception is occured in file '. $ex->getFile() .' at line ' . $ex->getLine() . ' raison : ' . $ex->getMessage(), 'PHP Exception #' . $ex->getCode()); |
| 326 | - } |
|
| 327 | - else{ |
|
| 324 | + } else{ |
|
| 328 | 325 | save_to_log('error', 'An exception is occured in file ' . $ex->getFile() . ' at line ' . $ex->getLine() . ' raison : ' . $ex->getMessage(), 'PHP Exception'); |
| 329 | 326 | } |
| 330 | 327 | return true; |
@@ -440,15 +437,13 @@ discard block |
||
| 440 | 437 | function clean_input($str){ |
| 441 | 438 | if (is_array($str)){ |
| 442 | 439 | $str = array_map('clean_input', $str); |
| 443 | - } |
|
| 444 | - else if (is_object($str)){ |
|
| 440 | + } else if (is_object($str)){ |
|
| 445 | 441 | $obj = $str; |
| 446 | 442 | foreach ($str as $var => $value) { |
| 447 | 443 | $obj->$var = clean_input($value); |
| 448 | 444 | } |
| 449 | 445 | $str = $obj; |
| 450 | - } |
|
| 451 | - else{ |
|
| 446 | + } else{ |
|
| 452 | 447 | $str = htmlspecialchars(strip_tags($str), ENT_QUOTES, 'UTF-8'); |
| 453 | 448 | } |
| 454 | 449 | return $str; |
@@ -521,8 +516,7 @@ discard block |
||
| 521 | 516 | session_save_path($sessionSavePath); |
| 522 | 517 | $logger->info('Session save path: ' . $sessionSavePath); |
| 523 | 518 | } |
| 524 | - } |
|
| 525 | - else if ($sessionHandler == 'database'){ |
|
| 519 | + } else if ($sessionHandler == 'database'){ |
|
| 526 | 520 | //load database session handle library |
| 527 | 521 | //Database Session handler Model |
| 528 | 522 | require_once CORE_CLASSES_MODEL_PATH . 'DBSessionHandlerModel.php'; |
@@ -530,8 +524,7 @@ discard block |
||
| 530 | 524 | $DBS =& class_loader('DBSessionHandler', 'classes'); |
| 531 | 525 | session_set_save_handler($DBS, true); |
| 532 | 526 | $logger->info('session save path: ' . get_config('session_save_path')); |
| 533 | - } |
|
| 534 | - else{ |
|
| 527 | + } else{ |
|
| 535 | 528 | show_error('Invalid session handler configuration'); |
| 536 | 529 | } |
| 537 | 530 | $lifetime = get_config('session_cookie_lifetime', 0); |
@@ -49,8 +49,7 @@ |
||
| 49 | 49 | while(($module = readdir($moduleDir)) !== false){ |
| 50 | 50 | if (preg_match('/^([a-z0-9-_]+)$/i', $module) && is_dir(MODULE_PATH . $module)){ |
| 51 | 51 | self::$list[] = $module; |
| 52 | - } |
|
| 53 | - else{ |
|
| 52 | + } else{ |
|
| 54 | 53 | $logger->info('Skipping [' .$module. '], may be this is not a directory or does not exists or is invalid name'); |
| 55 | 54 | } |
| 56 | 55 | } |