Move install to new router model, fix bootstrap checks
This commit is contained in:
parent
48ae6b2a40
commit
9ce0bab606
|
@ -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');
|
||||
|
||||
|
|
|
@ -1,17 +1,20 @@
|
|||
<?php
|
||||
|
||||
require_once '../src/lib.php';
|
||||
namespace Install;
|
||||
|
||||
if (file_exists('../.installed')) redirect('/');
|
||||
use Router;
|
||||
|
||||
$page = $_GET['page'] ?? 1;
|
||||
match ((int) $page) {
|
||||
2 => 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()
|
|||
<body>
|
||||
<b>Dragon Knight Installation: Page One</b><br><br>
|
||||
Installation for Dragon Knight is a simple two-step process: set up the database tables, then create the admin user. After that, you're done.<br><br>
|
||||
<a href="install.php?page=2"><button>Install</button></a>
|
||||
<a href="/install/second"><button>Install</button></a>
|
||||
</body>
|
||||
</html>
|
||||
HTML;
|
||||
|
@ -639,7 +642,7 @@ function second()
|
|||
echo $query === true ? 'Users table created.<br>' : 'Error creating Users table.';
|
||||
|
||||
$time = round((microtime(true) - START), 4);
|
||||
echo "<br>Database setup complete in $time seconds.<br><br><a href=\"install.php?page=3\">Click here to continue with installation.</a></body></html>";
|
||||
echo "<br>Database setup complete in $time seconds.<br><br><a href=\"/install/third\">Click here to continue with installation.</a></body></html>";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -655,7 +658,7 @@ function third()
|
|||
<body>
|
||||
<b>Dragon Knight Installation: Page Three</b><br><br>
|
||||
Now you must create an administrator account so you can use the control panel. Fill out the form below to create your account. You will be able to customize the class names through the control panel once your admin account is created.<br><br>
|
||||
<form action="install.php?page=4" method="post">
|
||||
<form action="/install/fourth" method="post">
|
||||
<table width="50%">
|
||||
<tr><td width="20%" style="vertical-align:top;">Username:</td><td><input type="text" name="username" /><br><br><br></td></tr>
|
||||
<tr><td style="vertical-align:top;">Password:</td><td><input type="password" name="password" /></td></tr>
|
||||
|
@ -711,7 +714,7 @@ function fourth()
|
|||
optional "call home" function in the installer, which notifies the author of your game installation. The ONLY information
|
||||
transmitted with this function is the URL to your game. This is included mainly to satisfy the author's curiosity about
|
||||
how many copies of the game are being installed and used. If you choose to submit your URL to the author, please
|
||||
<a href="install.php?page=5">click here</a>.
|
||||
<a href="/install/fifth">click here</a>.
|
||||
</body>
|
||||
</html>
|
||||
HTML;
|
45
src/bootstrap.php
Normal file
45
src/bootstrap.php
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
require_once 'lib.php';
|
||||
require_once 'router.php';
|
||||
require_once 'explore.php';
|
||||
require_once 'heal.php';
|
||||
require_once 'actions/users.php';
|
||||
require_once 'actions/help.php';
|
||||
require_once 'actions/towns.php';
|
||||
require_once 'actions/fight.php';
|
||||
require_once 'actions/forum.php';
|
||||
require_once 'actions/install.php';
|
||||
|
||||
$uri = uri();
|
||||
|
||||
if (!file_exists('../.installed') && $uri[0] !== 'install') {
|
||||
redirect('/install');
|
||||
} elseif (file_exists(('../.installed')) && $uri[0] === 'install') {
|
||||
redirect('/');
|
||||
} elseif (file_exists(('../.installed')) && $uri[0] !== 'install') {
|
||||
$controlrow = get_control_row();
|
||||
|
||||
if (!$controlrow["gameopen"]) {
|
||||
display("The game is currently closed for maintanence. Please check back later.", "Game Closed");
|
||||
}
|
||||
|
||||
// Login (or verify) if not logged in.
|
||||
if (($userrow = checkcookies()) === false) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user