From 9aa028730385c9bb9faa2983beebdf7cf1be78df Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Fri, 13 Apr 2018 14:27:39 +0900 Subject: [PATCH] Update index.php --- index.php | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/index.php b/index.php index 4923003..4eb0dd7 100644 --- a/index.php +++ b/index.php @@ -1,7 +1,7 @@ * @brief ReasonableFramework * @cvs http://github.com/gnh1201/reasonableframework @@ -16,10 +16,17 @@ $load_systems = array("base", "config", "database", "uri", "logger", "security") foreach($load_systems as $system_name) { $system_inc_file = "./system/" . $system_name . ".php"; if(file_exists($system_inc_file)) { - include_once($system_inc_file); + if($system_name == "base") { + include($system_inc_file); + } else { + include_isolate($system_inc_file, $scope); + } } } +// get config +$config = get_scope("config"); + // set max_execution_time $max_execution_time = get_value_in_array("max_execution_time", $config, 0); @ini_set("max_execution_time", $max_execution_time); @@ -41,15 +48,16 @@ if(empty($route)) { $route = get_value_in_array("default_route", $config, "welcome"); } else { $route_names = explode('/', $route); - if(count($route) > 1) { - $route = end($route_names); + if(count($route_names) > 1) { + $route = $route_names[0]; } } // including route file $route_file_name = "./route/" . $route . ".php"; -if(file_exists($route_file_name)) { - include($route_file_name); -} else { - include("./route/errors/404.php"); +if(!file_exists($route_file_name)) { + $route = "errors/404"; + $route_file_name = "./route/" . $route . ".php"; } +include_isolate($route_file_name, $scope); +register_loaded("route", $route);