@@ -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 | } |
@@ -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 | } |
@@ -82,8 +82,7 @@ discard block |
||
| 82 | 82 | if($cookieLang && $this->isValid($cookieLang)){ |
| 83 | 83 | $this->current = $cookieLang; |
| 84 | 84 | $this->logger->info('Language from cookie [' .$cfgKey. '] is valid so we will set the language using the cookie value [' .$cookieLang. ']'); |
| 85 | - } |
|
| 86 | - else{ |
|
| 85 | + } else{ |
|
| 87 | 86 | $this->logger->info('Language from cookie [' .$cfgKey. '] is not set, use the default value [' .$this->getDefault(). ']'); |
| 88 | 87 | $this->current = $this->getDefault(); |
| 89 | 88 | } |
@@ -171,8 +170,7 @@ discard block |
||
| 171 | 170 | } |
| 172 | 171 | if($this->isValid($name)){ |
| 173 | 172 | $this->availables[$name] = $description; |
| 174 | - } |
|
| 175 | - else{ |
|
| 173 | + } else{ |
|
| 176 | 174 | show_error('The language [' . $name . '] is not valid or does not exists.'); |
| 177 | 175 | } |
| 178 | 176 | } |
@@ -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){ |