getRoutes(); } /** * Redirect to a given route * * @param string $route */ private static function redirectDashboard(string $route): void { header('Location: ' . AM_BASE_INDEX . AM_PAGE_DASHBOARD . $route, true, 301); exit(); } /** * Register API routes. * * @param Router $Router * @param bool $isAuthenticatedUser */ private static function registerAPIRoutes(Router $Router, bool $isAuthenticatedUser): void { $apiBase = RequestHandler::$apiBase; $Router->register( "$apiBase/.*", function () { return RequestHandler::getResponse(); }, $isAuthenticatedUser ); $Router->register( "$apiBase/(Session/login|Session/validate|App/bootstrap|User/resetPassword)", function () { return RequestHandler::getResponse(); }, AM_PAGE_DASHBOARD ); $Router->register( "$apiBase/.*", function () { header('Content-Type: application/json; charset=utf-8'); $Response = new Response(); $Response->setRedirect('login'); exit($Response->json()); }, AM_PAGE_DASHBOARD ); } /** * Register dashboard routes. * * @param Router $Router * @param bool $isAuthenticatedUser */ private static function registerDashboardRoutes(Router $Router, bool $isAuthenticatedUser): void { $hasAccounts = is_readable(UserCollection::FILE_ACCOUNTS); $Router->register( AM_PAGE_DASHBOARD . '/setup', function () { return Dashboard::render(); }, !$hasAccounts ); $Router->register( AM_PAGE_DASHBOARD . '(/.*)?', function () { self::redirectDashboard('/setup'); }, !$hasAccounts ); $Router->register( AM_PAGE_DASHBOARD . '/setup', function () { self::redirectDashboard('/login'); }, $hasAccounts ); $Router->register( AM_PAGE_DASHBOARD . '/(login|resetpassword)', function () { self::redirectDashboard('/home'); }, $isAuthenticatedUser ); $Router->register( AM_PAGE_DASHBOARD . '/(login|resetpassword)', function () { return Dashboard::render(); }, AM_PAGE_DASHBOARD ); $Router->register( AM_PAGE_DASHBOARD . '(/.*)?', function () { return Dashboard::render(); }, $isAuthenticatedUser ); $Router->register( AM_PAGE_DASHBOARD . '(/.*)?', function () { self::redirectDashboard('/login'); }, AM_PAGE_DASHBOARD ); } /** * Register the RSS feed route. * * @param Router $Router */ private static function registerFeedRoute(Router $Router): void { $Router->register( AM_FEED_URL, function () { header('Content-Type: application/rss+xml; charset=UTF-8'); $Cache = new Cache(); if ($Cache->pageCacheIsApproved()) { return $Cache->readPageFromCache(); } $Feed = new Feed( $Cache->getAutomad(), Parse::csv(AM_FEED_FIELDS) ); return $Feed->get(); }, AM_FEED_ENABLED ); } /** * Register all left-over routes as page routes. * * @param Router $Router */ private static function registerPageRoutes(Router $Router): void { $Router->register( '/.*', array(PageController::class, 'render') ); } } __halt_compiler();----SIGNATURE:----X031/nlNQJIZDBqXZPRZJY9zpqKe/2n1s84tHv+xpLa9SCqRqJmRUSpzSRtXgsKbIdyvUrmkLfCXJGCU7drwvCPVhcWMw2Hr52++R/BlLXEcDh+Bv7hwxYwpMKgUygvEKAf2XsNK1HIvDauzKrwyhHSTNxuOYz5bXxc7ClOVuM9QAcAHfNnf/7lNz5OWJtblrf+Mbj1P3wrVAYUfSw6LJfb6JRZ8I6S/4h0gpgCmzxgyYMgA4vGL3rxK0arKt9c9UUw66Z4N4tZmT+cu6vrk+ktx9bVxWCWB3J0uidwds9CUOkiIs+mMYXtDCkF3y/LiIYK6OTGbnu6o76BI6/Kg9pdwDdCb8MXR//aRTnd+Isv0CI4dPVXbeP3uEk2w2AlsJt3cWsutvL11GvQe3Aiqxs9tOTy76wDoybVlCO8nfh9+Ra37/lGicVf2yhCvJQWsl6xCtvwNRYUI9LMPNDWrNFxWH5bqhjsyTW51UVg7KCg41NvrVcQv4L6EofP+eYKxkcWMW7vhT2TH3c7QiTX7gJocwq6B5RTD6to0CjopWvDp4IP42PnzrSoYq26ejqTp+hdZfwQsU5MyPTt/CiBsFBKDBIR6d1smrK3sabpQMZhx6gRdQUS4+Wnm5EkF98V4wKMZx+71ZN6a0Zf+nbQho8fIVhncq7T7V7wPK2/zE7M=----ATTACHMENT:----OTE5ODAxODA2MzIzMTU2OCA0MjIwNzQxMjIwNDk2MDY2IDgxNDQzNjkyNzY1MDA0NzA=