<?php
session_start();
$f3 = require('lib/base.php');
$f3->set('DEBUG', 3);
$f3->set('AUTOLOAD', 'api/models/');
// set defaults
$f3->set('loggedin', (isset($f3->get('SESSION')['username']))?true:false);
$f3->set('username', (isset($f3->get('SESSION')['username']))?$f3->get('SESSION')['username']:'Guest');
$f3->set('message', '');
$f3->config('config/global.cfg');
$f3->set('DB', new DB\SQL(
'mysql:host=localhost;port=3306;dbname=masterserver',
'root',
'password'
));
$f3->route('POST /do/@action',
function($f3, $params) {
$master = new Master;
if ($params['action'] === 'login') {
if (isset($_POST['user']) && isset($_POST['pass'])) {
$master->dologin($f3, $f3->get('POST')['user'], $f3->get('POST')['pass']);
}
}
}
);
$f3->route('GET @module: /@m',
function($f3, $params) {
$master = new Master;
if ($params['m'] === 'logout') {
$master->dologout($f3);
} else {
$master->parse($f3, $params);
}
}
);
$f3->route('GET /',
function($f3) {
$f3->reroute('@module(@m=home)');
}
);
/*
$f3->set('ONERROR',
function($f3) {
// recursively clear existing output buffers:
while (ob_get_level()) ob_end_clean();
echo $f3->get('ERROR.title');
}
);
*/
$f3->run();
?>