getString('apii:api', FlashiiUrls::PROD_API_URL), $cfg->getString('apii:id', FlashiiUrls::PROD_ID_URL) )); $authInfo = $flashii->v1()->me(); $users = new Users($db); if($authInfo !== null) { $users->syncApiUser($authInfo); $userInfo = $users->getUser($authInfo->getId()); } else $userInfo = null; $csrfp = new CsrfToken( $cfg->getString('csrfp:secret', 'wowof'), $authInfo === null ? $_SERVER['REMOTE_ADDR'] : $authToken ); $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();