2022-07-03 22:07:00 +00:00
|
|
|
<?php
|
|
|
|
namespace Mince;
|
|
|
|
|
2023-08-16 22:39:35 +00:00
|
|
|
use Index\XString;
|
2022-07-03 22:07:00 +00:00
|
|
|
use Index\Http\HttpFx;
|
2023-08-16 23:17:14 +00:00
|
|
|
use Index\Security\CSRFP;
|
2022-07-03 22:07:00 +00:00
|
|
|
|
|
|
|
require_once __DIR__ . '/../mince.php';
|
|
|
|
|
2023-08-16 23:17:14 +00:00
|
|
|
// 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);
|
2023-08-16 22:39:35 +00:00
|
|
|
|
2023-08-16 23:17:14 +00:00
|
|
|
$csrfp = new CSRFP(
|
|
|
|
$config['csrf_secret'],
|
|
|
|
$userInfo->success ? $authToken : $_SERVER['REMOTE_ADDR']
|
|
|
|
);
|
2023-08-16 22:39:35 +00:00
|
|
|
|
2023-08-16 23:17:14 +00:00
|
|
|
$templating = new Templating;
|
|
|
|
$templating->addPath(MCR_DIR_TPL);
|
|
|
|
|
|
|
|
$templating->addVars([
|
2023-08-16 22:39:35 +00:00
|
|
|
'global' => [
|
|
|
|
'title' => 'Flashii Minecraft Servers',
|
|
|
|
'loginUrl' => $config['login_url'],
|
|
|
|
],
|
|
|
|
'auth' => $userInfo,
|
2023-08-16 23:17:14 +00:00
|
|
|
'csrfp' => $csrfp->createToken(),
|
|
|
|
]);
|
2022-07-03 22:07:00 +00:00
|
|
|
|
2023-08-16 22:39:35 +00:00
|
|
|
$router = new HttpFx;
|
2023-08-16 23:45:46 +00:00
|
|
|
$router->use('/', function($response, $request) {
|
|
|
|
$response->setPoweredBy('Mince');
|
|
|
|
});
|
2022-07-03 22:07:00 +00:00
|
|
|
|
2023-08-16 23:45:46 +00:00
|
|
|
$router->setDefaultErrorHandler(function($response, $request, $code, $text) use ($templating) {
|
2023-08-16 23:17:14 +00:00
|
|
|
$response->setContent($templating->render('http-error', [
|
2023-08-16 22:39:35 +00:00
|
|
|
'error' => [
|
|
|
|
'code' => sprintf('%03d', $code),
|
|
|
|
'text' => $text,
|
|
|
|
],
|
|
|
|
]));
|
2022-07-03 22:07:00 +00:00
|
|
|
});
|
|
|
|
|
2023-08-16 23:45:46 +00:00
|
|
|
(new HomeRoutes($templating, $userInfo))->register($router);
|
|
|
|
(new WhitelistRoutes(new Whitelist($db), $csrfp, $userInfo))->register($router);
|
2022-07-03 22:07:00 +00:00
|
|
|
|
|
|
|
$router->dispatch();
|