scopeTo('cauth'), $authToken); $users = new Users($db); if($authInfo->success) { $users->syncChatUser($authInfo); $userInfo = $users->getUser($authInfo->user_id); } else $userInfo = null; $csrfp = new CsrfToken( $cfg->getString('csrfp:secret', 'wowof'), $authInfo->success ? $authToken : $_SERVER['REMOTE_ADDR'] ); $templating = new TplEnvironment(MCR_DIR_TPL, ['Mince'], debug: MCR_DEBUG); $templating->addGlobal('globals', [ '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(); $urls = new ArrayUrlRegistry; $templating->addFunction('url', $urls->format(...)); $router = new HttpRouter(errorHandler: new RouterErrorHandler($templating)); $router->use('/', function($response, $request) { $response->setPoweredBy('Mince'); }); $router->register(new RpcRoutes($users, $accountLinks, $authorisations, $verifications, $cfg->getString('rpc:secret'), $cfg->getString('urls:clients'))); $homeRoutes = new HomeRoutes($templating, $urls, new Servers($db), $authInfo, $cfg->getString('site:login')); $router->register($homeRoutes); $urls->register($homeRoutes); $clientRoutes = new ClientsRoutes($templating, $urls, $accountLinks, $authorisations, $verifications, $csrfp, $authInfo); $router->register($clientRoutes); $urls->register($clientRoutes); $skinsRoutes = new SkinsRoutes($templating, $urls, $accountLinks, new Skins($db), new Capes($db), $csrfp, $authInfo, $cfg->getString('urls:skins_base')); $router->register($skinsRoutes); $urls->register($skinsRoutes); MojangInterop::registerRoutes($router); $router->dispatch();