success) { $users->syncChatUser($authInfo); $userInfo = $users->getUser($authInfo->user_id); } else $userInfo = null; $csrfp = new CSRFP( $config['csrf_secret'], $authInfo->success ? $authToken : $_SERVER['REMOTE_ADDR'] ); $templating = new Templating; $templating->addPath(MCR_DIR_TPL); $templating->addVars([ 'global' => [ 'title' => 'Flashii Minecraft Servers', ], 'is_authed' => $userInfo !== null, 'user' => $userInfo, 'csrfp' => $csrfp->createToken(), ]); $accountLinks = new AccountLinks($db); $authorisations = new Authorisations($db); $authorisations->prune(); $verifications = new Verifications($db); $verifications->prune(); $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 RpcRoutes($users, $accountLinks, $authorisations, $verifications, $config['rpc_secret'], $config['clients_url']))->register($router); (new HomeRoutes(new Servers($db), $templating, $authInfo, $config['login_url']))->register($router); (new ClientsRoutes($templating, $accountLinks, $authorisations, $verifications, $csrfp, $authInfo))->register($router); (new SkinsRoutes($templating, $accountLinks, new Skins($db), new Capes($db), $csrfp, $authInfo, $config['skins_base_url']))->register($router); MojangInterop::registerRoutes($router); $router->dispatch();