2022-07-03 22:07:00 +00:00
|
|
|
<?php
|
|
|
|
namespace Mince;
|
|
|
|
|
2024-08-04 23:01:33 +00:00
|
|
|
use Index\CSRFP;
|
2024-03-28 23:28:19 +00:00
|
|
|
use Index\Http\Routing\HttpRouter;
|
2023-08-24 23:13:29 +00:00
|
|
|
use Sasae\SasaeEnvironment;
|
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');
|
2023-12-15 02:14:55 +00:00
|
|
|
$authInfo = ChatAuth::attempt($cfg->scopeTo('cauth'), $authToken);
|
2023-08-22 23:47:37 +00:00
|
|
|
|
|
|
|
$users = new Users($db);
|
|
|
|
if($authInfo->success) {
|
|
|
|
$users->syncChatUser($authInfo);
|
|
|
|
$userInfo = $users->getUser($authInfo->user_id);
|
|
|
|
} else $userInfo = null;
|
2023-08-16 22:39:35 +00:00
|
|
|
|
2023-08-16 23:17:14 +00:00
|
|
|
$csrfp = new CSRFP(
|
2023-12-15 02:14:55 +00:00
|
|
|
$cfg->getString('csrfp:secret', 'wowof'),
|
2023-08-22 23:47:37 +00:00
|
|
|
$authInfo->success ? $authToken : $_SERVER['REMOTE_ADDR']
|
2023-08-16 23:17:14 +00:00
|
|
|
);
|
2023-08-16 22:39:35 +00:00
|
|
|
|
2023-08-24 23:13:29 +00:00
|
|
|
$templating = new SasaeEnvironment(MCR_DIR_TPL, ['Mince'], debug: MCR_DEBUG);
|
|
|
|
$templating->addGlobal('globals', [
|
|
|
|
'title' => 'Flashii Minecraft Servers',
|
2023-08-22 23:47:37 +00:00
|
|
|
'is_authed' => $userInfo !== null,
|
|
|
|
'user' => $userInfo,
|
2023-08-16 23:17:14 +00:00
|
|
|
'csrfp' => $csrfp->createToken(),
|
|
|
|
]);
|
2022-07-03 22:07:00 +00:00
|
|
|
|
2023-08-22 23:47:37 +00:00
|
|
|
$accountLinks = new AccountLinks($db);
|
|
|
|
$authorisations = new Authorisations($db);
|
|
|
|
$authorisations->prune();
|
|
|
|
$verifications = new Verifications($db);
|
|
|
|
$verifications->prune();
|
|
|
|
|
2024-03-28 23:28:19 +00:00
|
|
|
$router = new HttpRouter(errorHandler: new RouterErrorHandler($templating));
|
|
|
|
$router->use('/', function($response, $request) { $response->setPoweredBy('Mince'); });
|
2022-07-03 22:07:00 +00:00
|
|
|
|
2024-02-21 16:08:45 +00:00
|
|
|
$router->register(new RpcRoutes($users, $accountLinks, $authorisations, $verifications, $cfg->getString('rpc:secret'), $cfg->getString('urls:clients')));
|
|
|
|
$router->register(new HomeRoutes($templating, new Servers($db), $authInfo, $cfg->getString('site:login')));
|
|
|
|
$router->register(new ClientsRoutes($templating, $accountLinks, $authorisations, $verifications, $csrfp, $authInfo));
|
|
|
|
$router->register(new SkinsRoutes($templating, $accountLinks, new Skins($db), new Capes($db), $csrfp, $authInfo, $cfg->getString('urls:skins_base')));
|
2023-08-22 23:47:37 +00:00
|
|
|
|
|
|
|
MojangInterop::registerRoutes($router);
|
2022-07-03 22:07:00 +00:00
|
|
|
|
|
|
|
$router->dispatch();
|