index.php 1.16 KB
Newer Older
1 2
<?php

3
require_once("../vendor/autoload.php");
4

5
require_once("../app/config.php");
6 7 8 9 10

// Retrieve instance of the framework
$f3 = Base::instance();

// Initialize CMS
11
$f3->config('../app/config.ini');
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38

$f3->set('container', new LQDN\Container());

// Deal with sessions
$session = $f3->get('container')['session'];
$session->start();
if (!$session->has('csrf')) {
    $session->set('csrf', md5(rand()));
}
$f3->CSRF = $session->get('csrf');

// Debug
$f3->set('DEBUG', DEBUG);
$f3->set('ONERROR', function ($f3) {
    $logger = new Log('error.log');
    $logger->write($f3->get('ERROR.code') . ' - ' . $f3->get('ERROR.text'));
    $logger->write($f3->get('ERROR.trace'));

    // If there is any problem, replace the current csrf
    $csrf = md5(rand());
    $f3->CSRF = $csrf;
    $f3->get('container')['session']->set('csrf', $csrf);

    while (ob_get_level()) {
        ob_end_clean();
    }
    $f3->set('block_content', 'campaign/errors.html');
39
    echo Template::instance()->render('base.html');
40 41 42 43 44 45 46 47
});

// Are we being invoked from CLI ?
if (php_sapi_name() == 'cli') {
    $f3->CLI = true;
}

// Define routes
48
$f3->config('../app/routes.ini');
49 50 51

// Execute application
$f3->run();