diff --git a/public/index.php b/public/index.php index 8210b13..ec4a7a2 100644 --- a/public/index.php +++ b/public/index.php @@ -2,50 +2,7 @@ // index.php :: Primary program script, evil alien overlord, you decide. -require_once '../src/lib.php'; -require_once '../src/router.php'; -require_once '../src/explore.php'; -require_once '../src/heal.php'; -require_once '../src/actions/users.php'; -require_once '../src/actions/help.php'; -require_once '../src/actions/towns.php'; -require_once '../src/actions/fight.php'; -require_once '../src/actions/forum.php'; - -if (!file_exists('../.installed')) redirect('install.php'); - -$controlrow = get_control_row(); - -if (!$controlrow["gameopen"]) { - display("The game is currently closed for maintanence. Please check back later.", "Game Closed"); - exit; -} - -// Login (or verify) if not logged in. -if (($userrow = checkcookies()) === false) { - $uri = uri(); - if (!in_array($uri[0], ['login', 'register', 'verify', 'lostpassword', 'help'])) { - redirect('/login'); - } -} else { - // Block user if he/she has been banned. - if ($userrow["authlevel"] === 2) { - exit("Your account has been banned."); - } - - // Force verify if the user isn't verified yet. - if ($controlrow["verifyemail"] && (bool) $userrow["verify"] === false) { - redirect('/verify'); - header("Location: users.php?do=verify"); - exit; - } -} - -// Close game. -if (!$controlrow["gameopen"]) { - display("The game is currently closed for maintanence. Please check back later.", "Game Closed"); - exit; -} +require_once '../src/bootstrap.php'; $r = new Router; @@ -74,6 +31,7 @@ Fights\register_routes($r); Users\register_routes($r); Help\register_routes($r); Forum\register_routes($r); +Install\register_routes($r); $r->post('/move', 'move'); diff --git a/public/install.php b/src/actions/install.php similarity index 98% rename from public/install.php rename to src/actions/install.php index 8edaa69..d7e2bed 100644 --- a/public/install.php +++ b/src/actions/install.php @@ -1,17 +1,20 @@ second(), - 3 => third(), - 4 => fourth(), - 5 => fifth(), - default => first(), -}; +function register_routes(Router $r): Router +{ + if (!file_exists('../.installed')) { + $r->get('/install', 'Install\first'); + $r->get('/install/second', 'Install\second'); + $r->get('/install/third', 'Install\third'); + $r->post('/install/fourth', 'Install\fourth'); + $r->get('/install/fifth', 'Install\fifth'); + } + return $r; +} /** * First page - show warnings and gather info @@ -27,7 +30,7 @@ function first()
Dragon Knight Installation: Page One