reasonableframework/index.php

64 lines
1.5 KiB
PHP
Raw Normal View History

2017-12-17 20:40:04 +00:00
<?php
2017-12-31 18:34:33 +00:00
/**
* @file index.php
2018-04-13 05:27:39 +00:00
* @date 2018-04-13
2017-12-31 18:34:33 +00:00
* @author Go Namhyeon <gnh1201@gmail.com>
2018-03-23 09:23:03 +00:00
* @brief ReasonableFramework
* @cvs http://github.com/gnh1201/reasonableframework
2017-12-17 20:40:04 +00:00
*/
2017-12-22 19:04:01 +00:00
define("_DEF_VSPF_", true);
2017-12-31 18:31:24 +00:00
2018-02-26 04:20:46 +00:00
// define system modules
2018-03-23 09:23:03 +00:00
$load_systems = array("base", "config", "database", "uri", "logger", "security");
2018-02-26 04:20:46 +00:00
// load system modules
2017-12-22 18:34:40 +00:00
foreach($load_systems as $system_name) {
2018-03-23 09:23:03 +00:00
$system_inc_file = "./system/" . $system_name . ".php";
2017-12-22 18:34:40 +00:00
if(file_exists($system_inc_file)) {
2018-04-13 05:27:39 +00:00
if($system_name == "base") {
include($system_inc_file);
} else {
include_isolate($system_inc_file, $scope);
}
2017-12-22 18:34:40 +00:00
}
}
2017-12-17 20:40:04 +00:00
2018-04-13 05:27:39 +00:00
// get config
$config = get_scope("config");
2018-03-23 09:23:03 +00:00
// set max_execution_time
$max_execution_time = get_value_in_array("max_execution_time", $config, 0);
@ini_set("max_execution_time", $max_execution_time);
2018-02-26 04:20:46 +00:00
// autoload module
2018-03-23 09:23:03 +00:00
if(!array_key_empty("enable_autoload", $config)) {
2018-02-26 04:20:46 +00:00
loadModule("autoload");
}
2018-02-09 11:14:17 +00:00
// set timezone
2018-03-23 09:23:03 +00:00
$default_timezone = get_value_in_array("timezone", $config, "UTC");
2018-02-09 11:14:17 +00:00
date_default_timezone_set($default_timezone);
2017-12-17 20:40:04 +00:00
// route controller
2018-03-23 09:23:03 +00:00
$route = get_value_in_array("route", $_REQUEST, "");
2017-12-17 20:40:04 +00:00
2018-02-26 04:20:46 +00:00
// load route
2017-12-17 20:40:04 +00:00
if(empty($route)) {
2018-03-23 09:26:14 +00:00
$route = get_value_in_array("default_route", $config, "welcome");
2017-12-17 20:40:04 +00:00
} else {
$route_names = explode('/', $route);
2018-04-13 05:27:39 +00:00
if(count($route_names) > 1) {
$route = $route_names[0];
2017-12-17 20:40:04 +00:00
}
}
// including route file
2018-03-23 09:23:03 +00:00
$route_file_name = "./route/" . $route . ".php";
2018-04-13 05:27:39 +00:00
if(!file_exists($route_file_name)) {
$route = "errors/404";
$route_file_name = "./route/" . $route . ".php";
2017-12-25 10:19:42 +00:00
}
2018-04-13 05:27:39 +00:00
include_isolate($route_file_name, $scope);
register_loaded("route", $route);