2024-12-13 15:52:37 -06:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once 'lib.php';
|
|
|
|
require_once 'router.php';
|
2024-12-17 22:10:49 -06:00
|
|
|
require_once 'auth.php';
|
2024-12-15 06:35:19 -06:00
|
|
|
require_once 'mail.php';
|
2024-12-18 10:00:41 -06:00
|
|
|
require_once 'render.php';
|
2024-12-15 06:35:19 -06:00
|
|
|
require_once 'actions/explore.php';
|
|
|
|
require_once 'actions/heal.php';
|
2024-12-13 15:52:37 -06:00
|
|
|
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';
|
2024-12-13 16:09:57 -06:00
|
|
|
require_once 'actions/admin.php';
|
2024-12-17 22:10:49 -06:00
|
|
|
require_once 'models/model.php';
|
|
|
|
require_once 'models/user.php';
|
2024-12-13 15:52:37 -06:00
|
|
|
|
2024-12-15 06:35:19 -06:00
|
|
|
env_load('../.env');
|
|
|
|
|
2024-12-18 18:47:28 -06:00
|
|
|
$uri = explode('/', trim($_SERVER['REQUEST_URI'], '/'));
|
2024-12-15 22:02:49 -06:00
|
|
|
$GLOBALS['cache'] = [];
|
2024-12-17 22:10:49 -06:00
|
|
|
$GLOBALS['state'] = [];
|
2024-12-13 15:52:37 -06:00
|
|
|
|
|
|
|
if (!file_exists('../.installed') && $uri[0] !== 'install') {
|
|
|
|
redirect('/install');
|
|
|
|
} elseif (file_exists(('../.installed')) && $uri[0] === 'install') {
|
|
|
|
redirect('/');
|
2024-12-18 17:00:23 -06:00
|
|
|
} elseif (file_exists(('../.installed')) && $uri[0] !== 'install') {
|
2024-12-13 15:52:37 -06:00
|
|
|
$controlrow = get_control_row();
|
|
|
|
|
|
|
|
if (!$controlrow["gameopen"]) {
|
|
|
|
display("The game is currently closed for maintanence. Please check back later.", "Game Closed");
|
|
|
|
}
|
|
|
|
|
2024-12-17 22:10:49 -06:00
|
|
|
$auth = new Auth;
|
|
|
|
|
2024-12-13 15:52:37 -06:00
|
|
|
// Login (or verify) if not logged in.
|
2024-12-17 22:10:49 -06:00
|
|
|
if (user() === false) {
|
2024-12-13 15:52:37 -06:00
|
|
|
if (!in_array($uri[0], ['login', 'register', 'verify', 'lostpassword', 'help'])) {
|
|
|
|
redirect('/login');
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Block user if he/she has been banned.
|
2024-12-17 22:10:49 -06:00
|
|
|
if (user()->authlevel === 2) {
|
2024-12-13 15:52:37 -06:00
|
|
|
exit("Your account has been banned.");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Force verify if the user isn't verified yet.
|
2024-12-17 22:10:49 -06:00
|
|
|
if ($controlrow['verifyemail'] && user()->verify !== 'g2g' && !in_array($uri[0], ['verify', 'logout'])) {
|
2024-12-13 15:52:37 -06:00
|
|
|
redirect('/verify');
|
|
|
|
}
|
2024-12-13 16:09:57 -06:00
|
|
|
|
|
|
|
// Ensure the user can't use the admin panel.
|
2024-12-17 22:10:49 -06:00
|
|
|
if (user()->authlevel !== 1 && $uri[0] === 'admin') {
|
2024-12-13 16:09:57 -06:00
|
|
|
redirect('/');
|
|
|
|
}
|
2024-12-13 15:52:37 -06:00
|
|
|
}
|
|
|
|
}
|