@@ -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. ']'); |
@@ -87,8 +86,7 @@ discard block |
||
| 87 | 86 | if(! Session::exists($key) || Session::get($keyExpire) <= $currentTime){ |
| 88 | 87 | $logger->warning('The CSRF session data is not valide'); |
| 89 | 88 | return false; |
| 90 | - } |
|
| 91 | - else{ |
|
| 89 | + } else{ |
|
| 92 | 90 | //perform form data |
| 93 | 91 | //need use request->query() for best retrieve |
| 94 | 92 | //super instance |
@@ -97,8 +95,7 @@ discard block |
||
| 97 | 95 | if(! $token || $token !== Session::get($key) || Session::get($keyExpire) <= $currentTime){ |
| 98 | 96 | $logger->warning('The CSRF data [' .$token. '] is not valide may be attacker do his job'); |
| 99 | 97 | return false; |
| 100 | - } |
|
| 101 | - else{ |
|
| 98 | + } else{ |
|
| 102 | 99 | $logger->info('The CSRF data [' .$token. '] is valide the form data is safe continue'); |
| 103 | 100 | //remove the token from session |
| 104 | 101 | Session::clear($key); |
@@ -127,8 +124,7 @@ discard block |
||
| 127 | 124 | $logger->info('IP address ' . $ip . ' allowed using the wildcard "*" or the full IP'); |
| 128 | 125 | //wildcard to access all ip address |
| 129 | 126 | return; |
| 130 | - } |
|
| 131 | - else{ |
|
| 127 | + } else{ |
|
| 132 | 128 | // go through all whitelisted ips |
| 133 | 129 | foreach ($list as $ipaddr) { |
| 134 | 130 | // find the wild card * in whitelisted ip (f.e. find position in "127.0.*" or "127*") |
@@ -153,8 +149,7 @@ discard block |
||
| 153 | 149 | show_error('Access to this application is not allowed'); |
| 154 | 150 | } |
| 155 | 151 | } |
| 156 | - } |
|
| 157 | - else{ |
|
| 152 | + } else{ |
|
| 158 | 153 | $logger->info('Whitelist IP access is not enabled in the configuration, ignore checking'); |
| 159 | 154 | } |
| 160 | 155 | } |
@@ -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 Event){ |
| 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){ |
@@ -179,8 +179,7 @@ discard block |
||
| 179 | 179 | require CONFIG_PATH . 'database.php'; |
| 180 | 180 | if(empty($db) || !is_array($db)){ |
| 181 | 181 | show_error('No database configuration found in database.php'); |
| 182 | - } |
|
| 183 | - else{ |
|
| 182 | + } else{ |
|
| 184 | 183 | if(! empty($overwriteConfig)){ |
| 185 | 184 | $db = array_merge($db, $overwriteConfig); |
| 186 | 185 | } |
@@ -201,11 +200,9 @@ discard block |
||
| 201 | 200 | $dsn = $config['driver'] . ':host=' . $config['hostname'] . ';' |
| 202 | 201 | . (($config['port']) != '' ? 'port=' . $config['port'] . ';' : '') |
| 203 | 202 | . 'dbname=' . $config['database']; |
| 204 | - } |
|
| 205 | - else if ($config['driver'] == 'sqlite'){ |
|
| 203 | + } else if ($config['driver'] == 'sqlite'){ |
|
| 206 | 204 | $dsn = 'sqlite:' . $config['database']; |
| 207 | - } |
|
| 208 | - else if($config['driver'] == 'oracle'){ |
|
| 205 | + } else if($config['driver'] == 'oracle'){ |
|
| 209 | 206 | $dsn = 'oci:dbname=' . $config['host'] . '/' . $config['database']; |
| 210 | 207 | } |
| 211 | 208 | |
@@ -214,8 +211,7 @@ discard block |
||
| 214 | 211 | $this->pdo->exec("SET NAMES '" . $config['charset'] . "' COLLATE '" . $config['collation'] . "'"); |
| 215 | 212 | $this->pdo->exec("SET CHARACTER SET '" . $config['charset'] . "'"); |
| 216 | 213 | $this->pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ); |
| 217 | - } |
|
| 218 | - catch (PDOException $e){ |
|
| 214 | + } catch (PDOException $e){ |
|
| 219 | 215 | $this->logger->fatal($e->getMessage()); |
| 220 | 216 | show_error('Cannot connect to Database.'); |
| 221 | 217 | } |
@@ -223,8 +219,7 @@ discard block |
||
| 223 | 219 | $this->temporaryCacheTtl = $this->cacheTtl; |
| 224 | 220 | $this->logger->info('The database configuration are listed below: ' . stringfy_vars(array_merge($config, array('password' => string_hidden($config['password']))))); |
| 225 | 221 | } |
| 226 | - } |
|
| 227 | - else{ |
|
| 222 | + } else{ |
|
| 228 | 223 | show_error('Unable to find database configuration'); |
| 229 | 224 | } |
| 230 | 225 | } |
@@ -241,8 +236,7 @@ discard block |
||
| 241 | 236 | $froms .= $this->prefix . $key . ', '; |
| 242 | 237 | } |
| 243 | 238 | $this->from = rtrim($froms, ', '); |
| 244 | - } |
|
| 245 | - else{ |
|
| 239 | + } else{ |
|
| 246 | 240 | $this->from = $this->prefix . $table; |
| 247 | 241 | } |
| 248 | 242 | return $this; |
@@ -348,8 +342,7 @@ discard block |
||
| 348 | 342 | } |
| 349 | 343 | if (is_null($this->join)){ |
| 350 | 344 | $this->join = ' ' . $type . 'JOIN' . ' ' . $table . ' ON ' . $on; |
| 351 | - } |
|
| 352 | - else{ |
|
| 345 | + } else{ |
|
| 353 | 346 | $this->join = $this->join . ' ' . $type . 'JOIN' . ' ' . $table . ' ON ' . $on; |
| 354 | 347 | } |
| 355 | 348 | return $this; |
@@ -420,12 +413,10 @@ discard block |
||
| 420 | 413 | foreach($field as $f){ |
| 421 | 414 | $this->whereIsNull($f, $andOr); |
| 422 | 415 | } |
| 423 | - } |
|
| 424 | - else{ |
|
| 416 | + } else{ |
|
| 425 | 417 | if (! $this->where){ |
| 426 | 418 | $this->where = $field.' IS NULL '; |
| 427 | - } |
|
| 428 | - else{ |
|
| 419 | + } else{ |
|
| 429 | 420 | $this->where = $this->where . ' '.$andOr.' ' . $field.' IS NULL '; |
| 430 | 421 | } |
| 431 | 422 | } |
@@ -443,12 +434,10 @@ discard block |
||
| 443 | 434 | foreach($field as $f){ |
| 444 | 435 | $this->whereIsNotNull($f, $andOr); |
| 445 | 436 | } |
| 446 | - } |
|
| 447 | - else{ |
|
| 437 | + } else{ |
|
| 448 | 438 | if (! $this->where){ |
| 449 | 439 | $this->where = $field.' IS NOT NULL '; |
| 450 | - } |
|
| 451 | - else{ |
|
| 440 | + } else{ |
|
| 452 | 441 | $this->where = $this->where . ' '.$andOr.' ' . $field.' IS NOT NULL '; |
| 453 | 442 | } |
| 454 | 443 | } |
@@ -475,8 +464,7 @@ discard block |
||
| 475 | 464 | $_where[] = $type . $column . '=' . ($escape ? $this->escape($data) : $data); |
| 476 | 465 | } |
| 477 | 466 | $where = implode(' '.$andOr.' ', $_where); |
| 478 | - } |
|
| 479 | - else{ |
|
| 467 | + } else{ |
|
| 480 | 468 | if(is_array($op)){ |
| 481 | 469 | $x = explode('?', $where); |
| 482 | 470 | $w = ''; |
@@ -489,14 +477,12 @@ discard block |
||
| 489 | 477 | } |
| 490 | 478 | } |
| 491 | 479 | $where = $w; |
| 492 | - } |
|
| 493 | - else if (! in_array((string)$op, $this->operatorList)){ |
|
| 480 | + } else if (! in_array((string)$op, $this->operatorList)){ |
|
| 494 | 481 | if(is_null($op)){ |
| 495 | 482 | $op = ''; |
| 496 | 483 | } |
| 497 | 484 | $where = $type . $where . ' = ' . ($escape ? $this->escape($op) : $op); |
| 498 | - } |
|
| 499 | - else{ |
|
| 485 | + } else{ |
|
| 500 | 486 | if(is_null($val)){ |
| 501 | 487 | $val = ''; |
| 502 | 488 | } |
@@ -505,12 +491,10 @@ discard block |
||
| 505 | 491 | } |
| 506 | 492 | if (is_null($this->where)){ |
| 507 | 493 | $this->where = $where; |
| 508 | - } |
|
| 509 | - else{ |
|
| 494 | + } else{ |
|
| 510 | 495 | if(substr($this->where, -1) == '('){ |
| 511 | 496 | $this->where = $this->where . ' ' . $where; |
| 512 | - } |
|
| 513 | - else{ |
|
| 497 | + } else{ |
|
| 514 | 498 | $this->where = $this->where . ' '.$andOr.' ' . $where; |
| 515 | 499 | } |
| 516 | 500 | } |
@@ -554,12 +538,10 @@ discard block |
||
| 554 | 538 | public function groupStart($type = '', $andOr = ' AND'){ |
| 555 | 539 | if (is_null($this->where)){ |
| 556 | 540 | $this->where = $type . ' ('; |
| 557 | - } |
|
| 558 | - else{ |
|
| 541 | + } else{ |
|
| 559 | 542 | if(substr($this->where, -1) == '('){ |
| 560 | 543 | $this->where .= $type . ' ('; |
| 561 | - } |
|
| 562 | - else{ |
|
| 544 | + } else{ |
|
| 563 | 545 | $this->where .= $andOr . ' ' . $type . ' ('; |
| 564 | 546 | } |
| 565 | 547 | } |
@@ -623,12 +605,10 @@ discard block |
||
| 623 | 605 | $keys = implode(', ', $_keys); |
| 624 | 606 | if (is_null($this->where)){ |
| 625 | 607 | $this->where = $field . ' ' . $type . 'IN (' . $keys . ')'; |
| 626 | - } |
|
| 627 | - else{ |
|
| 608 | + } else{ |
|
| 628 | 609 | if(substr($this->where, -1) == '('){ |
| 629 | 610 | $this->where = $this->where . ' ' . $field . ' '.$type.'IN (' . $keys . ')'; |
| 630 | - } |
|
| 631 | - else{ |
|
| 611 | + } else{ |
|
| 632 | 612 | $this->where = $this->where . ' ' . $andOr . ' ' . $field . ' '.$type.'IN (' . $keys . ')'; |
| 633 | 613 | } |
| 634 | 614 | } |
@@ -682,12 +662,10 @@ discard block |
||
| 682 | 662 | } |
| 683 | 663 | if (is_null($this->where)){ |
| 684 | 664 | $this->where = $field . ' ' . $type . 'BETWEEN ' . ($escape ? $this->escape($value1) : $value1) . ' AND ' . ($escape ? $this->escape($value2) : $value2); |
| 685 | - } |
|
| 686 | - else{ |
|
| 665 | + } else{ |
|
| 687 | 666 | if(substr($this->where, -1) == '('){ |
| 688 | 667 | $this->where = $this->where . ' ' . $field . ' ' . $type . 'BETWEEN ' . ($escape ? $this->escape($value1) : $value1) . ' AND ' . ($escape ? $this->escape($value2) : $value2); |
| 689 | - } |
|
| 690 | - else{ |
|
| 668 | + } else{ |
|
| 691 | 669 | $this->where = $this->where . ' ' . $andOr . ' ' . $field . ' ' . $type . 'BETWEEN ' . ($escape ? $this->escape($value1) : $value1) . ' AND ' . ($escape ? $this->escape($value2) : $value2); |
| 692 | 670 | } |
| 693 | 671 | } |
@@ -737,12 +715,10 @@ discard block |
||
| 737 | 715 | $like = $escape ? $this->escape($data) : $data; |
| 738 | 716 | if (is_null($this->where)){ |
| 739 | 717 | $this->where = $field . ' ' . $type . 'LIKE ' . $like; |
| 740 | - } |
|
| 741 | - else{ |
|
| 718 | + } else{ |
|
| 742 | 719 | if(substr($this->where, -1) == '('){ |
| 743 | 720 | $this->where = $this->where . ' ' . $field . ' ' . $type . 'LIKE ' . $like; |
| 744 | - } |
|
| 745 | - else{ |
|
| 721 | + } else{ |
|
| 746 | 722 | $this->where = $this->where . ' '.$andOr.' ' . $field . ' ' . $type . 'LIKE ' . $like; |
| 747 | 723 | } |
| 748 | 724 | } |
@@ -789,8 +765,7 @@ discard block |
||
| 789 | 765 | } |
| 790 | 766 | if (! is_null($limitEnd)){ |
| 791 | 767 | $this->limit = $limit . ', ' . $limitEnd; |
| 792 | - } |
|
| 793 | - else{ |
|
| 768 | + } else{ |
|
| 794 | 769 | $this->limit = $limit; |
| 795 | 770 | } |
| 796 | 771 | return $this; |
@@ -805,12 +780,10 @@ discard block |
||
| 805 | 780 | public function orderBy($orderBy, $orderDir = ' ASC'){ |
| 806 | 781 | if (! is_null($orderDir)){ |
| 807 | 782 | $this->orderBy = ! $this->orderBy ? ($orderBy . ' ' . strtoupper($orderDir)) : $this->orderBy . ', ' . $orderBy . ' ' . strtoupper($orderDir); |
| 808 | - } |
|
| 809 | - else{ |
|
| 783 | + } else{ |
|
| 810 | 784 | if(stristr($orderBy, ' ') || $orderBy == 'rand()'){ |
| 811 | 785 | $this->orderBy = ! $this->orderBy ? $orderBy : $this->orderBy . ', ' . $orderBy; |
| 812 | - } |
|
| 813 | - else{ |
|
| 786 | + } else{ |
|
| 814 | 787 | $this->orderBy = ! $this->orderBy ? ($orderBy . ' ASC') : $this->orderBy . ', ' . ($orderBy . ' ASC'); |
| 815 | 788 | } |
| 816 | 789 | } |
@@ -825,8 +798,7 @@ discard block |
||
| 825 | 798 | public function groupBy($field){ |
| 826 | 799 | if(is_array($field)){ |
| 827 | 800 | $this->groupBy = implode(', ', $field); |
| 828 | - } |
|
| 829 | - else{ |
|
| 801 | + } else{ |
|
| 830 | 802 | $this->groupBy = $field; |
| 831 | 803 | } |
| 832 | 804 | return $this; |
@@ -853,14 +825,12 @@ discard block |
||
| 853 | 825 | } |
| 854 | 826 | } |
| 855 | 827 | $this->having = $w; |
| 856 | - } |
|
| 857 | - else if (! in_array($op, $this->operatorList)){ |
|
| 828 | + } else if (! in_array($op, $this->operatorList)){ |
|
| 858 | 829 | if(is_null($op)){ |
| 859 | 830 | $op = ''; |
| 860 | 831 | } |
| 861 | 832 | $this->having = $field . ' > ' . ($escape ? $this->escape($op) : $op); |
| 862 | - } |
|
| 863 | - else{ |
|
| 833 | + } else{ |
|
| 864 | 834 | if(is_null($val)){ |
| 865 | 835 | $val = ''; |
| 866 | 836 | } |
@@ -905,8 +875,7 @@ discard block |
||
| 905 | 875 | $query = $this->getAll(true); |
| 906 | 876 | if($returnSQLQueryOrResultType === true){ |
| 907 | 877 | return $query; |
| 908 | - } |
|
| 909 | - else{ |
|
| 878 | + } else{ |
|
| 910 | 879 | return $this->query( $query, false, (($returnSQLQueryOrResultType == 'array') ? true : false) ); |
| 911 | 880 | } |
| 912 | 881 | } |
@@ -945,8 +914,7 @@ discard block |
||
| 945 | 914 | |
| 946 | 915 | if($returnSQLQueryOrResultType === true){ |
| 947 | 916 | return $query; |
| 948 | - } |
|
| 949 | - else{ |
|
| 917 | + } else{ |
|
| 950 | 918 | return $this->query($query, true, (($returnSQLQueryOrResultType == 'array') ? true : false) ); |
| 951 | 919 | } |
| 952 | 920 | } |
@@ -964,8 +932,7 @@ discard block |
||
| 964 | 932 | $columns = array_keys($this->getData()); |
| 965 | 933 | $column = implode(',', $columns); |
| 966 | 934 | $val = implode(', ', $this->getData()); |
| 967 | - } |
|
| 968 | - else{ |
|
| 935 | + } else{ |
|
| 969 | 936 | $columns = array_keys($data); |
| 970 | 937 | $column = implode(',', $columns); |
| 971 | 938 | $val = implode(', ', ($escape ? array_map(array($this, 'escape'), $data) : $data)); |
@@ -977,8 +944,7 @@ discard block |
||
| 977 | 944 | if ($query){ |
| 978 | 945 | $this->insertId = $this->pdo->lastInsertId(); |
| 979 | 946 | return $this->insertId(); |
| 980 | - } |
|
| 981 | - else{ |
|
| 947 | + } else{ |
|
| 982 | 948 | return false; |
| 983 | 949 | } |
| 984 | 950 | } |
@@ -996,8 +962,7 @@ discard block |
||
| 996 | 962 | foreach ($this->getData() as $column => $val){ |
| 997 | 963 | $values[] = $column . ' = ' . $val; |
| 998 | 964 | } |
| 999 | - } |
|
| 1000 | - else{ |
|
| 965 | + } else{ |
|
| 1001 | 966 | foreach ($data as $column => $val){ |
| 1002 | 967 | $values[] = $column . '=' . ($escape ? $this->escape($val) : $val); |
| 1003 | 968 | } |
@@ -1094,8 +1059,7 @@ discard block |
||
| 1094 | 1059 | $cacheKey = md5($query . $all . $array); |
| 1095 | 1060 | $cacheInstance = $obj->cache; |
| 1096 | 1061 | $cacheContent = $cacheInstance->get($cacheKey); |
| 1097 | - } |
|
| 1098 | - else{ |
|
| 1062 | + } else{ |
|
| 1099 | 1063 | $this->logger->info('The cache is not enabled for this query or is not the SELECT query, get the result directly from real database'); |
| 1100 | 1064 | } |
| 1101 | 1065 | |
@@ -1118,8 +1082,7 @@ discard block |
||
| 1118 | 1082 | //if need return all result like list of record |
| 1119 | 1083 | if ($all){ |
| 1120 | 1084 | $this->result = ($array == false) ? $sqlQuery->fetchAll(PDO::FETCH_OBJ) : $sqlQuery->fetchAll(PDO::FETCH_ASSOC); |
| 1121 | - } |
|
| 1122 | - else{ |
|
| 1085 | + } else{ |
|
| 1123 | 1086 | $this->result = ($array == false) ? $sqlQuery->fetch(PDO::FETCH_OBJ) : $sqlQuery->fetch(PDO::FETCH_ASSOC); |
| 1124 | 1087 | } |
| 1125 | 1088 | } |
@@ -1127,15 +1090,13 @@ discard block |
||
| 1127 | 1090 | $this->logger->info('Save the result for query [' .$this->query. '] into cache for future use'); |
| 1128 | 1091 | $cacheInstance->set($cacheKey, $this->result, $cacheExpire); |
| 1129 | 1092 | } |
| 1130 | - } |
|
| 1131 | - else{ |
|
| 1093 | + } else{ |
|
| 1132 | 1094 | $error = $this->pdo->errorInfo(); |
| 1133 | 1095 | $this->error = $error[2]; |
| 1134 | 1096 | $this->logger->fatal('The database query execution got error: ' . stringfy_vars($error)); |
| 1135 | 1097 | $this->error(); |
| 1136 | 1098 | } |
| 1137 | - } |
|
| 1138 | - else if ((! $cacheContent && !$sqlSELECTQuery) || ($cacheContent && !$sqlSELECTQuery)){ |
|
| 1099 | + } else if ((! $cacheContent && !$sqlSELECTQuery) || ($cacheContent && !$sqlSELECTQuery)){ |
|
| 1139 | 1100 | $queryStr = $this->pdo->query($this->query); |
| 1140 | 1101 | if($queryStr){ |
| 1141 | 1102 | $this->result = $queryStr->rowCount() >= 0; //to test the result for the query like UPDATE, INSERT, DELETE |
@@ -1147,8 +1108,7 @@ discard block |
||
| 1147 | 1108 | $this->logger->fatal('The database query execution got error: ' . stringfy_vars($error)); |
| 1148 | 1109 | $this->error(); |
| 1149 | 1110 | } |
| 1150 | - } |
|
| 1151 | - else{ |
|
| 1111 | + } else{ |
|
| 1152 | 1112 | $this->logger->info('The result for query [' .$this->query. '] already cached use it'); |
| 1153 | 1113 | $this->result = $cacheContent; |
| 1154 | 1114 | $this->numRows = count($this->result); |
@@ -152,8 +152,7 @@ discard block |
||
| 152 | 152 | if(! headers_sent()){ |
| 153 | 153 | header('Location: '.$url); |
| 154 | 154 | exit; |
| 155 | - } |
|
| 156 | - else{ |
|
| 155 | + } else{ |
|
| 157 | 156 | echo '<script> |
| 158 | 157 | location.href = "'.$url.'"; |
| 159 | 158 | </script>'; |
@@ -202,12 +201,10 @@ discard block |
||
| 202 | 201 | if($moduleViewPath){ |
| 203 | 202 | $path = $moduleViewPath; |
| 204 | 203 | $logger->info('Found view [' . $view . '] in module [' .$mod. '], the file path is [' .$moduleViewPath. '] we will used it'); |
| 205 | - } |
|
| 206 | - else{ |
|
| 204 | + } else{ |
|
| 207 | 205 | $logger->info('Cannot find view [' . $view . '] in module [' .$mod. '] using the default location'); |
| 208 | 206 | } |
| 209 | - } |
|
| 210 | - else{ |
|
| 207 | + } else{ |
|
| 211 | 208 | $logger->info('The current request does not use module using the default location.'); |
| 212 | 209 | } |
| 213 | 210 | } |
@@ -291,8 +288,7 @@ discard block |
||
| 291 | 288 | //compress the output if is available |
| 292 | 289 | if (static::$_canCompressOutput){ |
| 293 | 290 | ob_start('ob_gzhandler'); |
| 294 | - } |
|
| 295 | - else{ |
|
| 291 | + } else{ |
|
| 296 | 292 | ob_start(); |
| 297 | 293 | } |
| 298 | 294 | static::sendHeaders(200); |
@@ -324,8 +320,7 @@ discard block |
||
| 324 | 320 | $logger->info('The cache page content is not yet expire for the URL [' . $url . '] send 304 header to browser'); |
| 325 | 321 | static::sendHeaders(304); |
| 326 | 322 | exit; |
| 327 | - } |
|
| 328 | - else{ |
|
| 323 | + } else{ |
|
| 329 | 324 | $logger->info('The cache page content is expired or the browser don\'t send the HTTP_IF_MODIFIED_SINCE header for the URL [' . $url . '] send cache headers to tell the browser'); |
| 330 | 325 | static::sendHeaders(200); |
| 331 | 326 | //get the cache content |
@@ -345,15 +340,13 @@ discard block |
||
| 345 | 340 | //compress the output if is available |
| 346 | 341 | if (static::$_canCompressOutput){ |
| 347 | 342 | ob_start('ob_gzhandler'); |
| 348 | - } |
|
| 349 | - else{ |
|
| 343 | + } else{ |
|
| 350 | 344 | ob_start(); |
| 351 | 345 | } |
| 352 | 346 | echo $content; |
| 353 | 347 | @ob_end_flush(); |
| 354 | 348 | exit; |
| 355 | - } |
|
| 356 | - else{ |
|
| 349 | + } else{ |
|
| 357 | 350 | $logger->info('The page cache content for the URL [' . $url . '] is not valid may be already expired'); |
| 358 | 351 | $cache->delete($pageCacheKey); |
| 359 | 352 | } |
@@ -394,16 +387,14 @@ discard block |
||
| 394 | 387 | //compress the output if is available |
| 395 | 388 | if (static::$_canCompressOutput){ |
| 396 | 389 | ob_start('ob_gzhandler'); |
| 397 | - } |
|
| 398 | - else{ |
|
| 390 | + } else{ |
|
| 399 | 391 | ob_start(); |
| 400 | 392 | } |
| 401 | 393 | require_once $path; |
| 402 | 394 | $output = ob_get_clean(); |
| 403 | 395 | static::sendHeaders(404); |
| 404 | 396 | echo $output; |
| 405 | - } |
|
| 406 | - else{ |
|
| 397 | + } else{ |
|
| 407 | 398 | show_error('The 404 view [' .$path. '] does not exist'); |
| 408 | 399 | } |
| 409 | 400 | } |
@@ -418,8 +409,7 @@ discard block |
||
| 418 | 409 | //compress the output if exists |
| 419 | 410 | if (static::$_canCompressOutput){ |
| 420 | 411 | ob_start('ob_gzhandler'); |
| 421 | - } |
|
| 422 | - else{ |
|
| 412 | + } else{ |
|
| 423 | 413 | ob_start(); |
| 424 | 414 | } |
| 425 | 415 | extract($data); |
@@ -427,8 +417,7 @@ discard block |
||
| 427 | 417 | $output = ob_get_clean(); |
| 428 | 418 | static::sendHeaders(503); |
| 429 | 419 | echo $output; |
| 430 | - } |
|
| 431 | - else{ |
|
| 420 | + } else{ |
|
| 432 | 421 | //can't use show_error() at this time because some dependencies not yet loaded and to prevent loop |
| 433 | 422 | set_http_status_header(503); |
| 434 | 423 | echo 'The error view [' . $path . '] does not exist'; |
@@ -209,8 +209,7 @@ |
||
| 209 | 209 | //update |
| 210 | 210 | unset($params[$columns['sid']]); |
| 211 | 211 | $instance->update($sid, $params); |
| 212 | - } |
|
| 213 | - else{ |
|
| 212 | + } else{ |
|
| 214 | 213 | $this->logger->info('Session data for SID: ' . $sid . ' not yet exists, insert it now'); |
| 215 | 214 | $instance->insert($params); |
| 216 | 215 | } |
@@ -50,8 +50,7 @@ discard block |
||
| 50 | 50 | if(! empty($autoload) && is_array($autoload)){ |
| 51 | 51 | $autoloads = $autoload; |
| 52 | 52 | unset($autoload); |
| 53 | - } |
|
| 54 | - else{ |
|
| 53 | + } else{ |
|
| 55 | 54 | show_error('No autoload configuration found in autoload.php'); |
| 56 | 55 | } |
| 57 | 56 | } |
@@ -156,8 +155,7 @@ discard block |
||
| 156 | 155 | if(isset($path[1])){ |
| 157 | 156 | $instance = strtolower($path[1]); |
| 158 | 157 | } |
| 159 | - } |
|
| 160 | - else{ |
|
| 158 | + } else{ |
|
| 161 | 159 | $instance = strtolower($class); |
| 162 | 160 | } |
| 163 | 161 | } |
@@ -177,8 +175,7 @@ discard block |
||
| 177 | 175 | $searchModuleName = $path[0]; |
| 178 | 176 | $class = ucfirst($path[1]); |
| 179 | 177 | } |
| 180 | - } |
|
| 181 | - else{ |
|
| 178 | + } else{ |
|
| 182 | 179 | $class = ucfirst($class); |
| 183 | 180 | } |
| 184 | 181 | |
@@ -189,8 +186,7 @@ discard block |
||
| 189 | 186 | if($moduleModelFilePath){ |
| 190 | 187 | $logger->info('Found model [' . $class . '] from module [' .$searchModuleName. '], the file path is [' .$moduleModelFilePath. '] we will used it'); |
| 191 | 188 | $classFilePath = $moduleModelFilePath; |
| 192 | - } |
|
| 193 | - else{ |
|
| 189 | + } else{ |
|
| 194 | 190 | $logger->info('Cannot find model [' . $class . '] from modules using the default location'); |
| 195 | 191 | } |
| 196 | 192 | $logger->info('The model file path to be loaded is [' . $classFilePath . ']'); |
@@ -202,12 +198,10 @@ discard block |
||
| 202 | 198 | $obj->{$instance} = $c; |
| 203 | 199 | static::$loaded[$instance] = $class; |
| 204 | 200 | $logger->info('Model [' . $class . '] --> ' . $classFilePath . ' loaded successfully.'); |
| 205 | - } |
|
| 206 | - else{ |
|
| 201 | + } else{ |
|
| 207 | 202 | show_error('The file '.$classFilePath.' exists but does not contain the class ['. $class . ']'); |
| 208 | 203 | } |
| 209 | - } |
|
| 210 | - else{ |
|
| 204 | + } else{ |
|
| 211 | 205 | show_error('Unable to find the model [' . $class . ']'); |
| 212 | 206 | } |
| 213 | 207 | } |
@@ -235,8 +229,7 @@ discard block |
||
| 235 | 229 | if(isset($path[1])){ |
| 236 | 230 | $instance = strtolower($path[1]); |
| 237 | 231 | } |
| 238 | - } |
|
| 239 | - else{ |
|
| 232 | + } else{ |
|
| 240 | 233 | $instance = strtolower($class); |
| 241 | 234 | } |
| 242 | 235 | } |
@@ -262,8 +255,7 @@ discard block |
||
| 262 | 255 | $libraryFilePath = CORE_LIBRARY_PATH . $file; |
| 263 | 256 | $class = ucfirst($class); |
| 264 | 257 | $logger->info('This library is a system library'); |
| 265 | - } |
|
| 266 | - else{ |
|
| 258 | + } else{ |
|
| 267 | 259 | $logger->info('This library is not a system library'); |
| 268 | 260 | //first check if this library is in the module |
| 269 | 261 | $logger->debug('Checking library [' . $class . '] from module list ...'); |
@@ -275,8 +267,7 @@ discard block |
||
| 275 | 267 | $searchModuleName = $path[0]; |
| 276 | 268 | $class = ucfirst($path[1]); |
| 277 | 269 | } |
| 278 | - } |
|
| 279 | - else{ |
|
| 270 | + } else{ |
|
| 280 | 271 | $class = ucfirst($class); |
| 281 | 272 | } |
| 282 | 273 | if(! $searchModuleName && !empty($obj->moduleName)){ |
@@ -286,8 +277,7 @@ discard block |
||
| 286 | 277 | if($moduleLibraryPath){ |
| 287 | 278 | $logger->info('Found library [' . $class . '] from module [' .$searchModuleName. '], the file path is [' .$moduleLibraryPath. '] we will used it'); |
| 288 | 279 | $libraryFilePath = $moduleLibraryPath; |
| 289 | - } |
|
| 290 | - else{ |
|
| 280 | + } else{ |
|
| 291 | 281 | $logger->info('Cannot find library [' . $class . '] from modules using the default location'); |
| 292 | 282 | } |
| 293 | 283 | } |
@@ -311,12 +301,10 @@ discard block |
||
| 311 | 301 | $obj->{$instance} = $c; |
| 312 | 302 | static::$loaded[$instance] = $class; |
| 313 | 303 | $logger->info('Library [' . $class . '] --> ' . $libraryFilePath . ' loaded successfully.'); |
| 314 | - } |
|
| 315 | - else{ |
|
| 304 | + } else{ |
|
| 316 | 305 | show_error('The file '.$libraryFilePath.' exists but does not contain the class '.$class); |
| 317 | 306 | } |
| 318 | - } |
|
| 319 | - else{ |
|
| 307 | + } else{ |
|
| 320 | 308 | show_error('Unable to find library class [' . $class . ']'); |
| 321 | 309 | } |
| 322 | 310 | } |
@@ -360,8 +348,7 @@ discard block |
||
| 360 | 348 | if($moduleFunctionPath){ |
| 361 | 349 | $logger->info('Found helper [' . $function . '] from module [' .$searchModuleName. '], the file path is [' .$moduleFunctionPath. '] we will used it'); |
| 362 | 350 | $functionFilePath = $moduleFunctionPath; |
| 363 | - } |
|
| 364 | - else{ |
|
| 351 | + } else{ |
|
| 365 | 352 | $logger->info('Cannot find helper [' . $function . '] from modules using the default location'); |
| 366 | 353 | } |
| 367 | 354 | if(! $functionFilePath){ |
@@ -380,8 +367,7 @@ discard block |
||
| 380 | 367 | require_once $functionFilePath; |
| 381 | 368 | static::$loaded['function_' . $function] = $functionFilePath; |
| 382 | 369 | $logger->info('Helper [' . $function . '] --> ' . $functionFilePath . ' loaded successfully.'); |
| 383 | - } |
|
| 384 | - else{ |
|
| 370 | + } else{ |
|
| 385 | 371 | show_error('Unable to find helper file [' . $file . ']'); |
| 386 | 372 | } |
| 387 | 373 | } |
@@ -425,8 +411,7 @@ discard block |
||
| 425 | 411 | if($moduleConfigPath){ |
| 426 | 412 | $logger->info('Found config [' . $filename . '] from module [' .$searchModuleName. '], the file path is [' .$moduleConfigPath. '] we will used it'); |
| 427 | 413 | $configFilePath = $moduleConfigPath; |
| 428 | - } |
|
| 429 | - else{ |
|
| 414 | + } else{ |
|
| 430 | 415 | $logger->info('Cannot find config [' . $filename . '] from modules using the default location'); |
| 431 | 416 | } |
| 432 | 417 | $logger->info('The config file path to be loaded is [' . $configFilePath . ']'); |
@@ -434,12 +419,10 @@ discard block |
||
| 434 | 419 | require_once $configFilePath; |
| 435 | 420 | if(! empty($config) && is_array($config)){ |
| 436 | 421 | Config::setAll($config); |
| 437 | - } |
|
| 438 | - else{ |
|
| 422 | + } else{ |
|
| 439 | 423 | show_error('No configuration found in ['. $configFilePath . ']'); |
| 440 | 424 | } |
| 441 | - } |
|
| 442 | - else{ |
|
| 425 | + } else{ |
|
| 443 | 426 | show_error('Unable to find config file ['. $configFilePath . ']'); |
| 444 | 427 | } |
| 445 | 428 | static::$loaded['config_' . $filename] = $configFilePath; |
@@ -497,8 +480,7 @@ discard block |
||
| 497 | 480 | if($moduleLanguagePath){ |
| 498 | 481 | $logger->info('Found language [' . $language . '] from module [' .$searchModuleName. '], the file path is [' .$moduleLanguagePath. '] we will used it'); |
| 499 | 482 | $languageFilePath = $moduleLanguagePath; |
| 500 | - } |
|
| 501 | - else{ |
|
| 483 | + } else{ |
|
| 502 | 484 | $logger->info('Cannot find language [' . $language . '] from modules using the default location'); |
| 503 | 485 | } |
| 504 | 486 | if(! $languageFilePath){ |
@@ -522,14 +504,12 @@ discard block |
||
| 522 | 504 | $langObj->addLangMessages($lang); |
| 523 | 505 | //free the memory |
| 524 | 506 | unset($lang); |
| 525 | - } |
|
| 526 | - else{ |
|
| 507 | + } else{ |
|
| 527 | 508 | show_error('No language messages found in [' . $languageFilePath . ']'); |
| 528 | 509 | } |
| 529 | 510 | static::$loaded['lang_' . $language] = $languageFilePath; |
| 530 | 511 | $logger->info('Language [' . $language . '] --> ' . $languageFilePath . ' loaded successfully.'); |
| 531 | - } |
|
| 532 | - else{ |
|
| 512 | + } else{ |
|
| 533 | 513 | show_error('Unable to find language file [' . $file . ']'); |
| 534 | 514 | } |
| 535 | 515 | } |
@@ -103,8 +103,7 @@ |
||
| 103 | 103 | $this->header = array(); |
| 104 | 104 | if(function_exists('apache_request_headers')){ |
| 105 | 105 | $this->header = apache_request_headers(); |
| 106 | - } |
|
| 107 | - else if(function_exists('getallheaders')){ |
|
| 106 | + } else if(function_exists('getallheaders')){ |
|
| 108 | 107 | $this->header = getallheaders(); |
| 109 | 108 | } |
| 110 | 109 | } |
@@ -60,8 +60,7 @@ discard block |
||
| 60 | 60 | while(($module = readdir($moduleDir)) !== false){ |
| 61 | 61 | if($module != '.' && $module != '..' && preg_match('/^([a-z0-9-_]+)$/i', $module) && is_dir(MODULE_PATH . $module)){ |
| 62 | 62 | static::$list[] = $module; |
| 63 | - } |
|
| 64 | - else{ |
|
| 63 | + } else{ |
|
| 65 | 64 | $logger->info('Skipping [' .$module. '], may be this is not a directory or does not exists or is invalid name'); |
| 66 | 65 | } |
| 67 | 66 | } |
@@ -70,8 +69,7 @@ discard block |
||
| 70 | 69 | |
| 71 | 70 | if(static::hasModule()){ |
| 72 | 71 | $logger->info('The application contains the module below [' . implode(', ', static::getModuleList()) . ']'); |
| 73 | - } |
|
| 74 | - else{ |
|
| 72 | + } else{ |
|
| 75 | 73 | $logger->info('The application contains no module skipping'); |
| 76 | 74 | } |
| 77 | 75 | } |
@@ -118,8 +116,7 @@ discard block |
||
| 118 | 116 | $autoloads['languages'] = array_merge($autoloads['languages'], $autoload['languages']); |
| 119 | 117 | } |
| 120 | 118 | unset($autoload); |
| 121 | - } |
|
| 122 | - else{ |
|
| 119 | + } else{ |
|
| 123 | 120 | show_error('No autoload configuration found in autoload.php for module [' .$module. ']'); |
| 124 | 121 | } |
| 125 | 122 | } |
@@ -145,8 +142,7 @@ discard block |
||
| 145 | 142 | if(! empty($route) && is_array($route)){ |
| 146 | 143 | $routes = array_merge($routes, $route); |
| 147 | 144 | unset($route); |
| 148 | - } |
|
| 149 | - else{ |
|
| 145 | + } else{ |
|
| 150 | 146 | show_error('No routing configuration found in [' .$file. '] for module [' . $module . ']'); |
| 151 | 147 | } |
| 152 | 148 | } |
@@ -175,8 +171,7 @@ discard block |
||
| 175 | 171 | if(file_exists($filePath)){ |
| 176 | 172 | $logger->info('Found controller [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
| 177 | 173 | return $filePath; |
| 178 | - } |
|
| 179 | - else{ |
|
| 174 | + } else{ |
|
| 180 | 175 | $logger->info('Controller [' . $class . '] does not exist in the module [' .$module. ']'); |
| 181 | 176 | return false; |
| 182 | 177 | } |
@@ -202,8 +197,7 @@ discard block |
||
| 202 | 197 | if(file_exists($filePath)){ |
| 203 | 198 | $logger->info('Found model [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
| 204 | 199 | return $filePath; |
| 205 | - } |
|
| 206 | - else{ |
|
| 200 | + } else{ |
|
| 207 | 201 | $logger->info('Model [' . $class . '] does not exist in the module [' .$module. ']'); |
| 208 | 202 | return false; |
| 209 | 203 | } |
@@ -228,8 +222,7 @@ discard block |
||
| 228 | 222 | if(file_exists($filePath)){ |
| 229 | 223 | $logger->info('Found configuration [' . $configuration . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
| 230 | 224 | return $filePath; |
| 231 | - } |
|
| 232 | - else{ |
|
| 225 | + } else{ |
|
| 233 | 226 | $logger->info('Configuration [' . $configuration . '] does not exist in the module [' .$module. ']'); |
| 234 | 227 | return false; |
| 235 | 228 | } |
@@ -255,8 +248,7 @@ discard block |
||
| 255 | 248 | if(file_exists($filePath)){ |
| 256 | 249 | $logger->info('Found helper [' . $helper . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
| 257 | 250 | return $filePath; |
| 258 | - } |
|
| 259 | - else{ |
|
| 251 | + } else{ |
|
| 260 | 252 | $logger->info('Helper [' . $helper . '] does not exist in the module [' .$module. ']'); |
| 261 | 253 | return false; |
| 262 | 254 | } |
@@ -282,8 +274,7 @@ discard block |
||
| 282 | 274 | if(file_exists($filePath)){ |
| 283 | 275 | $logger->info('Found library [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
| 284 | 276 | return $filePath; |
| 285 | - } |
|
| 286 | - else{ |
|
| 277 | + } else{ |
|
| 287 | 278 | $logger->info('Library [' . $class . '] does not exist in the module [' .$module. ']'); |
| 288 | 279 | return false; |
| 289 | 280 | } |
@@ -311,8 +302,7 @@ discard block |
||
| 311 | 302 | if(file_exists($filePath)){ |
| 312 | 303 | $logger->info('Found view [' . $view . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
| 313 | 304 | return $filePath; |
| 314 | - } |
|
| 315 | - else{ |
|
| 305 | + } else{ |
|
| 316 | 306 | $logger->info('View [' . $view . '] does not exist in the module [' .$module. ']'); |
| 317 | 307 | return false; |
| 318 | 308 | } |
@@ -339,8 +329,7 @@ discard block |
||
| 339 | 329 | if(file_exists($filePath)){ |
| 340 | 330 | $logger->info('Found language [' . $language . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
| 341 | 331 | return $filePath; |
| 342 | - } |
|
| 343 | - else{ |
|
| 332 | + } else{ |
|
| 344 | 333 | $logger->info('Language [' . $language . '] does not exist in the module [' .$module. ']'); |
| 345 | 334 | return false; |
| 346 | 335 | } |
@@ -137,8 +137,7 @@ discard block |
||
| 137 | 137 | if(! in_array(strtolower($this->logger), $configLoggerName)){ |
| 138 | 138 | return; |
| 139 | 139 | } |
| 140 | - } |
|
| 141 | - else if(strtolower($this->logger) !== strtolower($configLoggerName)){ |
|
| 140 | + } else if(strtolower($this->logger) !== strtolower($configLoggerName)){ |
|
| 142 | 141 | return; |
| 143 | 142 | } |
| 144 | 143 | } |
@@ -218,20 +217,15 @@ discard block |
||
| 218 | 217 | //the default value is NONE, so means no need test for NONE |
| 219 | 218 | if($level == 'fatal'){ |
| 220 | 219 | $value = self::FATAL; |
| 221 | - } |
|
| 222 | - else if($level == 'error'){ |
|
| 220 | + } else if($level == 'error'){ |
|
| 223 | 221 | $value = self::ERROR; |
| 224 | - } |
|
| 225 | - else if($level == 'warning' || $level == 'warn'){ |
|
| 222 | + } else if($level == 'warning' || $level == 'warn'){ |
|
| 226 | 223 | $value = self::WARNING; |
| 227 | - } |
|
| 228 | - else if($level == 'info'){ |
|
| 224 | + } else if($level == 'info'){ |
|
| 229 | 225 | $value = self::INFO; |
| 230 | - } |
|
| 231 | - else if($level == 'debug'){ |
|
| 226 | + } else if($level == 'debug'){ |
|
| 232 | 227 | $value = self::DEBUG; |
| 233 | - } |
|
| 234 | - else if($level == 'all'){ |
|
| 228 | + } else if($level == 'all'){ |
|
| 235 | 229 | $value = self::ALL; |
| 236 | 230 | } |
| 237 | 231 | return $value; |
@@ -248,17 +242,13 @@ discard block |
||
| 248 | 242 | //the default value is NONE, so means no need test for NONE |
| 249 | 243 | if($level == self::FATAL){ |
| 250 | 244 | $value = 'FATAL'; |
| 251 | - } |
|
| 252 | - else if($level == self::ERROR){ |
|
| 245 | + } else if($level == self::ERROR){ |
|
| 253 | 246 | $value = 'ERROR'; |
| 254 | - } |
|
| 255 | - else if($level == self::WARNING){ |
|
| 247 | + } else if($level == self::WARNING){ |
|
| 256 | 248 | $value = 'WARNING'; |
| 257 | - } |
|
| 258 | - else if($level == self::INFO){ |
|
| 249 | + } else if($level == self::INFO){ |
|
| 259 | 250 | $value = 'INFO'; |
| 260 | - } |
|
| 261 | - else if($level == self::DEBUG){ |
|
| 251 | + } else if($level == self::DEBUG){ |
|
| 262 | 252 | $value = 'DEBUG'; |
| 263 | 253 | } |
| 264 | 254 | //no need for ALL |