<?php

define('DS', '/');
define('ROOT', __DIR__);
define('APP','Application');
define('VEND', ROOT."/vendor");

/**
 * Load autoloaders and Config files
 */
require_once ROOT."/autoload.php";
require_once VEND."/autoload.php";
require_once ROOT.DS.APP."/Config/config.php";

use Symfony\Component\Debug\Debug;
use SCF\Core\DI;
use SCF\Core\Database;
use SCF\Core\System;
use SCF\Additionals\Tracking;
use SCF\Core\Templates;

/**
 * CREATE SYMLINK FOR BOOTSTRAP FOLDER IF NOT EXISTS!
 */
if(!is_link(__DIR__."/web/lib/bootstrap")) {
    symlink(__DIR__."/vendor/twbs/bootstrap/dist", __DIR__."/web/lib/bootstrap");
}

/**
 * Check if Debug is Enabled and enabdle or disable Error Reporting
 */
if($config['debug'] == 1 || $_GET['debug'] == 1) {
    error_reporting(E_ALL & ~E_NOTICE);
    Debug::enable(E_ALL & ~E_NOTICE);
}
else {
    error_reporting(0);
    Debug::enable(0);
}

$di = DI::getInstance();
$di->set('db', new Database($config['dbext'], $config['server'], $config['mysqluser'], $config['mysqlpass'], $config['mysqldbname']), true);
$di->set('router', 'AltoRouter', true);
$di->set('tracking', new Tracking(DI::getInstance()->get('db')), true);

$settings = new System(DI::getInstance()->get('db'));
$router = DI::getInstance()->get('router');
$tpl = new Templates($settings,$router);
