2020-04-20 19:49:30 +00:00
|
|
|
<?php
|
2020-04-21 15:59:37 +00:00
|
|
|
|
2020-04-21 11:55:11 +00:00
|
|
|
//Autoloader
|
2020-04-21 15:59:37 +00:00
|
|
|
class Autoloader {
|
|
|
|
protected static $extension = ".php";
|
|
|
|
protected static $root = __DIR__;
|
|
|
|
protected static $files = [];
|
|
|
|
|
|
|
|
static function ClassLoader ($className = ""){
|
|
|
|
$directorys = new RecursiveDirectoryIterator(static::$root, RecursiveDirectoryIterator::SKIP_DOTS);
|
|
|
|
|
|
|
|
//echo '<pre>';
|
|
|
|
//var_dump($directorys);
|
|
|
|
//echo '</pre>';
|
|
|
|
|
|
|
|
$files = new RecursiveIteratorIterator($directorys, RecursiveIteratorIterator::LEAVES_ONLY);
|
|
|
|
|
|
|
|
$filename = $className . static::$extension;
|
|
|
|
|
|
|
|
foreach ($files as $key => $file) {
|
|
|
|
if (strtolower($file->getFilename()) === strtolower($filename) && $file->isReadable()) {
|
|
|
|
include_once $file->getPathname();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-04-21 11:55:11 +00:00
|
|
|
|
2020-04-21 15:59:37 +00:00
|
|
|
static function setRoot($rootPath){
|
|
|
|
static::$root = $rootPath;
|
|
|
|
}
|
2020-04-21 11:55:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
spl_autoload_register("Autoloader::ClassLoader");
|
2020-04-21 13:19:05 +00:00
|
|
|
Autoloader::setRoot('/var/www/dev.steelants.cz/vasek/home-update/');
|
2020-04-25 08:21:52 +00:00
|
|
|
|
|
|
|
class ErrorHandler {
|
|
|
|
static function exception($exception){
|
|
|
|
error_log($exception);
|
2020-04-25 09:09:32 +00:00
|
|
|
header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, $exception->getCode());
|
2020-04-25 08:21:52 +00:00
|
|
|
echo '<h1>Oops!</h1><p>Something went wrong!</p>';
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
}
|
2020-04-25 08:20:47 +00:00
|
|
|
set_exception_handler("ErrorHandler::exception");
|
2020-04-21 13:19:05 +00:00
|
|
|
|
|
|
|
//Debug
|
|
|
|
error_reporting(E_ALL);
|
|
|
|
ini_set( 'display_errors','1');
|
2020-04-21 11:55:11 +00:00
|
|
|
|
2020-04-21 12:11:34 +00:00
|
|
|
//setup
|
|
|
|
ini_set ('session.cookie_httponly', '1');
|
|
|
|
ini_set('session.cookie_domain', $_SERVER['HTTP_HOST']);
|
|
|
|
ini_set('session.cookie_path', str_replace("login", "", str_replace('https://' . $_SERVER['HTTP_HOST'], "", $_SERVER['REQUEST_URI'])));
|
|
|
|
ini_set('session.cookie_secure', '1');
|
|
|
|
session_start ();
|
|
|
|
mb_internal_encoding ("UTF-8");
|
|
|
|
|
2020-04-21 15:59:37 +00:00
|
|
|
// import configs
|
|
|
|
require_once '../config/config.php';
|
|
|
|
|
|
|
|
// Logs
|
2020-04-21 13:27:57 +00:00
|
|
|
$logManager = new LogManager();
|
|
|
|
|
2020-04-21 15:59:37 +00:00
|
|
|
// Language
|
2020-04-21 13:27:57 +00:00
|
|
|
$langTag = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
|
|
|
|
$langMng = new LanguageManager($langTag);
|
|
|
|
$langMng->load();
|
2020-04-21 12:11:34 +00:00
|
|
|
|
2020-04-21 15:59:37 +00:00
|
|
|
//D B Conector
|
|
|
|
Db::connect (DBHOST, DBUSER, DBPASS, DBNAME);
|
2020-04-21 13:27:57 +00:00
|
|
|
|
2020-04-21 15:59:37 +00:00
|
|
|
// TODO: Přesunout do Login Pohledu
|
2020-04-21 12:11:34 +00:00
|
|
|
$userManager = new UserManager();
|
|
|
|
|
2020-04-21 12:14:13 +00:00
|
|
|
// import routes
|
2020-04-21 13:20:29 +00:00
|
|
|
require_once '../app/Routes.php';
|