Compare commits
2 Commits
7e9ce285e0
...
98204ee9f1
Author | SHA1 | Date | |
---|---|---|---|
98204ee9f1 | |||
9348c17179 |
1028
public/admin.php
1028
public/admin.php
File diff suppressed because it is too large
Load Diff
|
@ -2,10 +2,10 @@
|
|||
|
||||
// forum.php :: Internal forums script for the game.
|
||||
|
||||
if (!file_exists('../.installed')) redirect('install.php');
|
||||
|
||||
require_once '../src/lib.php';
|
||||
|
||||
if (!file_exists('../.installed')) redirect('install.php');
|
||||
|
||||
$controlrow = get_control_row();
|
||||
|
||||
// Login (or verify) if not logged in.
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
<?php
|
||||
if (!file_exists('../.installed')) redirect('install.php');
|
||||
|
||||
require_once '../src/lib.php';
|
||||
|
||||
if (!file_exists('../.installed')) redirect('install.php');
|
||||
|
||||
$controlrow = get_control_row();
|
||||
|
||||
$page = $_GET['page'] ?? '';
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
// index.php :: Primary program script, evil alien overlord, you decide.
|
||||
|
||||
if (!file_exists('../.installed')) redirect('install.php');
|
||||
|
||||
require_once '../src/lib.php';
|
||||
|
||||
if (!file_exists('../.installed')) redirect('install.php');
|
||||
|
||||
$controlrow = get_control_row();
|
||||
|
||||
// Login (or verify) if not logged in.
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
<?php
|
||||
|
||||
if (file_exists('../.installed')) {
|
||||
header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once '../src/lib.php';
|
||||
|
||||
if (file_exists('../.installed')) redirect('index.php');
|
||||
|
||||
$page = $_GET['page'] ?? 1;
|
||||
match ((int) $page) {
|
||||
2 => second(),
|
||||
|
@ -29,17 +26,8 @@ function first()
|
|||
|
||||
<body>
|
||||
<b>Dragon Knight Installation: Page One</b><br><br>
|
||||
<b>NOTE:</b> Please ensure you have filled in the correct values in config.php before continuing. Installation will fail if these values are not correct. Also, the MySQL database needs to already exist. This installer script will take care of setting up its structure and content, but the database itself must already exist on your MySQL server before the installer will work.<br><br>
|
||||
Installation for Dragon Knight is a simple two-step process: set up the database tables, then create the admin user. After that, you're done.<br><br>
|
||||
You have two options for database setup: complete or partial.
|
||||
<ul>
|
||||
<li><b>Complete Setup</b> includes table structure and all default data (items, drops, monsters, levels, spells, towns) - after complete setup, the game is totally ready to run.</li>
|
||||
<li><b>Partial Setup</b> only creates the table structure, it does not populate the tables - use this if you are going to be creating and importing your own customized game data later.</li>
|
||||
</ul>
|
||||
Click the appropriate button below for your preferred installation method.<br><br>
|
||||
<form action="install.php?page=2" method="post">
|
||||
<input type="submit" name="complete" value="Complete Setup" /><br> - OR - <br><input type="submit" name="partial" value="Partial Setup" />
|
||||
</form>
|
||||
<a href="install.php?page=2"><button>Install</button></a>
|
||||
</body>
|
||||
</html>
|
||||
HTML;
|
||||
|
@ -52,8 +40,6 @@ function second()
|
|||
{
|
||||
echo "<html><head><title>Dragon Knight Installation</title></head><body><b>Dragon Knight Installation: Page Two</b><br><br>";
|
||||
|
||||
$full = isset($_POST["complete"]);
|
||||
|
||||
$query = db()->exec(<<<SQL
|
||||
CREATE TABLE babble (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
|
@ -68,20 +54,14 @@ function second()
|
|||
$query = db()->exec(<<<SQL
|
||||
CREATE TABLE control (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`gamename` TEXT NOT NULL DEFAULT '',
|
||||
`gamesize` INTEGER NOT NULL DEFAULT 0,
|
||||
`gameopen` INTEGER NOT NULL DEFAULT 0,
|
||||
`gamename` TEXT NOT NULL DEFAULT 'Dragon Knight',
|
||||
`gamesize` INTEGER NOT NULL DEFAULT 250,
|
||||
`gameopen` INTEGER NOT NULL DEFAULT 1,
|
||||
`gameurl` TEXT NOT NULL DEFAULT '',
|
||||
`adminemail` TEXT NOT NULL DEFAULT '',
|
||||
`class1name` TEXT NOT NULL DEFAULT '',
|
||||
`class2name` TEXT NOT NULL DEFAULT '',
|
||||
`class3name` TEXT NOT NULL DEFAULT '',
|
||||
`diff1name` TEXT NOT NULL DEFAULT '',
|
||||
`diff1mod` REAL NOT NULL DEFAULT 0,
|
||||
`diff2name` TEXT NOT NULL DEFAULT '',
|
||||
`diff2mod` REAL NOT NULL DEFAULT 0,
|
||||
`diff3name` TEXT NOT NULL DEFAULT '',
|
||||
`diff3mod` REAL NOT NULL DEFAULT 0,
|
||||
`verifyemail` INTEGER NOT NULL DEFAULT 0,
|
||||
`shownews` INTEGER NOT NULL DEFAULT 0,
|
||||
`showbabble` INTEGER NOT NULL DEFAULT 0,
|
||||
|
@ -91,7 +71,7 @@ function second()
|
|||
|
||||
echo $query === true ? 'Control table created.<br>' : 'Error creating Control table.';
|
||||
|
||||
$query = db()->exec("INSERT INTO control VALUES (1, 'Dragon Knight', 250, 1, '', '', 1, '', 'Mage', 'Warrior', 'Paladin', 'Easy', 1, 'Medium', 1.2, 'Hard', 1.5, 1, 1, 1, 1);");
|
||||
$query = db()->exec("INSERT INTO control VALUES (1, 'Dragon Knight', 250, 1, '', '', 'Mage', 'Warrior', 'Paladin', 1, 1, 1, 1);");
|
||||
|
||||
echo $query === true ? 'Control table populated.<br>' : 'Error populating Control table.';
|
||||
|
||||
|
@ -108,7 +88,6 @@ function second()
|
|||
|
||||
echo $query == true ? 'Drops table created.<br>' : 'Error creating Drops table.';
|
||||
|
||||
if ($full) {
|
||||
$query = db()->exec(<<<SQL
|
||||
INSERT INTO drops VALUES
|
||||
(1, 'Life Pebble', 1, 1, 'maxhp,10', 'X'),
|
||||
|
@ -146,7 +125,6 @@ function second()
|
|||
SQL);
|
||||
|
||||
echo $query === true ? 'Drops table populated.<br>' : 'Error populating Drops table.';
|
||||
}
|
||||
|
||||
$query = db()->exec(<<<SQL
|
||||
CREATE TABLE forum (
|
||||
|
@ -176,7 +154,6 @@ function second()
|
|||
|
||||
echo $query === true ? 'Items table created.<br>' : 'Error creating Items table.';
|
||||
|
||||
if ($full) {
|
||||
$query = db()->exec(<<<SQL
|
||||
INSERT INTO items VALUES
|
||||
(1, 1, 'Stick', 10, 2, 'X'),
|
||||
|
@ -215,7 +192,6 @@ function second()
|
|||
SQL);
|
||||
|
||||
echo $query === true ? 'Items table populated.<br>' : 'Error populating Items table.';
|
||||
}
|
||||
|
||||
$query = db()->exec(<<<SQL
|
||||
CREATE TABLE levels (
|
||||
|
@ -246,7 +222,6 @@ function second()
|
|||
|
||||
echo $query === true ? 'Levels table created.<br>' : 'Error creating Levels table.';
|
||||
|
||||
if ($full) {
|
||||
$query = db()->exec(<<<SQL
|
||||
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),
|
||||
|
@ -352,7 +327,6 @@ function second()
|
|||
SQL);
|
||||
|
||||
echo $query === true ? 'Levels table populated.<br>' : 'Error populating Levels table.';
|
||||
}
|
||||
|
||||
$query = db()->exec(<<<SQL
|
||||
CREATE TABLE monsters (
|
||||
|
@ -370,7 +344,6 @@ function second()
|
|||
|
||||
echo $query === true ? 'Monsters table created.<br>' : 'Error creating Monsters table.';
|
||||
|
||||
if ($full) {
|
||||
$query = db()->exec(<<<SQL
|
||||
INSERT INTO monsters VALUES
|
||||
(1, 'Blue Slime', 4, 3, 1, 1, 1, 1, 0),
|
||||
|
@ -527,11 +500,11 @@ function second()
|
|||
SQL);
|
||||
|
||||
echo $query === true ? 'Monsters table populated.<br>' : 'Error populating Monsters table.';
|
||||
}
|
||||
|
||||
$query = db()->exec(<<<SQL
|
||||
CREATE TABLE news (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`author` TEXT NOT NULL DEFAULT 'Guild Master',
|
||||
`postdate` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`content` TEXT NOT NULL
|
||||
);
|
||||
|
@ -539,7 +512,7 @@ function second()
|
|||
|
||||
echo $query === true ? 'News table created.<br>' : 'Error creating News table.';
|
||||
|
||||
$query = db()->exec("INSERT INTO news VALUES (1, '2004-01-01 12:00:00', 'This is the first news post. Please use the admin control panel to add another one and make this one go away.');");
|
||||
$query = db()->exec("INSERT INTO news (content) VALUES ('This is the first news post. Please use the admin control panel to add another one and make this one go away.');");
|
||||
|
||||
echo $query === true ? 'News table populated.<br>' : 'Error populating News table.';
|
||||
|
||||
|
@ -555,7 +528,6 @@ function second()
|
|||
|
||||
echo $query === true ? 'Spells table created.<br>' : 'Error creating Spells table.';
|
||||
|
||||
if ($full) {
|
||||
$query = db()->exec(<<<SQL
|
||||
INSERT INTO spells VALUES
|
||||
(1, 'Heal', 5, 10, 1),
|
||||
|
@ -580,7 +552,6 @@ function second()
|
|||
SQL);
|
||||
|
||||
echo $query === true ? 'Spells table populated.<br>' : 'Error populating Spells table.';
|
||||
}
|
||||
|
||||
$query = db()->exec(<<<SQL
|
||||
CREATE TABLE towns (
|
||||
|
@ -597,7 +568,6 @@ function second()
|
|||
|
||||
echo $query === true ? 'Towns table created.<br>' : 'Error creating Towns table.';
|
||||
|
||||
if ($full) {
|
||||
$query = db()->exec(<<<SQL
|
||||
INSERT INTO towns VALUES
|
||||
(1, 'Midworld', 0, 0, 5, 0, 0, '1,2,3,17,18,19,28,29'),
|
||||
|
@ -611,7 +581,6 @@ function second()
|
|||
SQL);
|
||||
|
||||
echo $query === true ? 'Towns table populated.<br>' : 'Error populating Towns table.';
|
||||
}
|
||||
|
||||
$query = db()->exec(<<<SQL
|
||||
CREATE TABLE users (
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
// login.php :: Handles logins and cookies.
|
||||
|
||||
if (!file_exists('../.installed')) redirect('install.php');
|
||||
|
||||
require_once '../src/lib.php';
|
||||
|
||||
if (!file_exists('../.installed')) redirect('install.php');
|
||||
|
||||
match ($_GET['do'] ?? 'login') {
|
||||
'login' => login(),
|
||||
'logout' => logout()
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
// users.php :: Handles user account functions.
|
||||
|
||||
if (!file_exists('../.installed')) redirect('install.php');
|
||||
|
||||
require_once '../src/lib.php';
|
||||
|
||||
if (!file_exists('../.installed')) redirect('install.php');
|
||||
|
||||
$controlrow = get_control_row();
|
||||
|
||||
$do = $_GET['do'] ?? 'register';
|
||||
|
|
103
src/fight.php
103
src/fight.php
|
@ -1,26 +1,27 @@
|
|||
<?php // fight.php :: Handles all fighting action.
|
||||
<?php
|
||||
|
||||
function fight() { // One big long function that determines the outcome of the fight.
|
||||
// fight.php :: Handles all fighting action.
|
||||
|
||||
global $userrow, $controlrow;
|
||||
if ($userrow["currentaction"] != "Fighting") { display("Cheat attempt detected.<br><br>Get a life, loser.", "Error"); }
|
||||
/**
|
||||
* One big long function that determines the outcome of the fight.
|
||||
*/
|
||||
function fight()
|
||||
{
|
||||
global $userrow;
|
||||
if ($userrow["currentaction"] != "Fighting") display("Cheat attempt detected.<br><br>Get a life, loser.", "Error");
|
||||
$pagearray = array();
|
||||
$playerisdead = 0;
|
||||
|
||||
$pagearray["magiclist"] = "";
|
||||
$userspells = explode(",", $userrow["spells"]);
|
||||
$spellquery = doquery("SELECT id,name FROM {{table}}", "spells");
|
||||
while ($spellrow = mysql_fetch_array($spellquery)) {
|
||||
$spellquery = db()->query('SELECT id, name FROM spells ORDER BY id;');
|
||||
while ($spellrow = $spellquery->fetchArray(SQLITE3_ASSOC)) {
|
||||
$spell = false;
|
||||
foreach ($userspells as $a => $b) {
|
||||
if ($b == $spellrow["id"]) { $spell = true; }
|
||||
}
|
||||
if ($spell == true) {
|
||||
$pagearray["magiclist"] .= "<option value=\"".$spellrow["id"]."\">".$spellrow["name"]."</option>\n";
|
||||
}
|
||||
foreach ($userspells as $b) if ($b == $spellrow["id"]) $spell = true;
|
||||
if ($spell == true) $pagearray["magiclist"] .= "<option value=\"".$spellrow["id"]."\">".$spellrow["name"]."</option>\n";
|
||||
unset($spell);
|
||||
}
|
||||
if ($pagearray["magiclist"] == "") { $pagearray["magiclist"] = "<option value=\"0\">None</option>\n"; }
|
||||
if ($pagearray["magiclist"] == "") $pagearray["magiclist"] = "<option value=\"0\">None</option>\n";
|
||||
$magiclist = $pagearray["magiclist"];
|
||||
|
||||
$chancetoswingfirst = 1;
|
||||
|
@ -37,8 +38,9 @@ function fight() { // One big long function that determines the outcome of the f
|
|||
|
||||
|
||||
// Pick a monster.
|
||||
$monsterquery = doquery("SELECT * FROM {{table}} WHERE level>='$minlevel' AND level<='$maxlevel' ORDER BY RAND() LIMIT 1", "monsters");
|
||||
$monsterrow = mysql_fetch_array($monsterquery);
|
||||
$monsterrow = db()->query('SELECT * FROM monsters WHERE level >= ? AND level <= ? ORDER BY RANDOM() LIMIT 1;', [
|
||||
$minlevel, $maxlevel
|
||||
])->fetchArray(SQLITE3_ASSOC);
|
||||
$userrow["currentmonster"] = $monsterrow["id"];
|
||||
$userrow["currentmonsterhp"] = rand((($monsterrow["maxhp"]/5)*4),$monsterrow["maxhp"]);
|
||||
$userrow["currentmonstersleep"] = 0;
|
||||
|
@ -49,12 +51,10 @@ function fight() { // One big long function that determines the outcome of the f
|
|||
|
||||
unset($monsterquery);
|
||||
unset($monsterrow);
|
||||
|
||||
}
|
||||
|
||||
// Next, get the monster statistics.
|
||||
$monsterquery = doquery("SELECT * FROM {{table}} WHERE id='".$userrow["currentmonster"]."' LIMIT 1", "monsters");
|
||||
$monsterrow = mysql_fetch_array($monsterquery);
|
||||
$monsterrow = get_monster($userrow['currentmonster']);
|
||||
$pagearray["monstername"] = $monsterrow["name"];
|
||||
|
||||
// Do run stuff.
|
||||
|
@ -96,15 +96,16 @@ function fight() { // One big long function that determines the outcome of the f
|
|||
if ($userrow["currenthp"] <= 0) {
|
||||
$newgold = ceil($userrow["gold"]/2);
|
||||
$newhp = ceil($userrow["maxhp"]/4);
|
||||
$updatequery = doquery("UPDATE {{table}} SET currenthp='$newhp',currentaction='In Town',currentmonster='0',currentmonsterhp='0',currentmonstersleep='0',currentmonsterimmune='0',currentfight='0',latitude='0',longitude='0',gold='$newgold' WHERE id='".$userrow["id"]."' LIMIT 1", "users");
|
||||
db()->query("UPDATE users SET currenthp=?, currentaction='In Town', currentmonster=0, currentmonsterhp=0, currentmonstersleep=0, currentmonsterimmune=0, currentfight=0, latitude=0, longitude=0, gold=? WHERE id=?;", [
|
||||
$newhp, $newgold, $userrow['id']
|
||||
]);
|
||||
$playerisdead = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$updatequery = doquery("UPDATE {{table}} SET currentaction='Exploring' WHERE id='".$userrow["id"]."' LIMIT 1", "users");
|
||||
header("Location: index.php");
|
||||
die();
|
||||
db()->query("UPDATE users SET currentaction='Exploring' WHERE id=?;", [$userrow['id']]);
|
||||
redirect('index.php');
|
||||
|
||||
// Do fight stuff.
|
||||
} elseif (isset($_POST["fight"])) {
|
||||
|
@ -130,9 +131,8 @@ function fight() { // One big long function that determines the outcome of the f
|
|||
$userrow["currentmonsterhp"] -= $monsterdamage;
|
||||
$pagearray["monsterhp"] = "Monster's HP: " . $userrow["currentmonsterhp"] . "<br><br>";
|
||||
if ($userrow["currentmonsterhp"] <= 0) {
|
||||
$updatequery = doquery("UPDATE {{table}} SET currentmonsterhp='0' WHERE id='".$userrow["id"]."' LIMIT 1", "users");
|
||||
header("Location: index.php?do=victory");
|
||||
die();
|
||||
db()->query('UPDATE users SET currentmonsterhp=0 WHERE id=?;', [$userrow['id']]);
|
||||
redirect('index.php?do=victory');
|
||||
}
|
||||
|
||||
// Monster's turn.
|
||||
|
@ -166,7 +166,9 @@ function fight() { // One big long function that determines the outcome of the f
|
|||
if ($userrow["currenthp"] <= 0) {
|
||||
$newgold = ceil($userrow["gold"]/2);
|
||||
$newhp = ceil($userrow["maxhp"]/4);
|
||||
$updatequery = doquery("UPDATE {{table}} SET currenthp='$newhp',currentaction='In Town',currentmonster='0',currentmonsterhp='0',currentmonstersleep='0',currentmonsterimmune='0',currentfight='0',latitude='0',longitude='0',gold='$newgold' WHERE id='".$userrow["id"]."' LIMIT 1", "users");
|
||||
db()->query("UPDATE users SET currenthp=?, currentaction='In Town', currentmonster=0, currentmonsterhp=0, currentmonstersleep=0, currentmonsterimmune=0, currentfight=0, latitude=0, longitude=0, gold=? WHERE id=?;", [
|
||||
$newhp, $newgold, $userrow['id']
|
||||
]);
|
||||
$playerisdead = 1;
|
||||
}
|
||||
}
|
||||
|
@ -178,8 +180,7 @@ function fight() { // One big long function that determines the outcome of the f
|
|||
$pickedspell = $_POST["userspell"];
|
||||
if ($pickedspell == 0) { display("You must select a spell first. Please go back and try again.", "Error"); die(); }
|
||||
|
||||
$newspellquery = doquery("SELECT * FROM {{table}} WHERE id='$pickedspell' LIMIT 1", "spells");
|
||||
$newspellrow = mysql_fetch_array($newspellquery);
|
||||
$newspellrow = get_spell($pickedspell);
|
||||
$spell = false;
|
||||
foreach($userspells as $a => $b) {
|
||||
if ($b == $pickedspell) { $spell = true; }
|
||||
|
@ -222,9 +223,10 @@ function fight() { // One big long function that determines the outcome of the f
|
|||
|
||||
$pagearray["monsterhp"] = "Monster's HP: " . $userrow["currentmonsterhp"] . "<br><br>";
|
||||
if ($userrow["currentmonsterhp"] <= 0) {
|
||||
$updatequery = doquery("UPDATE {{table}} SET currentmonsterhp='0',currenthp='".$userrow["currenthp"]."',currentmp='".$userrow["currentmp"]."' WHERE id='".$userrow["id"]."' LIMIT 1", "users");
|
||||
header("Location: index.php?do=victory");
|
||||
die();
|
||||
db()->query('UPDATE users SET currentmonsterhp=0, currenthp=?, currentmp=? WHERE id=?;', [
|
||||
$userrow['currenthp'], $userrow['currentmp'], $userrow['id']
|
||||
]);
|
||||
redirect('index.php?do=victory');
|
||||
}
|
||||
|
||||
// Monster's turn.
|
||||
|
@ -258,7 +260,9 @@ function fight() { // One big long function that determines the outcome of the f
|
|||
if ($userrow["currenthp"] <= 0) {
|
||||
$newgold = ceil($userrow["gold"]/2);
|
||||
$newhp = ceil($userrow["maxhp"]/4);
|
||||
$updatequery = doquery("UPDATE {{table}} SET currenthp='$newhp',currentaction='In Town',currentmonster='0',currentmonsterhp='0',currentmonstersleep='0',currentmonsterimmune='0',currentfight='0',latitude='0',longitude='0',gold='$newgold' WHERE id='".$userrow["id"]."' LIMIT 1", "users");
|
||||
db()->query("UPDATE users SET currenthp=?, currentaction='In Town', currentmonster=0, currentmonsterhp=0, currentmonstersleep=0, currentmonsterimmune=0, currentfight=0, latitude=0, longitude=0, gold=? WHERE id=?;", [
|
||||
$newhp, $newgold, $userrow['id']
|
||||
]);
|
||||
$playerisdead = 1;
|
||||
}
|
||||
}
|
||||
|
@ -297,7 +301,9 @@ function fight() { // One big long function that determines the outcome of the f
|
|||
if ($userrow["currenthp"] <= 0) {
|
||||
$newgold = ceil($userrow["gold"]/2);
|
||||
$newhp = ceil($userrow["maxhp"]/4);
|
||||
$updatequery = doquery("UPDATE {{table}} SET currenthp='$newhp',currentaction='In Town',currentmonster='0',currentmonsterhp='0',currentmonstersleep='0',currentmonsterimmune='0',currentfight='0',latitude='0',longitude='0',gold='$newgold' WHERE id='".$userrow["id"]."' LIMIT 1", "users");
|
||||
db()->query("UPDATE users SET currenthp=?, currentaction='In Town', currentmonster=0, currentmonsterhp=0, currentmonstersleep=0, currentmonsterimmune=0, currentfight=0, latitude=0, longitude=0, gold=? WHERE id=?;", [
|
||||
$newhp, $newgold, $userrow['id']
|
||||
]);
|
||||
$playerisdead = 1;
|
||||
}
|
||||
}
|
||||
|
@ -320,25 +326,24 @@ function fight() { // One big long function that determines the outcome of the f
|
|||
$newmp = $userrow["currentmp"];
|
||||
|
||||
if ($playerisdead != 1) {
|
||||
$pagearray["command"] = <<<END
|
||||
$pagearray["command"] = <<<HTML
|
||||
Command?<br><br>
|
||||
<form action="index.php?do=fight" method="post">
|
||||
<input type="submit" name="fight" value="Fight" /><br><br>
|
||||
<select name="userspell"><option value="0">Choose One</option>$magiclist</select> <input type="submit" name="spell" value="Spell" /><br><br>
|
||||
<input type="submit" name="run" value="Run" /><br><br>
|
||||
</form>
|
||||
END;
|
||||
$updatequery = doquery("UPDATE {{table}} SET currentaction='Fighting',currenthp='$newhp',currentmp='$newmp',currentfight='$newfight',currentmonster='$newmonster',currentmonsterhp='$newmonsterhp',currentmonstersleep='$newmonstersleep',currentmonsterimmune='$newmonsterimmune',currentuberdamage='$newuberdamage',currentuberdefense='$newuberdefense' WHERE id='".$userrow["id"]."' LIMIT 1", "users");
|
||||
HTML;
|
||||
|
||||
db()->query("UPDATE users SET currentaction='Fighting', currenthp=?, currentmp=?, currentfight=?, currentmonster=?, currentmonsterhp=?, currentmonstersleep=?, currentmonsterimmune=?, currentuberdamage=?, currentuberdefense=? WHERE id=?;", [
|
||||
$newhp, $newmp, $newfight, $newmonster, $newmonsterhp, $newmonstersleep, $newmonsterimmune, $newuberdamage, $newuberdefense, $userrow['id']
|
||||
]);
|
||||
} else {
|
||||
$pagearray["command"] = "<b>You have died.</b><br><br>As a consequence, you've lost half of your gold. However, you have been given back a portion of your hit points to continue your journey.<br><br>You may now continue back to <a href=\"index.php\">town</a>, and we hope you fair better next time.";
|
||||
}
|
||||
|
||||
// Finalize page and display it.
|
||||
$template = gettemplate("fight");
|
||||
$page = parsetemplate($template,$pagearray);
|
||||
|
||||
display($page, "Fighting");
|
||||
|
||||
display(parsetemplate(gettemplate("fight"), $pagearray), "Fighting");
|
||||
}
|
||||
|
||||
function victory() {
|
||||
|
@ -515,12 +520,12 @@ function drop() {
|
|||
}
|
||||
|
||||
|
||||
function dead() {
|
||||
|
||||
$page = "<b>You have died.</b><br><br>As a consequence, you've lost half of your gold. However, you have been given back a portion of your hit points to continue your journey.<br><br>You may now continue back to <a href=\"index.php\">town</a>, and we hope you fair better next time.";
|
||||
|
||||
function dead()
|
||||
{
|
||||
return <<<HTML
|
||||
<b>You have died.</b><br><br>
|
||||
As a consequence, you've lost half of your gold. However, you have been given back a portion of your hit points
|
||||
to continue your journey.<br><br>
|
||||
You may now continue back to <a href="index.php">town</a>, and we hope you fair better next time.
|
||||
HTML;
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
|
37
src/lib.php
37
src/lib.php
|
@ -66,19 +66,14 @@ function is_email($email) { // Thanks to "mail(at)philipp-louis.de" from php.net
|
|||
}
|
||||
|
||||
function makesafe($d) {
|
||||
|
||||
$d = str_replace("\t","",$d);
|
||||
$d = str_replace("<","<",$d);
|
||||
$d = str_replace(">",">",$d);
|
||||
$d = str_replace("\n","",$d);
|
||||
$d = str_replace("|","??",$d);
|
||||
$d = str_replace(" "," ",$d);
|
||||
return $d;
|
||||
|
||||
return htmlentities($d);
|
||||
}
|
||||
|
||||
function admindisplay($content, $title) { // Finalize page and output to browser.
|
||||
|
||||
/**
|
||||
* Finalize page and output to browser.
|
||||
*/
|
||||
function admindisplay($content, $title)
|
||||
{
|
||||
global $userrow, $controlrow;
|
||||
if (!isset($controlrow)) {
|
||||
$query = db()->query('SELECT * FROM control WHERE id=1 LIMIT 1;');
|
||||
|
@ -292,6 +287,16 @@ function get_item(int $id): array|false
|
|||
return $query->fetchArray(SQLITE3_ASSOC);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a drop by it's ID.
|
||||
*/
|
||||
function get_drop(int $id): array|false
|
||||
{
|
||||
$query = db()->query('SELECT * FROM drops WHERE id=? LIMIT 1;', [$id]);
|
||||
if ($query === false) return false;
|
||||
return $query->fetchArray(SQLITE3_ASSOC);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a spell by it's ID.
|
||||
*/
|
||||
|
@ -302,6 +307,16 @@ function get_spell(int $id): array|false
|
|||
return $query->fetchArray(SQLITE3_ASSOC);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a monster by it's ID.
|
||||
*/
|
||||
function get_monster(int $id): array|false
|
||||
{
|
||||
$query = db()->query('SELECT * FROM monsters WHERE id=? LIMIT 1;', [$id]);
|
||||
if ($query === false) return false;
|
||||
return $query->fetchArray(SQLITE3_ASSOC);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate a Specials keyword to it's string.
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
$template = <<<THEVERYENDOFYOU
|
||||
$template = <<<HTML
|
||||
<table width="100%">
|
||||
<tr><td class="title"><img src="images/button_location.gif" alt="Location" title="Location" /></td></tr>
|
||||
<tr><td>
|
||||
|
@ -15,7 +15,9 @@ Longitude: {{longitude}}<br>
|
|||
</center>
|
||||
</form>
|
||||
</td></tr>
|
||||
</table><br>
|
||||
</table>
|
||||
|
||||
<br>
|
||||
|
||||
<table width="100%">
|
||||
<tr><td class="title"><img src="images/button_towns.gif" alt="Towns" title="Towns" /></td></tr>
|
||||
|
@ -24,17 +26,19 @@ Longitude: {{longitude}}<br>
|
|||
Travel To:<br>
|
||||
{{townslist}}
|
||||
</td></tr>
|
||||
</table><br>
|
||||
</table>
|
||||
|
||||
<br>
|
||||
|
||||
<table width="100%">
|
||||
<tr><td class="title"><img src="images/button_functions.gif" alt="Functions" title="Functions" /></td></tr>
|
||||
<tr><td>
|
||||
<a href="/index.php">Home</a><br>
|
||||
{{forumslink}}
|
||||
{{adminlink}}
|
||||
<a href="users.php?do=changepassword">Change Password</a><br>
|
||||
<a href="login.php?do=logout">Log Out</a><br>
|
||||
<a href="help.php">Help</a>
|
||||
</td></tr>
|
||||
</table><br>
|
||||
THEVERYENDOFYOU;
|
||||
?>
|
||||
</table>
|
||||
HTML;
|
||||
|
|
Loading…
Reference in New Issue
Block a user