65 lines
1.7 KiB
PHP
65 lines
1.7 KiB
PHP
<?php
|
|
|
|
require_once 'lib.php';
|
|
require_once 'router.php';
|
|
require_once 'auth.php';
|
|
require_once 'mail.php';
|
|
require_once 'render.php';
|
|
require_once 'actions/explore.php';
|
|
require_once 'actions/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';
|
|
require_once 'actions/admin.php';
|
|
require_once 'models/model.php';
|
|
require_once 'models/user.php';
|
|
|
|
env_load('../.env');
|
|
|
|
$uri = explode('/', trim($_SERVER['REQUEST_URI'], '/'));
|
|
$GLOBALS['cache'] = [];
|
|
$GLOBALS['state'] = [];
|
|
|
|
if (!file_exists('../.installed') && $uri[0] !== 'install') {
|
|
redirect('/install');
|
|
} elseif (file_exists(('../.installed')) && $uri[0] === 'install') {
|
|
redirect('/');
|
|
} elseif (file_exists(('../.installed')) && $uri[0] !== 'install') {
|
|
if (!env('game_open')) {
|
|
echo Render\content('The game is currently closed for maintanence. Please check back later.');
|
|
exit;
|
|
}
|
|
|
|
$auth = new Auth;
|
|
|
|
// Login (or verify) if not logged in.
|
|
if (user() === false) {
|
|
if (!in_array($uri[0], ['login', 'register', 'verify', 'lostpassword', 'help'])) {
|
|
redirect('/login');
|
|
}
|
|
} elseif ($auth->good()) {
|
|
// Block user if he/she has been banned.
|
|
if (user()->authlevel === 2) {
|
|
exit("Your account has been banned.");
|
|
}
|
|
|
|
// Force verify if the user isn't verified yet.
|
|
if (env('verify_email') && user()->verify !== 'g2g' && !in_array($uri[0], ['verify', 'logout'])) {
|
|
redirect('/verify');
|
|
}
|
|
|
|
// Ensure the user can't use the admin panel.
|
|
if (user()->authlevel !== 1 && $uri[0] === 'admin') {
|
|
redirect('/');
|
|
}
|
|
|
|
user()->update_online_time();
|
|
} else {
|
|
$auth->logout();
|
|
redirect('/login');
|
|
}
|
|
}
|