48 lines
1.3 KiB
PHP
48 lines
1.3 KiB
PHP
<?php
|
|
namespace Mince;
|
|
|
|
use Index\XString;
|
|
use Index\Http\HttpFx;
|
|
use Index\Security\CSRFP;
|
|
|
|
require_once __DIR__ . '/../mince.php';
|
|
|
|
// replace this with id.flashii.net shit
|
|
$authToken = (string)filter_input(INPUT_COOKIE, 'msz_auth');
|
|
$userInfo = ChatAuth::attempt($db, $config['chat_endpoint'], $config['chat_secret'], $authToken);
|
|
|
|
$csrfp = new CSRFP(
|
|
$config['csrf_secret'],
|
|
$userInfo->success ? $authToken : $_SERVER['REMOTE_ADDR']
|
|
);
|
|
|
|
$templating = new Templating;
|
|
$templating->addPath(MCR_DIR_TPL);
|
|
|
|
$templating->addVars([
|
|
'global' => [
|
|
'title' => 'Flashii Minecraft Servers',
|
|
'loginUrl' => $config['login_url'],
|
|
],
|
|
'auth' => $userInfo,
|
|
'csrfp' => $csrfp->createToken(),
|
|
]);
|
|
|
|
$router = new HttpFx;
|
|
$router->use('/', function($response, $request) {
|
|
$response->setPoweredBy('Mince');
|
|
});
|
|
|
|
$router->setDefaultErrorHandler(function($response, $request, $code, $text) use ($templating) {
|
|
$response->setContent($templating->render('http-error', [
|
|
'error' => [
|
|
'code' => sprintf('%03d', $code),
|
|
'text' => $text,
|
|
],
|
|
]));
|
|
});
|
|
|
|
(new HomeRoutes($templating, $userInfo))->register($router);
|
|
(new WhitelistRoutes(new Whitelist($db), $csrfp, $userInfo))->register($router);
|
|
|
|
$router->dispatch();
|