2017-12-17 20:40:04 +00:00
|
|
|
<?php
|
2017-12-31 18:34:33 +00:00
|
|
|
/**
|
|
|
|
* @file index.php
|
|
|
|
* @date 2017-12-18
|
|
|
|
* @author Go Namhyeon <gnh1201@gmail.com>
|
2018-02-09 11:21:46 +00:00
|
|
|
* @brief ReasonablePHPFramework
|
2017-12-31 18:34:33 +00:00
|
|
|
* @cvs http://github.com/gnh1201/verysimplephpframework
|
2017-12-17 20:40:04 +00:00
|
|
|
*/
|
|
|
|
|
2017-12-22 19:04:01 +00:00
|
|
|
define("_DEF_VSPF_", true);
|
2017-12-25 10:19:42 +00:00
|
|
|
ini_set("max_execution_time", 0);
|
2017-12-22 19:04:01 +00:00
|
|
|
|
2017-12-31 18:31:24 +00:00
|
|
|
error_reporting(E_ALL);
|
|
|
|
ini_set("display_errors", 1);
|
|
|
|
|
2017-12-17 20:40:04 +00:00
|
|
|
// including vendor autoloader
|
|
|
|
include_once('./vendor/autoload.php');
|
|
|
|
|
2017-12-22 18:34:40 +00:00
|
|
|
// load system files
|
2018-01-17 16:28:42 +00:00
|
|
|
$load_systems = array('base', 'config', 'database', 'uri', 'logger', 'security');
|
2017-12-22 18:34:40 +00:00
|
|
|
foreach($load_systems as $system_name) {
|
|
|
|
$system_inc_file = './system/' . $system_name . '.php';
|
|
|
|
if(file_exists($system_inc_file)) {
|
|
|
|
include_once($system_inc_file);
|
|
|
|
}
|
|
|
|
}
|
2017-12-17 20:40:04 +00:00
|
|
|
|
2018-02-09 11:14:17 +00:00
|
|
|
// set timezone
|
|
|
|
$default_timezone = array_key_empty("timezone", $config) ? $config['timezone'] : "UTC";
|
|
|
|
date_default_timezone_set($default_timezone);
|
|
|
|
|
2018-02-09 11:21:46 +00:00
|
|
|
// start session (enable $_SESSON)
|
|
|
|
session_start();
|
|
|
|
|
2017-12-17 20:40:04 +00:00
|
|
|
// route controller
|
|
|
|
$route = '';
|
|
|
|
if(array_key_exists('route', $_REQUEST)) {
|
|
|
|
$route = $_REQUEST['route'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if(empty($route)) {
|
2017-12-31 18:31:24 +00:00
|
|
|
$route = 'index';
|
2017-12-17 20:40:04 +00:00
|
|
|
} else {
|
|
|
|
$route_names = explode('/', $route);
|
|
|
|
if(count($route) > 1) {
|
|
|
|
$route = end($route_names);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// including route file
|
2017-12-25 10:19:42 +00:00
|
|
|
$route_file_name = './route/' . $route . '.php';
|
|
|
|
if(file_exists($route_file_name)) {
|
2017-12-25 10:20:28 +00:00
|
|
|
include($route_file_name);
|
2017-12-25 10:19:42 +00:00
|
|
|
} else {
|
2017-12-31 18:31:24 +00:00
|
|
|
include('./route/errors/404.php');
|
2017-12-25 10:19:42 +00:00
|
|
|
}
|