From 37599b90b96b3b585fca63d2072ae5225a401ee8 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Fri, 28 Feb 2025 22:53:43 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Start=20using=20boot=20fun?= =?UTF-8?q?ctions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin.php | 5 +++ forum.php | 5 +++ help.php | 5 +++ help_items.php | 5 +++ help_levels.php | 5 +++ help_monsters.php | 5 +++ help_spells.php | 5 +++ index.php | 81 ++++++++++++++----------------------------- kernel/boot/admin.php | 0 kernel/boot/init.php | 42 ++++++++++++++++++++++ kernel/boot/site.php | 54 +++++++++++++++++++++++++++++ kernel/lib.php | 4 +-- login.php | 5 +++ users.php | 5 +++ 14 files changed, 169 insertions(+), 57 deletions(-) create mode 100644 kernel/boot/admin.php create mode 100644 kernel/boot/init.php create mode 100644 kernel/boot/site.php diff --git a/admin.php b/admin.php index b8239c3..b6c60b0 100644 --- a/admin.php +++ b/admin.php @@ -1,5 +1,10 @@ install.php from your Dragon Knight directory before continuing."); } -include('kernel/lib.php'); -include('kernel/cookies.php'); -$link = opendb(); -$controlquery = doquery("SELECT * FROM {{table}} WHERE id='1' LIMIT 1", "control"); -$controlrow = mysqli_fetch_array($controlquery); +/* + * Dragon Forks + * https://git.kobold.cafe/game-projects/dragon-forks + * Original author Jamin Blount, forked by Kazhnuz + * Some code and structure are forked from Bludit by Diego Najar + * Dragon Forks is opensource software licensed under the MIT license. +*/ -// Login (or verify) if not logged in. -$userrow = checkcookies(); -if ($userrow == false) { - if (isset($_GET["do"])) { - if ($_GET["do"] == "verify") { header("Location: users.php?do=verify"); die(); } - } - header("Location: login.php?do=login"); die(); -} -// Close game. -if ($controlrow["gameopen"] == 0) { display("The game is currently closed for maintanence. Please check back later.","Game Closed"); die(); } -// Force verify if the user isn't verified yet. -if ($controlrow["verifyemail"] == 1 && $userrow["verify"] != 1) { header("Location: users.php?do=verify"); die(); } -// Block user if he/she has been banned. -if ($userrow["authlevel"] == 2) { die("Your account has been blocked. Please try back later."); } +// TODO: use a better way to handle security +//if (file_exists('install.php')) { die("Please delete install.php from your Dragon Knight directory before continuing."); } -if (isset($_GET["do"])) { - $do = explode(":",$_GET["do"]); - - // Town functions. - if ($do[0] == "inn") { include('game/towns.php'); inn(); } - elseif ($do[0] == "buy") { include('game/towns.php'); buy(); } - elseif ($do[0] == "buy2") { include('game/towns.php'); buy2($do[1]); } - elseif ($do[0] == "buy3") { include('game/towns.php'); buy3($do[1]); } - elseif ($do[0] == "sell") { include('game/towns.php'); sell(); } - elseif ($do[0] == "maps") { include('game/towns.php'); maps(); } - elseif ($do[0] == "maps2") { include('game/towns.php'); maps2($do[1]); } - elseif ($do[0] == "maps3") { include('game/towns.php'); maps3($do[1]); } - elseif ($do[0] == "gotown") { include('game/towns.php'); travelto($do[1]); } - - // Exploring functions. - elseif ($do[0] == "move") { include('game/explore.php'); move(); } - - // Fighting functions. - elseif ($do[0] == "fight") { include('game/fight.php'); fight(); } - elseif ($do[0] == "victory") { include('game/fight.php'); victory(); } - elseif ($do[0] == "drop") { include('game/fight.php'); drop(); } - elseif ($do[0] == "dead") { include('game/fight.php'); dead(); } - - // Misc functions. - elseif ($do[0] == "verify") { header("Location: users.php?do=verify"); die(); } - elseif ($do[0] == "spell") { include('game/heal.php'); healspells($do[1]); } - elseif ($do[0] == "showchar") { include('game/misc.php'); showchar(); } - elseif ($do[0] == "onlinechar") { include('game/misc.php'); onlinechar($do[1]); } - elseif ($do[0] == "showmap") { include('game/misc.php'); showmap(); } - elseif ($do[0] == "babblebox") { include('game/misc.php'); babblebox(); } - elseif ($do[0] == "ninja") { include('game/misc.php'); ninja(); } - elseif ($do[0] == "die") { header('Location: index.php?do=buy'); die(); } - -} else { include('game/misc.php'); donothing(); } +// Load time init +$loadTime = microtime(true); + +// Security constant +define('DRAGONFORK', true); + +// Directory separator +define('DS', DIRECTORY_SEPARATOR); + +// PHP paths for init +define('PATH_ROOT', __DIR__.DS); +define('PATH_BOOT', PATH_ROOT.'kernel'.DS.'boot'.DS); + +// Init +require(PATH_BOOT.'init.php'); +require(PATH_BOOT.'site.php'); ?> \ No newline at end of file diff --git a/kernel/boot/admin.php b/kernel/boot/admin.php new file mode 100644 index 0000000..e69de29 diff --git a/kernel/boot/init.php b/kernel/boot/init.php new file mode 100644 index 0000000..f072914 --- /dev/null +++ b/kernel/boot/init.php @@ -0,0 +1,42 @@ +