-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
32 lines (26 loc) · 882 Bytes
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
use Core\Session;
use Core\Cookie;
use Core\Router;
use App\Models\Users;
define('DS', DIRECTORY_SEPARATOR);
define('ROOT', dirname(__FILE__));
// load configuration and helper functions
require_once(ROOT . DS . 'config' . DS . 'config.php');
function autoload($className){
$classAry = explode('\\',$className);
$class = array_pop($classAry);
$subPath = strtolower(implode(DS,$classAry));
$path = ROOT . DS . $subPath . DS . $class . '.php';
if(file_exists($path)){
require_once($path);
}
}
spl_autoload_register('autoload');
session_start();
$url = isset($_SERVER['PATH_INFO']) ? explode('/', ltrim($_SERVER['PATH_INFO'], '/')) : [];
if(!Session::exists(CURRENT_USER_SESSION_NAME) && Cookie::exists(REMEMBER_ME_COOKIE_NAME)) {
Users::loginUserFromCookie();
}
// Route the request
Router::route($url);