@@ -242,8 +242,7 @@ |
||
| 242 | 242 | ini_set('display_errors', 0); |
| 243 | 243 | if (version_compare(PHP_VERSION, '5.3', '>=')) { |
| 244 | 244 | error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED); |
| 245 | - } |
|
| 246 | - else{ |
|
| 245 | + } else{ |
|
| 247 | 246 | error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE); |
| 248 | 247 | } |
| 249 | 248 | break; |
@@ -78,8 +78,7 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | if (version_compare(phpversion(), TNH_REQUIRED_PHP_MIN_VERSION, '<')){ |
| 80 | 80 | show_error('Your PHP Version [' . phpversion() . '] is less than [' . TNH_REQUIRED_PHP_MIN_VERSION . '], please install a new version or update your PHP to the latest.', 'PHP Error environment'); |
| 81 | - } |
|
| 82 | - else if(version_compare(phpversion(), TNH_REQUIRED_PHP_MAX_VERSION, '>')){ |
|
| 81 | + } else if(version_compare(phpversion(), TNH_REQUIRED_PHP_MAX_VERSION, '>')){ |
|
| 83 | 82 | show_error('Your PHP Version [' . phpversion() . '] is greather than [' . TNH_REQUIRED_PHP_MAX_VERSION . '] please install a PHP version that is compatible.', 'PHP Error environment'); |
| 84 | 83 | } |
| 85 | 84 | $LOGGER->info('PHP version [' . phpversion() . '] is OK [REQUIRED MINIMUM: ' . TNH_REQUIRED_PHP_MIN_VERSION . ', REQUIRED MAXIMUM: ' . TNH_REQUIRED_PHP_MAX_VERSION . '], application can work without any issue'); |
@@ -104,8 +103,7 @@ discard block |
||
| 104 | 103 | if(file_exists(VENDOR_PATH . 'autoload.php')){ |
| 105 | 104 | $LOGGER->info('The composer autoload file exists include it'); |
| 106 | 105 | require_once VENDOR_PATH . 'autoload.php'; |
| 107 | - } |
|
| 108 | - else{ |
|
| 106 | + } else{ |
|
| 109 | 107 | $LOGGER->info('The composer autoload file does not exist skipping'); |
| 110 | 108 | } |
| 111 | 109 | |
@@ -176,8 +174,7 @@ discard block |
||
| 176 | 174 | //first check if the cache handler is the system driver |
| 177 | 175 | if(file_exists(CORE_CLASSES_CACHE_PATH . $cacheHandler . '.php')){ |
| 178 | 176 | $CACHE =& class_loader($cacheHandler, 'classes/cache'); |
| 179 | - } |
|
| 180 | - else{ |
|
| 177 | + } else{ |
|
| 181 | 178 | //it's not a system driver use user library |
| 182 | 179 | $CACHE =& class_loader($cacheHandler); |
| 183 | 180 | } |
@@ -66,15 +66,13 @@ discard block |
||
| 66 | 66 | //check if the server is running under IPv6 |
| 67 | 67 | if (strpos($_SERVER['SERVER_ADDR'], ':') !== FALSE){ |
| 68 | 68 | $baseUrl = '['.$_SERVER['SERVER_ADDR'].']'; |
| 69 | - } |
|
| 70 | - else{ |
|
| 69 | + } else{ |
|
| 71 | 70 | $baseUrl = $_SERVER['SERVER_ADDR']; |
| 72 | 71 | } |
| 73 | 72 | $port = ((isset($_SERVER['SERVER_PORT']) && ($_SERVER['SERVER_PORT'] != '80' && ! is_https() || $_SERVER['SERVER_PORT'] != '443' && is_https()) ) ? ':' . $_SERVER['SERVER_PORT'] : ''); |
| 74 | 73 | $baseUrl = (is_https() ? 'https' : 'http').'://' . $baseUrl . $port |
| 75 | 74 | . substr($_SERVER['SCRIPT_NAME'], 0, strpos($_SERVER['SCRIPT_NAME'], basename($_SERVER['SCRIPT_FILENAME']))); |
| 76 | - } |
|
| 77 | - else{ |
|
| 75 | + } else{ |
|
| 78 | 76 | $logger->warning('Can not determine the application base URL automatically, use http://localhost as default'); |
| 79 | 77 | $baseUrl = 'http://localhost/'; |
| 80 | 78 | } |
@@ -139,8 +137,7 @@ discard block |
||
| 139 | 137 | $logger->info('Delete config item ['.$item.']'); |
| 140 | 138 | unset(static::$config[$item]); |
| 141 | 139 | return true; |
| 142 | - } |
|
| 143 | - else{ |
|
| 140 | + } else{ |
|
| 144 | 141 | $logger->warning('Config item ['.$item.'] to be deleted does not exists'); |
| 145 | 142 | return false; |
| 146 | 143 | } |
@@ -98,8 +98,7 @@ discard block |
||
| 98 | 98 | // Unlinking when the file was expired |
| 99 | 99 | unlink($filePath); |
| 100 | 100 | return false; |
| 101 | - } |
|
| 102 | - else{ |
|
| 101 | + } else{ |
|
| 103 | 102 | $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']) . ']'); |
| 104 | 103 | return $data['data']; |
| 105 | 104 | } |
@@ -138,8 +137,7 @@ discard block |
||
| 138 | 137 | $logger->error('Can not write cache data into file [' .$filePath. '] for the key ['. $key .'], return false'); |
| 139 | 138 | fclose($handle); |
| 140 | 139 | return false; |
| 141 | - } |
|
| 142 | - else{ |
|
| 140 | + } else{ |
|
| 143 | 141 | $logger->info('Cache data saved into file [' .$filePath. '] for the key ['. $key .']'); |
| 144 | 142 | fclose($handle); |
| 145 | 143 | chmod($filePath, 0640); |
@@ -162,8 +160,7 @@ discard block |
||
| 162 | 160 | if(! file_exists($filePath)){ |
| 163 | 161 | $logger->info('This cache file does not exists skipping'); |
| 164 | 162 | return false; |
| 165 | - } |
|
| 166 | - else{ |
|
| 163 | + } else{ |
|
| 167 | 164 | $logger->info('Found cache file [' .$filePath. '] remove it'); |
| 168 | 165 | @unlink($filePath); |
| 169 | 166 | return true; |
@@ -186,16 +183,14 @@ discard block |
||
| 186 | 183 | if(! file_exists($filePath)){ |
| 187 | 184 | $logger->info('This cache file does not exists skipping'); |
| 188 | 185 | return false; |
| 189 | - } |
|
| 190 | - else{ |
|
| 186 | + } else{ |
|
| 191 | 187 | $logger->info('Found cache file [' .$filePath. '] check the validity'); |
| 192 | 188 | $data = file_get_contents($filePath); |
| 193 | 189 | $data = @unserialize($this->compressCacheData ? gzinflate($data) : $data); |
| 194 | 190 | if(! $data){ |
| 195 | 191 | $logger->warning('Can not unserialize the cache data for file [' . $filePath . ']'); |
| 196 | 192 | return false; |
| 197 | - } |
|
| 198 | - else{ |
|
| 193 | + } else{ |
|
| 199 | 194 | $logger->info('This cache data is OK check for expire'); |
| 200 | 195 | if(isset($data['expire']) && $data['expire'] > time()){ |
| 201 | 196 | $logger->info('This cache not yet expired return cache informations'); |
@@ -205,8 +200,7 @@ discard block |
||
| 205 | 200 | 'ttl' => $data['ttl'] |
| 206 | 201 | ); |
| 207 | 202 | return $info; |
| 208 | - } |
|
| 209 | - else{ |
|
| 203 | + } else{ |
|
| 210 | 204 | $logger->info('This cache already expired return false'); |
| 211 | 205 | return false; |
| 212 | 206 | } |
@@ -224,8 +218,7 @@ discard block |
||
| 224 | 218 | $list = glob(CACHE_PATH . '*.cache'); |
| 225 | 219 | if(! $list){ |
| 226 | 220 | $logger->info('No cache files were found skipping'); |
| 227 | - } |
|
| 228 | - else{ |
|
| 221 | + } else{ |
|
| 229 | 222 | $logger->info('Found [' . count($list) . '] cache files to remove if expired'); |
| 230 | 223 | foreach ($list as $file) { |
| 231 | 224 | $logger->debug('Processing the cache file [' . $file . ']'); |
@@ -233,12 +226,10 @@ discard block |
||
| 233 | 226 | $data = @unserialize($this->compressCacheData ? gzinflate($data) : $data); |
| 234 | 227 | if(! $data){ |
| 235 | 228 | $logger->warning('Can not unserialize the cache data for file [' . $file . ']'); |
| 236 | - } |
|
| 237 | - else if(time() > $data['expire']){ |
|
| 229 | + } else if(time() > $data['expire']){ |
|
| 238 | 230 | $logger->info('The cache data for file [' . $file . '] already expired remove it'); |
| 239 | 231 | @unlink($file); |
| 240 | - } |
|
| 241 | - else{ |
|
| 232 | + } else{ |
|
| 242 | 233 | $logger->info('The cache data for file [' . $file . '] not yet expired skip it'); |
| 243 | 234 | } |
| 244 | 235 | } |
@@ -254,8 +245,7 @@ discard block |
||
| 254 | 245 | $list = glob(CACHE_PATH . '*.cache'); |
| 255 | 246 | if(! $list){ |
| 256 | 247 | $logger->info('No cache files were found skipping'); |
| 257 | - } |
|
| 258 | - else{ |
|
| 248 | + } else{ |
|
| 259 | 249 | $logger->info('Found [' . count($list) . '] cache files to remove'); |
| 260 | 250 | foreach ($list as $file) { |
| 261 | 251 | $logger->debug('Processing the cache file [' . $file . ']'); |
@@ -282,8 +272,7 @@ discard block |
||
| 282 | 272 | $logger = static::getLogger(); |
| 283 | 273 | $logger->warning('The zlib extension is not loaded set cache compress data to FALSE'); |
| 284 | 274 | $this->compressCacheData = false; |
| 285 | - } |
|
| 286 | - else{ |
|
| 275 | + } else{ |
|
| 287 | 276 | $this->compressCacheData = $status; |
| 288 | 277 | } |
| 289 | 278 | return $this; |
@@ -64,8 +64,7 @@ discard block |
||
| 64 | 64 | if($success === false){ |
| 65 | 65 | $logger->info('No cache found for the key ['. $key .'], return false'); |
| 66 | 66 | return false; |
| 67 | - } |
|
| 68 | - else{ |
|
| 67 | + } else{ |
|
| 69 | 68 | $cacheInfo = $this->_getCacheInfo($key); |
| 70 | 69 | $expire = time(); |
| 71 | 70 | if($cacheInfo){ |
@@ -92,8 +91,7 @@ discard block |
||
| 92 | 91 | if($result === false){ |
| 93 | 92 | $logger->error('Can not write cache data for the key ['. $key .'], return false'); |
| 94 | 93 | return false; |
| 95 | - } |
|
| 96 | - else{ |
|
| 94 | + } else{ |
|
| 97 | 95 | $logger->info('Cache data saved for the key ['. $key .']'); |
| 98 | 96 | return true; |
| 99 | 97 | } |
@@ -113,8 +111,7 @@ discard block |
||
| 113 | 111 | if($cacheInfo === false){ |
| 114 | 112 | $logger->info('This cache data does not exists skipping'); |
| 115 | 113 | return false; |
| 116 | - } |
|
| 117 | - else{ |
|
| 114 | + } else{ |
|
| 118 | 115 | $logger->info('Found cache data for the key [' .$key. '] remove it'); |
| 119 | 116 | return apc_delete($key); |
| 120 | 117 | } |
@@ -140,8 +137,7 @@ discard block |
||
| 140 | 137 | 'ttl' => $cacheInfos['ttl'] |
| 141 | 138 | ); |
| 142 | 139 | return $data; |
| 143 | - } |
|
| 144 | - else{ |
|
| 140 | + } else{ |
|
| 145 | 141 | $logger->info('This cache does not exists skipping'); |
| 146 | 142 | return false; |
| 147 | 143 | } |
@@ -166,8 +162,7 @@ discard block |
||
| 166 | 162 | if(empty($cacheInfos['cache_list'])){ |
| 167 | 163 | $logger->info('No cache data were found skipping'); |
| 168 | 164 | return false; |
| 169 | - } |
|
| 170 | - else{ |
|
| 165 | + } else{ |
|
| 171 | 166 | $logger->info('Found [' . count($cacheInfos) . '] cache data to remove'); |
| 172 | 167 | return apc_clear_cache('user'); |
| 173 | 168 | } |
@@ -243,8 +243,7 @@ discard block |
||
| 243 | 243 | $insert_id = $this->_database->insertId(); |
| 244 | 244 | $this->trigger('after_create', $insert_id); |
| 245 | 245 | return $insert_id; |
| 246 | - } |
|
| 247 | - else |
|
| 246 | + } else |
|
| 248 | 247 | { |
| 249 | 248 | return FALSE; |
| 250 | 249 | } |
@@ -281,8 +280,7 @@ discard block |
||
| 281 | 280 | ->update($data, $escape); |
| 282 | 281 | $this->trigger('after_update', array($data, $result)); |
| 283 | 282 | return $result; |
| 284 | - } |
|
| 285 | - else |
|
| 283 | + } else |
|
| 286 | 284 | { |
| 287 | 285 | return FALSE; |
| 288 | 286 | } |
@@ -305,8 +303,7 @@ discard block |
||
| 305 | 303 | ->update($data, $escape); |
| 306 | 304 | $this->trigger('after_update', array($data, $result)); |
| 307 | 305 | return $result; |
| 308 | - } |
|
| 309 | - else |
|
| 306 | + } else |
|
| 310 | 307 | { |
| 311 | 308 | return FALSE; |
| 312 | 309 | } |
@@ -323,8 +320,7 @@ discard block |
||
| 323 | 320 | if(is_array($args[1])){ |
| 324 | 321 | $data = array_pop($args); |
| 325 | 322 | } |
| 326 | - } |
|
| 327 | - else if(count($args) == 3){ |
|
| 323 | + } else if(count($args) == 3){ |
|
| 328 | 324 | if(is_array($args[2])){ |
| 329 | 325 | $data = array_pop($args); |
| 330 | 326 | } |
@@ -336,8 +332,7 @@ discard block |
||
| 336 | 332 | $result = $this->_database->from($this->_table)->update($data); |
| 337 | 333 | $this->trigger('after_update', array($data, $result)); |
| 338 | 334 | return $result; |
| 339 | - } |
|
| 340 | - else |
|
| 335 | + } else |
|
| 341 | 336 | { |
| 342 | 337 | return FALSE; |
| 343 | 338 | } |
@@ -364,8 +359,7 @@ discard block |
||
| 364 | 359 | if ($this->soft_delete) |
| 365 | 360 | { |
| 366 | 361 | $result = $this->_database->from($this->_table)->update(array( $this->soft_delete_key => TRUE )); |
| 367 | - } |
|
| 368 | - else |
|
| 362 | + } else |
|
| 369 | 363 | { |
| 370 | 364 | $result = $this->_database->from($this->_table)->delete(); |
| 371 | 365 | } |
@@ -385,8 +379,7 @@ discard block |
||
| 385 | 379 | if ($this->soft_delete) |
| 386 | 380 | { |
| 387 | 381 | $result = $this->_database->from($this->_table)->update(array( $this->soft_delete_key => TRUE )); |
| 388 | - } |
|
| 389 | - else |
|
| 382 | + } else |
|
| 390 | 383 | { |
| 391 | 384 | $result = $this->_database->from($this->_table)->delete(); |
| 392 | 385 | } |
@@ -404,8 +397,7 @@ discard block |
||
| 404 | 397 | if ($this->soft_delete) |
| 405 | 398 | { |
| 406 | 399 | $result = $this->_database->from($this->_table)->update(array( $this->soft_delete_key => TRUE )); |
| 407 | - } |
|
| 408 | - else |
|
| 400 | + } else |
|
| 409 | 401 | { |
| 410 | 402 | $result = $this->_database->from($this->_table)->delete(); |
| 411 | 403 | } |
@@ -450,8 +442,7 @@ discard block |
||
| 450 | 442 | { |
| 451 | 443 | $relationship = $value; |
| 452 | 444 | $options = array( 'primary_key' => $value . '_id', 'model' => $value . '_model' ); |
| 453 | - } |
|
| 454 | - else |
|
| 445 | + } else |
|
| 455 | 446 | { |
| 456 | 447 | $relationship = $key; |
| 457 | 448 | $options = $value; |
@@ -463,8 +454,7 @@ discard block |
||
| 463 | 454 | if (is_object($row)) |
| 464 | 455 | { |
| 465 | 456 | $row->{$relationship} = $this->{$relationship . '_model'}->get($row->{$options['primary_key']}); |
| 466 | - } |
|
| 467 | - else |
|
| 457 | + } else |
|
| 468 | 458 | { |
| 469 | 459 | $row[$relationship] = $this->{$relationship . '_model'}->get($row[$options['primary_key']]); |
| 470 | 460 | } |
@@ -477,8 +467,7 @@ discard block |
||
| 477 | 467 | { |
| 478 | 468 | $relationship = $value; |
| 479 | 469 | $options = array( 'primary_key' => $this->_table . '_id', 'model' => $value . '_model' ); |
| 480 | - } |
|
| 481 | - else |
|
| 470 | + } else |
|
| 482 | 471 | { |
| 483 | 472 | $relationship = $key; |
| 484 | 473 | $options = $value; |
@@ -490,8 +479,7 @@ discard block |
||
| 490 | 479 | if (is_object($row)) |
| 491 | 480 | { |
| 492 | 481 | $row->{$relationship} = $this->{$relationship . '_model'}->get_many_by($options['primary_key'], $row->{$this->primary_key}); |
| 493 | - } |
|
| 494 | - else |
|
| 482 | + } else |
|
| 495 | 483 | { |
| 496 | 484 | $row[$relationship] = $this->{$relationship . '_model'}->get_many_by($options['primary_key'], $row[$this->primary_key]); |
| 497 | 485 | } |
@@ -513,8 +501,7 @@ discard block |
||
| 513 | 501 | if(count($args) == 2) |
| 514 | 502 | { |
| 515 | 503 | list($key, $value) = $args; |
| 516 | - } |
|
| 517 | - else |
|
| 504 | + } else |
|
| 518 | 505 | { |
| 519 | 506 | $key = $this->primary_key; |
| 520 | 507 | $value = $args[0]; |
@@ -662,8 +649,7 @@ discard block |
||
| 662 | 649 | if (is_object($row)) |
| 663 | 650 | { |
| 664 | 651 | $row->created_at = date('Y-m-d H:i:s'); |
| 665 | - } |
|
| 666 | - else |
|
| 652 | + } else |
|
| 667 | 653 | { |
| 668 | 654 | $row['created_at'] = date('Y-m-d H:i:s'); |
| 669 | 655 | } |
@@ -676,8 +662,7 @@ discard block |
||
| 676 | 662 | if (is_object($row)) |
| 677 | 663 | { |
| 678 | 664 | $row->updated_at = date('Y-m-d H:i:s'); |
| 679 | - } |
|
| 680 | - else |
|
| 665 | + } else |
|
| 681 | 666 | { |
| 682 | 667 | $row['updated_at'] = date('Y-m-d H:i:s'); |
| 683 | 668 | } |
@@ -704,8 +689,7 @@ discard block |
||
| 704 | 689 | if (is_array($row)) |
| 705 | 690 | { |
| 706 | 691 | $row[$column] = unserialize($row[$column]); |
| 707 | - } |
|
| 708 | - else |
|
| 692 | + } else |
|
| 709 | 693 | { |
| 710 | 694 | $row->$column = unserialize($row->$column); |
| 711 | 695 | } |
@@ -725,8 +709,7 @@ discard block |
||
| 725 | 709 | if(isset($row->$attr)){ |
| 726 | 710 | unset($row->$attr); |
| 727 | 711 | } |
| 728 | - } |
|
| 729 | - else |
|
| 712 | + } else |
|
| 730 | 713 | { |
| 731 | 714 | if(isset($row[$attr])){ |
| 732 | 715 | unset($row[$attr]); |
@@ -759,8 +742,7 @@ discard block |
||
| 759 | 742 | { |
| 760 | 743 | $this->_database->orderBy($key, $value); |
| 761 | 744 | } |
| 762 | - } |
|
| 763 | - else |
|
| 745 | + } else |
|
| 764 | 746 | { |
| 765 | 747 | $this->_database->orderBy($criteria, $order); |
| 766 | 748 | } |
@@ -827,17 +809,14 @@ discard block |
||
| 827 | 809 | if ($this->formvalidation->run()) |
| 828 | 810 | { |
| 829 | 811 | return $data; |
| 830 | - } |
|
| 831 | - else |
|
| 812 | + } else |
|
| 832 | 813 | { |
| 833 | 814 | return FALSE; |
| 834 | 815 | } |
| 835 | - } |
|
| 836 | - else { |
|
| 816 | + } else { |
|
| 837 | 817 | return $data; |
| 838 | 818 | } |
| 839 | - } |
|
| 840 | - else |
|
| 819 | + } else |
|
| 841 | 820 | { |
| 842 | 821 | return $data; |
| 843 | 822 | } |
@@ -856,46 +835,38 @@ discard block |
||
| 856 | 835 | if (is_array($filter)) |
| 857 | 836 | { |
| 858 | 837 | $this->_database->in($field, $filter); |
| 859 | - } |
|
| 860 | - else |
|
| 838 | + } else |
|
| 861 | 839 | { |
| 862 | 840 | if (is_int($field)) |
| 863 | 841 | { |
| 864 | 842 | $this->_database->where($filter); |
| 865 | - } |
|
| 866 | - else |
|
| 843 | + } else |
|
| 867 | 844 | { |
| 868 | 845 | $this->_database->where($field, $filter); |
| 869 | 846 | } |
| 870 | 847 | } |
| 871 | 848 | } |
| 872 | - } |
|
| 873 | - else if (count($params) == 1) |
|
| 849 | + } else if (count($params) == 1) |
|
| 874 | 850 | { |
| 875 | 851 | $this->_database->where($params[0]); |
| 876 | - } |
|
| 877 | - else if(count($params) == 2) |
|
| 852 | + } else if(count($params) == 2) |
|
| 878 | 853 | { |
| 879 | 854 | if (is_array($params[1])) |
| 880 | 855 | { |
| 881 | 856 | $this->_database->in($params[0], $params[1]); |
| 882 | - } |
|
| 883 | - else |
|
| 857 | + } else |
|
| 884 | 858 | { |
| 885 | 859 | $this->_database->where($params[0], $params[1]); |
| 886 | 860 | } |
| 887 | - } |
|
| 888 | - else if(count($params) == 3) |
|
| 861 | + } else if(count($params) == 3) |
|
| 889 | 862 | { |
| 890 | 863 | $this->_database->where($params[0], $params[1], $params[2]); |
| 891 | - } |
|
| 892 | - else |
|
| 864 | + } else |
|
| 893 | 865 | { |
| 894 | 866 | if (is_array($params[1])) |
| 895 | 867 | { |
| 896 | 868 | $this->_database->in($params[0], $params[1]); |
| 897 | - } |
|
| 898 | - else |
|
| 869 | + } else |
|
| 899 | 870 | { |
| 900 | 871 | $this->_database->where($params[0], $params[1]); |
| 901 | 872 | } |
@@ -62,8 +62,7 @@ discard block |
||
| 62 | 62 | $query[0] = rtrim($query[0], '/'); |
| 63 | 63 | $query[0] .= $suffix; |
| 64 | 64 | $path = implode('?', $query); |
| 65 | - } |
|
| 66 | - else{ |
|
| 65 | + } else{ |
|
| 67 | 66 | $path .= $suffix; |
| 68 | 67 | } |
| 69 | 68 | } |
@@ -119,11 +118,9 @@ discard block |
||
| 119 | 118 | |
| 120 | 119 | if($obj->request->server('HTTP_HOST')){ |
| 121 | 120 | $domain = $obj->request->server('HTTP_HOST'); |
| 122 | - } |
|
| 123 | - else if($obj->request->server('SERVER_NAME')){ |
|
| 121 | + } else if($obj->request->server('SERVER_NAME')){ |
|
| 124 | 122 | $domain = $obj->request->server('SERVER_NAME'); |
| 125 | - } |
|
| 126 | - else if($obj->request->server('SERVER_ADDR')){ |
|
| 123 | + } else if($obj->request->server('SERVER_ADDR')){ |
|
| 127 | 124 | $domain = $obj->request->server('SERVER_ADDR'); |
| 128 | 125 | } |
| 129 | 126 | if($port && (is_https() && $port != 443 || !is_https() && $port != 80)){ |
@@ -90,8 +90,7 @@ discard block |
||
| 90 | 90 | ($_SESSION[$key]) : $default; |
| 91 | 91 | if(array_key_exists($key, $_SESSION)){ |
| 92 | 92 | unset($_SESSION[$key]); |
| 93 | - } |
|
| 94 | - else{ |
|
| 93 | + } else{ |
|
| 95 | 94 | $logger->warning('Cannot find session flash item ['. $key .'] using the default value ['. $default .']'); |
| 96 | 95 | } |
| 97 | 96 | return $return; |
@@ -126,8 +125,7 @@ discard block |
||
| 126 | 125 | if(array_key_exists($item, $_SESSION)){ |
| 127 | 126 | $logger->info('Deleting of session for item ['.$item.' ]'); |
| 128 | 127 | unset($_SESSION[$item]); |
| 129 | - } |
|
| 130 | - else{ |
|
| 128 | + } else{ |
|
| 131 | 129 | $logger->warning('Session item ['.$item.'] to be deleted does not exists'); |
| 132 | 130 | } |
| 133 | 131 | } |
@@ -142,8 +140,7 @@ discard block |
||
| 142 | 140 | if(array_key_exists($key, $_SESSION)){ |
| 143 | 141 | $logger->info('Delete session flash for item ['.$item.']'); |
| 144 | 142 | unset($_SESSION[$item]); |
| 145 | - } |
|
| 146 | - else{ |
|
| 143 | + } else{ |
|
| 147 | 144 | $logger->warning('Dession flash item ['.$item.'] to be deleted does not exists'); |
| 148 | 145 | } |
| 149 | 146 | } |
@@ -103,12 +103,10 @@ discard block |
||
| 103 | 103 | if(! empty($route) && is_array($route)){ |
| 104 | 104 | $this->routes = $route; |
| 105 | 105 | unset($route); |
| 106 | - } |
|
| 107 | - else{ |
|
| 106 | + } else{ |
|
| 108 | 107 | show_error('No routing configuration found in [' . $routesPath . ']'); |
| 109 | 108 | } |
| 110 | - } |
|
| 111 | - else{ |
|
| 109 | + } else{ |
|
| 112 | 110 | show_error('Unable to find the routes configuration file [' . $routesPath . ']'); |
| 113 | 111 | } |
| 114 | 112 | |
@@ -118,8 +116,7 @@ discard block |
||
| 118 | 116 | if($modulesRoutes && is_array($modulesRoutes)){ |
| 119 | 117 | $this->routes = array_merge($this->routes, $modulesRoutes); |
| 120 | 118 | $this->logger->info('Routes for all modules loaded successfully'); |
| 121 | - } |
|
| 122 | - else{ |
|
| 119 | + } else{ |
|
| 123 | 120 | $this->logger->info('No routes found for all modules skipping.'); |
| 124 | 121 | } |
| 125 | 122 | $this->logger->info('The routes configuration are listed below: ' . stringfy_vars($this->routes)); |
@@ -135,8 +132,7 @@ discard block |
||
| 135 | 132 | if($suffix = get_config('url_suffix')){ |
| 136 | 133 | $this->logger->info('URL suffix is enabled in the configuration, the value is [' . $suffix . ']' ); |
| 137 | 134 | $uri = str_ireplace($suffix, '', $uri); |
| 138 | - } |
|
| 139 | - else{ |
|
| 135 | + } else{ |
|
| 140 | 136 | $this->logger->info('URL suffix is not enabled in the configuration'); |
| 141 | 137 | } |
| 142 | 138 | if(strpos($uri, '?') !== false){ |
@@ -229,8 +225,7 @@ discard block |
||
| 229 | 225 | $this->logger->info('The request URI contains the front controller'); |
| 230 | 226 | array_shift($segment); |
| 231 | 227 | $this->segments = $segment; |
| 232 | - } |
|
| 233 | - else{ |
|
| 228 | + } else{ |
|
| 234 | 229 | $this->logger->info('The request URI does not contain the front controller'); |
| 235 | 230 | } |
| 236 | 231 | $uri = implode('/', $segment); |
@@ -252,8 +247,7 @@ discard block |
||
| 252 | 247 | $this->logger->info('The current request use the module [' .$moduleControllerMethod[0]. ']'); |
| 253 | 248 | $this->module = $moduleControllerMethod[0]; |
| 254 | 249 | $moduleControllerMethod = explode('@', $moduleControllerMethod[1]); |
| 255 | - } |
|
| 256 | - else{ |
|
| 250 | + } else{ |
|
| 257 | 251 | $this->logger->info('The current request does not use the module'); |
| 258 | 252 | $moduleControllerMethod = explode('@', $this->callback[$index]); |
| 259 | 253 | } |
@@ -300,8 +294,7 @@ discard block |
||
| 300 | 294 | } |
| 301 | 295 | //args |
| 302 | 296 | $this->args = $segment; |
| 303 | - } |
|
| 304 | - else{ |
|
| 297 | + } else{ |
|
| 305 | 298 | $this->logger->info('The application contains a loaded module will check if the current request is found in the module list'); |
| 306 | 299 | if(in_array($segment[0], $modules)){ |
| 307 | 300 | $this->logger->info('Found, the current request use the module [' . $segment[0] . ']'); |
@@ -315,8 +308,7 @@ discard block |
||
| 315 | 308 | if(! $path){ |
| 316 | 309 | $this->logger->info('The controller [' . $this->getController() . '] not found in the module, may be will use the module [' . $this->getModule() . '] as controller'); |
| 317 | 310 | $this->controller = $this->getModule(); |
| 318 | - } |
|
| 319 | - else{ |
|
| 311 | + } else{ |
|
| 320 | 312 | $this->controllerPath = $path; |
| 321 | 313 | array_shift($segment); |
| 322 | 314 | } |
@@ -328,8 +320,7 @@ discard block |
||
| 328 | 320 | } |
| 329 | 321 | //the remaining is for args |
| 330 | 322 | $this->args = $segment; |
| 331 | - } |
|
| 332 | - else{ |
|
| 323 | + } else{ |
|
| 333 | 324 | $this->logger->info('The current request information is not found in the module list'); |
| 334 | 325 | //controller |
| 335 | 326 | if(isset($segment[0])){ |
@@ -357,8 +348,7 @@ discard block |
||
| 357 | 348 | //if it is the module controller |
| 358 | 349 | if($this->getModule()){ |
| 359 | 350 | $this->controllerPath = Module::findControllerFullPath(ucfirst($this->getController()), $this->getModule()); |
| 360 | - } |
|
| 361 | - else{ |
|
| 351 | + } else{ |
|
| 362 | 352 | $this->controllerPath = APPS_CONTROLLER_PATH . ucfirst($this->getController()) . '.php'; |
| 363 | 353 | } |
| 364 | 354 | } |
@@ -373,15 +363,13 @@ discard block |
||
| 373 | 363 | if(! class_exists($controller, false)){ |
| 374 | 364 | $e404 = true; |
| 375 | 365 | $this->logger->info('The controller file [' .$classFilePath. '] exists but does not contain the class [' . $controller . ']'); |
| 376 | - } |
|
| 377 | - else{ |
|
| 366 | + } else{ |
|
| 378 | 367 | $controllerInstance = new $controller(); |
| 379 | 368 | $controllerMethod = $this->getMethod(); |
| 380 | 369 | if(! method_exists($controllerInstance, $controllerMethod)){ |
| 381 | 370 | $e404 = true; |
| 382 | 371 | $this->logger->info('The controller [' . $controller . '] exist but does not contain the method [' . $controllerMethod . ']'); |
| 383 | - } |
|
| 384 | - else{ |
|
| 372 | + } else{ |
|
| 385 | 373 | $this->logger->info('Routing data is set correctly now GO!'); |
| 386 | 374 | call_user_func_array(array($controllerInstance, $controllerMethod), $this->getArgs()); |
| 387 | 375 | $obj = & get_instance(); |
@@ -390,8 +378,7 @@ discard block |
||
| 390 | 378 | $obj->response->renderFinalPage(); |
| 391 | 379 | } |
| 392 | 380 | } |
| 393 | - } |
|
| 394 | - else{ |
|
| 381 | + } else{ |
|
| 395 | 382 | $this->logger->info('The controller file path [' . $classFilePath . '] does not exist'); |
| 396 | 383 | $e404 = true; |
| 397 | 384 | } |