/
index.php
35 lines (34 loc) · 1.04 KB
/
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
33
34
35
<?php
$global_start_time = microtime(true);
define('SITE_ROOT', __DIR__);
define('ADMIN_ROOT', SITE_ROOT.'/admin');
mb_internal_encoding('UTF-8');
require_once(SITE_ROOT.'/config.php');
if(SConfig::SITE_DEBUG){
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
ini_set('error_reporting', E_ALL);
}
try{
//подключаем классы
spl_autoload_register(function($class){
$lib_dirs = ['core', 'exceptions', 'helpers', 'system'];
foreach($lib_dirs as $dir){
if(is_readable(SITE_ROOT.'/lib/'.$dir.'/'.$class.'.php')){
require_once(SITE_ROOT.'/lib/'.$dir.'/'.$class.'.php');
return;
}
}
throw new SystemException('Класса '.$class.' не существует');
});
//запускаем выполнение
Router::start();
}
catch (SystemException $e){
header('HTTP/1.0 500 Internal Server Error');
echo $e->getError();
}
catch(ValidatorException $e){
header('HTTP/1.0 400 Bad Request');
echo $e->getError();
}