@@ -921,20 +921,15 @@ |
||
| 921 | 921 | if(preg_match('#trident/([0-9\.]+);#i', $this->_agent, $aresult)){ |
| 922 | 922 | if($aresult[1] == '3.1'){ |
| 923 | 923 | $this->setVersion('7.0'); |
| 924 | - } |
|
| 925 | - else if($aresult[1] == '4.0'){ |
|
| 924 | + } else if($aresult[1] == '4.0'){ |
|
| 926 | 925 | $this->setVersion('8.0'); |
| 927 | - } |
|
| 928 | - else if($aresult[1] == '5.0'){ |
|
| 926 | + } else if($aresult[1] == '5.0'){ |
|
| 929 | 927 | $this->setVersion('9.0'); |
| 930 | - } |
|
| 931 | - else if($aresult[1] == '6.0'){ |
|
| 928 | + } else if($aresult[1] == '6.0'){ |
|
| 932 | 929 | $this->setVersion('10.0'); |
| 933 | - } |
|
| 934 | - else if($aresult[1] == '7.0'){ |
|
| 930 | + } else if($aresult[1] == '7.0'){ |
|
| 935 | 931 | $this->setVersion('11.0'); |
| 936 | - } |
|
| 937 | - else if($aresult[1] == '8.0'){ |
|
| 932 | + } else if($aresult[1] == '8.0'){ |
|
| 938 | 933 | $this->setVersion('11.0'); |
| 939 | 934 | } |
| 940 | 935 | } |
@@ -55,17 +55,13 @@ |
||
| 55 | 55 | |
| 56 | 56 | if (isset($_SERVER["HTTP_CLIENT_IP"])) { |
| 57 | 57 | $ip = $_SERVER["HTTP_CLIENT_IP"]; |
| 58 | - } |
|
| 59 | - else if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) { |
|
| 58 | + } else if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) { |
|
| 60 | 59 | $ip = $_SERVER["HTTP_X_FORWARDED_FOR"]; |
| 61 | - } |
|
| 62 | - else if (isset($_SERVER["HTTP_X_FORWARDED"])) { |
|
| 60 | + } else if (isset($_SERVER["HTTP_X_FORWARDED"])) { |
|
| 63 | 61 | $ip = $_SERVER["HTTP_X_FORWARDED"]; |
| 64 | - } |
|
| 65 | - else if (isset($_SERVER["HTTP_FORWARDED_FOR"])) { |
|
| 62 | + } else if (isset($_SERVER["HTTP_FORWARDED_FOR"])) { |
|
| 66 | 63 | $ip = $_SERVER["HTTP_FORWARDED_FOR"]; |
| 67 | - } |
|
| 68 | - else if (isset($_SERVER["HTTP_FORWARDED"])) { |
|
| 64 | + } else if (isset($_SERVER["HTTP_FORWARDED"])) { |
|
| 69 | 65 | $ip = $_SERVER["HTTP_FORWARDED"]; |
| 70 | 66 | } |
| 71 | 67 | |
@@ -224,16 +224,14 @@ discard block |
||
| 224 | 224 | ); |
| 225 | 225 | if(isset($http_status[$code])){ |
| 226 | 226 | $text = $http_status[$code]; |
| 227 | - } |
|
| 228 | - else{ |
|
| 227 | + } else{ |
|
| 229 | 228 | show_error('No HTTP status text found for your code please check it.'); |
| 230 | 229 | } |
| 231 | 230 | } |
| 232 | 231 | |
| 233 | 232 | if(strpos(php_sapi_name(), 'cgi') === 0){ |
| 234 | 233 | header('Status: ' . $code . ' ' . $text, TRUE); |
| 235 | - } |
|
| 236 | - else{ |
|
| 234 | + } else{ |
|
| 237 | 235 | $proto = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1'; |
| 238 | 236 | header($proto . ' ' . $code . ' ' . $text, TRUE, $code); |
| 239 | 237 | } |
@@ -271,11 +269,9 @@ discard block |
||
| 271 | 269 | */ |
| 272 | 270 | if(isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off'){ |
| 273 | 271 | return true; |
| 274 | - } |
|
| 275 | - else if(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https'){ |
|
| 272 | + } else if(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https'){ |
|
| 276 | 273 | return true; |
| 277 | - } |
|
| 278 | - else if(isset($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off'){ |
|
| 274 | + } else if(isset($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off'){ |
|
| 279 | 275 | return true; |
| 280 | 276 | } |
| 281 | 277 | return false; |
@@ -313,8 +309,7 @@ discard block |
||
| 313 | 309 | function php_exception_handler($ex){ |
| 314 | 310 | if (str_ireplace(array('off', 'none', 'no', 'false', 'null'), '', ini_get('display_errors'))){ |
| 315 | 311 | show_error('An exception is occured in file '. $ex->getFile() .' at line ' . $ex->getLine() . ' raison : ' . $ex->getMessage(), 'PHP Exception #' . $ex->getCode()); |
| 316 | - } |
|
| 317 | - else{ |
|
| 312 | + } else{ |
|
| 318 | 313 | save_to_log('error', 'An exception is occured in file ' . $ex->getFile() . ' at line ' . $ex->getLine() . ' raison : ' . $ex->getMessage(), 'PHP Exception'); |
| 319 | 314 | } |
| 320 | 315 | exit(1); |
@@ -431,15 +426,13 @@ discard block |
||
| 431 | 426 | function clean_input($str){ |
| 432 | 427 | if(is_array($str)){ |
| 433 | 428 | $str = array_map('clean_input', $str); |
| 434 | - } |
|
| 435 | - else if(is_object($str)){ |
|
| 429 | + } else if(is_object($str)){ |
|
| 436 | 430 | $obj = $str; |
| 437 | 431 | foreach ($str as $var => $value) { |
| 438 | 432 | $obj->$var = clean_input($value); |
| 439 | 433 | } |
| 440 | 434 | $str = $obj; |
| 441 | - } |
|
| 442 | - else{ |
|
| 435 | + } else{ |
|
| 443 | 436 | $str = htmlspecialchars(strip_tags($str), ENT_QUOTES, 'UTF-8'); |
| 444 | 437 | } |
| 445 | 438 | return $str; |
@@ -510,8 +503,7 @@ discard block |
||
| 510 | 503 | session_save_path($sessionSavePath); |
| 511 | 504 | $logger->info('Session save path: ' . $sessionSavePath); |
| 512 | 505 | } |
| 513 | - } |
|
| 514 | - else if($sessionHandler == 'database'){ |
|
| 506 | + } else if($sessionHandler == 'database'){ |
|
| 515 | 507 | //load database session handle library |
| 516 | 508 | //Model |
| 517 | 509 | require_once CORE_CLASSES_MODEL_PATH . 'Model.php'; |
@@ -522,8 +514,7 @@ discard block |
||
| 522 | 514 | $DBS =& class_loader('DBSessionHandler', 'classes'); |
| 523 | 515 | session_set_save_handler($DBS, true); |
| 524 | 516 | $logger->info('session save path: ' . get_config('session_save_path')); |
| 525 | - } |
|
| 526 | - else{ |
|
| 517 | + } else{ |
|
| 527 | 518 | show_error('Invalid session handler configuration'); |
| 528 | 519 | } |
| 529 | 520 | $lifetime = get_config('session_cookie_lifetime', 0); |
@@ -42,8 +42,7 @@ |
||
| 42 | 42 | if(isset($classesMap[$class])){ |
| 43 | 43 | if(file_exists($classesMap[$class])){ |
| 44 | 44 | include_once $classesMap[$class]; |
| 45 | - } |
|
| 46 | - else{ |
|
| 45 | + } else{ |
|
| 47 | 46 | echo 'File for class ' . $class . ' not found'; |
| 48 | 47 | } |
| 49 | 48 | } |
@@ -178,15 +178,13 @@ |
||
| 178 | 178 | function clean_input($str){ |
| 179 | 179 | if(is_array($str)){ |
| 180 | 180 | $str = array_map('clean_input', $str); |
| 181 | - } |
|
| 182 | - else if(is_object($str)){ |
|
| 181 | + } else if(is_object($str)){ |
|
| 183 | 182 | $obj = $str; |
| 184 | 183 | foreach ($str as $var => $value) { |
| 185 | 184 | $obj->$var = clean_input($value); |
| 186 | 185 | } |
| 187 | 186 | $str = $obj; |
| 188 | - } |
|
| 189 | - else{ |
|
| 187 | + } else{ |
|
| 190 | 188 | $str = htmlspecialchars(strip_tags($str), ENT_QUOTES, 'UTF-8'); |
| 191 | 189 | } |
| 192 | 190 | return $str; |
@@ -87,8 +87,7 @@ discard block |
||
| 87 | 87 | */ |
| 88 | 88 | if(is_object($logger)){ |
| 89 | 89 | $this->setLogger($logger); |
| 90 | - } |
|
| 91 | - else{ |
|
| 90 | + } else{ |
|
| 92 | 91 | $this->logger =& class_loader('Log', 'classes'); |
| 93 | 92 | $this->logger->setLogger('Library::DBSessionHandler'); |
| 94 | 93 | } |
@@ -197,8 +196,7 @@ discard block |
||
| 197 | 196 | if($this->getLoader()){ |
| 198 | 197 | $this->getLoader()->functions('user_agent'); |
| 199 | 198 | $this->getLoader()->library('Browser'); |
| 200 | - } |
|
| 201 | - else{ |
|
| 199 | + } else{ |
|
| 202 | 200 | Loader::functions('user_agent'); |
| 203 | 201 | Loader::library('Browser'); |
| 204 | 202 | } |
@@ -237,8 +235,7 @@ discard block |
||
| 237 | 235 | if($this->getLoader()){ |
| 238 | 236 | $this->getLoader()->functions('user_agent'); |
| 239 | 237 | $this->getLoader()->library('Browser'); |
| 240 | - } |
|
| 241 | - else{ |
|
| 238 | + } else{ |
|
| 242 | 239 | Loader::functions('user_agent'); |
| 243 | 240 | Loader::library('Browser'); |
| 244 | 241 | } |
@@ -264,8 +261,7 @@ discard block |
||
| 264 | 261 | //update |
| 265 | 262 | unset($params[$columns['sid']]); |
| 266 | 263 | $instance->update($sid, $params); |
| 267 | - } |
|
| 268 | - else{ |
|
| 264 | + } else{ |
|
| 269 | 265 | $this->logger->info('Session data for SID: ' . $sid . ' not yet exists, insert it now'); |
| 270 | 266 | $instance->insert($params); |
| 271 | 267 | } |
@@ -143,8 +143,7 @@ discard block |
||
| 143 | 143 | public function __construct(Database $db = null){ |
| 144 | 144 | if(is_object($db)){ |
| 145 | 145 | $this->setDatabaseInstance($db); |
| 146 | - } |
|
| 147 | - else{ |
|
| 146 | + } else{ |
|
| 148 | 147 | $obj = & get_instance(); |
| 149 | 148 | if(isset($obj->database) && is_object($obj->database)){ |
| 150 | 149 | /** |
@@ -256,8 +255,7 @@ discard block |
||
| 256 | 255 | $insert_id = $this->_database->insertId(); |
| 257 | 256 | $this->trigger('after_create', $insert_id); |
| 258 | 257 | return $insert_id; |
| 259 | - } |
|
| 260 | - else |
|
| 258 | + } else |
|
| 261 | 259 | { |
| 262 | 260 | return FALSE; |
| 263 | 261 | } |
@@ -294,8 +292,7 @@ discard block |
||
| 294 | 292 | ->update($data, $escape); |
| 295 | 293 | $this->trigger('after_update', array($data, $result)); |
| 296 | 294 | return $result; |
| 297 | - } |
|
| 298 | - else |
|
| 295 | + } else |
|
| 299 | 296 | { |
| 300 | 297 | return FALSE; |
| 301 | 298 | } |
@@ -318,8 +315,7 @@ discard block |
||
| 318 | 315 | ->update($data, $escape); |
| 319 | 316 | $this->trigger('after_update', array($data, $result)); |
| 320 | 317 | return $result; |
| 321 | - } |
|
| 322 | - else |
|
| 318 | + } else |
|
| 323 | 319 | { |
| 324 | 320 | return FALSE; |
| 325 | 321 | } |
@@ -336,8 +332,7 @@ discard block |
||
| 336 | 332 | if(is_array($args[1])){ |
| 337 | 333 | $data = array_pop($args); |
| 338 | 334 | } |
| 339 | - } |
|
| 340 | - else if(count($args) == 3){ |
|
| 335 | + } else if(count($args) == 3){ |
|
| 341 | 336 | if(is_array($args[2])){ |
| 342 | 337 | $data = array_pop($args); |
| 343 | 338 | } |
@@ -349,8 +344,7 @@ discard block |
||
| 349 | 344 | $result = $this->_database->from($this->_table)->update($data); |
| 350 | 345 | $this->trigger('after_update', array($data, $result)); |
| 351 | 346 | return $result; |
| 352 | - } |
|
| 353 | - else |
|
| 347 | + } else |
|
| 354 | 348 | { |
| 355 | 349 | return FALSE; |
| 356 | 350 | } |
@@ -377,8 +371,7 @@ discard block |
||
| 377 | 371 | if ($this->soft_delete) |
| 378 | 372 | { |
| 379 | 373 | $result = $this->_database->from($this->_table)->update(array( $this->soft_delete_key => TRUE )); |
| 380 | - } |
|
| 381 | - else |
|
| 374 | + } else |
|
| 382 | 375 | { |
| 383 | 376 | $result = $this->_database->from($this->_table)->delete(); |
| 384 | 377 | } |
@@ -398,8 +391,7 @@ discard block |
||
| 398 | 391 | if ($this->soft_delete) |
| 399 | 392 | { |
| 400 | 393 | $result = $this->_database->from($this->_table)->update(array( $this->soft_delete_key => TRUE )); |
| 401 | - } |
|
| 402 | - else |
|
| 394 | + } else |
|
| 403 | 395 | { |
| 404 | 396 | $result = $this->_database->from($this->_table)->delete(); |
| 405 | 397 | } |
@@ -417,8 +409,7 @@ discard block |
||
| 417 | 409 | if ($this->soft_delete) |
| 418 | 410 | { |
| 419 | 411 | $result = $this->_database->from($this->_table)->update(array( $this->soft_delete_key => TRUE )); |
| 420 | - } |
|
| 421 | - else |
|
| 412 | + } else |
|
| 422 | 413 | { |
| 423 | 414 | $result = $this->_database->from($this->_table)->delete(); |
| 424 | 415 | } |
@@ -463,8 +454,7 @@ discard block |
||
| 463 | 454 | { |
| 464 | 455 | $relationship = $value; |
| 465 | 456 | $options = array( 'primary_key' => $value . '_id', 'model' => $value . '_model' ); |
| 466 | - } |
|
| 467 | - else |
|
| 457 | + } else |
|
| 468 | 458 | { |
| 469 | 459 | $relationship = $key; |
| 470 | 460 | $options = $value; |
@@ -474,15 +464,13 @@ discard block |
||
| 474 | 464 | { |
| 475 | 465 | if(is_object($this->loaderInstance)){ |
| 476 | 466 | $this->loaderInstance->model($options['model'], $relationship . '_model'); |
| 477 | - } |
|
| 478 | - else{ |
|
| 467 | + } else{ |
|
| 479 | 468 | Loader::model($options['model'], $relationship . '_model'); |
| 480 | 469 | } |
| 481 | 470 | if (is_object($row)) |
| 482 | 471 | { |
| 483 | 472 | $row->{$relationship} = $this->{$relationship . '_model'}->get($row->{$options['primary_key']}); |
| 484 | - } |
|
| 485 | - else |
|
| 473 | + } else |
|
| 486 | 474 | { |
| 487 | 475 | $row[$relationship] = $this->{$relationship . '_model'}->get($row[$options['primary_key']]); |
| 488 | 476 | } |
@@ -495,8 +483,7 @@ discard block |
||
| 495 | 483 | { |
| 496 | 484 | $relationship = $value; |
| 497 | 485 | $options = array( 'primary_key' => $this->_table . '_id', 'model' => $value . '_model' ); |
| 498 | - } |
|
| 499 | - else |
|
| 486 | + } else |
|
| 500 | 487 | { |
| 501 | 488 | $relationship = $key; |
| 502 | 489 | $options = $value; |
@@ -506,15 +493,13 @@ discard block |
||
| 506 | 493 | { |
| 507 | 494 | if(is_object($this->loaderInstance)){ |
| 508 | 495 | $this->loaderInstance->model($options['model'], $relationship . '_model'); |
| 509 | - } |
|
| 510 | - else{ |
|
| 496 | + } else{ |
|
| 511 | 497 | Loader::model($options['model'], $relationship . '_model'); |
| 512 | 498 | } |
| 513 | 499 | if (is_object($row)) |
| 514 | 500 | { |
| 515 | 501 | $row->{$relationship} = $this->{$relationship . '_model'}->get_many_by($options['primary_key'], $row->{$this->primary_key}); |
| 516 | - } |
|
| 517 | - else |
|
| 502 | + } else |
|
| 518 | 503 | { |
| 519 | 504 | $row[$relationship] = $this->{$relationship . '_model'}->get_many_by($options['primary_key'], $row[$this->primary_key]); |
| 520 | 505 | } |
@@ -536,8 +521,7 @@ discard block |
||
| 536 | 521 | if(count($args) == 2) |
| 537 | 522 | { |
| 538 | 523 | list($key, $value) = $args; |
| 539 | - } |
|
| 540 | - else |
|
| 524 | + } else |
|
| 541 | 525 | { |
| 542 | 526 | $key = $this->primary_key; |
| 543 | 527 | $value = $args[0]; |
@@ -685,8 +669,7 @@ discard block |
||
| 685 | 669 | if (is_object($row)) |
| 686 | 670 | { |
| 687 | 671 | $row->created_at = date('Y-m-d H:i:s'); |
| 688 | - } |
|
| 689 | - else |
|
| 672 | + } else |
|
| 690 | 673 | { |
| 691 | 674 | $row['created_at'] = date('Y-m-d H:i:s'); |
| 692 | 675 | } |
@@ -699,8 +682,7 @@ discard block |
||
| 699 | 682 | if (is_object($row)) |
| 700 | 683 | { |
| 701 | 684 | $row->updated_at = date('Y-m-d H:i:s'); |
| 702 | - } |
|
| 703 | - else |
|
| 685 | + } else |
|
| 704 | 686 | { |
| 705 | 687 | $row['updated_at'] = date('Y-m-d H:i:s'); |
| 706 | 688 | } |
@@ -727,8 +709,7 @@ discard block |
||
| 727 | 709 | if (is_array($row)) |
| 728 | 710 | { |
| 729 | 711 | $row[$column] = unserialize($row[$column]); |
| 730 | - } |
|
| 731 | - else |
|
| 712 | + } else |
|
| 732 | 713 | { |
| 733 | 714 | $row->$column = unserialize($row->$column); |
| 734 | 715 | } |
@@ -748,8 +729,7 @@ discard block |
||
| 748 | 729 | if(isset($row->$attr)){ |
| 749 | 730 | unset($row->$attr); |
| 750 | 731 | } |
| 751 | - } |
|
| 752 | - else |
|
| 732 | + } else |
|
| 753 | 733 | { |
| 754 | 734 | if(isset($row[$attr])){ |
| 755 | 735 | unset($row[$attr]); |
@@ -828,8 +808,7 @@ discard block |
||
| 828 | 808 | { |
| 829 | 809 | $this->_database->orderBy($key, $value); |
| 830 | 810 | } |
| 831 | - } |
|
| 832 | - else |
|
| 811 | + } else |
|
| 833 | 812 | { |
| 834 | 813 | $this->_database->orderBy($criteria, $order); |
| 835 | 814 | } |
@@ -887,8 +866,7 @@ discard block |
||
| 887 | 866 | $fv = null; |
| 888 | 867 | if(is_object($this->formValidationInstance)){ |
| 889 | 868 | $fv = $this->formValidationInstance; |
| 890 | - } |
|
| 891 | - else{ |
|
| 869 | + } else{ |
|
| 892 | 870 | Loader::library('FormValidation'); |
| 893 | 871 | $fv = $this->formvalidation; |
| 894 | 872 | $this->setFormValidation($fv); |
@@ -901,17 +879,14 @@ discard block |
||
| 901 | 879 | if ($fv->run()) |
| 902 | 880 | { |
| 903 | 881 | return $data; |
| 904 | - } |
|
| 905 | - else |
|
| 882 | + } else |
|
| 906 | 883 | { |
| 907 | 884 | return FALSE; |
| 908 | 885 | } |
| 909 | - } |
|
| 910 | - else { |
|
| 886 | + } else { |
|
| 911 | 887 | return $data; |
| 912 | 888 | } |
| 913 | - } |
|
| 914 | - else |
|
| 889 | + } else |
|
| 915 | 890 | { |
| 916 | 891 | return $data; |
| 917 | 892 | } |
@@ -930,46 +905,38 @@ discard block |
||
| 930 | 905 | if (is_array($filter)) |
| 931 | 906 | { |
| 932 | 907 | $this->_database->in($field, $filter); |
| 933 | - } |
|
| 934 | - else |
|
| 908 | + } else |
|
| 935 | 909 | { |
| 936 | 910 | if (is_int($field)) |
| 937 | 911 | { |
| 938 | 912 | $this->_database->where($filter); |
| 939 | - } |
|
| 940 | - else |
|
| 913 | + } else |
|
| 941 | 914 | { |
| 942 | 915 | $this->_database->where($field, $filter); |
| 943 | 916 | } |
| 944 | 917 | } |
| 945 | 918 | } |
| 946 | - } |
|
| 947 | - else if (count($params) == 1) |
|
| 919 | + } else if (count($params) == 1) |
|
| 948 | 920 | { |
| 949 | 921 | $this->_database->where($params[0]); |
| 950 | - } |
|
| 951 | - else if(count($params) == 2) |
|
| 922 | + } else if(count($params) == 2) |
|
| 952 | 923 | { |
| 953 | 924 | if (is_array($params[1])) |
| 954 | 925 | { |
| 955 | 926 | $this->_database->in($params[0], $params[1]); |
| 956 | - } |
|
| 957 | - else |
|
| 927 | + } else |
|
| 958 | 928 | { |
| 959 | 929 | $this->_database->where($params[0], $params[1]); |
| 960 | 930 | } |
| 961 | - } |
|
| 962 | - else if(count($params) == 3) |
|
| 931 | + } else if(count($params) == 3) |
|
| 963 | 932 | { |
| 964 | 933 | $this->_database->where($params[0], $params[1], $params[2]); |
| 965 | - } |
|
| 966 | - else |
|
| 934 | + } else |
|
| 967 | 935 | { |
| 968 | 936 | if (is_array($params[1])) |
| 969 | 937 | { |
| 970 | 938 | $this->_database->in($params[0], $params[1]); |
| 971 | - } |
|
| 972 | - else |
|
| 939 | + } else |
|
| 973 | 940 | { |
| 974 | 941 | $this->_database->where($params[0], $params[1]); |
| 975 | 942 | } |
@@ -148,8 +148,7 @@ discard block |
||
| 148 | 148 | if(isset($path[1])){ |
| 149 | 149 | $instance = strtolower($path[1]); |
| 150 | 150 | } |
| 151 | - } |
|
| 152 | - else{ |
|
| 151 | + } else{ |
|
| 153 | 152 | $instance = strtolower($class); |
| 154 | 153 | } |
| 155 | 154 | } |
@@ -169,8 +168,7 @@ discard block |
||
| 169 | 168 | $searchModuleName = $path[0]; |
| 170 | 169 | $class = ucfirst($path[1]); |
| 171 | 170 | } |
| 172 | - } |
|
| 173 | - else{ |
|
| 171 | + } else{ |
|
| 174 | 172 | $class = ucfirst($class); |
| 175 | 173 | } |
| 176 | 174 | |
@@ -181,8 +179,7 @@ discard block |
||
| 181 | 179 | if($moduleModelFilePath){ |
| 182 | 180 | $logger->info('Found model [' . $class . '] from module [' .$searchModuleName. '], the file path is [' .$moduleModelFilePath. '] we will used it'); |
| 183 | 181 | $classFilePath = $moduleModelFilePath; |
| 184 | - } |
|
| 185 | - else{ |
|
| 182 | + } else{ |
|
| 186 | 183 | $logger->info('Cannot find model [' . $class . '] from modules using the default location'); |
| 187 | 184 | } |
| 188 | 185 | $logger->info('The model file path to be loaded is [' . $classFilePath . ']'); |
@@ -194,12 +191,10 @@ discard block |
||
| 194 | 191 | $obj->{$instance} = $c; |
| 195 | 192 | static::$loaded[$instance] = $class; |
| 196 | 193 | $logger->info('Model [' . $class . '] --> ' . $classFilePath . ' loaded successfully.'); |
| 197 | - } |
|
| 198 | - else{ |
|
| 194 | + } else{ |
|
| 199 | 195 | show_error('The file '.$classFilePath.' exists but does not contain the class ['. $class . ']'); |
| 200 | 196 | } |
| 201 | - } |
|
| 202 | - else{ |
|
| 197 | + } else{ |
|
| 203 | 198 | show_error('Unable to find the model [' . $class . ']'); |
| 204 | 199 | } |
| 205 | 200 | } |
@@ -227,8 +222,7 @@ discard block |
||
| 227 | 222 | if(isset($path[1])){ |
| 228 | 223 | $instance = strtolower($path[1]); |
| 229 | 224 | } |
| 230 | - } |
|
| 231 | - else{ |
|
| 225 | + } else{ |
|
| 232 | 226 | $instance = strtolower($class); |
| 233 | 227 | } |
| 234 | 228 | } |
@@ -254,8 +248,7 @@ discard block |
||
| 254 | 248 | $libraryFilePath = CORE_LIBRARY_PATH . $file; |
| 255 | 249 | $class = ucfirst($class); |
| 256 | 250 | $logger->info('This library is a system library'); |
| 257 | - } |
|
| 258 | - else{ |
|
| 251 | + } else{ |
|
| 259 | 252 | $logger->info('This library is not a system library'); |
| 260 | 253 | //first check if this library is in the module |
| 261 | 254 | $logger->debug('Checking library [' . $class . '] from module list ...'); |
@@ -267,8 +260,7 @@ discard block |
||
| 267 | 260 | $searchModuleName = $path[0]; |
| 268 | 261 | $class = ucfirst($path[1]); |
| 269 | 262 | } |
| 270 | - } |
|
| 271 | - else{ |
|
| 263 | + } else{ |
|
| 272 | 264 | $class = ucfirst($class); |
| 273 | 265 | } |
| 274 | 266 | if(! $searchModuleName && !empty($obj->moduleName)){ |
@@ -278,8 +270,7 @@ discard block |
||
| 278 | 270 | if($moduleLibraryPath){ |
| 279 | 271 | $logger->info('Found library [' . $class . '] from module [' .$searchModuleName. '], the file path is [' .$moduleLibraryPath. '] we will used it'); |
| 280 | 272 | $libraryFilePath = $moduleLibraryPath; |
| 281 | - } |
|
| 282 | - else{ |
|
| 273 | + } else{ |
|
| 283 | 274 | $logger->info('Cannot find library [' . $class . '] from modules using the default location'); |
| 284 | 275 | } |
| 285 | 276 | } |
@@ -303,12 +294,10 @@ discard block |
||
| 303 | 294 | $obj->{$instance} = $c; |
| 304 | 295 | static::$loaded[$instance] = $class; |
| 305 | 296 | $logger->info('Library [' . $class . '] --> ' . $libraryFilePath . ' loaded successfully.'); |
| 306 | - } |
|
| 307 | - else{ |
|
| 297 | + } else{ |
|
| 308 | 298 | show_error('The file '.$libraryFilePath.' exists but does not contain the class '.$class); |
| 309 | 299 | } |
| 310 | - } |
|
| 311 | - else{ |
|
| 300 | + } else{ |
|
| 312 | 301 | show_error('Unable to find library class [' . $class . ']'); |
| 313 | 302 | } |
| 314 | 303 | } |
@@ -352,8 +341,7 @@ discard block |
||
| 352 | 341 | if($moduleFunctionPath){ |
| 353 | 342 | $logger->info('Found helper [' . $function . '] from module [' .$searchModuleName. '], the file path is [' .$moduleFunctionPath. '] we will used it'); |
| 354 | 343 | $functionFilePath = $moduleFunctionPath; |
| 355 | - } |
|
| 356 | - else{ |
|
| 344 | + } else{ |
|
| 357 | 345 | $logger->info('Cannot find helper [' . $function . '] from modules using the default location'); |
| 358 | 346 | } |
| 359 | 347 | if(! $functionFilePath){ |
@@ -372,8 +360,7 @@ discard block |
||
| 372 | 360 | require_once $functionFilePath; |
| 373 | 361 | static::$loaded['function_' . $function] = $functionFilePath; |
| 374 | 362 | $logger->info('Helper [' . $function . '] --> ' . $functionFilePath . ' loaded successfully.'); |
| 375 | - } |
|
| 376 | - else{ |
|
| 363 | + } else{ |
|
| 377 | 364 | show_error('Unable to find helper file [' . $file . ']'); |
| 378 | 365 | } |
| 379 | 366 | } |
@@ -417,8 +404,7 @@ discard block |
||
| 417 | 404 | if($moduleConfigPath){ |
| 418 | 405 | $logger->info('Found config [' . $filename . '] from module [' .$searchModuleName. '], the file path is [' .$moduleConfigPath. '] we will used it'); |
| 419 | 406 | $configFilePath = $moduleConfigPath; |
| 420 | - } |
|
| 421 | - else{ |
|
| 407 | + } else{ |
|
| 422 | 408 | $logger->info('Cannot find config [' . $filename . '] from modules using the default location'); |
| 423 | 409 | } |
| 424 | 410 | $logger->info('The config file path to be loaded is [' . $configFilePath . ']'); |
@@ -426,12 +412,10 @@ discard block |
||
| 426 | 412 | require_once $configFilePath; |
| 427 | 413 | if(! empty($config) && is_array($config)){ |
| 428 | 414 | Config::setAll($config); |
| 429 | - } |
|
| 430 | - else{ |
|
| 415 | + } else{ |
|
| 431 | 416 | show_error('No configuration found in ['. $configFilePath . ']'); |
| 432 | 417 | } |
| 433 | - } |
|
| 434 | - else{ |
|
| 418 | + } else{ |
|
| 435 | 419 | show_error('Unable to find config file ['. $configFilePath . ']'); |
| 436 | 420 | } |
| 437 | 421 | static::$loaded['config_' . $filename] = $configFilePath; |
@@ -489,8 +473,7 @@ discard block |
||
| 489 | 473 | if($moduleLanguagePath){ |
| 490 | 474 | $logger->info('Found language [' . $language . '] from module [' .$searchModuleName. '], the file path is [' .$moduleLanguagePath. '] we will used it'); |
| 491 | 475 | $languageFilePath = $moduleLanguagePath; |
| 492 | - } |
|
| 493 | - else{ |
|
| 476 | + } else{ |
|
| 494 | 477 | $logger->info('Cannot find language [' . $language . '] from modules using the default location'); |
| 495 | 478 | } |
| 496 | 479 | if(! $languageFilePath){ |
@@ -517,8 +500,7 @@ discard block |
||
| 517 | 500 | } |
| 518 | 501 | static::$loaded['lang_' . $language] = $languageFilePath; |
| 519 | 502 | $logger->info('Language [' . $language . '] --> ' . $languageFilePath . ' loaded successfully.'); |
| 520 | - } |
|
| 521 | - else{ |
|
| 503 | + } else{ |
|
| 522 | 504 | show_error('Unable to find language file [' . $file . ']'); |
| 523 | 505 | } |
| 524 | 506 | } |
@@ -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 | } |
@@ -134,8 +132,7 @@ discard block |
||
| 134 | 132 | $this->logger->error('Can not write cache data into file [' .$filePath. '] for the key ['. $key .'], return false'); |
| 135 | 133 | fclose($handle); |
| 136 | 134 | return false; |
| 137 | - } |
|
| 138 | - else{ |
|
| 135 | + } else{ |
|
| 139 | 136 | $this->logger->info('Cache data saved into file [' .$filePath. '] for the key ['. $key .']'); |
| 140 | 137 | fclose($handle); |
| 141 | 138 | chmod($filePath, 0640); |
@@ -157,8 +154,7 @@ discard block |
||
| 157 | 154 | if(! file_exists($filePath)){ |
| 158 | 155 | $this->logger->info('This cache file does not exists skipping'); |
| 159 | 156 | return false; |
| 160 | - } |
|
| 161 | - else{ |
|
| 157 | + } else{ |
|
| 162 | 158 | $this->logger->info('Found cache file [' .$filePath. '] remove it'); |
| 163 | 159 | @unlink($filePath); |
| 164 | 160 | return true; |
@@ -180,16 +176,14 @@ discard block |
||
| 180 | 176 | if(! file_exists($filePath)){ |
| 181 | 177 | $this->logger->info('This cache file does not exists skipping'); |
| 182 | 178 | return false; |
| 183 | - } |
|
| 184 | - else{ |
|
| 179 | + } else{ |
|
| 185 | 180 | $this->logger->info('Found cache file [' .$filePath. '] check the validity'); |
| 186 | 181 | $data = file_get_contents($filePath); |
| 187 | 182 | $data = @unserialize($this->compressCacheData ? gzinflate($data) : $data); |
| 188 | 183 | if(! $data){ |
| 189 | 184 | $this->logger->warning('Can not unserialize the cache data for file [' . $filePath . ']'); |
| 190 | 185 | return false; |
| 191 | - } |
|
| 192 | - else{ |
|
| 186 | + } else{ |
|
| 193 | 187 | $this->logger->info('This cache data is OK check for expire'); |
| 194 | 188 | if(isset($data['expire']) && $data['expire'] > time()){ |
| 195 | 189 | $this->logger->info('This cache not yet expired return cache informations'); |
@@ -199,8 +193,7 @@ discard block |
||
| 199 | 193 | 'ttl' => $data['ttl'] |
| 200 | 194 | ); |
| 201 | 195 | return $info; |
| 202 | - } |
|
| 203 | - else{ |
|
| 196 | + } else{ |
|
| 204 | 197 | $this->logger->info('This cache already expired return false'); |
| 205 | 198 | return false; |
| 206 | 199 | } |
@@ -217,8 +210,7 @@ discard block |
||
| 217 | 210 | $list = glob(CACHE_PATH . '*.cache'); |
| 218 | 211 | if(! $list){ |
| 219 | 212 | $this->logger->info('No cache files were found skipping'); |
| 220 | - } |
|
| 221 | - else{ |
|
| 213 | + } else{ |
|
| 222 | 214 | $this->logger->info('Found [' . count($list) . '] cache files to remove if expired'); |
| 223 | 215 | foreach ($list as $file) { |
| 224 | 216 | $this->logger->debug('Processing the cache file [' . $file . ']'); |
@@ -226,12 +218,10 @@ discard block |
||
| 226 | 218 | $data = @unserialize($this->compressCacheData ? gzinflate($data) : $data); |
| 227 | 219 | if(! $data){ |
| 228 | 220 | $this->logger->warning('Can not unserialize the cache data for file [' . $file . ']'); |
| 229 | - } |
|
| 230 | - else if(time() > $data['expire']){ |
|
| 221 | + } else if(time() > $data['expire']){ |
|
| 231 | 222 | $this->logger->info('The cache data for file [' . $file . '] already expired remove it'); |
| 232 | 223 | @unlink($file); |
| 233 | - } |
|
| 234 | - else{ |
|
| 224 | + } else{ |
|
| 235 | 225 | $this->logger->info('The cache data for file [' . $file . '] not yet expired skip it'); |
| 236 | 226 | } |
| 237 | 227 | } |
@@ -246,8 +236,7 @@ discard block |
||
| 246 | 236 | $list = glob(CACHE_PATH . '*.cache'); |
| 247 | 237 | if(! $list){ |
| 248 | 238 | $this->logger->info('No cache files were found skipping'); |
| 249 | - } |
|
| 250 | - else{ |
|
| 239 | + } else{ |
|
| 251 | 240 | $this->logger->info('Found [' . count($list) . '] cache files to remove'); |
| 252 | 241 | foreach ($list as $file) { |
| 253 | 242 | $this->logger->debug('Processing the cache file [' . $file . ']'); |
@@ -274,8 +263,7 @@ discard block |
||
| 274 | 263 | |
| 275 | 264 | $this->logger->warning('The zlib extension is not loaded set cache compress data to FALSE'); |
| 276 | 265 | $this->compressCacheData = false; |
| 277 | - } |
|
| 278 | - else{ |
|
| 266 | + } else{ |
|
| 279 | 267 | $this->compressCacheData = $status; |
| 280 | 268 | } |
| 281 | 269 | return $this; |