40 lines
1 KiB
PHP
40 lines
1 KiB
PHP
<?php
|
|
require_once('config/config.php');
|
|
require_once('src/func.php');
|
|
require_once('src/model.php');
|
|
session_start();
|
|
/*
|
|
* Env path
|
|
*/
|
|
define('__PATH', str_replace(WEBSITE_PATH, '', $_SERVER['REQUEST_URI']));
|
|
/*
|
|
* User session
|
|
*/
|
|
|
|
if(!isset($_SESSION['user'])){
|
|
$_SESSION['user'] = new User();
|
|
}
|
|
/*
|
|
* Lang
|
|
*/
|
|
$lang = LANG_DEFAULT;
|
|
$langs = glob(LANG_PATH. '*.{json}', GLOB_BRACE);
|
|
if(isset($_SESSION['lang']) && in_array(LANG_PATH.$_SESSION['lang'].'.json', $langs)) $lang = $_SESSION['lang'];
|
|
if(isset($_GET['lang']) && in_array(LANG_PATH.$_GET['lang'].'.json', $langs)){ $lang = $_GET['lang']; $_SESSION['lang'] = $lang; }
|
|
|
|
/*
|
|
* Routing
|
|
*/
|
|
$path = explode('/',explode('?',__PATH)[0]);
|
|
$assetsLevel = count($path)-1;
|
|
switch($path[0]){
|
|
case '':
|
|
$path[0] = WEBSITE_DEFAULT_PATH;
|
|
require_once(CONTROLLER_PATH.WEBSITE_DEFAULT_PATH.'.php');
|
|
break;
|
|
case (is_file(CONTROLLER_PATH. $path[0] .'.php')):
|
|
require_once(CONTROLLER_PATH.$path[0].'.php');
|
|
break;
|
|
default:
|
|
require_once(CONTROLLER_PATH.'404.php');
|
|
}
|