more refactoring, add src dir, update index logic
This commit is contained in:
parent
ce06aecf84
commit
0511da22fb
213
public/index.php
213
public/index.php
|
@ -1,63 +1,77 @@
|
||||||
<?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."); }
|
// index.php :: Primary program script, evil alien overlord, you decide.
|
||||||
include('lib.php');
|
|
||||||
include('cookies.php');
|
if (!file_exists('../.installed')) {
|
||||||
$link = opendb();
|
header('Location: install.php');
|
||||||
$controlquery = doquery("SELECT * FROM {{table}} WHERE id='1' LIMIT 1", "control");
|
exit;
|
||||||
$controlrow = mysql_fetch_array($controlquery);
|
}
|
||||||
|
|
||||||
|
require_once '../src/lib.php';
|
||||||
|
|
||||||
|
$controlrow = get_control_row();
|
||||||
|
|
||||||
// Login (or verify) if not logged in.
|
// Login (or verify) if not logged in.
|
||||||
$userrow = checkcookies();
|
if (($userrow = checkcookies()) === false) {
|
||||||
if ($userrow == false) {
|
if (isset($_GET['do']) && $_GET['do'] === 'verify') {
|
||||||
if (isset($_GET["do"])) {
|
header("Location: users.php?do=verify");
|
||||||
if ($_GET["do"] == "verify") { header("Location: users.php?do=verify"); die(); }
|
exit;
|
||||||
}
|
}
|
||||||
header("Location: login.php?do=login"); die();
|
|
||||||
|
header("Location: login.php?do=login");
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close game.
|
// Close game.
|
||||||
if ($controlrow["gameopen"] == 0) { display("The game is currently closed for maintanence. Please check back later.","Game Closed"); die(); }
|
if ((bool) $controlrow["gameopen"] === false) {
|
||||||
|
display("The game is currently closed for maintanence. Please check back later.", "Game Closed");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
// Force verify if the user isn't verified yet.
|
// Force verify if the user isn't verified yet.
|
||||||
if ($controlrow["verifyemail"] == 1 && $userrow["verify"] != 1) { header("Location: users.php?do=verify"); die(); }
|
if ((bool) $controlrow["verifyemail"] && (bool) $userrow["verify"] === false) {
|
||||||
|
header("Location: users.php?do=verify");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
// Block user if he/she has been banned.
|
// Block user if he/she has been banned.
|
||||||
if ($userrow["authlevel"] == 2) { die("Your account has been blocked. Please try back later."); }
|
if ($userrow["authlevel"] === 2) {
|
||||||
|
exit("Your account has been blocked.");
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($_GET["do"])) {
|
require_once '../src/towns.php';
|
||||||
$do = explode(":",$_GET["do"]);
|
require_once '../src/explore.php';
|
||||||
|
require_once '../src/fight.php';
|
||||||
|
require_once '../src/heal.php';
|
||||||
|
|
||||||
// Town functions.
|
$do = explode(':', $_GET['do'] ?? '');
|
||||||
if ($do[0] == "inn") { include('towns.php'); inn(); }
|
match ($do[0]) {
|
||||||
elseif ($do[0] == "buy") { include('towns.php'); buy(); }
|
'inn' => inn(),
|
||||||
elseif ($do[0] == "buy2") { include('towns.php'); buy2($do[1]); }
|
'buy' => buy(),
|
||||||
elseif ($do[0] == "buy3") { include('towns.php'); buy3($do[1]); }
|
'buy2' => buy2($do[1]),
|
||||||
elseif ($do[0] == "sell") { include('towns.php'); sell(); }
|
'buy3' => buy3($do[1]),
|
||||||
elseif ($do[0] == "maps") { include('towns.php'); maps(); }
|
// 'sell' => sell(),
|
||||||
elseif ($do[0] == "maps2") { include('towns.php'); maps2($do[1]); }
|
'maps' => maps(),
|
||||||
elseif ($do[0] == "maps3") { include('towns.php'); maps3($do[1]); }
|
'maps2' => maps2($do[1]),
|
||||||
elseif ($do[0] == "gotown") { include('towns.php'); travelto($do[1]); }
|
'maps3' => maps3($do[1]),
|
||||||
|
'gotown' => travelto($do[1]),
|
||||||
// Exploring functions.
|
'move' => move(),
|
||||||
elseif ($do[0] == "move") { include('explore.php'); move(); }
|
'fight' => fight(),
|
||||||
|
'victory' => victory(),
|
||||||
// Fighting functions.
|
'drop' => drop(),
|
||||||
elseif ($do[0] == "fight") { include('fight.php'); fight(); }
|
'dead' => dead(),
|
||||||
elseif ($do[0] == "victory") { include('fight.php'); victory(); }
|
'verify' => header("Location: users.php?do=verify"),
|
||||||
elseif ($do[0] == "drop") { include('fight.php'); drop(); }
|
'spell' => healspells($do[1]),
|
||||||
elseif ($do[0] == "dead") { include('fight.php'); dead(); }
|
'showchar' => showchar(),
|
||||||
|
'onlinechar' => onlinechar($do[1]),
|
||||||
// Misc functions.
|
'showmap' => showmap(),
|
||||||
elseif ($do[0] == "verify") { header("Location: users.php?do=verify"); die(); }
|
'babblebox' => babblebox(),
|
||||||
elseif ($do[0] == "spell") { include('heal.php'); healspells($do[1]); }
|
'ninja' => ninja(),
|
||||||
elseif ($do[0] == "showchar") { showchar(); }
|
default => donothing()
|
||||||
elseif ($do[0] == "onlinechar") { onlinechar($do[1]); }
|
};
|
||||||
elseif ($do[0] == "showmap") { showmap(); }
|
|
||||||
elseif ($do[0] == "babblebox") { babblebox(); }
|
|
||||||
elseif ($do[0] == "ninja") { ninja(); }
|
|
||||||
|
|
||||||
} else { donothing(); }
|
|
||||||
|
|
||||||
function donothing() {
|
|
||||||
|
|
||||||
|
function donothing()
|
||||||
|
{
|
||||||
global $userrow;
|
global $userrow;
|
||||||
|
|
||||||
if ($userrow["currentaction"] == "In Town") {
|
if ($userrow["currentaction"] == "In Town") {
|
||||||
|
@ -72,74 +86,90 @@ function donothing() {
|
||||||
}
|
}
|
||||||
|
|
||||||
display($page, $title);
|
display($page, $title);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function dotown() { // Spit out the main town page.
|
/**
|
||||||
|
* Spit out the main town page.
|
||||||
|
*/
|
||||||
|
function dotown()
|
||||||
|
{
|
||||||
|
global $userrow, $controlrow;
|
||||||
|
|
||||||
global $userrow, $controlrow, $numqueries;
|
$townquery = db()->query('SELECT * FROM towns WHERE latitude = ? AND longitude = ? LIMIT 1;', [$userrow["latitude"], $userrow["longitude"]]);
|
||||||
|
if ($townquery === false) display("There is an error with your user account, or with the town data. Please try again.", "Error");
|
||||||
$townquery = doquery("SELECT * FROM {{table}} WHERE latitude='".$userrow["latitude"]."' AND longitude='".$userrow["longitude"]."' LIMIT 1", "towns");
|
$townrow = $townquery->fetchArray(SQLITE3_ASSOC);
|
||||||
if (mysql_num_rows($townquery) == 0) { display("There is an error with your user account, or with the town data. Please try again.","Error"); }
|
if ($townrow === false) display("There is an error with your user account, or with the town data. Please try again.","Error");
|
||||||
$townrow = mysql_fetch_array($townquery);
|
|
||||||
|
|
||||||
// News box. Grab latest news entry and display it. Something a little more graceful coming soon maybe.
|
// News box. Grab latest news entry and display it. Something a little more graceful coming soon maybe.
|
||||||
if ($controlrow["shownews"] == 1) {
|
if ($controlrow["shownews"] == 1) {
|
||||||
$newsquery = doquery("SELECT * FROM {{table}} ORDER BY id DESC LIMIT 1", "news");
|
$newsrow = db()->query('SELECT * FROM news ORDER BY id DESC LIMIT 1;')->fetchArray(SQLITE3_ASSOC);
|
||||||
$newsrow = mysql_fetch_array($newsquery);
|
|
||||||
$townrow["news"] = "<table width=\"95%\"><tr><td class=\"title\">Latest News</td></tr><tr><td>\n";
|
$townrow["news"] = "<table width=\"95%\"><tr><td class=\"title\">Latest News</td></tr><tr><td>\n";
|
||||||
$townrow["news"] .= "<span class=\"light\">[".prettydate($newsrow["postdate"])."]</span><br />".nl2br($newsrow["content"]);
|
$townrow["news"] .= "<span class=\"light\">[".prettydate($newsrow["postdate"])."]</span><br />".nl2br($newsrow["content"]);
|
||||||
$townrow["news"] .= "</td></tr></table>\n";
|
$townrow["news"] .= "</td></tr></table>\n";
|
||||||
} else { $townrow["news"] = ""; }
|
} else {
|
||||||
|
$townrow["news"] = "";
|
||||||
|
}
|
||||||
|
|
||||||
// Who's Online. Currently just members. Guests maybe later.
|
// Who's Online. Currently just members. Guests maybe later.
|
||||||
if ($controlrow["showonline"] == 1) {
|
if ($controlrow["showonline"] == 1) {
|
||||||
$onlinequery = doquery("SELECT * FROM {{table}} WHERE UNIX_TIMESTAMP(onlinetime) >= '".(time()-600)."' ORDER BY charname", "users");
|
$onlinequery = db()->query("SELECT * FROM news WHERE strftime('%s', onlinetime) >= strftime('%s', 'now') - 600 ORDER BY charname");
|
||||||
|
|
||||||
|
$online_count = 0;
|
||||||
|
$online_rows = [];
|
||||||
|
|
||||||
|
foreach ($onlinequery->fetchArray(SQLITE3_ASSOC) as $onlinerow) {
|
||||||
|
$online_count++;
|
||||||
|
$online_rows[] = "<a href=\"index.php?do=onlinechar:".$onlinerow["id"]."\">".$onlinerow["charname"]."</a>" . ", ";
|
||||||
|
}
|
||||||
|
|
||||||
$townrow["whosonline"] = "<table width=\"95%\"><tr><td class=\"title\">Who's Online</td></tr><tr><td>\n";
|
$townrow["whosonline"] = "<table width=\"95%\"><tr><td class=\"title\">Who's Online</td></tr><tr><td>\n";
|
||||||
$townrow["whosonline"] .= "There are <b>" . mysql_num_rows($onlinequery) . "</b> user(s) online within the last 10 minutes: ";
|
$townrow["whosonline"] .= "There are <b>$online_count</b> user(s) online within the last 10 minutes: ";
|
||||||
while ($onlinerow = mysql_fetch_array($onlinequery)) { $townrow["whosonline"] .= "<a href=\"index.php?do=onlinechar:".$onlinerow["id"]."\">".$onlinerow["charname"]."</a>" . ", "; }
|
$townrow["whosonline"] .= rtrim(implode(', ', $online_rows), ', ');
|
||||||
$townrow["whosonline"] = rtrim($townrow["whosonline"], ", ");
|
|
||||||
$townrow["whosonline"] .= "</td></tr></table>\n";
|
$townrow["whosonline"] .= "</td></tr></table>\n";
|
||||||
} else { $townrow["whosonline"] = ""; }
|
} else {
|
||||||
|
$townrow["whosonline"] = "";
|
||||||
|
}
|
||||||
|
|
||||||
if ($controlrow["showbabble"] == 1) {
|
if ($controlrow["showbabble"] == 1) {
|
||||||
$townrow["babblebox"] = "<table width=\"95%\"><tr><td class=\"title\">Babble Box</td></tr><tr><td>\n";
|
$townrow["babblebox"] = "<table width=\"95%\"><tr><td class=\"title\">Babble Box</td></tr><tr><td>\n";
|
||||||
$townrow["babblebox"] .= "<iframe src=\"index.php?do=babblebox\" name=\"sbox\" width=\"100%\" height=\"250\" frameborder=\"0\" id=\"bbox\">Your browser does not support inline frames! The Babble Box will not be available until you upgrade to a newer <a href=\"http://www.mozilla.org\" target=\"_new\">browser</a>.</iframe>";
|
$townrow["babblebox"] .= "<iframe src=\"index.php?do=babblebox\" name=\"sbox\" width=\"100%\" height=\"250\" frameborder=\"0\" id=\"bbox\">Your browser does not support inline frames! The Babble Box will not be available until you upgrade to a newer <a href=\"http://www.mozilla.org\" target=\"_new\">browser</a>.</iframe>";
|
||||||
$townrow["babblebox"] .= "</td></tr></table>\n";
|
$townrow["babblebox"] .= "</td></tr></table>\n";
|
||||||
} else { $townrow["babblebox"] = ""; }
|
} else {
|
||||||
|
$townrow["babblebox"] = "";
|
||||||
|
}
|
||||||
|
|
||||||
$page = gettemplate("towns");
|
$page = gettemplate("towns");
|
||||||
$page = parsetemplate($page, $townrow);
|
$page = parsetemplate($page, $townrow);
|
||||||
|
|
||||||
return $page;
|
return $page;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function doexplore() { // Just spit out a blank exploring page.
|
/**
|
||||||
|
* Just spit out a blank exploring page. Exploring without a GET string is normally when they first log in, or when
|
||||||
// Exploring without a GET string is normally when they first log in, or when they've just finished fighting.
|
* they've just finished fighting.
|
||||||
|
*/
|
||||||
$page = <<<END
|
function doexplore()
|
||||||
<table width="100%">
|
{
|
||||||
<tr><td class="title"><img src="images/title_exploring.gif" alt="Exploring" /></td></tr>
|
return <<<HTML
|
||||||
<tr><td>
|
<table width="100%">
|
||||||
You are exploring the map, and nothing has happened. Continue exploring using the direction buttons or the Travel To menus.
|
<tr><td class="title"><img src="images/title_exploring.gif" alt="Exploring" /></td></tr>
|
||||||
</td></tr>
|
<tr><td>
|
||||||
</table>
|
You are exploring the map, and nothing has happened. Continue exploring using the direction buttons or the Travel To menus.
|
||||||
END;
|
</td></tr>
|
||||||
|
</table>
|
||||||
return $page;
|
HTML;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function dofight() { // Redirect to fighting.
|
/**
|
||||||
|
* Redirect to fighting.
|
||||||
|
*/
|
||||||
|
function dofight()
|
||||||
|
{
|
||||||
header("Location: index.php?do=fight");
|
header("Location: index.php?do=fight");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function showchar() {
|
function showchar()
|
||||||
|
{
|
||||||
global $userrow, $controlrow;
|
global $userrow, $controlrow;
|
||||||
|
|
||||||
// Format various userrow stuffs.
|
// Format various userrow stuffs.
|
||||||
|
@ -192,7 +222,6 @@ function showchar() {
|
||||||
$array = array("content"=>parsetemplate($charsheet, $userrow), "title"=>"Character Information");
|
$array = array("content"=>parsetemplate($charsheet, $userrow), "title"=>"Character Information");
|
||||||
echo parsetemplate($page, $array);
|
echo parsetemplate($page, $array);
|
||||||
die();
|
die();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onlinechar($id) {
|
function onlinechar($id) {
|
||||||
|
@ -281,8 +310,10 @@ function babblebox() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function ninja() {
|
/**
|
||||||
header("Location: http://www.se7enet.com/img/shirtninja.jpg");
|
* NINJA! 🥷
|
||||||
|
*/
|
||||||
|
function ninja(): void
|
||||||
|
{
|
||||||
|
exit('NINJA! 🥷');
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -1,15 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (file_exists('../.installed')) {
|
if (file_exists('../.installed')) {
|
||||||
echo 'Game already installed.';
|
header('Location: index.php');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once '../lib.php';
|
require_once '../src/lib.php';
|
||||||
|
|
||||||
define('START', microtime(true));
|
match ((int) $_GET['page'] ?? 1) {
|
||||||
|
|
||||||
match ((int) $_GET['page'] ?? 0) {
|
|
||||||
2 => second(),
|
2 => second(),
|
||||||
3 => third(),
|
3 => third(),
|
||||||
4 => fourth(),
|
4 => fourth(),
|
||||||
|
@ -17,13 +15,12 @@ match ((int) $_GET['page'] ?? 0) {
|
||||||
default => first(),
|
default => first(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* First page - show warnings and gather info
|
* First page - show warnings and gather info
|
||||||
*/
|
*/
|
||||||
function first()
|
function first()
|
||||||
{
|
{
|
||||||
echo <<<END
|
echo <<<HTML
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Dragon Knight Installation</title>
|
<title>Dragon Knight Installation</title>
|
||||||
|
@ -44,7 +41,7 @@ function first()
|
||||||
</form>
|
</form>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
END;
|
HTML;
|
||||||
|
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
@ -58,18 +55,18 @@ function second()
|
||||||
|
|
||||||
$full = isset($_POST["complete"]);
|
$full = isset($_POST["complete"]);
|
||||||
|
|
||||||
$query = db()->exec(<<<END
|
$query = db()->exec(<<<SQL
|
||||||
CREATE TABLE babble (
|
CREATE TABLE babble (
|
||||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
`posttime` TEXT NOT NULL DEFAULT '00:00:00',
|
`posttime` TEXT NOT NULL DEFAULT '00:00:00',
|
||||||
`author` TEXT NOT NULL DEFAULT '',
|
`author` TEXT NOT NULL DEFAULT '',
|
||||||
`babble` TEXT NOT NULL DEFAULT ''
|
`babble` TEXT NOT NULL DEFAULT ''
|
||||||
);
|
);
|
||||||
END);
|
SQL);
|
||||||
|
|
||||||
echo $query === true ? 'Babble Box table created.<br />' : 'Error creating Babble Box table.';
|
echo $query === true ? 'Babble Box table created.<br />' : 'Error creating Babble Box table.';
|
||||||
|
|
||||||
$query = db()->exec(<<<END
|
$query = db()->exec(<<<SQL
|
||||||
CREATE TABLE control (
|
CREATE TABLE control (
|
||||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
`gamename` TEXT NOT NULL DEFAULT '',
|
`gamename` TEXT NOT NULL DEFAULT '',
|
||||||
|
@ -93,7 +90,7 @@ function second()
|
||||||
`showbabble` INTEGER NOT NULL DEFAULT 0,
|
`showbabble` INTEGER NOT NULL DEFAULT 0,
|
||||||
`showonline` INTEGER NOT NULL DEFAULT 0
|
`showonline` INTEGER NOT NULL DEFAULT 0
|
||||||
);
|
);
|
||||||
END);
|
SQL);
|
||||||
|
|
||||||
echo $query === true ? 'Control table created.<br />' : 'Error creating Control table.';
|
echo $query === true ? 'Control table created.<br />' : 'Error creating Control table.';
|
||||||
|
|
||||||
|
@ -101,7 +98,7 @@ function second()
|
||||||
|
|
||||||
echo $query === true ? 'Control table populated.<br />' : 'Error populating Control table.';
|
echo $query === true ? 'Control table populated.<br />' : 'Error populating Control table.';
|
||||||
|
|
||||||
$query = db()->exec(<<<END
|
$query = db()->exec(<<<SQL
|
||||||
CREATE TABLE drops (
|
CREATE TABLE drops (
|
||||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
`name` TEXT NOT NULL DEFAULT '',
|
`name` TEXT NOT NULL DEFAULT '',
|
||||||
|
@ -110,12 +107,12 @@ function second()
|
||||||
`attribute1` TEXT NOT NULL DEFAULT '',
|
`attribute1` TEXT NOT NULL DEFAULT '',
|
||||||
`attribute2` TEXT NOT NULL DEFAULT ''
|
`attribute2` TEXT NOT NULL DEFAULT ''
|
||||||
);
|
);
|
||||||
END);
|
SQL);
|
||||||
|
|
||||||
echo $query == true ? 'Drops table created.<br />' : 'Error creating Drops table.';
|
echo $query == true ? 'Drops table created.<br />' : 'Error creating Drops table.';
|
||||||
|
|
||||||
if ($full) {
|
if ($full) {
|
||||||
$query = db()->exec(<<<END
|
$query = db()->exec(<<<SQL
|
||||||
INSERT INTO drops VALUES
|
INSERT INTO drops VALUES
|
||||||
(1, 'Life Pebble', 1, 1, 'maxhp,10', 'X'),
|
(1, 'Life Pebble', 1, 1, 'maxhp,10', 'X'),
|
||||||
(2, 'Life Stone', 10, 1, 'maxhp,25', 'X'),
|
(2, 'Life Stone', 10, 1, 'maxhp,25', 'X'),
|
||||||
|
@ -149,12 +146,12 @@ function second()
|
||||||
(30, 'Diamond', 50, 1, 'defensepower,150', 'X'),
|
(30, 'Diamond', 50, 1, 'defensepower,150', 'X'),
|
||||||
(31, 'Memory Drop', 5, 1, 'expbonus,10', 'X'),
|
(31, 'Memory Drop', 5, 1, 'expbonus,10', 'X'),
|
||||||
(32, 'Fortune Drop', 5, 1, 'goldbonus,10', 'X');
|
(32, 'Fortune Drop', 5, 1, 'goldbonus,10', 'X');
|
||||||
END);
|
SQL);
|
||||||
|
|
||||||
echo $query === true ? 'Drops table populated.<br />' : 'Error populating Drops table.';
|
echo $query === true ? 'Drops table populated.<br />' : 'Error populating Drops table.';
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = db()->exec(<<<END
|
$query = db()->exec(<<<SQL
|
||||||
CREATE TABLE forum (
|
CREATE TABLE forum (
|
||||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
`postdate` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
`postdate` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
@ -165,11 +162,11 @@ function second()
|
||||||
`title` TEXT NOT NULL DEFAULT '',
|
`title` TEXT NOT NULL DEFAULT '',
|
||||||
`content` TEXT NOT NULL
|
`content` TEXT NOT NULL
|
||||||
);
|
);
|
||||||
END);
|
SQL);
|
||||||
|
|
||||||
echo $query === true ? 'Forum table created.<br />' : 'Error creating Forum table.';
|
echo $query === true ? 'Forum table created.<br />' : 'Error creating Forum table.';
|
||||||
|
|
||||||
$query = db()->exec(<<<END
|
$query = db()->exec(<<<SQL
|
||||||
CREATE TABLE items (
|
CREATE TABLE items (
|
||||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
`type` INTEGER NOT NULL DEFAULT 0,
|
`type` INTEGER NOT NULL DEFAULT 0,
|
||||||
|
@ -178,12 +175,12 @@ function second()
|
||||||
`attribute` INTEGER NOT NULL DEFAULT 0,
|
`attribute` INTEGER NOT NULL DEFAULT 0,
|
||||||
`special` TEXT NOT NULL DEFAULT ''
|
`special` TEXT NOT NULL DEFAULT ''
|
||||||
);
|
);
|
||||||
END);
|
SQL);
|
||||||
|
|
||||||
echo $query === true ? 'Items table created.<br />' : 'Error creating Items table.';
|
echo $query === true ? 'Items table created.<br />' : 'Error creating Items table.';
|
||||||
|
|
||||||
if ($full) {
|
if ($full) {
|
||||||
$query = db()->exec(<<<END
|
$query = db()->exec(<<<SQL
|
||||||
INSERT INTO items VALUES
|
INSERT INTO items VALUES
|
||||||
(1, 1, 'Stick', 10, 2, 'X'),
|
(1, 1, 'Stick', 10, 2, 'X'),
|
||||||
(2, 1, 'Branch', 30, 4, 'X'),
|
(2, 1, 'Branch', 30, 4, 'X'),
|
||||||
|
@ -218,12 +215,12 @@ function second()
|
||||||
(31, 3, 'Large Shield', 2500, 30, 'X'),
|
(31, 3, 'Large Shield', 2500, 30, 'X'),
|
||||||
(32, 3, 'Silver Shield', 10000, 60, 'X'),
|
(32, 3, 'Silver Shield', 10000, 60, 'X'),
|
||||||
(33, 3, 'Destiny Aegis', 25000, 100, 'maxhp,50');
|
(33, 3, 'Destiny Aegis', 25000, 100, 'maxhp,50');
|
||||||
END);
|
SQL);
|
||||||
|
|
||||||
echo $query === true ? 'Items table populated.<br />' : 'Error populating Items table.';
|
echo $query === true ? 'Items table populated.<br />' : 'Error populating Items table.';
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = db()->exec(<<<END
|
$query = db()->exec(<<<SQL
|
||||||
CREATE TABLE levels (
|
CREATE TABLE levels (
|
||||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
`1_exp` INTEGER NOT NULL DEFAULT 0,
|
`1_exp` INTEGER NOT NULL DEFAULT 0,
|
||||||
|
@ -248,12 +245,12 @@ function second()
|
||||||
`3_dexterity` INTEGER NOT NULL DEFAULT 0,
|
`3_dexterity` INTEGER NOT NULL DEFAULT 0,
|
||||||
`3_spells` INTEGER NOT NULL DEFAULT 0
|
`3_spells` INTEGER NOT NULL DEFAULT 0
|
||||||
);
|
);
|
||||||
END);
|
SQL);
|
||||||
|
|
||||||
echo $query === true ? 'Levels table created.<br />' : 'Error creating Levels table.';
|
echo $query === true ? 'Levels table created.<br />' : 'Error creating Levels table.';
|
||||||
|
|
||||||
if ($full) {
|
if ($full) {
|
||||||
$query = db()->exec(<<<END
|
$query = db()->exec(<<<SQL
|
||||||
INSERT INTO levels VALUES
|
INSERT INTO levels VALUES
|
||||||
(1, 0, 15, 0, 5, 5, 5, 0, 0, 15, 0, 5, 5, 5, 0, 0, 15, 0, 5, 5, 5, 0),
|
(1, 0, 15, 0, 5, 5, 5, 0, 0, 15, 0, 5, 5, 5, 0, 0, 15, 0, 5, 5, 5, 0),
|
||||||
(2, 15, 2, 5, 1, 0, 1, 1, 18, 2, 4, 1, 2, 1, 1, 20, 2, 5, 1, 0, 2, 1),
|
(2, 15, 2, 5, 1, 0, 1, 1, 18, 2, 4, 1, 2, 1, 1, 20, 2, 5, 1, 0, 2, 1),
|
||||||
|
@ -355,12 +352,12 @@ function second()
|
||||||
(98, 7837308, 4, 5, 5, 4, 3, 0, 8492119, 4, 3, 5, 7, 3, 0, 9461106, 4, 4, 5, 4, 4, 0),
|
(98, 7837308, 4, 5, 5, 4, 3, 0, 8492119, 4, 3, 5, 7, 3, 0, 9461106, 4, 4, 5, 4, 4, 0),
|
||||||
(99, 7964068, 50, 5, 5, 6, 5, 0, 8627330, 50, 3, 5, 9, 5, 0, 9609488, 50, 4, 5, 6, 6, 0),
|
(99, 7964068, 50, 5, 5, 6, 5, 0, 8627330, 50, 3, 5, 9, 5, 0, 9609488, 50, 4, 5, 6, 6, 0),
|
||||||
(100, 16777215, 0, 0, 0, 0, 0, 0, 16777215, 0, 0, 0, 0, 0, 0, 16777215, 0, 0, 0, 0, 0, 0);
|
(100, 16777215, 0, 0, 0, 0, 0, 0, 16777215, 0, 0, 0, 0, 0, 0, 16777215, 0, 0, 0, 0, 0, 0);
|
||||||
END);
|
SQL);
|
||||||
|
|
||||||
echo $query === true ? 'Levels table populated.<br />' : 'Error populating Levels table.';
|
echo $query === true ? 'Levels table populated.<br />' : 'Error populating Levels table.';
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = db()->exec(<<<END
|
$query = db()->exec(<<<SQL
|
||||||
CREATE TABLE monsters (
|
CREATE TABLE monsters (
|
||||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
`name` TEXT NOT NULL DEFAULT '',
|
`name` TEXT NOT NULL DEFAULT '',
|
||||||
|
@ -372,12 +369,12 @@ function second()
|
||||||
`maxgold` INTEGER NOT NULL DEFAULT 0,
|
`maxgold` INTEGER NOT NULL DEFAULT 0,
|
||||||
`immune` INTEGER NOT NULL DEFAULT 0
|
`immune` INTEGER NOT NULL DEFAULT 0
|
||||||
);
|
);
|
||||||
END);
|
SQL);
|
||||||
|
|
||||||
echo $query === true ? 'Monsters table created.<br />' : 'Error creating Monsters table.';
|
echo $query === true ? 'Monsters table created.<br />' : 'Error creating Monsters table.';
|
||||||
|
|
||||||
if ($full) {
|
if ($full) {
|
||||||
$query = db()->exec(<<<END
|
$query = db()->exec(<<<SQL
|
||||||
INSERT INTO monsters VALUES
|
INSERT INTO monsters VALUES
|
||||||
(1, 'Blue Slime', 4, 3, 1, 1, 1, 1, 0),
|
(1, 'Blue Slime', 4, 3, 1, 1, 1, 1, 0),
|
||||||
(2, 'Red Slime', 6, 5, 1, 1, 2, 1, 0),
|
(2, 'Red Slime', 6, 5, 1, 1, 2, 1, 0),
|
||||||
|
@ -530,18 +527,18 @@ function second()
|
||||||
(149, 'Titan', 360, 340, 270, 50, 2400, 800, 0),
|
(149, 'Titan', 360, 340, 270, 50, 2400, 800, 0),
|
||||||
(150, 'Black Daemon', 400, 400, 280, 50, 3000, 1000, 1),
|
(150, 'Black Daemon', 400, 400, 280, 50, 3000, 1000, 1),
|
||||||
(151, 'Lucifuge', 600, 600, 400, 50, 10000, 10000, 2);
|
(151, 'Lucifuge', 600, 600, 400, 50, 10000, 10000, 2);
|
||||||
END);
|
SQL);
|
||||||
|
|
||||||
echo $query === true ? 'Monsters table populated.<br />' : 'Error populating Monsters table.';
|
echo $query === true ? 'Monsters table populated.<br />' : 'Error populating Monsters table.';
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = db()->exec(<<<END
|
$query = db()->exec(<<<SQL
|
||||||
CREATE TABLE news (
|
CREATE TABLE news (
|
||||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
`postdate` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
`postdate` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
`content` TEXT NOT NULL
|
`content` TEXT NOT NULL
|
||||||
);
|
);
|
||||||
END);
|
SQL);
|
||||||
|
|
||||||
echo $query === true ? 'News table created.<br />' : 'Error creating News table.';
|
echo $query === true ? 'News table created.<br />' : 'Error creating News table.';
|
||||||
|
|
||||||
|
@ -549,7 +546,7 @@ function second()
|
||||||
|
|
||||||
echo $query === true ? 'News table populated.<br />' : 'Error populating News table.';
|
echo $query === true ? 'News table populated.<br />' : 'Error populating News table.';
|
||||||
|
|
||||||
$query = db()->exec(<<<END
|
$query = db()->exec(<<<SQL
|
||||||
CREATE TABLE spells (
|
CREATE TABLE spells (
|
||||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
`name` TEXT NOT NULL,
|
`name` TEXT NOT NULL,
|
||||||
|
@ -557,12 +554,12 @@ function second()
|
||||||
`attribute` INTEGER NOT NULL DEFAULT 0,
|
`attribute` INTEGER NOT NULL DEFAULT 0,
|
||||||
`type` INTEGER NOT NULL DEFAULT 0
|
`type` INTEGER NOT NULL DEFAULT 0
|
||||||
);
|
);
|
||||||
END);
|
SQL);
|
||||||
|
|
||||||
echo $query === true ? 'Spells table created.<br />' : 'Error creating Spells table.';
|
echo $query === true ? 'Spells table created.<br />' : 'Error creating Spells table.';
|
||||||
|
|
||||||
if ($full) {
|
if ($full) {
|
||||||
$query = db()->exec(<<<END
|
$query = db()->exec(<<<SQL
|
||||||
INSERT INTO spells VALUES
|
INSERT INTO spells VALUES
|
||||||
(1, 'Heal', 5, 10, 1),
|
(1, 'Heal', 5, 10, 1),
|
||||||
(2, 'Revive', 10, 25, 1),
|
(2, 'Revive', 10, 25, 1),
|
||||||
|
@ -583,12 +580,12 @@ function second()
|
||||||
(17, 'Ward', 10, 10, 5),
|
(17, 'Ward', 10, 10, 5),
|
||||||
(18, 'Fend', 20, 25, 5),
|
(18, 'Fend', 20, 25, 5),
|
||||||
(19, 'Barrier', 30, 50, 5);
|
(19, 'Barrier', 30, 50, 5);
|
||||||
END);
|
SQL);
|
||||||
|
|
||||||
echo $query === true ? 'Spells table populated.<br />' : 'Error populating Spells table.';
|
echo $query === true ? 'Spells table populated.<br />' : 'Error populating Spells table.';
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = db()->exec(<<<END
|
$query = db()->exec(<<<SQL
|
||||||
CREATE TABLE towns (
|
CREATE TABLE towns (
|
||||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
`name` TEXT NOT NULL,
|
`name` TEXT NOT NULL,
|
||||||
|
@ -599,12 +596,12 @@ function second()
|
||||||
`travelpoints` INTEGER NOT NULL DEFAULT 0,
|
`travelpoints` INTEGER NOT NULL DEFAULT 0,
|
||||||
`itemslist` TEXT NOT NULL
|
`itemslist` TEXT NOT NULL
|
||||||
);
|
);
|
||||||
END);
|
SQL);
|
||||||
|
|
||||||
echo $query === true ? 'Towns table created.<br />' : 'Error creating Towns table.';
|
echo $query === true ? 'Towns table created.<br />' : 'Error creating Towns table.';
|
||||||
|
|
||||||
if ($full) {
|
if ($full) {
|
||||||
$query = db()->exec(<<<END
|
$query = db()->exec(<<<SQL
|
||||||
INSERT INTO towns VALUES
|
INSERT INTO towns VALUES
|
||||||
(1, 'Midworld', 0, 0, 5, 0, 0, '1,2,3,17,18,19,28,29'),
|
(1, 'Midworld', 0, 0, 5, 0, 0, '1,2,3,17,18,19,28,29'),
|
||||||
(2, 'Roma', 30, 30, 10, 25, 5, '2,3,4,18,19,29'),
|
(2, 'Roma', 30, 30, 10, 25, 5, '2,3,4,18,19,29'),
|
||||||
|
@ -614,12 +611,12 @@ function second()
|
||||||
(6, 'Hambry', 170, 170, 90, 1000, 80, '10,11,12,13,14,23,24,30,31'),
|
(6, 'Hambry', 170, 170, 90, 1000, 80, '10,11,12,13,14,23,24,30,31'),
|
||||||
(7, 'Gilead', 200, -200, 100, 3000, 110, '12,13,14,15,24,25,26,32'),
|
(7, 'Gilead', 200, -200, 100, 3000, 110, '12,13,14,15,24,25,26,32'),
|
||||||
(8, 'Endworld', -250, -250, 125, 9000, 160, '16,27,33');
|
(8, 'Endworld', -250, -250, 125, 9000, 160, '16,27,33');
|
||||||
END);
|
SQL);
|
||||||
|
|
||||||
echo $query === true ? 'Towns table populated.<br />' : 'Error populating Towns table.';
|
echo $query === true ? 'Towns table populated.<br />' : 'Error populating Towns table.';
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = db()->exec(<<<END
|
$query = db()->exec(<<<SQL
|
||||||
CREATE TABLE users (
|
CREATE TABLE users (
|
||||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
`username` TEXT NOT NULL,
|
`username` TEXT NOT NULL,
|
||||||
|
@ -672,7 +669,7 @@ function second()
|
||||||
`spells` TEXT NOT NULL default '0',
|
`spells` TEXT NOT NULL default '0',
|
||||||
`towns` TEXT NOT NULL default '0'
|
`towns` TEXT NOT NULL default '0'
|
||||||
);
|
);
|
||||||
END);
|
SQL);
|
||||||
|
|
||||||
echo $query === true ? 'Users table created.<br />' : 'Error creating Users table.';
|
echo $query === true ? 'Users table created.<br />' : 'Error creating Users table.';
|
||||||
|
|
||||||
|
@ -686,7 +683,7 @@ function second()
|
||||||
*/
|
*/
|
||||||
function third()
|
function third()
|
||||||
{
|
{
|
||||||
echo <<<END
|
echo <<<HTML
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Dragon Knight Installation</title>
|
<title>Dragon Knight Installation</title>
|
||||||
|
@ -708,7 +705,7 @@ function third()
|
||||||
</form>
|
</form>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
END;
|
HTML;
|
||||||
|
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
@ -764,7 +761,7 @@ function fourth()
|
||||||
|
|
||||||
file_put_contents('../.installed', date('Y-m-d H:i:s'));
|
file_put_contents('../.installed', date('Y-m-d H:i:s'));
|
||||||
|
|
||||||
echo <<<END
|
echo <<<HTML
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Dragon Knight Installation</title>
|
<title>Dragon Knight Installation</title>
|
||||||
|
@ -782,7 +779,7 @@ function fourth()
|
||||||
<a href="install.php?page=5">click here</a>.
|
<a href="install.php?page=5">click here</a>.
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
END;
|
HTML;
|
||||||
|
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
@ -796,7 +793,7 @@ function fifth()
|
||||||
die('Dragon Knight was unable to send your URL. Please go back and try again, or just continue on to <a href=\"index.php\">the game</a>.');
|
die('Dragon Knight was unable to send your URL. Please go back and try again, or just continue on to <a href=\"index.php\">the game</a>.');
|
||||||
}
|
}
|
||||||
|
|
||||||
echo <<<END
|
echo <<<HTML
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Dragon Knight Installation</title>
|
<title>Dragon Knight Installation</title>
|
||||||
|
@ -807,7 +804,7 @@ function fifth()
|
||||||
You are now ready to <a href="index.php">play the game</a>. Note that you must log in through the public section before being allowed into the control panel. Once logged in, an "Admin" link will appear in the Functions box of the left sidebar panel.
|
You are now ready to <a href="index.php">play the game</a>. Note that you must log in through the public section before being allowed into the control panel. Once logged in, an "Admin" link will appear in the Functions box of the left sidebar panel.
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
END;
|
HTML;
|
||||||
|
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,42 +1,47 @@
|
||||||
<?php // login.php :: Handles logins and cookies.
|
<?php
|
||||||
|
|
||||||
include('lib.php');
|
// login.php :: Handles logins and cookies.
|
||||||
if (isset($_GET["do"])) {
|
|
||||||
if ($_GET["do"] == "login") { login(); }
|
if (!file_exists('../.installed')) {
|
||||||
elseif ($_GET["do"] == "logout") { logout(); }
|
header('Location: install.php');
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
function login() {
|
require_once '../src/lib.php';
|
||||||
|
|
||||||
include('config.php');
|
match ($_GET['do'] ?? 'login') {
|
||||||
$link = opendb();
|
'login' => login(),
|
||||||
|
'logout' => logout()
|
||||||
|
};
|
||||||
|
|
||||||
if (isset($_POST["submit"])) {
|
function login()
|
||||||
|
{
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
$u = trim($_POST['username'] ?? '');
|
||||||
|
|
||||||
$query = doquery("SELECT * FROM {{table}} WHERE username='".$_POST["username"]."' AND password='".md5($_POST["password"])."' LIMIT 1", "users");
|
$query = db()->query('SELECT * FROM users WHERE username = ? LIMIT 1;', [$u]);
|
||||||
if (mysql_num_rows($query) != 1) { die("Invalid username or password. Please go back and try again."); }
|
if ($query === false) die("Invalid username or password. Please go back and try again.");
|
||||||
$row = mysql_fetch_array($query);
|
$row = $query->fetchArray(SQLITE3_ASSOC);
|
||||||
if (isset($_POST["rememberme"])) { $expiretime = time()+31536000; $rememberme = 1; } else { $expiretime = 0; $rememberme = 0; }
|
if (!password_verify($_POST['password'] ?? '', $row['password'])) die("Invalid username or password. Please go back and try again.");
|
||||||
$cookie = $row["id"] . " " . $row["username"] . " " . md5($row["password"] . "--" . $dbsettings["secretword"]) . " " . $rememberme;
|
|
||||||
setcookie("dkgame", $cookie, $expiretime, "/", "", 0);
|
$expiretime = isset($_POST["rememberme"]) ? time() + 31536000 : 0;
|
||||||
|
$rememberme = isset($_POST["rememberme"]) ? 1 : 0;
|
||||||
|
$cookie = implode(' ', [$row['id'], $row['username'], $row['password'], $rememberme]);
|
||||||
|
|
||||||
|
set_cookie("dkgame", $cookie, $expiretime);
|
||||||
header("Location: index.php");
|
header("Location: index.php");
|
||||||
die();
|
exit;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$page = gettemplate("login");
|
$page = gettemplate("login");
|
||||||
$title = "Log In";
|
$title = "Log In";
|
||||||
display($page, $title, false, false, false, false);
|
display($page, $title, false, false, false, false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function logout() {
|
function logout()
|
||||||
|
{
|
||||||
setcookie("dkgame", "", time()-100000, "/", "", 0);
|
set_cookie("dkgame", "", -3600);
|
||||||
header("Location: login.php?do=login");
|
header("Location: login.php?do=login");
|
||||||
die();
|
die();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -2,22 +2,21 @@
|
||||||
|
|
||||||
require_once __DIR__ . '/database.php';
|
require_once __DIR__ . '/database.php';
|
||||||
|
|
||||||
$starttime = getmicrotime();
|
define('VERSION', '1.1.11');
|
||||||
$numqueries = 0;
|
define('BUILD', '');
|
||||||
$version = "1.1.11";
|
define('START', microtime(true));
|
||||||
$build = "";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open/get SQLite database connection.
|
* Open or get SQLite database connection.
|
||||||
*/
|
*/
|
||||||
function db(): Database
|
function db(): Database
|
||||||
{
|
{
|
||||||
return $GLOBALS['database'] ??= new Database(__DIR__ . '/database.db');
|
return $GLOBALS['database'] ??= new Database(__DIR__ . '/../database.db');
|
||||||
}
|
}
|
||||||
|
|
||||||
function gettemplate($templatename) { // SQL query for the template.
|
function gettemplate($templatename) { // SQL query for the template.
|
||||||
|
|
||||||
$filename = "templates/" . $templatename . ".php";
|
$filename = __DIR__ . "/../templates/" . $templatename . ".php";
|
||||||
include("$filename");
|
include("$filename");
|
||||||
return $template;
|
return $template;
|
||||||
|
|
||||||
|
@ -71,19 +70,19 @@ function makesafe($d) {
|
||||||
|
|
||||||
function admindisplay($content, $title) { // Finalize page and output to browser.
|
function admindisplay($content, $title) { // Finalize page and output to browser.
|
||||||
|
|
||||||
global $numqueries, $userrow, $controlrow, $starttime, $version, $build;
|
global $userrow, $controlrow;
|
||||||
if (!isset($controlrow)) {
|
if (!isset($controlrow)) {
|
||||||
$query = db()->query('SELECT * FROM control WHERE id=1 LIMIT 1;');
|
$query = db()->query('SELECT * FROM control WHERE id=1 LIMIT 1;');
|
||||||
$controlrow = $query->fetchArray(SQLITE3_ASSOC);
|
$controlrow = $query->fetchArray(SQLITE3_ASSOC);
|
||||||
}
|
}
|
||||||
|
|
||||||
$page = parsetemplate(gettemplate("admin"), [
|
$page = parsetemplate(gettemplate("admin"), [
|
||||||
"title"=>$title,
|
"title" => $title,
|
||||||
"content"=>$content,
|
"content" => $content,
|
||||||
"totaltime"=>round(getmicrotime() - $starttime, 4),
|
"totaltime" => round(getmicrotime() - START, 4),
|
||||||
"numqueries"=>$numqueries,
|
"numqueries" => db()->count,
|
||||||
"version"=>$version,
|
"version" => VERSION,
|
||||||
"build"=>$build
|
"build" => BUILD
|
||||||
]);
|
]);
|
||||||
|
|
||||||
echo "<html>\n" . $page;
|
echo "<html>\n" . $page;
|
||||||
|
@ -194,16 +193,16 @@ function display($content, $title, $topnav=true, $leftnav=true, $rightnav=true,
|
||||||
}
|
}
|
||||||
|
|
||||||
$page = parsetemplate(gettemplate("primary"), [
|
$page = parsetemplate(gettemplate("primary"), [
|
||||||
"dkgamename"=>$controlrow["gamename"],
|
"dkgamename" => $controlrow["gamename"],
|
||||||
"title"=>$title,
|
"title" => $title,
|
||||||
"content"=>$content,
|
"content" => $content,
|
||||||
"rightnav"=>parsetemplate($rightnav,$userrow),
|
"rightnav" => parsetemplate($rightnav, $userrow),
|
||||||
"leftnav"=>parsetemplate($leftnav,$userrow),
|
"leftnav" => parsetemplate($leftnav, $userrow),
|
||||||
"topnav"=>$topnav,
|
"topnav" => $topnav,
|
||||||
"totaltime"=>round(microtime(true) - $starttime, 4),
|
"totaltime" => round(getmicrotime() - START, 4),
|
||||||
"numqueries"=>$numqueries,
|
"numqueries" => db()->count,
|
||||||
"version"=>$version,
|
"version" => VERSION,
|
||||||
"build"=>$build
|
"build" => BUILD
|
||||||
]);
|
]);
|
||||||
|
|
||||||
echo "<html>\n" . $page;
|
echo "<html>\n" . $page;
|
||||||
|
@ -245,3 +244,13 @@ function set_cookie($name, $value, $expires)
|
||||||
'samesite' => 'Strict' // Enforce SameSite=Strict
|
'samesite' => 'Strict' // Enforce SameSite=Strict
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current control row from the database.
|
||||||
|
*/
|
||||||
|
function get_control_row(): array|false
|
||||||
|
{
|
||||||
|
$query = db()->query('SELECT * FROM control WHERE id = 1 LIMIT 1;');
|
||||||
|
if ($query === false) return false;
|
||||||
|
return $query->fetchArray(SQLITE3_ASSOC);
|
||||||
|
}
|
|
@ -388,6 +388,3 @@ function travelto($id, $usepoints=true) { // Send a user to a town from the Trav
|
||||||
display($page, "Travel To");
|
display($page, "Travel To");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
?>
|
|
Loading…
Reference in New Issue
Block a user