♻️ Start using boot functions
This commit is contained in:
parent
d8aaccce5b
commit
37599b90b9
14 changed files with 169 additions and 57 deletions
|
@ -1,5 +1,10 @@
|
|||
<?php // admin.php :: primary administration script.
|
||||
|
||||
// TODO: remove when porting to real boot files
|
||||
define('DS', DIRECTORY_SEPARATOR);
|
||||
define('PATH_ROOT', __DIR__.DS);
|
||||
define('PATH_BOOT', PATH_ROOT.'kernel'.DS.'boot'.DS);
|
||||
|
||||
include('kernel/lib.php');
|
||||
include('kernel/cookies.php');
|
||||
$link = opendb();
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
<?php // forum.php :: Internal forums script for the game.
|
||||
|
||||
// TODO: remove when porting to real boot files
|
||||
define('DS', DIRECTORY_SEPARATOR);
|
||||
define('PATH_ROOT', __DIR__.DS);
|
||||
define('PATH_BOOT', PATH_ROOT.'kernel'.DS.'boot'.DS);
|
||||
|
||||
include('kernel/lib.php');
|
||||
include('kernel/cookies.php');
|
||||
$link = opendb();
|
||||
|
|
5
help.php
5
help.php
|
@ -1,4 +1,9 @@
|
|||
<?php
|
||||
|
||||
// TODO: remove when porting to real boot files
|
||||
define('DS', DIRECTORY_SEPARATOR);
|
||||
define('PATH_ROOT', __DIR__.DS);
|
||||
define('PATH_BOOT', PATH_ROOT.'kernel'.DS.'boot'.DS);
|
||||
include('kernel/lib.php');
|
||||
$link = opendb();
|
||||
$controlquery = doquery("SELECT * FROM {{table}} WHERE id='1' LIMIT 1", "control");
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
<?php
|
||||
|
||||
// TODO: remove when porting to real boot files
|
||||
define('DS', DIRECTORY_SEPARATOR);
|
||||
define('PATH_ROOT', __DIR__.DS);
|
||||
define('PATH_BOOT', PATH_ROOT.'kernel'.DS.'boot'.DS);
|
||||
include('kernel/lib.php');
|
||||
$link = opendb();
|
||||
$controlquery = doquery("SELECT * FROM {{table}} WHERE id='1' LIMIT 1", "control");
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
<?php
|
||||
|
||||
// TODO: remove when porting to real boot files
|
||||
define('DS', DIRECTORY_SEPARATOR);
|
||||
define('PATH_ROOT', __DIR__.DS);
|
||||
define('PATH_BOOT', PATH_ROOT.'kernel'.DS.'boot'.DS);
|
||||
include('kernel/lib.php');
|
||||
$link = opendb();
|
||||
$controlquery = doquery("SELECT * FROM {{table}} WHERE id='1' LIMIT 1", "control");
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
<?php
|
||||
|
||||
// TODO: remove when porting to real boot files
|
||||
define('DS', DIRECTORY_SEPARATOR);
|
||||
define('PATH_ROOT', __DIR__.DS);
|
||||
define('PATH_BOOT', PATH_ROOT.'kernel'.DS.'boot'.DS);
|
||||
include('kernel/lib.php');
|
||||
$link = opendb();
|
||||
$controlquery = doquery("SELECT * FROM {{table}} WHERE id='1' LIMIT 1", "control");
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
<?php
|
||||
|
||||
// TODO: remove when porting to real boot files
|
||||
define('DS', DIRECTORY_SEPARATOR);
|
||||
define('PATH_ROOT', __DIR__.DS);
|
||||
define('PATH_BOOT', PATH_ROOT.'kernel'.DS.'boot'.DS);
|
||||
include('kernel/lib.php');
|
||||
$link = opendb();
|
||||
$controlquery = doquery("SELECT * FROM {{table}} WHERE id='1' LIMIT 1", "control");
|
||||
|
|
81
index.php
81
index.php
|
@ -1,60 +1,31 @@
|
|||
<?php // index.php :: Primary program script, evil alien overlord, you decide.
|
||||
<?php
|
||||
|
||||
if (file_exists('install.php')) { die("Please delete <b>install.php</b> 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 <b>install.php</b> 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');
|
||||
|
||||
?>
|
0
kernel/boot/admin.php
Normal file
0
kernel/boot/admin.php
Normal file
42
kernel/boot/init.php
Normal file
42
kernel/boot/init.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php // The initialisation of the kernel of dragon-fork
|
||||
|
||||
// Dragon Fork version
|
||||
define('DRAGONFORK_VERSION', '0.0.1');
|
||||
define('DRAGONFORK_CODENAME', '');
|
||||
define('DRAGONFORK_RELEASE_DATE', '2024-08-23');
|
||||
define('DRAGONFORK_BUILD', '20240806');
|
||||
|
||||
// Change to TRUE for debugging
|
||||
define('DEBUG_MODE', TRUE);
|
||||
define('DEBUG_TYPE', 'INFO'); // INFO, TRACE
|
||||
|
||||
// This determines whether errors should be printed to the screen as part of the output or if they should be hidden from the user.
|
||||
ini_set("display_errors", 0);
|
||||
|
||||
// Even when display_errors is on, errors that occur during PHP's startup sequence are not displayed.
|
||||
// It's strongly recommended to keep display_startup_errors off, except for debugging.
|
||||
ini_set('display_startup_errors', 0);
|
||||
|
||||
// If disabled, error message will be solely plain text instead HTML code.
|
||||
ini_set("html_errors", 0);
|
||||
|
||||
// Tells whether script error messages should be logged to the server's error log or error_log.
|
||||
ini_set('log_errors', 1);
|
||||
|
||||
if (DEBUG_MODE) {
|
||||
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
|
||||
} else {
|
||||
error_reporting(E_ERROR);
|
||||
}
|
||||
|
||||
define('PATH_TEMPLATES', PATH_ROOT . 'templates' . DS);
|
||||
//define('PATH_LANGUAGES', PATH_ROOT . 'languages' . DS);
|
||||
//define('PATH_CONFIG', PATH_ROOT . 'config' . DS);
|
||||
//define('PATH_PLUGINS', PATH_ROOT . 'plugins' . DS);
|
||||
define('PATH_KERNEL', PATH_ROOT . 'kernel' . DS);
|
||||
define('PATH_GAME', PATH_ROOT . 'game' . DS);
|
||||
//define('PATH_ADMIN', PATH_ROOT . 'admin' . DS);
|
||||
|
||||
include(PATH_KERNEL . 'lib.php');
|
||||
include(PATH_KERNEL . 'cookies.php');
|
||||
$link = opendb();
|
54
kernel/boot/site.php
Normal file
54
kernel/boot/site.php
Normal file
|
@ -0,0 +1,54 @@
|
|||
<?php // Functions relative to the site
|
||||
|
||||
$controlquery = doquery("SELECT * FROM {{table}} WHERE id='1' LIMIT 1", "control");
|
||||
$controlrow = mysqli_fetch_array($controlquery);
|
||||
|
||||
// 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."); }
|
||||
|
||||
if (isset($_GET["do"])) {
|
||||
$do = explode(":",$_GET["do"]);
|
||||
|
||||
// Town functions.
|
||||
if ($do[0] == "inn") { include(PATH_GAME . 'towns.php'); inn(); }
|
||||
elseif ($do[0] == "buy") { include(PATH_GAME . 'towns.php'); buy(); }
|
||||
elseif ($do[0] == "buy2") { include(PATH_GAME . 'towns.php'); buy2($do[1]); }
|
||||
elseif ($do[0] == "buy3") { include(PATH_GAME . 'towns.php'); buy3($do[1]); }
|
||||
elseif ($do[0] == "sell") { include(PATH_GAME . 'towns.php'); sell(); }
|
||||
elseif ($do[0] == "maps") { include(PATH_GAME . 'towns.php'); maps(); }
|
||||
elseif ($do[0] == "maps2") { include(PATH_GAME . 'towns.php'); maps2($do[1]); }
|
||||
elseif ($do[0] == "maps3") { include(PATH_GAME . 'towns.php'); maps3($do[1]); }
|
||||
elseif ($do[0] == "gotown") { include(PATH_GAME . 'towns.php'); travelto($do[1]); }
|
||||
|
||||
// Exploring functions.
|
||||
elseif ($do[0] == "move") { include(PATH_GAME . 'explore.php'); move(); }
|
||||
|
||||
// Fighting functions.
|
||||
elseif ($do[0] == "fight") { include(PATH_GAME . 'fight.php'); fight(); }
|
||||
elseif ($do[0] == "victory") { include(PATH_GAME . 'fight.php'); victory(); }
|
||||
elseif ($do[0] == "drop") { include(PATH_GAME . 'fight.php'); drop(); }
|
||||
elseif ($do[0] == "dead") { include(PATH_GAME . 'fight.php'); dead(); }
|
||||
|
||||
// Misc functions.
|
||||
elseif ($do[0] == "verify") { header("Location: users.php?do=verify"); die(); }
|
||||
elseif ($do[0] == "spell") { include(PATH_GAME . 'heal.php'); healspells($do[1]); }
|
||||
elseif ($do[0] == "showchar") { include(PATH_GAME . 'misc.php'); showchar(); }
|
||||
elseif ($do[0] == "onlinechar") { include(PATH_GAME . 'misc.php'); onlinechar($do[1]); }
|
||||
elseif ($do[0] == "showmap") { include(PATH_GAME . 'misc.php');showmap(); }
|
||||
elseif ($do[0] == "babblebox") { include(PATH_GAME . 'misc.php');babblebox(); }
|
||||
elseif ($do[0] == "ninja") { include(PATH_GAME . 'misc.php');ninja(); }
|
||||
elseif ($do[0] == "die") { header('Location: index.php?do=buy'); die(); }
|
||||
|
||||
} else { include(PATH_GAME . 'misc.php');donothing(); }
|
|
@ -40,7 +40,7 @@ function html_deep($value) {
|
|||
}
|
||||
|
||||
function opendb() { // Open database connection.
|
||||
include('../config.php');
|
||||
include(PATH_ROOT.'config.php');
|
||||
extract($dbsettings);
|
||||
|
||||
// Créer une connexion à la base de données
|
||||
|
@ -55,7 +55,7 @@ function opendb() { // Open database connection.
|
|||
}
|
||||
|
||||
function doquery($query, $table) { // Something of a tiny little database abstraction layer.
|
||||
include('../config.php');
|
||||
include(PATH_ROOT.'/config.php');
|
||||
global $numqueries;
|
||||
|
||||
// Remplacer {{table}} par le préfixe de la table
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
<?php // login.php :: Handles logins and cookies.
|
||||
|
||||
// TODO: remove when porting to real boot files
|
||||
define('DS', DIRECTORY_SEPARATOR);
|
||||
define('PATH_ROOT', __DIR__.DS);
|
||||
define('PATH_BOOT', PATH_ROOT.'kernel'.DS.'boot'.DS);
|
||||
|
||||
include('kernel/lib.php');
|
||||
if (isset($_GET["do"])) {
|
||||
if ($_GET["do"] == "login") { login(); }
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
<?php // users.php :: Handles user account functions.
|
||||
|
||||
// TODO: remove when porting to real boot files
|
||||
define('DS', DIRECTORY_SEPARATOR);
|
||||
define('PATH_ROOT', __DIR__.DS);
|
||||
define('PATH_BOOT', PATH_ROOT.'kernel'.DS.'boot'.DS);
|
||||
|
||||
include('kernel/lib.php');
|
||||
$link = opendb();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue