Compare commits

..

66 Commits
old ... master

Author SHA1 Message Date
247d5dc461 Add math and classes to install 2024-12-21 17:46:29 -06:00
c689f37afc Create EXP, point and stat functions 2024-12-20 22:57:42 -06:00
abe827eabd finish new version of admin panel 2024-12-20 14:20:34 -06:00
2074a09663 Build out new table generator 2024-12-19 23:16:59 -06:00
aca8bcc3fe Part one of admin panel rework 2024-12-19 18:33:17 -06:00
8c667cbd2a Update env example 2024-12-19 13:17:29 -06:00
b90a9c179c Full conversion from control row to env 2024-12-19 13:16:55 -06:00
d47e1c5744 Replace all display() calls with new Render\content call, which accounts for HTMX 2024-12-19 12:53:51 -06:00
d45d3f74e5 Finish updating forum to use HTMX 2024-12-19 12:20:59 -06:00
b8c3c96f8d Finish updating the last links in fight to HTMX 2024-12-19 10:09:06 -06:00
35b0e07e4e Did a lot of updating and moving around to make fights and exploring work with HTMX 2024-12-19 10:04:03 -06:00
74a0e32cb7 Update healing spell logic, and add HTMX 2024-12-19 09:12:54 -06:00
1026e93ce3 Fix item buy error 2024-12-19 08:58:26 -06:00
e094bb86cd Fix infinite loop, adjust maps shop language 2024-12-19 08:51:34 -06:00
9d28a9b380 Update online time, auth logic 2024-12-19 08:47:08 -06:00
8b3b1845dc Start rewriting README, move explore, fix buying maps, fix showchar 2024-12-18 23:09:04 -06:00
27f38f7ebc Update town behavior to HTMX, fix some redirect issues 2024-12-18 18:47:28 -06:00
5fa648ab7b Continue updating rendering and user access 2024-12-18 17:00:23 -06:00
58012f5808 Update query log on requests 2024-12-18 11:09:00 -06:00
8084a84576 Update page title handling, reduce reliance on JS 2024-12-18 11:05:11 -06:00
faefbb37d4 Made the babblebox a live, reactive component 2024-12-18 10:51:29 -06:00
1b9106fadb So many changes... sheesh. Adds HTMX, reworks rendering, etc 2024-12-18 10:00:41 -06:00
169e617989 big model changes 2024-12-17 22:10:49 -06:00
3291c1caa6 Lots of rendering fixes, adjust user table, add settings, skins 2024-12-16 19:58:46 -06:00
f7f6e7fb97 Clean up some redundancy 2024-12-15 22:02:49 -06:00
ae0f0802cb Integrate a new mailer with SMTP and log capabilities. 2024-12-15 06:35:19 -06:00
3bc53c1a31 Migrate some improvements to the router. 2024-12-14 18:44:33 -06:00
02533addb4 Update query log to be more useful 2024-12-14 14:12:14 -06:00
adcd4166c6 Fix help footer, do some lib housekeeping and improve parse function. 2024-12-14 14:01:35 -06:00
240f121298 Remaining user pages have been updated to new renderer 2024-12-14 13:39:22 -06:00
10fa8e423a Admin now uses new renderer and has it's own CSS and layout. 2024-12-14 13:31:23 -06:00
3152cca51f Primary and side navs now use the new renderer 2024-12-14 13:14:41 -06:00
bf0b05064a Fix registration and update register form to new render 2024-12-13 22:21:11 -06:00
c2e15d580a Update showchar to use new renderer, move display logic 2024-12-13 22:14:44 -06:00
2801550bdd Switch babblebox and map to new render model. Add positioning dot to map. 2024-12-13 17:28:51 -06:00
93638f65d4 Add query log debugging via a constant flag 2024-12-13 16:52:03 -06:00
67045c8c8d Reduced visual clutter for routing with some helpers 2024-12-13 16:35:05 -06:00
f80cb7cd5b Fix minor bug in admin towns form 2024-12-13 16:22:55 -06:00
30588252d8 Moved admin to new router/actions model 2024-12-13 16:09:57 -06:00
9ce0bab606 Move install to new router model, fix bootstrap checks 2024-12-13 15:52:37 -06:00
48ae6b2a40 Move "actions" to their own dir 2024-12-13 15:38:54 -06:00
b5c271e77b Move forum to new router model 2024-12-13 15:35:06 -06:00
d10d69fb1a Fix some links, onlinetime update 2024-12-13 15:24:08 -06:00
5235239c1c Completely move functions to new routing and namespaces 2024-12-13 14:57:48 -06:00
5ea0de2ae1 Town page no longer uses tables 2024-12-13 13:15:04 -06:00
82a2e42cb9 Right nax no longer uses tables 2024-12-13 12:51:10 -06:00
61ae46714d Left nav no longer uses tables 2024-12-13 12:47:29 -06:00
2b53868f52 Update move buttons to old compass graphic 2024-12-13 12:40:13 -06:00
67cacf7882 Primary layout no longer uses table 2024-12-13 12:04:19 -06:00
ba4719f97a Move images, move CSS to file, add router, refactor links 2024-12-13 11:42:22 -06:00
042bca2364 Add new form validator 2024-12-13 10:24:52 -06:00
df99415ece Massive fight refactor 2024-12-12 21:28:19 -06:00
ae6376c478 Finish repairing fight functions 2024-12-12 21:10:24 -06:00
98204ee9f1 Repair most of fight 2024-12-12 18:52:12 -06:00
9348c17179 Completely repair admin panel 2024-12-12 18:36:30 -06:00
7e9ce285e0 Restore forum functionality, remove forum settings from control 2024-12-12 12:34:35 -06:00
b4d188de16 Repair all users page functionality 2024-12-12 12:05:28 -06:00
2b6ec4d4ab Completely rework help page 2024-12-12 11:28:19 -06:00
9df90861e2 Fix explore, refactor heal 2024-12-12 10:20:49 -06:00
b2ef29ca9c Finish towns refactor 2024-12-12 10:13:29 -06:00
ea7e6e8646 remove difficulty, finish index refactor 2024-12-12 09:33:17 -06:00
0511da22fb more refactoring, add src dir, update index logic 2024-12-11 22:05:45 -06:00
ce06aecf84 Rewrite lib and install to use new database and have better syntax 2024-12-11 21:05:50 -06:00
743c3cd6c4 move files to public 2024-12-11 13:04:00 -06:00
c7e1e2ce9a delete old magic quotes stuff 2024-12-11 13:02:22 -06:00
07823cea01 delete update scripts, update copyright 2024-12-11 13:00:20 -06:00
121 changed files with 6071 additions and 5594 deletions

23
.env.example Normal file
View File

@ -0,0 +1,23 @@
# Game
game_name = 'Dragon Knight'
game_size = 250
game_open = true
game_url = 'localhost:8080'
admin_email = 'noreply@localhost'
class_1_name = 'Mage'
class_2_name = 'Warrior'
class_3_name = 'Paladin'
verify_email = false
show_news = true
show_babble = true
show_online = true
# Environment
debug = false
# Email
smtp_host = smtp.foobar.com
smtp_port = 546
smtp_encryption = tls
smtp_username = foo
smtp_password = bar123

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
.installed
database.db
database.db-*
.env
logs

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2017 renderse7en
Copyright (c) 2024 Sharkk
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -1,51 +1,16 @@
# Dragon Knight
- See also: [Dragon Scourge](https://github.com/renderse7en/dragon-scourge)
- [Live Demo](http://dragon.se7enet.com/)
Many years ago, when I was young and dumb, I wrote a simple little game based on the game *Dragon Warrior* for the NES. It was fun, it helped me learn how to code, and a lot of people liked it.
I am now turning it over to the open source community. Fork it, do what you want, make it your own.
Couple things to keep in mind though:
- It's super old. It may not even work on modern versions of PHP. It may have security issues. I have no idea.
- I have moved on with my life, and am no longer changing or doing anything with this game.
- I am not providing help or support. You're on your own.
- I am not accepting pull requests. If you fork this, you are welcome to do whatever you want, but no changes will be merged back into this.
- Quite frankly, I don't really suggest that you use this as is. It's probably better as an inspiration for your own project.
- Have fun with this. I gave it a lot of love a long time ago. I hope it inspires you to give something a lot of love as well.
- This Git repo represents the final released version, 1.1.11, originally released 3/26/2006.
@todo
# System Requirements
- PHP (4.1 and higher)
- MySQL
- zlib compression enabled on your server (optional)
- PHP 8.3+
- PHP SQLite3 Extension
# Installation Instructions
1. Clone this repo or download the zip.
2. Create a new database for Dragon Knight to use, if you don't already have one set up.
3. Edit `config.php` to include the correct values for your database setup.
3. Duplicate `.env.example` as `.env` and change the settings you want.
4. Upload the contents of the Dragon Knight folder to your site.
5. In your browser, run `install.php` and follow the instructions.
6. After completing installation, delete `install.php` from your Dragon Knight directory for security.
5. In your browser, go to `/install` and follow the instructions.
7. Enjoy the game.
# License
MIT License
Copyright (c) 2017 renderse7en
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
See the [license](LICENSE).

912
admin.php
View File

@ -1,912 +0,0 @@
<?php // admin.php :: primary administration script.
include('lib.php');
include('cookies.php');
$link = opendb();
$userrow = checkcookies();
if ($userrow == false) { die("Please log in to the <a href=\"../login.php?do=login\">game</a> before using the control panel."); }
if ($userrow["authlevel"] != 1) { die("You must have administrator privileges to use the control panel."); }
$controlquery = doquery("SELECT * FROM {{table}} WHERE id='1' LIMIT 1", "control");
$controlrow = mysql_fetch_array($controlquery);
if (isset($_GET["do"])) {
$do = explode(":",$_GET["do"]);
if ($do[0] == "main") { main(); }
elseif ($do[0] == "items") { items(); }
elseif ($do[0] == "edititem") { edititem($do[1]); }
elseif ($do[0] == "drops") { drops(); }
elseif ($do[0] == "editdrop") { editdrop($do[1]); }
elseif ($do[0] == "towns") { towns(); }
elseif ($do[0] == "edittown") { edittown($do[1]); }
elseif ($do[0] == "monsters") { monsters(); }
elseif ($do[0] == "editmonster") { editmonster($do[1]); }
elseif ($do[0] == "levels") { levels(); }
elseif ($do[0] == "editlevel") { editlevel(); }
elseif ($do[0] == "spells") { spells(); }
elseif ($do[0] == "editspell") { editspell($do[1]); }
elseif ($do[0] == "users") { users(); }
elseif ($do[0] == "edituser") { edituser($do[1]); }
elseif ($do[0] == "news") { addnews(); }
} else { donothing(); }
function donothing() {
$page = "Welcome to the Dragon Knight Administration section. Use the links on the left bar to control and edit various elements of the game.<br /><br />Please note that the control panel has been created mostly as a shortcut for certain individual settings. It is meant for use primarily with editing one thing at a time. If you need to completely replace an entire table (say, to replace all stock monsters with your own new ones), it is suggested that you use a more in-depth database tool such as <a href=\"http://www.phpmyadmin.net\" target=\"_new\">phpMyAdmin</a>. Also, you may want to have a copy of the Dragon Knight development kit, available from the <a href=\"http://dragon.se7enet.com/dev.php\">Dragon Knight homepage</a>.<br /><br />Also, you should be aware that certain portions of the DK code are dependent on the formatting of certain database results (for example, the special attributes on item drops). While I have attempted to point these out throughout the admin script, you should definitely pay attention and be careful when editing some fields, because mistakes in the database content may result in script errors or your game breaking completely.";
admindisplay($page, "Admin Home");
}
function main() {
if (isset($_POST["submit"])) {
extract($_POST);
$errors = 0;
$errorlist = "";
if ($gamename == "") { $errors++; $errorlist .= "Game name is required.<br />"; }
if (($gamesize % 5) != 0) { $errors++; $errorlist .= "Map size must be divisible by five.<br />"; }
if (!is_numeric($gamesize)) { $errors++; $errorlist .= "Map size must be a number.<br />"; }
if ($forumtype == 2 && $forumaddress == "") { $errors++; $errorlist .= "You must specify a forum address when using the External setting.<br />"; }
if ($class1name == "") { $errors++; $errorlist .= "Class 1 name is required.<br />"; }
if ($class2name == "") { $errors++; $errorlist .= "Class 2 name is required.<br />"; }
if ($class3name == "") { $errors++; $errorlist .= "Class 3 name is required.<br />"; }
if ($diff1name == "") { $errors++; $errorlist .= "Difficulty 1 name is required.<br />"; }
if ($diff2name == "") { $errors++; $errorlist .= "Difficulty 2 name is required.<br />"; }
if ($diff3name == "") { $errors++; $errorlist .= "Difficulty 3 name is required.<br />"; }
if ($diff2mod == "") { $errors++; $errorlist .= "Difficulty 2 value is required.<br />"; }
if ($diff3mod == "") { $errors++; $errorlist .= "Difficulty 3 value is required.<br />"; }
if ($errors == 0) {
$query = doquery("UPDATE {{table}} SET gamename='$gamename',gamesize='$gamesize',forumtype='$forumtype',forumaddress='$forumaddress',compression='$compression',class1name='$class1name',class2name='$class2name',class3name='$class3name',diff1name='$diff1name',diff2name='$diff2name',diff3name='$diff3name',diff2mod='$diff2mod',diff3mod='$diff3mod',gameopen='$gameopen',verifyemail='$verifyemail',gameurl='$gameurl',adminemail='$adminemail',shownews='$shownews',showonline='$showonline',showbabble='$showbabble' WHERE id='1' LIMIT 1", "control");
admindisplay("Settings updated.","Main Settings");
} else {
admindisplay("<b>Errors:</b><br /><div style=\"color:red;\">$errorlist</div><br />Please go back and try again.", "Main Settings");
}
}
global $controlrow;
$page = <<<END
<b><u>Main Settings</u></b><br />
These options control several major settings for the overall game engine.<br /><br />
<form action="admin.php?do=main" method="post">
<table width="90%">
<tr><td width="20%"><span class="highlight">Game Open:</span></td><td><select name="gameopen"><option value="1" {{open1select}}>Open</option><option value="0" {{open0select}}>Closed</option></select><br /><span class="small">Close the game if you are upgrading or working on settings and don't want to cause odd errors for end-users. Closing the game will completely halt all activity.</span></td></tr>
<tr><td width="20%">Game Name:</td><td><input type="text" name="gamename" size="30" maxlength="50" value="{{gamename}}" /><br /><span class="small">Default is "Dragon Knight". Change this if you want to change to call your game something different.</span></td></tr>
<tr><td width="20%">Game URL:</td><td><input type="text" name="gameurl" size="50" maxlength="100" value="{{gameurl}}" /><br /><span class="small">Please specify the full URL to your game installation ("http://www.server.com/dkpath/index.php"). This gets used in the registration email sent to users. If you leave this field blank or incorrect, users may not be able to register correctly.</span></td></tr>
<tr><td width="20%">Admin Email:</td><td><input type="text" name="adminemail" size="30" maxlength="100" value="{{adminemail}}" /><br /><span class="small">Please specify your email address. This gets used when the game has to send an email to users.</span></td></tr>
<tr><td width="20%">Map Size:</td><td><input type="text" name="gamesize" size="3" maxlength="3" value="{{gamesize}}" /><br /><span class="small">Default is 250. This is the size of each map quadrant. Note that monster levels increase every 5 spaces, so you should ensure that you have at least (map size / 5) monster levels total, otherwise there will be parts of the map without any monsters, or some monsters won't ever get used. Ex: with a map size of 250, you should have 50 monster levels total.</span></td></tr>
<tr><td width="20%">Forum Type:</td><td><select name="forumtype"><option value="0" {{selecttype0}}>Disabled</option><option value="1" {{selecttype1}}>Internal</option><option value="2" {{selecttype2}}>External</option></select><br /><span class="small">'Disabled' removes the forum link. 'Internal' uses the built-in (and very stripped-down) forum program included with Dragon Knight, if you don't have your own forums software already installed. 'External' uses the address provided below and links to your own forums software.</span></td></tr>
<tr><td width="20%">External Forum:</td><td><input type="text" name="forumaddress" size="30" maxlength="200" value="{{forumaddress}}" /><br /><span class="small">If the above value is set to 'External,' please specify the complete URL to your forums here.</span></td></tr>
<tr><td width="20%">Page Compression:</td><td><select name="compression"><option value="0" {{selectcomp0}}>Disabled</option><option value="1" {{selectcomp1}}>Enabled</option></select><br /><span class="small">Enable page compression if it is supported by your server, and this will greatly reduce the amount of bandwidth required by the game.</span></td></tr>
<tr><td width="20%">Email Verification:</td><td><select name="verifyemail"><option value="0" {{selectverify0}}>Disabled</option><option value="1" {{selectverify1}}>Enabled</option></select><br /><span class="small">Make users verify their email address for added security.</span></td></tr>
<tr><td width="20%">Show News:</td><td><select name="shownews"><option value="0" {{selectnews0}}>No</option><option value="1" {{selectnews1}}>Yes</option></select><br /><span class="small">Toggle display of the Latest News box in towns.</td></tr>
<tr><td width="20%">Show Who's Online:</td><td><select name="showonline"><option value="0" {{selectonline0}}>No</option><option value="1" {{selectonline1}}>Yes</option></select><br /><span class="small">Toggle display of the Who's Online box in towns.</span></td></tr>
<tr><td width="20%">Show Babblebox:</td><td><select name="showbabble"><option value="0" {{selectbabble0}}>No</option><option value="1" {{selectbabble1}}>Yes</option></select><br /><span class="small">Toggle display of the Babble Box in towns.</span></td></tr>
<tr><td width="20%">Class 1 Name:</td><td><input type="text" name="class1name" size="20" maxlength="50" value="{{class1name}}" /><br /></td></tr>
<tr><td width="20%">Class 2 Name:</td><td><input type="text" name="class2name" size="20" maxlength="50" value="{{class2name}}" /><br /></td></tr>
<tr><td width="20%">Class 3 Name:</td><td><input type="text" name="class3name" size="20" maxlength="50" value="{{class3name}}" /><br /></td></tr>
<tr><td width="20%">Difficulty 1 Name:</td><td><input type="text" name="diff1name" size="20" maxlength="50" value="{{diff1name}}" /><br /></td></tr>
<tr><td width="20%">Difficulty 2 Name:</td><td><input type="text" name="diff2name" size="20" maxlength="50" value="{{diff2name}}" /><br /></td></tr>
<tr><td width="20%">Difficulty 2 Value:</td><td><input type="text" name="diff2mod" size="3" maxlength="3" value="{{diff2mod}}" /><br /><span class="small">Default is 1.2. Specify factoral value for medium difficulty here.</span></td></tr>
<tr><td width="20%">Difficulty 3 Name:</td><td><input type="text" name="diff3name" size="20" maxlength="50" value="{{diff3name}}" /><br /></td></tr>
<tr><td width="20%">Difficulty 3 Value:</td><td><input type="text" name="diff3mod" size="3" maxlength="3" value="{{diff3mod}}" /><br /><span class="small">Default is 1.5. Specify factoral value for hard difficulty here.</span></td></tr>
</table>
<input type="submit" name="submit" value="Submit" /> <input type="reset" name="reset" value="Reset" />
</form>
END;
if ($controlrow["forumtype"] == 0) { $controlrow["selecttype0"] = "selected=\"selected\" "; } else { $controlrow["selecttype0"] = ""; }
if ($controlrow["forumtype"] == 1) { $controlrow["selecttype1"] = "selected=\"selected\" "; } else { $controlrow["selecttype1"] = ""; }
if ($controlrow["forumtype"] == 2) { $controlrow["selecttype2"] = "selected=\"selected\" "; } else { $controlrow["selecttype2"] = ""; }
if ($controlrow["compression"] == 0) { $controlrow["selectcomp0"] = "selected=\"selected\" "; } else { $controlrow["selectcomp0"] = ""; }
if ($controlrow["compression"] == 1) { $controlrow["selectcomp1"] = "selected=\"selected\" "; } else { $controlrow["selectcomp1"] = ""; }
if ($controlrow["verifyemail"] == 0) { $controlrow["selectverify0"] = "selected=\"selected\" "; } else { $controlrow["selectverify0"] = ""; }
if ($controlrow["verifyemail"] == 1) { $controlrow["selectverify1"] = "selected=\"selected\" "; } else { $controlrow["selectverify1"] = ""; }
if ($controlrow["shownews"] == 0) { $controlrow["selectnews0"] = "selected=\"selected\" "; } else { $controlrow["selectnews0"] = ""; }
if ($controlrow["shownews"] == 1) { $controlrow["selectnews1"] = "selected=\"selected\" "; } else { $controlrow["selectnews1"] = ""; }
if ($controlrow["showonline"] == 0) { $controlrow["selectonline0"] = "selected=\"selected\" "; } else { $controlrow["selectonline0"] = ""; }
if ($controlrow["showonline"] == 1) { $controlrow["selectonline1"] = "selected=\"selected\" "; } else { $controlrow["selectonline1"] = ""; }
if ($controlrow["showbabble"] == 0) { $controlrow["selectbabble0"] = "selected=\"selected\" "; } else { $controlrow["selectbabble0"] = ""; }
if ($controlrow["showbabble"] == 1) { $controlrow["selectbabble1"] = "selected=\"selected\" "; } else { $controlrow["selectbabble1"] = ""; }
if ($controlrow["gameopen"] == 1) { $controlrow["open1select"] = "selected=\"selected\" "; } else { $controlrow["open1select"] = ""; }
if ($controlrow["gameopen"] == 0) { $controlrow["open0select"] = "selected=\"selected\" "; } else { $controlrow["open0select"] = ""; }
$page = parsetemplate($page, $controlrow);
admindisplay($page, "Main Settings");
}
function items() {
$query = doquery("SELECT id,name FROM {{table}} ORDER BY id", "items");
$page = "<b><u>Edit Items</u></b><br />Click an item's name to edit it.<br /><br /><table width=\"50%\">\n";
$count = 1;
while ($row = mysql_fetch_array($query)) {
if ($count == 1) { $page .= "<tr><td width=\"8%\" style=\"background-color: #eeeeee;\">".$row["id"]."</td><td style=\"background-color: #eeeeee;\"><a href=\"admin.php?do=edititem:".$row["id"]."\">".$row["name"]."</a></td></tr>\n"; $count = 2; }
else { $page .= "<tr><td width=\"8%\" style=\"background-color: #ffffff;\">".$row["id"]."</td><td style=\"background-color: #ffffff;\"><a href=\"admin.php?do=edititem:".$row["id"]."\">".$row["name"]."</a></td></tr>\n"; $count = 1; }
}
if (mysql_num_rows($query) == 0) { $page .= "<tr><td width=\"8%\" style=\"background-color: #eeeeee;\">No items found.</td></tr>\n"; }
$page .= "</table>";
admindisplay($page, "Edit Items");
}
function edititem($id) {
if (isset($_POST["submit"])) {
extract($_POST);
$errors = 0;
$errorlist = "";
if ($name == "") { $errors++; $errorlist .= "Name is required.<br />"; }
if ($buycost == "") { $errors++; $errorlist .= "Cost is required.<br />"; }
if (!is_numeric($buycost)) { $errors++; $errorlist .= "Cost must be a number.<br />"; }
if ($attribute == "") { $errors++; $errorlist .= "Attribute is required.<br />"; }
if (!is_numeric($attribute)) { $errors++; $errorlist .= "Attribute must be a number.<br />"; }
if ($special == "" || $special == " ") { $special = "X"; }
if ($errors == 0) {
$query = doquery("UPDATE {{table}} SET name='$name',type='$type',buycost='$buycost',attribute='$attribute',special='$special' WHERE id='$id' LIMIT 1", "items");
admindisplay("Item updated.","Edit Items");
} else {
admindisplay("<b>Errors:</b><br /><div style=\"color:red;\">$errorlist</div><br />Please go back and try again.", "Edit Items");
}
}
$query = doquery("SELECT * FROM {{table}} WHERE id='$id' LIMIT 1", "items");
$row = mysql_fetch_array($query);
$page = <<<END
<b><u>Edit Items</u></b><br /><br />
<form action="admin.php?do=edititem:$id" method="post">
<table width="90%">
<tr><td width="20%">ID:</td><td>{{id}}</td></tr>
<tr><td width="20%">Name:</td><td><input type="text" name="name" size="30" maxlength="30" value="{{name}}" /></td></tr>
<tr><td width="20%">Type:</td><td><select name="type"><option value="1" {{type1select}}>Weapon</option><option value="2" {{type2select}}>Armor</option><option value="3" {{type3select}}>Shield</option></select></td></tr>
<tr><td width="20%">Cost:</td><td><input type="text" name="buycost" size="5" maxlength="10" value="{{buycost}}" /> gold</td></tr>
<tr><td width="20%">Attribute:</td><td><input type="text" name="attribute" size="5" maxlength="10" value="{{attribute}}" /><br /><span class="small">How much the item adds to total attackpower (weapons) or defensepower (armor/shields).</span></td></tr>
<tr><td width="20%">Special:</td><td><input type="text" name="special" size="30" maxlength="50" value="{{special}}" /><br /><span class="small">Should be either a special code or <span class="highlight">X</span> to disable. Edit this field very carefully because mistakes to formatting or field names can create problems in the game.</span></td></tr>
</table>
<input type="submit" name="submit" value="Submit" /> <input type="reset" name="reset" value="Reset" />
</form>
<b>Special Codes:</b><br />
Special codes can be added in the item's Special field to give it extra user attributes. Special codes are in the format <span class="highlight">attribute,value</span>. <span class="highlight">Attribute</span> can be any database field from the Users table - however, it is suggested that you only use the ones from the list below, otherwise things can get freaky. <span class="highlight">Value</span> may be any positive or negative whole number. For example, if you want a weapon to give an additional 50 max hit points, the special code would be <span class="highlight">maxhp,50</span>.<br /><br />
Suggested user fields for special codes:<br />
maxhp - max hit points<br />
maxmp - max magic points<br />
maxtp - max travel points<br />
goldbonus - gold bonus, in percent<br />
expbonus - experience bonus, in percent<br />
strength - strength (which also adds to attackpower)<br />
dexterity - dexterity (which also adds to defensepower)<br />
attackpower - total attack power<br />
defensepower - total defense power
END;
if ($row["type"] == 1) { $row["type1select"] = "selected=\"selected\" "; } else { $row["type1select"] = ""; }
if ($row["type"] == 2) { $row["type2select"] = "selected=\"selected\" "; } else { $row["type2select"] = ""; }
if ($row["type"] == 3) { $row["type3select"] = "selected=\"selected\" "; } else { $row["type3select"] = ""; }
$page = parsetemplate($page, $row);
admindisplay($page, "Edit Items");
}
function drops() {
$query = doquery("SELECT id,name FROM {{table}} ORDER BY id", "drops");
$page = "<b><u>Edit Drops</u></b><br />Click an item's name to edit it.<br /><br /><table width=\"50%\">\n";
$count = 1;
while ($row = mysql_fetch_array($query)) {
if ($count == 1) { $page .= "<tr><td width=\"8%\" style=\"background-color: #eeeeee;\">".$row["id"]."</td><td style=\"background-color: #eeeeee;\"><a href=\"admin.php?do=editdrop:".$row["id"]."\">".$row["name"]."</a></td></tr>\n"; $count = 2; }
else { $page .= "<tr><td width=\"8%\" style=\"background-color: #ffffff;\">".$row["id"]."</td><td style=\"background-color: #ffffff;\"><a href=\"admin.php?do=editdrop:".$row["id"]."\">".$row["name"]."</a></td></tr>\n"; $count = 1; }
}
if (mysql_num_rows($query) == 0) { $page .= "<tr><td width=\"8%\" style=\"background-color: #eeeeee;\">No items found.</td></tr>\n"; }
$page .= "</table>";
admindisplay($page, "Edit Drops");
}
function editdrop($id) {
if (isset($_POST["submit"])) {
extract($_POST);
$errors = 0;
$errorlist = "";
if ($name == "") { $errors++; $errorlist .= "Name is required.<br />"; }
if ($mlevel == "") { $errors++; $errorlist .= "Monster level is required.<br />"; }
if (!is_numeric($mlevel)) { $errors++; $errorlist .= "Monster level must be a number.<br />"; }
if ($attribute1 == "" || $attribute1 == " " || $attribute1 == "X") { $errors++; $errorlist .= "First attribute is required.<br />"; }
if ($attribute2 == "" || $attribute2 == " ") { $attribute2 = "X"; }
if ($errors == 0) {
$query = doquery("UPDATE {{table}} SET name='$name',mlevel='$mlevel',attribute1='$attribute1',attribute2='$attribute2' WHERE id='$id' LIMIT 1", "drops");
admindisplay("Item updated.","Edit Drops");
} else {
admindisplay("<b>Errors:</b><br /><div style=\"color:red;\">$errorlist</div><br />Please go back and try again.", "Edit Drops");
}
}
$query = doquery("SELECT * FROM {{table}} WHERE id='$id' LIMIT 1", "drops");
$row = mysql_fetch_array($query);
$page = <<<END
<b><u>Edit Drops</u></b><br /><br />
<form action="admin.php?do=editdrop:$id" method="post">
<table width="90%">
<tr><td width="20%">ID:</td><td>{{id}}</td></tr>
<tr><td width="20%">Name:</td><td><input type="text" name="name" size="30" maxlength="30" value="{{name}}" /></td></tr>
<tr><td width="20%">Monster Level:</td><td><input type="text" name="mlevel" size="5" maxlength="10" value="{{mlevel}}" /><br /><span class="small">Minimum monster level that will drop this item.</span></td></tr>
<tr><td width="20%">Attribute 1:</td><td><input type="text" name="attribute1" size="30" maxlength="50" value="{{attribute1}}" /><br /><span class="small">Must be a special code. First attribute cannot be disabled. Edit this field very carefully because mistakes to formatting or field names can create problems in the game.</span></td></tr>
<tr><td width="20%">Attribute 2:</td><td><input type="text" name="attribute2" size="30" maxlength="50" value="{{attribute2}}" /><br /><span class="small">Should be either a special code or <span class="highlight">X</span> to disable. Edit this field very carefully because mistakes to formatting or field names can create problems in the game.</span></td></tr>
</table>
<input type="submit" name="submit" value="Submit" /> <input type="reset" name="reset" value="Reset" />
</form>
<b>Special Codes:</b><br />
Special codes are used in the two attribute fields to give the item properties. The first attribute field must contain a special code, but the second one may be left empty ("X") if you wish. Special codes are in the format <span class="highlight">attribute,value</span>. <span class="highlight">Attribute</span> can be any database field from the Users table - however, it is suggested that you only use the ones from the list below, otherwise things can get freaky. <span class="highlight">Value</span> may be any positive or negative whole number. For example, if you want a weapon to give an additional 50 max hit points, the special code would be <span class="highlight">maxhp,50</span>.<br /><br />
Suggested user fields for special codes:<br />
maxhp - max hit points<br />
maxmp - max magic points<br />
maxtp - max travel points<br />
goldbonus - gold bonus, in percent<br />
expbonus - experience bonus, in percent<br />
strength - strength (which also adds to attackpower)<br />
dexterity - dexterity (which also adds to defensepower)<br />
attackpower - total attack power<br />
defensepower - total defense power
END;
$page = parsetemplate($page, $row);
admindisplay($page, "Edit Drops");
}
function towns() {
$query = doquery("SELECT id,name FROM {{table}} ORDER BY id", "towns");
$page = "<b><u>Edit Towns</u></b><br />Click an town's name to edit it.<br /><br /><table width=\"50%\">\n";
$count = 1;
while ($row = mysql_fetch_array($query)) {
if ($count == 1) { $page .= "<tr><td width=\"8%\" style=\"background-color: #eeeeee;\">".$row["id"]."</td><td style=\"background-color: #eeeeee;\"><a href=\"admin.php?do=edittown:".$row["id"]."\">".$row["name"]."</a></td></tr>\n"; $count = 2; }
else { $page .= "<tr><td width=\"8%\" style=\"background-color: #ffffff;\">".$row["id"]."</td><td style=\"background-color: #ffffff;\"><a href=\"admin.php?do=edittown:".$row["id"]."\">".$row["name"]."</a></td></tr>\n"; $count = 1; }
}
if (mysql_num_rows($query) == 0) { $page .= "<tr><td width=\"8%\" style=\"background-color: #eeeeee;\">No towns found.</td></tr>\n"; }
$page .= "</table>";
admindisplay($page, "Edit Towns");
}
function edittown($id) {
if (isset($_POST["submit"])) {
extract($_POST);
$errors = 0;
$errorlist = "";
if ($name == "") { $errors++; $errorlist .= "Name is required.<br />"; }
if ($latitude == "") { $errors++; $errorlist .= "Latitude is required.<br />"; }
if (!is_numeric($latitude)) { $errors++; $errorlist .= "Latitude must be a number.<br />"; }
if ($longitude == "") { $errors++; $errorlist .= "Longitude is required.<br />"; }
if (!is_numeric($longitude)) { $errors++; $errorlist .= "Longitude must be a number.<br />"; }
if ($innprice == "") { $errors++; $errorlist .= "Inn Price is required.<br />"; }
if (!is_numeric($innprice)) { $errors++; $errorlist .= "Inn Price must be a number.<br />"; }
if ($mapprice == "") { $errors++; $errorlist .= "Map Price is required.<br />"; }
if (!is_numeric($mapprice)) { $errors++; $errorlist .= "Map Price must be a number.<br />"; }
if ($travelpoints == "") { $errors++; $errorlist .= "Travel Points is required.<br />"; }
if (!is_numeric($travelpoints)) { $errors++; $errorlist .= "Travel Points must be a number.<br />"; }
if ($itemslist == "") { $errors++; $errorlist .= "Items List is required.<br />"; }
if ($errors == 0) {
$query = doquery("UPDATE {{table}} SET name='$name',latitude='$latitude',longitude='$longitude',innprice='$innprice',mapprice='$mapprice',travelpoints='$travelpoints',itemslist='$itemslist' WHERE id='$id' LIMIT 1", "towns");
admindisplay("Town updated.","Edit Towns");
} else {
admindisplay("<b>Errors:</b><br /><div style=\"color:red;\">$errorlist</div><br />Please go back and try again.", "Edit Towns");
}
}
$query = doquery("SELECT * FROM {{table}} WHERE id='$id' LIMIT 1", "towns");
$row = mysql_fetch_array($query);
$page = <<<END
<b><u>Edit Towns</u></b><br /><br />
<form action="admin.php?do=edittown:$id" method="post">
<table width="90%">
<tr><td width="20%">ID:</td><td>{{id}}</td></tr>
<tr><td width="20%">Name:</td><td><input type="text" name="name" size="30" maxlength="30" value="{{name}}" /></td></tr>
<tr><td width="20%">Latitude:</td><td><input type="text" name="latitude" size="5" maxlength="10" value="{{latitude}}" /><br /><span class="small">Positive or negative integer.</span></td></tr>
<tr><td width="20%">Longitude:</td><td><input type="text" name="longitude" size="5" maxlength="10" value="{{longitude}}" /><br /><span class="small">Positive or negative integer.</span></td></tr>
<tr><td width="20%">Inn Price:</td><td><input type="text" name="innprice" size="5" maxlength="10" value="{{innprice}}" /> gold</td></tr>
<tr><td width="20%">Map Price:</td><td><input type="text" name="mapprice" size="5" maxlength="10" value="{{mapprice}}" /> gold<br /><span class="small">How much it costs to buy the map to this town.</span></td></tr>
<tr><td width="20%">Travel Points:</td><td><input type="text" name="travelpoints" size="5" maxlength="10" value="{{travelpoints}}" /><br /><span class="small">How many TP are consumed when travelling to this town.</span></td></tr>
<tr><td width="20%">Items List:</td><td><input type="text" name="itemslist" size="30" maxlength="200" value="{{itemslist}}" /><br /><span class="small">Comma-separated list of item ID numbers available for purchase at this town. (Example: <span class="highlight">1,2,3,6,9,10,13,20</span>)</span></td></tr>
</table>
<input type="submit" name="submit" value="Submit" /> <input type="reset" name="reset" value="Reset" />
</form>
END;
$page = parsetemplate($page, $row);
admindisplay($page, "Edit Towns");
}
function monsters() {
global $controlrow;
$statquery = doquery("SELECT * FROM {{table}} ORDER BY level DESC LIMIT 1", "monsters");
$statrow = mysql_fetch_array($statquery);
$query = doquery("SELECT id,name FROM {{table}} ORDER BY id", "monsters");
$page = "<b><u>Edit Monsters</u></b><br />";
if (($controlrow["gamesize"]/5) != $statrow["level"]) {
$page .= "<span class=\"highlight\">Note:</span> Your highest monster level does not match with your entered map size. Highest monster level should be ".($controlrow["gamesize"]/5).", yours is ".$statrow["level"].". Please fix this before opening the game to the public.<br /><br />";
} else { $page .= "Monster level and map size match. No further actions are required for map compatibility.<br /><br />"; }
$page .= "Click an monster's name to edit it.<br /><br /><table width=\"50%\">\n";
$count = 1;
while ($row = mysql_fetch_array($query)) {
if ($count == 1) { $page .= "<tr><td width=\"8%\" style=\"background-color: #eeeeee;\">".$row["id"]."</td><td style=\"background-color: #eeeeee;\"><a href=\"admin.php?do=editmonster:".$row["id"]."\">".$row["name"]."</a></td></tr>\n"; $count = 2; }
else { $page .= "<tr><td width=\"8%\" style=\"background-color: #ffffff;\">".$row["id"]."</td><td style=\"background-color: #ffffff;\"><a href=\"admin.php?do=editmonster:".$row["id"]."\">".$row["name"]."</a></td></tr>\n"; $count = 1; }
}
if (mysql_num_rows($query) == 0) { $page .= "<tr><td width=\"8%\" style=\"background-color: #eeeeee;\">No towns found.</td></tr>\n"; }
$page .= "</table>";
admindisplay($page, "Edit Monster");
}
function editmonster($id) {
if (isset($_POST["submit"])) {
extract($_POST);
$errors = 0;
$errorlist = "";
if ($name == "") { $errors++; $errorlist .= "Name is required.<br />"; }
if ($maxhp == "") { $errors++; $errorlist .= "Max HP is required.<br />"; }
if (!is_numeric($maxhp)) { $errors++; $errorlist .= "Max HP must be a number.<br />"; }
if ($maxdam == "") { $errors++; $errorlist .= "Max Damage is required.<br />"; }
if (!is_numeric($maxdam)) { $errors++; $errorlist .= "Max Damage must be a number.<br />"; }
if ($armor == "") { $errors++; $errorlist .= "Armor is required.<br />"; }
if (!is_numeric($armor)) { $errors++; $errorlist .= "Armor must be a number.<br />"; }
if ($level == "") { $errors++; $errorlist .= "Monster Level is required.<br />"; }
if (!is_numeric($level)) { $errors++; $errorlist .= "Monster Level must be a number.<br />"; }
if ($maxexp == "") { $errors++; $errorlist .= "Max Exp is required.<br />"; }
if (!is_numeric($maxexp)) { $errors++; $errorlist .= "Max Exp must be a number.<br />"; }
if ($maxgold == "") { $errors++; $errorlist .= "Max Gold is required.<br />"; }
if (!is_numeric($maxgold)) { $errors++; $errorlist .= "Max Gold must be a number.<br />"; }
if ($errors == 0) {
$query = doquery("UPDATE {{table}} SET name='$name',maxhp='$maxhp',maxdam='$maxdam',armor='$armor',level='$level',maxexp='$maxexp',maxgold='$maxgold',immune='$immune' WHERE id='$id' LIMIT 1", "monsters");
admindisplay("Monster updated.","Edit monsters");
} else {
admindisplay("<b>Errors:</b><br /><div style=\"color:red;\">$errorlist</div><br />Please go back and try again.", "Edit monsters");
}
}
$query = doquery("SELECT * FROM {{table}} WHERE id='$id' LIMIT 1", "monsters");
$row = mysql_fetch_array($query);
$page = <<<END
<b><u>Edit Monsters</u></b><br /><br />
<form action="admin.php?do=editmonster:$id" method="post">
<table width="90%">
<tr><td width="20%">ID:</td><td>{{id}}</td></tr>
<tr><td width="20%">Name:</td><td><input type="text" name="name" size="30" maxlength="30" value="{{name}}" /></td></tr>
<tr><td width="20%">Max Hit Points:</td><td><input type="text" name="maxhp" size="5" maxlength="10" value="{{maxhp}}" /></td></tr>
<tr><td width="20%">Max Damage:</td><td><input type="text" name="maxdam" size="5" maxlength="10" value="{{maxdam}}" /><br /><span class="small">Compares to player's attackpower.</span></td></tr>
<tr><td width="20%">Armor:</td><td><input type="text" name="armor" size="5" maxlength="10" value="{{armor}}" /><br /><span class="small">Compares to player's defensepower.</span></td></tr>
<tr><td width="20%">Monster Level:</td><td><input type="text" name="level" size="5" maxlength="10" value="{{level}}" /><br /><span class="small">Determines spawn location and item drops.</span></td></tr>
<tr><td width="20%">Max Experience:</td><td><input type="text" name="maxexp" size="5" maxlength="10" value="{{maxexp}}" /><br /><span class="small">Max experience gained from defeating monster.</span></td></tr>
<tr><td width="20%">Max Gold:</td><td><input type="text" name="maxgold" size="5" maxlength="10" value="{{maxgold}}" /><br /><span class="small">Max gold gained from defeating monster.</span></td></tr>
<tr><td width="20%">Immunity:</td><td><select name="immune"><option value="0" {{immune0select}}>None</option><option value="1" {{immune1select}}>Hurt Spells</option><option value="2" {{immune2select}}>Hurt & Sleep Spells</option></select><br /><span class="small">Some monsters may not be hurt by certain spells.</span></td></tr>
</table>
<input type="submit" name="submit" value="Submit" /> <input type="reset" name="reset" value="Reset" />
</form>
END;
if ($row["immune"] == 1) { $row["immune1select"] = "selected=\"selected\" "; } else { $row["immune1select"] = ""; }
if ($row["immune"] == 2) { $row["immune2select"] = "selected=\"selected\" "; } else { $row["immune2select"] = ""; }
if ($row["immune"] == 3) { $row["immune3select"] = "selected=\"selected\" "; } else { $row["immune3select"] = ""; }
$page = parsetemplate($page, $row);
admindisplay($page, "Edit Monsters");
}
function spells() {
$query = doquery("SELECT id,name FROM {{table}} ORDER BY id", "spells");
$page = "<b><u>Edit Spells</u></b><br />Click an spell's name to edit it.<br /><br /><table width=\"50%\">\n";
$count = 1;
while ($row = mysql_fetch_array($query)) {
if ($count == 1) { $page .= "<tr><td width=\"8%\" style=\"background-color: #eeeeee;\">".$row["id"]."</td><td style=\"background-color: #eeeeee;\"><a href=\"admin.php?do=editspell:".$row["id"]."\">".$row["name"]."</a></td></tr>\n"; $count = 2; }
else { $page .= "<tr><td width=\"8%\" style=\"background-color: #ffffff;\">".$row["id"]."</td><td style=\"background-color: #ffffff;\"><a href=\"admin.php?do=editspell:".$row["id"]."\">".$row["name"]."</a></td></tr>\n"; $count = 1; }
}
if (mysql_num_rows($query) == 0) { $page .= "<tr><td width=\"8%\" style=\"background-color: #eeeeee;\">No spells found.</td></tr>\n"; }
$page .= "</table>";
admindisplay($page, "Edit Spells");
}
function editspell($id) {
if (isset($_POST["submit"])) {
extract($_POST);
$errors = 0;
$errorlist = "";
if ($name == "") { $errors++; $errorlist .= "Name is required.<br />"; }
if ($mp == "") { $errors++; $errorlist .= "MP is required.<br />"; }
if (!is_numeric($mp)) { $errors++; $errorlist .= "MP must be a number.<br />"; }
if ($attribute == "") { $errors++; $errorlist .= "Attribute is required.<br />"; }
if (!is_numeric($attribute)) { $errors++; $errorlist .= "Attribute must be a number.<br />"; }
if ($errors == 0) {
$query = doquery("UPDATE {{table}} SET name='$name',mp='$mp',attribute='$attribute',type='$type' WHERE id='$id' LIMIT 1", "spells");
admindisplay("Spell updated.","Edit Spells");
} else {
admindisplay("<b>Errors:</b><br /><div style=\"color:red;\">$errorlist</div><br />Please go back and try again.", "Edit Spells");
}
}
$query = doquery("SELECT * FROM {{table}} WHERE id='$id' LIMIT 1", "spells");
$row = mysql_fetch_array($query);
$page = <<<END
<b><u>Edit Spells</u></b><br /><br />
<form action="admin.php?do=editspell:$id" method="post">
<table width="90%">
<tr><td width="20%">ID:</td><td>{{id}}</td></tr>
<tr><td width="20%">Name:</td><td><input type="text" name="name" size="30" maxlength="30" value="{{name}}" /></td></tr>
<tr><td width="20%">Magic Points:</td><td><input type="text" name="mp" size="5" maxlength="10" value="{{mp}}" /><br /><span class="small">MP required to cast spell.</span></td></tr>
<tr><td width="20%">Attribute:</td><td><input type="text" name="attribute" size="5" maxlength="10" value="{{attribute}}" /><br /><span class="small">Numeric value of the spell's effect. Ties with type, below.</span></td></tr>
<tr><td width="20%">Type:</td><td><select name="type"><option value="1" {{type1select}}>Heal</option><option value="2" {{type2select}}>Hurt</option><option value="3" {{type3select}}>Sleep</option><option value="4" {{type4select}}>Uber Attack</option><option value="5" {{type5select}}>Uber Defense</option></select><br /><span class="small">- Heal gives player back [attribute] hit points.<br />- Hurt deals [attribute] damage to monster.<br />- Sleep keeps monster from attacking ([attribute] is monster's chance out of 15 to stay asleep each turn).<br />- Uber Attack increases total attack damage by [attribute] percent.<br />- Uber Defense increases total defense from attack by [attribute] percent.</span></td></tr>
</table>
<input type="submit" name="submit" value="Submit" /> <input type="reset" name="reset" value="Reset" />
</form>
END;
if ($row["type"] == 1) { $row["type1select"] = "selected=\"selected\" "; } else { $row["type1select"] = ""; }
if ($row["type"] == 2) { $row["type2select"] = "selected=\"selected\" "; } else { $row["type2select"] = ""; }
if ($row["type"] == 3) { $row["type3select"] = "selected=\"selected\" "; } else { $row["type3select"] = ""; }
if ($row["type"] == 4) { $row["type4select"] = "selected=\"selected\" "; } else { $row["type4select"] = ""; }
if ($row["type"] == 5) { $row["type5select"] = "selected=\"selected\" "; } else { $row["type5select"] = ""; }
$page = parsetemplate($page, $row);
admindisplay($page, "Edit Spells");
}
function levels() {
$query = doquery("SELECT id FROM {{table}} ORDER BY id DESC LIMIT 1", "levels");
$row = mysql_fetch_array($query);
$options = "";
for($i=2; $i<$row["id"]; $i++) {
$options .= "<option value=\"$i\">$i</option>\n";
}
$page = <<<END
<b><u>Edit Levels</u></b><br />Select a level number from the dropdown box to edit it.<br /><br />
<form action="admin.php?do=editlevel" method="post">
<select name="level">
$options
</select>
<input type="submit" name="go" value="Submit" />
</form>
END;
admindisplay($page, "Edit Levels");
}
function editlevel() {
if (!isset($_POST["level"])) { admindisplay("No level to edit.", "Edit Levels"); die(); }
$id = $_POST["level"];
if (isset($_POST["submit"])) {
extract($_POST);
$errors = 0;
$errorlist = "";
if ($_POST["one_exp"] == "") { $errors++; $errorlist .= "Class 1 Experience is required.<br />"; }
if ($_POST["one_hp"] == "") { $errors++; $errorlist .= "Class 1 HP is required.<br />"; }
if ($_POST["one_mp"] == "") { $errors++; $errorlist .= "Class 1 MP is required.<br />"; }
if ($_POST["one_tp"] == "") { $errors++; $errorlist .= "Class 1 TP is required.<br />"; }
if ($_POST["one_strength"] == "") { $errors++; $errorlist .= "Class 1 Strength is required.<br />"; }
if ($_POST["one_dexterity"] == "") { $errors++; $errorlist .= "Class 1 Dexterity is required.<br />"; }
if ($_POST["one_spells"] == "") { $errors++; $errorlist .= "Class 1 Spells is required.<br />"; }
if (!is_numeric($_POST["one_exp"])) { $errors++; $errorlist .= "Class 1 Experience must be a number.<br />"; }
if (!is_numeric($_POST["one_hp"])) { $errors++; $errorlist .= "Class 1 HP must be a number.<br />"; }
if (!is_numeric($_POST["one_mp"])) { $errors++; $errorlist .= "Class 1 MP must be a number.<br />"; }
if (!is_numeric($_POST["one_tp"])) { $errors++; $errorlist .= "Class 1 TP must be a number.<br />"; }
if (!is_numeric($_POST["one_strength"])) { $errors++; $errorlist .= "Class 1 Strength must be a number.<br />"; }
if (!is_numeric($_POST["one_dexterity"])) { $errors++; $errorlist .= "Class 1 Dexterity must be a number.<br />"; }
if (!is_numeric($_POST["one_spells"])) { $errors++; $errorlist .= "Class 1 Spells must be a number.<br />"; }
if ($_POST["two_exp"] == "") { $errors++; $errorlist .= "Class 2 Experience is required.<br />"; }
if ($_POST["two_hp"] == "") { $errors++; $errorlist .= "Class 2 HP is required.<br />"; }
if ($_POST["two_mp"] == "") { $errors++; $errorlist .= "Class 2 MP is required.<br />"; }
if ($_POST["two_tp"] == "") { $errors++; $errorlist .= "Class 2 TP is required.<br />"; }
if ($_POST["two_strength"] == "") { $errors++; $errorlist .= "Class 2 Strength is required.<br />"; }
if ($_POST["two_dexterity"] == "") { $errors++; $errorlist .= "Class 2 Dexterity is required.<br />"; }
if ($_POST["two_spells"] == "") { $errors++; $errorlist .= "Class 2 Spells is required.<br />"; }
if (!is_numeric($_POST["two_exp"])) { $errors++; $errorlist .= "Class 2 Experience must be a number.<br />"; }
if (!is_numeric($_POST["two_hp"])) { $errors++; $errorlist .= "Class 2 HP must be a number.<br />"; }
if (!is_numeric($_POST["two_mp"])) { $errors++; $errorlist .= "Class 2 MP must be a number.<br />"; }
if (!is_numeric($_POST["two_tp"])) { $errors++; $errorlist .= "Class 2 TP must be a number.<br />"; }
if (!is_numeric($_POST["two_strength"])) { $errors++; $errorlist .= "Class 2 Strength must be a number.<br />"; }
if (!is_numeric($_POST["two_dexterity"])) { $errors++; $errorlist .= "Class 2 Dexterity must be a number.<br />"; }
if (!is_numeric($_POST["two_spells"])) { $errors++; $errorlist .= "Class 2 Spells must be a number.<br />"; }
if ($_POST["three_exp"] == "") { $errors++; $errorlist .= "Class 3 Experience is required.<br />"; }
if ($_POST["three_hp"] == "") { $errors++; $errorlist .= "Class 3 HP is required.<br />"; }
if ($_POST["three_mp"] == "") { $errors++; $errorlist .= "Class 3 MP is required.<br />"; }
if ($_POST["three_tp"] == "") { $errors++; $errorlist .= "Class 3 TP is required.<br />"; }
if ($_POST["three_strength"] == "") { $errors++; $errorlist .= "Class 3 Strength is required.<br />"; }
if ($_POST["three_dexterity"] == "") { $errors++; $errorlist .= "Class 3 Dexterity is required.<br />"; }
if ($_POST["three_spells"] == "") { $errors++; $errorlist .= "Class 3 Spells is required.<br />"; }
if (!is_numeric($_POST["three_exp"])) { $errors++; $errorlist .= "Class 3 Experience must be a number.<br />"; }
if (!is_numeric($_POST["three_hp"])) { $errors++; $errorlist .= "Class 3 HP must be a number.<br />"; }
if (!is_numeric($_POST["three_mp"])) { $errors++; $errorlist .= "Class 3 MP must be a number.<br />"; }
if (!is_numeric($_POST["three_tp"])) { $errors++; $errorlist .= "Class 3 TP must be a number.<br />"; }
if (!is_numeric($_POST["three_strength"])) { $errors++; $errorlist .= "Class 3 Strength must be a number.<br />"; }
if (!is_numeric($_POST["three_dexterity"])) { $errors++; $errorlist .= "Class 3 Dexterity must be a number.<br />"; }
if (!is_numeric($_POST["three_spells"])) { $errors++; $errorlist .= "Class 3 Spells must be a number.<br />"; }
if ($errors == 0) {
$updatequery = <<<END
UPDATE {{table}} SET
1_exp='$one_exp', 1_hp='$one_hp', 1_mp='$one_mp', 1_tp='$one_tp', 1_strength='$one_strength', 1_dexterity='$one_dexterity', 1_spells='$one_spells',
2_exp='$two_exp', 2_hp='$two_hp', 2_mp='$two_mp', 2_tp='$two_tp', 2_strength='$two_strength', 2_dexterity='$two_dexterity', 2_spells='$two_spells',
3_exp='$three_exp', 3_hp='$three_hp', 3_mp='$three_mp', 3_tp='$three_tp', 3_strength='$three_strength', 3_dexterity='$three_dexterity', 3_spells='$three_spells'
WHERE id='$id' LIMIT 1
END;
$query = doquery($updatequery, "levels");
admindisplay("Level updated.","Edit Levels");
} else {
admindisplay("<b>Errors:</b><br /><div style=\"color:red;\">$errorlist</div><br />Please go back and try again.", "Edit Spells");
}
}
$query = doquery("SELECT * FROM {{table}} WHERE id='$id' LIMIT 1", "levels");
$row = mysql_fetch_array($query);
global $controlrow;
$class1name = $controlrow["class1name"];
$class2name = $controlrow["class2name"];
$class3name = $controlrow["class3name"];
$page = <<<END
<b><u>Edit Levels</u></b><br /><br />
Experience values for each level should be the cumulative total amount of experience up to this point. All other values should be only the new amount to add this level.<br /><br />
<form action="admin.php?do=editlevel" method="post">
<input type="hidden" name="level" value="$id" />
<table width="90%">
<tr><td width="20%">ID:</td><td>{{id}}</td></tr>
<tr><td colspan="2" style="background-color:#cccccc;">&nbsp;</td></tr>
<tr><td width="20%">$class1name Experience:</td><td><input type="text" name="one_exp" size="10" maxlength="8" value="{{1_exp}}" /></td></tr>
<tr><td width="20%">$class1name HP:</td><td><input type="text" name="one_hp" size="5" maxlength="5" value="{{1_hp}}" /></td></tr>
<tr><td width="20%">$class1name MP:</td><td><input type="text" name="one_mp" size="5" maxlength="5" value="{{1_mp}}" /></td></tr>
<tr><td width="20%">$class1name TP:</td><td><input type="text" name="one_tp" size="5" maxlength="5" value="{{1_tp}}" /></td></tr>
<tr><td width="20%">$class1name Strength:</td><td><input type="text" name="one_strength" size="5" maxlength="5" value="{{1_strength}}" /></td></tr>
<tr><td width="20%">$class1name Dexterity:</td><td><input type="text" name="one_dexterity" size="5" maxlength="5" value="{{1_dexterity}}" /></td></tr>
<tr><td width="20%">$class1name Spells:</td><td><input type="text" name="one_spells" size="5" maxlength="3" value="{{1_spells}}" /></td></tr>
<tr><td colspan="2" style="background-color:#cccccc;">&nbsp;</td></tr>
<tr><td width="20%">$class2name Experience:</td><td><input type="text" name="two_exp" size="10" maxlength="8" value="{{2_exp}}" /></td></tr>
<tr><td width="20%">$class2name HP:</td><td><input type="text" name="two_hp" size="5" maxlength="5" value="{{2_hp}}" /></td></tr>
<tr><td width="20%">$class2name MP:</td><td><input type="text" name="two_mp" size="5" maxlength="5" value="{{2_mp}}" /></td></tr>
<tr><td width="20%">$class2name TP:</td><td><input type="text" name="two_tp" size="5" maxlength="5" value="{{2_tp}}" /></td></tr>
<tr><td width="20%">$class2name Strength:</td><td><input type="text" name="two_strength" size="5" maxlength="5" value="{{2_strength}}" /></td></tr>
<tr><td width="20%">$class2name Dexterity:</td><td><input type="text" name="two_dexterity" size="5" maxlength="5" value="{{2_dexterity}}" /></td></tr>
<tr><td width="20%">$class2name Spells:</td><td><input type="text" name="two_spells" size="5" maxlength="3" value="{{2_spells}}" /></td></tr>
<tr><td colspan="2" style="background-color:#cccccc;">&nbsp;</td></tr>
<tr><td width="20%">$class3name Experience:</td><td><input type="text" name="three_exp" size="10" maxlength="8" value="{{3_exp}}" /></td></tr>
<tr><td width="20%">$class3name HP:</td><td><input type="text" name="three_hp" size="5" maxlength="5" value="{{3_hp}}" /></td></tr>
<tr><td width="20%">$class3name MP:</td><td><input type="text" name="three_mp" size="5" maxlength="5" value="{{3_mp}}" /></td></tr>
<tr><td width="20%">$class3name TP:</td><td><input type="text" name="three_tp" size="5" maxlength="5" value="{{3_tp}}" /></td></tr>
<tr><td width="20%">$class3name Strength:</td><td><input type="text" name="three_strength" size="5" maxlength="5" value="{{3_strength}}" /></td></tr>
<tr><td width="20%">$class3name Dexterity:</td><td><input type="text" name="three_dexterity" size="5" maxlength="5" value="{{3_dexterity}}" /></td></tr>
<tr><td width="20%">$class3name Spells:</td><td><input type="text" name="three_spells" size="5" maxlength="3" value="{{3_spells}}" /></td></tr>
</table>
<input type="submit" name="submit" value="Submit" /> <input type="reset" name="reset" value="Reset" />
</form>
END;
$page = parsetemplate($page, $row);
admindisplay($page, "Edit Levels");
}
function users() {
$query = doquery("SELECT id,username FROM {{table}} ORDER BY id", "users");
$page = "<b><u>Edit Users</u></b><br />Click a username to edit the account.<br /><br /><table width=\"50%\">\n";
$count = 1;
while ($row = mysql_fetch_array($query)) {
if ($count == 1) { $page .= "<tr><td width=\"8%\" style=\"background-color: #eeeeee;\">".$row["id"]."</td><td style=\"background-color: #eeeeee;\"><a href=\"admin.php?do=edituser:".$row["id"]."\">".$row["username"]."</a></td></tr>\n"; $count = 2; }
else { $page .= "<tr><td width=\"8%\" style=\"background-color: #ffffff;\">".$row["id"]."</td><td style=\"background-color: #ffffff;\"><a href=\"admin.php?do=edituser:".$row["id"]."\">".$row["username"]."</a></td></tr>\n"; $count = 1; }
}
if (mysql_num_rows($query) == 0) { $page .= "<tr><td width=\"8%\" style=\"background-color: #eeeeee;\">No spells found.</td></tr>\n"; }
$page .= "</table>";
admindisplay($page, "Edit Users");
}
function edituser($id) {
if (isset($_POST["submit"])) {
extract($_POST);
$errors = 0;
$errorlist = "";
if ($email == "") { $errors++; $errorlist .= "Email is required.<br />"; }
if ($verify == "") { $errors++; $errorlist .= "Verify is required.<br />"; }
if ($charname == "") { $errors++; $errorlist .= "Character Name is required.<br />"; }
if ($authlevel == "") { $errors++; $errorlist .= "Auth Level is required.<br />"; }
if ($latitude == "") { $errors++; $errorlist .= "Latitude is required.<br />"; }
if ($longitude == "") { $errors++; $errorlist .= "Longitude is required.<br />"; }
if ($difficulty == "") { $errors++; $errorlist .= "Difficulty is required.<br />"; }
if ($charclass == "") { $errors++; $errorlist .= "Character Class is required.<br />"; }
if ($currentaction == "") { $errors++; $errorlist .= "Current Action is required.<br />"; }
if ($currentfight == "") { $errors++; $errorlist .= "Current Fight is required.<br />"; }
if ($currentmonster == "") { $errors++; $errorlist .= "Current Monster is required.<br />"; }
if ($currentmonsterhp == "") { $errors++; $errorlist .= "Current Monster HP is required.<br />"; }
if ($currentmonstersleep == "") { $errors++; $errorlist .= "Current Monster Sleep is required.<br />"; }
if ($currentmonsterimmune == "") { $errors++; $errorlist .= "Current Monster Immune is required.<br />"; }
if ($currentuberdamage == "") { $errors++; $errorlist .= "Current Uber Damage is required.<br />"; }
if ($currentuberdefense == "") { $errors++; $errorlist .= "Current Uber Defense is required.<br />"; }
if ($currenthp == "") { $errors++; $errorlist .= "Current HP is required.<br />"; }
if ($currentmp == "") { $errors++; $errorlist .= "Current MP is required.<br />"; }
if ($currenttp == "") { $errors++; $errorlist .= "Current TP is required.<br />"; }
if ($maxhp == "") { $errors++; $errorlist .= "Max HP is required.<br />"; }
if ($maxmp == "") { $errors++; $errorlist .= "Max MP is required.<br />"; }
if ($maxtp == "") { $errors++; $errorlist .= "Max TP is required.<br />"; }
if ($level == "") { $errors++; $errorlist .= "Level is required.<br />"; }
if ($gold == "") { $errors++; $errorlist .= "Gold is required.<br />"; }
if ($experience == "") { $errors++; $errorlist .= "Experience is required.<br />"; }
if ($goldbonus == "") { $errors++; $errorlist .= "Gold Bonus is required.<br />"; }
if ($expbonus == "") { $errors++; $errorlist .= "Experience Bonus is required.<br />"; }
if ($strength == "") { $errors++; $errorlist .= "Strength is required.<br />"; }
if ($dexterity == "") { $errors++; $errorlist .= "Dexterity is required.<br />"; }
if ($attackpower == "") { $errors++; $errorlist .= "Attack Power is required.<br />"; }
if ($defensepower == "") { $errors++; $errorlist .= "Defense Power is required.<br />"; }
if ($weaponid == "") { $errors++; $errorlist .= "Weapon ID is required.<br />"; }
if ($armorid == "") { $errors++; $errorlist .= "Armor ID is required.<br />"; }
if ($shieldid == "") { $errors++; $errorlist .= "Shield ID is required.<br />"; }
if ($slot1id == "") { $errors++; $errorlist .= "Slot 1 ID is required.<br />"; }
if ($slot2id == "") { $errors++; $errorlist .= "Slot 2 ID is required.<br />"; }
if ($slot3id == "") { $errors++; $errorlist .= "Slot 3 ID is required.<br />"; }
if ($weaponname == "") { $errors++; $errorlist .= "Weapon Name is required.<br />"; }
if ($armorname == "") { $errors++; $errorlist .= "Armor Name is required.<br />"; }
if ($shieldname == "") { $errors++; $errorlist .= "Shield Name is required.<br />"; }
if ($slot1name == "") { $errors++; $errorlist .= "Slot 1 Name is required.<br />"; }
if ($slot2name == "") { $errors++; $errorlist .= "Slot 2 Name is required.<br />"; }
if ($slot3name == "") { $errors++; $errorlist .= "Slot 3 Name is required.<br />"; }
if ($dropcode == "") { $errors++; $errorlist .= "Drop Code is required.<br />"; }
if ($spells == "") { $errors++; $errorlist .= "Spells is required.<br />"; }
if ($towns == "") { $errors++; $errorlist .= "Towns is required.<br />"; }
if (!is_numeric($authlevel)) { $errors++; $errorlist .= "Auth Level must be a number.<br />"; }
if (!is_numeric($latitude)) { $errors++; $errorlist .= "Latitude must be a number.<br />"; }
if (!is_numeric($longitude)) { $errors++; $errorlist .= "Longitude must be a number.<br />"; }
if (!is_numeric($difficulty)) { $errors++; $errorlist .= "Difficulty must be a number.<br />"; }
if (!is_numeric($charclass)) { $errors++; $errorlist .= "Character Class must be a number.<br />"; }
if (!is_numeric($currentfight)) { $errors++; $errorlist .= "Current Fight must be a number.<br />"; }
if (!is_numeric($currentmonster)) { $errors++; $errorlist .= "Current Monster must be a number.<br />"; }
if (!is_numeric($currentmonsterhp)) { $errors++; $errorlist .= "Current Monster HP must be a number.<br />"; }
if (!is_numeric($currentmonstersleep)) { $errors++; $errorlist .= "Current Monster Sleep must be a number.<br />"; }
if (!is_numeric($currentmonsterimmune)) { $errors++; $errorlist .= "Current Monster Immune must be a number.<br />"; }
if (!is_numeric($currentuberdamage)) { $errors++; $errorlist .= "Current Uber Damage must be a number.<br />"; }
if (!is_numeric($currentuberdefense)) { $errors++; $errorlist .= "Current Uber Defense must be a number.<br />"; }
if (!is_numeric($currenthp)) { $errors++; $errorlist .= "Current HP must be a number.<br />"; }
if (!is_numeric($currentmp)) { $errors++; $errorlist .= "Current MP must be a number.<br />"; }
if (!is_numeric($currenttp)) { $errors++; $errorlist .= "Current TP must be a number.<br />"; }
if (!is_numeric($maxhp)) { $errors++; $errorlist .= "Max HP must be a number.<br />"; }
if (!is_numeric($maxmp)) { $errors++; $errorlist .= "Max MP must be a number.<br />"; }
if (!is_numeric($maxtp)) { $errors++; $errorlist .= "Max TP must be a number.<br />"; }
if (!is_numeric($level)) { $errors++; $errorlist .= "Level must be a number.<br />"; }
if (!is_numeric($gold)) { $errors++; $errorlist .= "Gold must be a number.<br />"; }
if (!is_numeric($experience)) { $errors++; $errorlist .= "Experience must be a number.<br />"; }
if (!is_numeric($goldbonus)) { $errors++; $errorlist .= "Gold Bonus must be a number.<br />"; }
if (!is_numeric($expbonus)) { $errors++; $errorlist .= "Experience Bonus must be a number.<br />"; }
if (!is_numeric($strength)) { $errors++; $errorlist .= "Strength must be a number.<br />"; }
if (!is_numeric($dexterity)) { $errors++; $errorlist .= "Dexterity must be a number.<br />"; }
if (!is_numeric($attackpower)) { $errors++; $errorlist .= "Attack Power must be a number.<br />"; }
if (!is_numeric($defensepower)) { $errors++; $errorlist .= "Defense Power must be a number.<br />"; }
if (!is_numeric($weaponid)) { $errors++; $errorlist .= "Weapon ID must be a number.<br />"; }
if (!is_numeric($armorid)) { $errors++; $errorlist .= "Armor ID must be a number.<br />"; }
if (!is_numeric($shieldid)) { $errors++; $errorlist .= "Shield ID must be a number.<br />"; }
if (!is_numeric($slot1id)) { $errors++; $errorlist .= "Slot 1 ID must be a number.<br />"; }
if (!is_numeric($slot2id)) { $errors++; $errorlist .= "Slot 2 ID must be a number.<br />"; }
if (!is_numeric($slot3id)) { $errors++; $errorlist .= "Slot 3 ID must be a number.<br />"; }
if (!is_numeric($dropcode)) { $errors++; $errorlist .= "Drop Code must be a number.<br />"; }
if ($errors == 0) {
$updatequery = <<<END
UPDATE {{table}} SET
email="$email", verify="$verify", charname="$charname", authlevel="$authlevel", latitude="$latitude",
longitude="$longitude", difficulty="$difficulty", charclass="$charclass", currentaction="$currentaction", currentfight="$currentfight",
currentmonster="$currentmonster", currentmonsterhp="$currentmonsterhp", currentmonstersleep="$currentmonstersleep", currentmonsterimmune="$currentmonsterimmune", currentuberdamage="$currentuberdamage",
currentuberdefense="$currentuberdefense", currenthp="$currenthp", currentmp="$currentmp", currenttp="$currenttp", maxhp="$maxhp",
maxmp="$maxmp", maxtp="$maxtp", level="$level", gold="$gold", experience="$experience",
goldbonus="$goldbonus", expbonus="$expbonus", strength="$strength", dexterity="$dexterity", attackpower="$attackpower",
defensepower="$defensepower", weaponid="$weaponid", armorid="$armorid", shieldid="$shieldid", slot1id="$slot1id",
slot2id="$slot2id", slot3id="$slot3id", weaponname="$weaponname", armorname="$armorname", shieldname="$shieldname",
slot1name="$slot1name", slot2name="$slot2name", slot3name="$slot3name", dropcode="$dropcode", spells="$spells",
towns="$towns" WHERE id="$id" LIMIT 1
END;
$query = doquery($updatequery, "users");
admindisplay("User updated.","Edit Users");
} else {
admindisplay("<b>Errors:</b><br /><div style=\"color:red;\">$errorlist</div><br />Please go back and try again.", "Edit Users");
}
}
$query = doquery("SELECT * FROM {{table}} WHERE id='$id' LIMIT 1", "users");
$row = mysql_fetch_array($query);
global $controlrow;
$diff1name = $controlrow["diff1name"];
$diff2name = $controlrow["diff2name"];
$diff3name = $controlrow["diff3name"];
$class1name = $controlrow["class1name"];
$class2name = $controlrow["class2name"];
$class3name = $controlrow["class3name"];
$page = <<<END
<b><u>Edit Users</u></b><br /><br />
<form action="admin.php?do=edituser:$id" method="post">
<table width="90%">
<tr><td width="20%">ID:</td><td>{{id}}</td></tr>
<tr><td width="20%">Username:</td><td>{{username}}</td></tr>
<tr><td width="20%">Email:</td><td><input type="text" name="email" size="30" maxlength="100" value="{{email}}" /></td></tr>
<tr><td width="20%">Verify:</td><td><input type="text" name="verify" size="30" maxlength="8" value="{{verify}}" /></td></tr>
<tr><td width="20%">Character Name:</td><td><input type="text" name="charname" size="30" maxlength="30" value="{{charname}}" /></td></tr>
<tr><td width="20%">Register Date:</td><td>{{regdate}}</td></tr>
<tr><td width="20%">Last Online:</td><td>{{onlinetime}}</td></tr>
<tr><td width="20%">Auth Level:</td><td><select name="authlevel"><option value="0" {{auth0select}}>User</option><option value="1" {{auth1select}}>Admin</option><option value="2" {{auth2select}}>Blocked</option></select><br /><span class="small">Set to "Blocked" to temporarily (or permanently) ban a user.</span></td></tr>
<tr><td colspan="2" style="background-color:#cccccc;">&nbsp;</td></tr>
<tr><td width="20%">Latitude:</td><td><input type="text" name="latitude" size="5" maxlength="6" value="{{latitude}}" /></td></tr>
<tr><td width="20%">Longitude:</td><td><input type="text" name="longitude" size="5" maxlength="6" value="{{longitude}}" /></td></tr>
<tr><td width="20%">Difficulty:</td><td><select name="difficulty"><option value="1" {{diff1select}}>$diff1name</option><option value="2" {{diff2select}}>$diff2name</option><option value="3" {{diff3select}}>$diff3name</option></select></td></tr>
<tr><td width="20%">Character Class:</td><td><select name="charclass"><option value="1" {{class1select}}>$class1name</option><option value="2" {{class2select}}>$class2name</option><option value="3" {{class3select}}>$class3name</option></select></td></tr>
<tr><td colspan="2" style="background-color:#cccccc;">&nbsp;</td></tr>
<tr><td width="20%">Current Action:</td><td><input type="text" name="currentaction" size="30" maxlength="30" value="{{currentaction}}" /></td></tr>
<tr><td width="20%">Current Fight:</td><td><input type="text" name="currentfight" size="5" maxlength="4" value="{{currentfight}}" /></td></tr>
<tr><td width="20%">Current Monster:</td><td><input type="text" name="currentmonster" size="5" maxlength="6" value="{{currentmonster}}" /></td></tr>
<tr><td width="20%">Current Monster HP:</td><td><input type="text" name="currentmonsterhp" size="5" maxlength="6" value="{{currentmonsterhp}}" /></td></tr>
<tr><td width="20%">Current Monster Sleep:</td><td><input type="text" name="currentmonsterimmune" size="5" maxlength="3" value="{{currentmonsterimmune}}" /></td></tr>
<tr><td width="20%">Current Monster Immune:</td><td><input type="text" name="currentmonstersleep" size="5" maxlength="3" value="{{currentmonstersleep}}" /></td></tr>
<tr><td width="20%">Current Uber Damage:</td><td><input type="text" name="currentuberdamage" size="5" maxlength="3" value="{{currentuberdamage}}" /></td></tr>
<tr><td width="20%">Current Uber Defense:</td><td><input type="text" name="currentuberdefense" size="5" maxlength="3" value="{{currentuberdefense}}" /></td></tr>
<tr><td colspan="2" style="background-color:#cccccc;">&nbsp;</td></tr>
<tr><td width="20%">Current HP:</td><td><input type="text" name="currenthp" size="5" maxlength="6" value="{{currenthp}}" /></td></tr>
<tr><td width="20%">Current MP:</td><td><input type="text" name="currentmp" size="5" maxlength="6" value="{{currentmp}}" /></td></tr>
<tr><td width="20%">Current TP:</td><td><input type="text" name="currenttp" size="5" maxlength="6" value="{{currenttp}}" /></td></tr>
<tr><td width="20%">Max HP:</td><td><input type="text" name="maxhp" size="5" maxlength="6" value="{{maxhp}}" /></td></tr>
<tr><td width="20%">Max MP:</td><td><input type="text" name="maxmp" size="5" maxlength="6" value="{{maxmp}}" /></td></tr>
<tr><td width="20%">Max TP:</td><td><input type="text" name="maxtp" size="5" maxlength="6" value="{{maxtp}}" /></td></tr>
<tr><td colspan="2" style="background-color:#cccccc;">&nbsp;</td></tr>
<tr><td width="20%">Level:</td><td><input type="text" name="level" size="5" maxlength="5" value="{{level}}" /></td></tr>
<tr><td width="20%">Gold:</td><td><input type="text" name="gold" size="10" maxlength="8" value="{{gold}}" /></td></tr>
<tr><td width="20%">Experience:</td><td><input type="text" name="experience" size="10" maxlength="8" value="{{experience}}" /></td></tr>
<tr><td width="20%">Gold Bonus:</td><td><input type="text" name="goldbonus" size="5" maxlength="5" value="{{goldbonus}}" /></td></tr>
<tr><td width="20%">Experience Bonus:</td><td><input type="text" name="expbonus" size="5" maxlength="5" value="{{expbonus}}" /></td></tr>
<tr><td width="20%">Strength:</td><td><input type="text" name="strength" size="5" maxlength="5" value="{{strength}}" /></td></tr>
<tr><td width="20%">Dexterity:</td><td><input type="text" name="dexterity" size="5" maxlength="5" value="{{dexterity}}" /></td></tr>
<tr><td width="20%">Attack Power:</td><td><input type="text" name="attackpower" size="5" maxlength="5" value="{{attackpower}}" /></td></tr>
<tr><td width="20%">Defense Power:</td><td><input type="text" name="defensepower" size="5" maxlength="5" value="{{defensepower}}" /></td></tr>
<tr><td colspan="2" style="background-color:#cccccc;">&nbsp;</td></tr>
<tr><td width="20%">Weapon ID:</td><td><input type="text" name="weaponid" size="5" maxlength="5" value="{{weaponid}}" /></td></tr>
<tr><td width="20%">Armor ID:</td><td><input type="text" name="armorid" size="5" maxlength="5" value="{{armorid}}" /></td></tr>
<tr><td width="20%">Shield ID:</td><td><input type="text" name="shieldid" size="5" maxlength="5" value="{{shieldid}}" /></td></tr>
<tr><td width="20%">Slot 1 ID:</td><td><input type="text" name="slot1id" size="5" maxlength="5" value="{{slot1id}}" /></td></tr>
<tr><td width="20%">Slot 2 ID:</td><td><input type="text" name="slot2id" size="5" maxlength="5" value="{{slot2id}}" /></td></tr>
<tr><td width="20%">Slot 3 ID:</td><td><input type="text" name="slot3id" size="5" maxlength="5" value="{{slot3id}}" /></td></tr>
<tr><td width="20%">Weapon Name:</td><td><input type="text" name="weaponname" size="30" maxlength="30" value="{{weaponname}}" /></td></tr>
<tr><td width="20%">Armor Name:</td><td><input type="text" name="armorname" size="30" maxlength="30" value="{{armorname}}" /></td></tr>
<tr><td width="20%">Shield Name:</td><td><input type="text" name="shieldname" size="30" maxlength="30" value="{{shieldname}}" /></td></tr>
<tr><td width="20%">Slot 1 Name:</td><td><input type="text" name="slot1name" size="30" maxlength="30" value="{{slot1name}}" /></td></tr>
<tr><td width="20%">Slot 2 Name:</td><td><input type="text" name="slot2name" size="30" maxlength="30" value="{{slot2name}}" /></td></tr>
<tr><td width="20%">Slot 3 Name:</td><td><input type="text" name="slot3name" size="30" maxlength="30" value="{{slot3name}}" /></td></tr>
<tr><td colspan="2" style="background-color:#cccccc;">&nbsp;</td></tr>
<tr><td width="20%">Drop Code:</td><td><input type="text" name="dropcode" size="5" maxlength="8" value="{{dropcode}}" /></td></tr>
<tr><td width="20%">Spells:</td><td><input type="text" name="spells" size="50" maxlength="50" value="{{spells}}" /></td></tr>
<tr><td width="20%">Towns:</td><td><input type="text" name="towns" size="50" maxlength="50" value="{{towns}}" /></td></tr>
</table>
<input type="submit" name="submit" value="Submit" /> <input type="reset" name="reset" value="Reset" />
</form>
END;
if ($row["authlevel"] == 0) { $row["auth0select"] = "selected=\"selected\" "; } else { $row["auth0select"] = ""; }
if ($row["authlevel"] == 1) { $row["auth1select"] = "selected=\"selected\" "; } else { $row["auth1select"] = ""; }
if ($row["authlevel"] == 2) { $row["auth2select"] = "selected=\"selected\" "; } else { $row["auth2select"] = ""; }
if ($row["charclass"] == 1) { $row["class1select"] = "selected=\"selected\" "; } else { $row["class1select"] = ""; }
if ($row["charclass"] == 2) { $row["class2select"] = "selected=\"selected\" "; } else { $row["class2select"] = ""; }
if ($row["charclass"] == 3) { $row["class3select"] = "selected=\"selected\" "; } else { $row["class3select"] = ""; }
if ($row["difficulty"] == 1) { $row["diff1select"] = "selected=\"selected\" "; } else { $row["diff1select"] = ""; }
if ($row["difficulty"] == 2) { $row["diff2select"] = "selected=\"selected\" "; } else { $row["diff2select"] = ""; }
if ($row["difficulty"] == 3) { $row["diff3select"] = "selected=\"selected\" "; } else { $row["diff3select"] = ""; }
$page = parsetemplate($page, $row);
admindisplay($page, "Edit Users");
}
function addnews() {
if (isset($_POST["submit"])) {
extract($_POST);
$errors = 0;
$errorlist = "";
if ($content == "") { $errors++; $errorlist .= "Content is required.<br />"; }
if ($errors == 0) {
$query = doquery("INSERT INTO {{table}} SET id='',postdate=NOW(),content='$content'", "news");
admindisplay("News post added.","Add News");
} else {
admindisplay("<b>Errors:</b><br /><div style=\"color:red;\">$errorlist</div><br />Please go back and try again.", "Add News");
}
}
$page = <<<END
<b><u>Add A News Post</u></b><br /><br />
<form action="admin.php?do=news" method="post">
Type your post below and then click Submit to add it.<br />
<textarea name="content" rows="5" cols="50"></textarea><br />
<input type="submit" name="submit" value="Submit" /> <input type="reset" name="reset" value="Reset" />
</form>
END;
admindisplay($page, "Add News");
}
?>

View File

@ -1,11 +0,0 @@
<?php // config.php :: Low-level app/database variables.
$dbsettings = Array(
"server" => "localhost", // MySQL server name. (Default: localhost)
"user" => "", // MySQL username.
"pass" => "", // MySQL password.
"name" => "", // MySQL database name.
"prefix" => "dk", // Prefix for table names. (Default: dk)
"secretword" => ""); // Secret word used when hashing information for cookies.
?>

View File

@ -1,32 +0,0 @@
<?php // cookies.php :: Handles cookies. (Mmm, tasty!)
function checkcookies() {
include('config.php');
$row = false;
if (isset($_COOKIE["dkgame"])) {
// COOKIE FORMAT:
// {ID} {USERNAME} {PASSWORDHASH} {REMEMBERME}
$theuser = explode(" ",$_COOKIE["dkgame"]);
$query = doquery("SELECT * FROM {{table}} WHERE username='$theuser[1]'", "users");
if (mysql_num_rows($query) != 1) { die("Invalid cookie data (Error 1). Please clear cookies and log in again."); }
$row = mysql_fetch_array($query);
if ($row["id"] != $theuser[0]) { die("Invalid cookie data (Error 2). Please clear cookies and log in again."); }
if (md5($row["password"] . "--" . $dbsettings["secretword"]) !== $theuser[2]) { die("Invalid cookie data (Error 3). Please clear cookies and log in again."); }
// If we've gotten this far, cookie should be valid, so write a new one.
$newcookie = implode(" ",$theuser);
if ($theuser[3] == 1) { $expiretime = time()+31536000; } else { $expiretime = 0; }
setcookie ("dkgame", $newcookie, $expiretime, "/", "", 0);
$onlinequery = doquery("UPDATE {{table}} SET onlinetime=NOW() WHERE id='$theuser[0]' LIMIT 1", "users");
}
return $row;
}
?>

View File

@ -1,37 +0,0 @@
<?php // explore.php :: Handles all map exploring, chances to fight, etc.
function move() {
global $userrow, $controlrow;
if ($userrow["currentaction"] == "Fighting") { header("Location: index.php?do=fight"); die(); }
$latitude = $userrow["latitude"];
$longitude = $userrow["longitude"];
if (isset($_POST["north"])) { $latitude++; if ($latitude > $controlrow["gamesize"]) { $latitude = $controlrow["gamesize"]; } }
if (isset($_POST["south"])) { $latitude--; if ($latitude < ($controlrow["gamesize"]*-1)) { $latitude = ($controlrow["gamesize"]*-1); } }
if (isset($_POST["east"])) { $longitude++; if ($longitude > $controlrow["gamesize"]) { $longitude = $controlrow["gamesize"]; } }
if (isset($_POST["west"])) { $longitude--; if ($longitude < ($controlrow["gamesize"]*-1)) { $longitude = ($controlrow["gamesize"]*-1); } }
$townquery = doquery("SELECT id FROM {{table}} WHERE latitude='$latitude' AND longitude='$longitude' LIMIT 1", "towns");
if (mysql_num_rows($townquery) > 0) {
$townrow = mysql_fetch_array($townquery);
include('towns.php');
travelto($townrow["id"], false);
die();
}
$chancetofight = rand(1,5);
if ($chancetofight == 1) {
$action = "currentaction='Fighting', currentfight='1',";
} else {
$action = "currentaction='Exploring',";
}
$updatequery = doquery("UPDATE {{table}} SET $action latitude='$latitude', longitude='$longitude', dropcode='0' WHERE id='".$userrow["id"]."' LIMIT 1", "users");
header("Location: index.php");
}
?>

540
fight.php
View File

@ -1,540 +0,0 @@
<?php // fight.php :: Handles all fighting action.
function fight() { // One big long function that determines the outcome of the fight.
global $userrow, $controlrow;
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)) {
$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";
}
unset($spell);
}
if ($pagearray["magiclist"] == "") { $pagearray["magiclist"] = "<option value=\"0\">None</option>\n"; }
$magiclist = $pagearray["magiclist"];
$chancetoswingfirst = 1;
// First, check to see if we need to pick a monster.
if ($userrow["currentfight"] == 1) {
if ($userrow["latitude"] < 0) { $userrow["latitude"] *= -1; } // Equalize negatives.
if ($userrow["longitude"] < 0) { $userrow["longitude"] *= -1; } // Ditto.
$maxlevel = floor(max($userrow["latitude"]+5, $userrow["longitude"]+5) / 5); // One mlevel per five spaces.
if ($maxlevel < 1) { $maxlevel = 1; }
$minlevel = $maxlevel - 2;
if ($minlevel < 1) { $minlevel = 1; }
// 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);
$userrow["currentmonster"] = $monsterrow["id"];
$userrow["currentmonsterhp"] = rand((($monsterrow["maxhp"]/5)*4),$monsterrow["maxhp"]);
if ($userrow["difficulty"] == 2) { $userrow["currentmonsterhp"] = ceil($userrow["currentmonsterhp"] * $controlrow["diff2mod"]); }
if ($userrow["difficulty"] == 3) { $userrow["currentmonsterhp"] = ceil($userrow["currentmonsterhp"] * $controlrow["diff3mod"]); }
$userrow["currentmonstersleep"] = 0;
$userrow["currentmonsterimmune"] = $monsterrow["immune"];
$chancetoswingfirst = rand(1,10) + ceil(sqrt($userrow["dexterity"]));
if ($chancetoswingfirst > (rand(1,7) + ceil(sqrt($monsterrow["maxdam"])))) { $chancetoswingfirst = 1; } else { $chancetoswingfirst = 0; }
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);
$pagearray["monstername"] = $monsterrow["name"];
// Do run stuff.
if (isset($_POST["run"])) {
$chancetorun = rand(4,10) + ceil(sqrt($userrow["dexterity"]));
if ($chancetorun > (rand(1,5) + ceil(sqrt($monsterrow["maxdam"])))) { $chancetorun = 1; } else { $chancetorun = 0; }
if ($chancetorun == 0) {
$pagearray["yourturn"] = "You tried to run away, but were blocked in front!<br /><br />";
$pagearray["monsterhp"] = "Monster's HP: " . $userrow["currentmonsterhp"] . "<br /><br />";
$pagearray["monsterturn"] = "";
if ($userrow["currentmonstersleep"] != 0) { // Check to wake up.
$chancetowake = rand(1,15);
if ($chancetowake > $userrow["currentmonstersleep"]) {
$userrow["currentmonstersleep"] = 0;
$pagearray["monsterturn"] .= "The monster has woken up.<br />";
} else {
$pagearray["monsterturn"] .= "The monster is still asleep.<br />";
}
}
if ($userrow["currentmonstersleep"] == 0) { // Only do this if the monster is awake.
$tohit = ceil(rand($monsterrow["maxdam"]*.5,$monsterrow["maxdam"]));
if ($userrow["difficulty"] == 2) { $tohit = ceil($tohit * $controlrow["diff2mod"]); }
if ($userrow["difficulty"] == 3) { $tohit = ceil($tohit * $controlrow["diff3mod"]); }
$toblock = ceil(rand($userrow["defensepower"]*.75,$userrow["defensepower"])/4);
$tododge = rand(1,150);
if ($tododge <= sqrt($userrow["dexterity"])) {
$tohit = 0; $pagearray["monsterturn"] .= "You dodge the monster's attack. No damage has been scored.<br />";
$persondamage = 0;
} else {
$persondamage = $tohit - $toblock;
if ($persondamage < 1) { $persondamage = 1; }
if ($userrow["currentuberdefense"] != 0) {
$persondamage -= ceil($persondamage * ($userrow["currentuberdefense"]/100));
}
if ($persondamage < 1) { $persondamage = 1; }
}
$pagearray["monsterturn"] .= "The monster attacks you for $persondamage damage.<br /><br />";
$userrow["currenthp"] -= $persondamage;
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");
$playerisdead = 1;
}
}
}
$updatequery = doquery("UPDATE {{table}} SET currentaction='Exploring' WHERE id='".$userrow["id"]."' LIMIT 1", "users");
header("Location: index.php");
die();
// Do fight stuff.
} elseif (isset($_POST["fight"])) {
// Your turn.
$pagearray["yourturn"] = "";
$tohit = ceil(rand($userrow["attackpower"]*.75,$userrow["attackpower"])/3);
$toexcellent = rand(1,150);
if ($toexcellent <= sqrt($userrow["strength"])) { $tohit *= 2; $pagearray["yourturn"] .= "Excellent hit!<br />"; }
$toblock = ceil(rand($monsterrow["armor"]*.75,$monsterrow["armor"])/3);
$tododge = rand(1,200);
if ($tododge <= sqrt($monsterrow["armor"])) {
$tohit = 0; $pagearray["yourturn"] .= "The monster is dodging. No damage has been scored.<br />";
$monsterdamage = 0;
} else {
$monsterdamage = $tohit - $toblock;
if ($monsterdamage < 1) { $monsterdamage = 1; }
if ($userrow["currentuberdamage"] != 0) {
$monsterdamage += ceil($monsterdamage * ($userrow["currentuberdamage"]/100));
}
}
$pagearray["yourturn"] .= "You attack the monster for $monsterdamage damage.<br /><br />";
$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();
}
// Monster's turn.
$pagearray["monsterturn"] = "";
if ($userrow["currentmonstersleep"] != 0) { // Check to wake up.
$chancetowake = rand(1,15);
if ($chancetowake > $userrow["currentmonstersleep"]) {
$userrow["currentmonstersleep"] = 0;
$pagearray["monsterturn"] .= "The monster has woken up.<br />";
} else {
$pagearray["monsterturn"] .= "The monster is still asleep.<br />";
}
}
if ($userrow["currentmonstersleep"] == 0) { // Only do this if the monster is awake.
$tohit = ceil(rand($monsterrow["maxdam"]*.5,$monsterrow["maxdam"]));
if ($userrow["difficulty"] == 2) { $tohit = ceil($tohit * $controlrow["diff2mod"]); }
if ($userrow["difficulty"] == 3) { $tohit = ceil($tohit * $controlrow["diff3mod"]); }
$toblock = ceil(rand($userrow["defensepower"]*.75,$userrow["defensepower"])/4);
$tododge = rand(1,150);
if ($tododge <= sqrt($userrow["dexterity"])) {
$tohit = 0; $pagearray["monsterturn"] .= "You dodge the monster's attack. No damage has been scored.<br />";
$persondamage = 0;
} else {
$persondamage = $tohit - $toblock;
if ($persondamage < 1) { $persondamage = 1; }
if ($userrow["currentuberdefense"] != 0) {
$persondamage -= ceil($persondamage * ($userrow["currentuberdefense"]/100));
}
if ($persondamage < 1) { $persondamage = 1; }
}
$pagearray["monsterturn"] .= "The monster attacks you for $persondamage damage.<br /><br />";
$userrow["currenthp"] -= $persondamage;
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");
$playerisdead = 1;
}
}
// Do spell stuff.
} elseif (isset($_POST["spell"])) {
// Your turn.
$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);
$spell = false;
foreach($userspells as $a => $b) {
if ($b == $pickedspell) { $spell = true; }
}
if ($spell != true) { display("You have not yet learned this spell. Please go back and try again.", "Error"); die(); }
if ($userrow["currentmp"] < $newspellrow["mp"]) { display("You do not have enough Magic Points to cast this spell. Please go back and try again.", "Error"); die(); }
if ($newspellrow["type"] == 1) { // Heal spell.
$newhp = $userrow["currenthp"] + $newspellrow["attribute"];
if ($userrow["maxhp"] < $newhp) { $newspellrow["attribute"] = $userrow["maxhp"] - $userrow["currenthp"]; $newhp = $userrow["currenthp"] + $newspellrow["attribute"]; }
$userrow["currenthp"] = $newhp;
$userrow["currentmp"] -= $newspellrow["mp"];
$pagearray["yourturn"] = "You have cast the ".$newspellrow["name"]." spell, and gained ".$newspellrow["attribute"]." Hit Points.<br /><br />";
} elseif ($newspellrow["type"] == 2) { // Hurt spell.
if ($userrow["currentmonsterimmune"] == 0) {
$monsterdamage = rand((($newspellrow["attribute"]/6)*5), $newspellrow["attribute"]);
$userrow["currentmonsterhp"] -= $monsterdamage;
$pagearray["yourturn"] = "You have cast the ".$newspellrow["name"]." spell for $monsterdamage damage.<br /><br />";
} else {
$pagearray["yourturn"] = "You have cast the ".$newspellrow["name"]." spell, but the monster is immune to it.<br /><br />";
}
$userrow["currentmp"] -= $newspellrow["mp"];
} elseif ($newspellrow["type"] == 3) { // Sleep spell.
if ($userrow["currentmonsterimmune"] != 2) {
$userrow["currentmonstersleep"] = $newspellrow["attribute"];
$pagearray["yourturn"] = "You have cast the ".$newspellrow["name"]." spell. The monster is asleep.<br /><br />";
} else {
$pagearray["yourturn"] = "You have cast the ".$newspellrow["name"]." spell, but the monster is immune to it.<br /><br />";
}
$userrow["currentmp"] -= $newspellrow["mp"];
} elseif ($newspellrow["type"] == 4) { // +Damage spell.
$userrow["currentuberdamage"] = $newspellrow["attribute"];
$userrow["currentmp"] -= $newspellrow["mp"];
$pagearray["yourturn"] = "You have cast the ".$newspellrow["name"]." spell, and will gain ".$newspellrow["attribute"]."% damage until the end of this fight.<br /><br />";
} elseif ($newspellrow["type"] == 5) { // +Defense spell.
$userrow["currentuberdefense"] = $newspellrow["attribute"];
$userrow["currentmp"] -= $newspellrow["mp"];
$pagearray["yourturn"] = "You have cast the ".$newspellrow["name"]." spell, and will gain ".$newspellrow["attribute"]."% defense until the end of this fight.<br /><br />";
}
$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();
}
// Monster's turn.
$pagearray["monsterturn"] = "";
if ($userrow["currentmonstersleep"] != 0) { // Check to wake up.
$chancetowake = rand(1,15);
if ($chancetowake > $userrow["currentmonstersleep"]) {
$userrow["currentmonstersleep"] = 0;
$pagearray["monsterturn"] .= "The monster has woken up.<br />";
} else {
$pagearray["monsterturn"] .= "The monster is still asleep.<br />";
}
}
if ($userrow["currentmonstersleep"] == 0) { // Only do this if the monster is awake.
$tohit = ceil(rand($monsterrow["maxdam"]*.5,$monsterrow["maxdam"]));
if ($userrow["difficulty"] == 2) { $tohit = ceil($tohit * $controlrow["diff2mod"]); }
if ($userrow["difficulty"] == 3) { $tohit = ceil($tohit * $controlrow["diff3mod"]); }
$toblock = ceil(rand($userrow["defensepower"]*.75,$userrow["defensepower"])/4);
$tododge = rand(1,150);
if ($tododge <= sqrt($userrow["dexterity"])) {
$tohit = 0; $pagearray["monsterturn"] .= "You dodge the monster's attack. No damage has been scored.<br />";
$persondamage = 0;
} else {
if ($tohit <= $toblock) { $tohit = $toblock + 1; }
$persondamage = $tohit - $toblock;
if ($userrow["currentuberdefense"] != 0) {
$persondamage -= ceil($persondamage * ($userrow["currentuberdefense"]/100));
}
if ($persondamage < 1) { $persondamage = 1; }
}
$pagearray["monsterturn"] .= "The monster attacks you for $persondamage damage.<br /><br />";
$userrow["currenthp"] -= $persondamage;
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");
$playerisdead = 1;
}
}
// Do a monster's turn if person lost the chance to swing first. Serves him right!
} elseif ( $chancetoswingfirst == 0 ) {
$pagearray["yourturn"] = "The monster attacks before you are ready!<br /><br />";
$pagearray["monsterhp"] = "Monster's HP: " . $userrow["currentmonsterhp"] . "<br /><br />";
$pagearray["monsterturn"] = "";
if ($userrow["currentmonstersleep"] != 0) { // Check to wake up.
$chancetowake = rand(1,15);
if ($chancetowake > $userrow["currentmonstersleep"]) {
$userrow["currentmonstersleep"] = 0;
$pagearray["monsterturn"] .= "The monster has woken up.<br />";
} else {
$pagearray["monsterturn"] .= "The monster is still asleep.<br />";
}
}
if ($userrow["currentmonstersleep"] == 0) { // Only do this if the monster is awake.
$tohit = ceil(rand($monsterrow["maxdam"]*.5,$monsterrow["maxdam"]));
if ($userrow["difficulty"] == 2) { $tohit = ceil($tohit * $controlrow["diff2mod"]); }
if ($userrow["difficulty"] == 3) { $tohit = ceil($tohit * $controlrow["diff3mod"]); }
$toblock = ceil(rand($userrow["defensepower"]*.75,$userrow["defensepower"])/4);
$tododge = rand(1,150);
if ($tododge <= sqrt($userrow["dexterity"])) {
$tohit = 0; $pagearray["monsterturn"] .= "You dodge the monster's attack. No damage has been scored.<br />";
$persondamage = 0;
} else {
$persondamage = $tohit - $toblock;
if ($persondamage < 1) { $persondamage = 1; }
if ($userrow["currentuberdefense"] != 0) {
$persondamage -= ceil($persondamage * ($userrow["currentuberdefense"]/100));
}
if ($persondamage < 1) { $persondamage = 1; }
}
$pagearray["monsterturn"] .= "The monster attacks you for $persondamage damage.<br /><br />";
$userrow["currenthp"] -= $persondamage;
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");
$playerisdead = 1;
}
}
} else {
$pagearray["yourturn"] = "";
$pagearray["monsterhp"] = "Monster's HP: " . $userrow["currentmonsterhp"] . "<br /><br />";
$pagearray["monsterturn"] = "";
}
$newmonster = $userrow["currentmonster"];
$newmonsterhp = $userrow["currentmonsterhp"];
$newmonstersleep = $userrow["currentmonstersleep"];
$newmonsterimmune = $userrow["currentmonsterimmune"];
$newuberdamage = $userrow["currentuberdamage"];
$newuberdefense = $userrow["currentuberdefense"];
$newfight = $userrow["currentfight"] + 1;
$newhp = $userrow["currenthp"];
$newmp = $userrow["currentmp"];
if ($playerisdead != 1) {
$pagearray["command"] = <<<END
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");
} 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");
}
function victory() {
global $userrow, $controlrow;
if ($userrow["currentmonsterhp"] != 0) { header("Location: index.php?do=fight"); die(); }
if ($userrow["currentfight"] == 0) { header("Location: index.php"); die(); }
$monsterquery = doquery("SELECT * FROM {{table}} WHERE id='".$userrow["currentmonster"]."' LIMIT 1", "monsters");
$monsterrow = mysql_fetch_array($monsterquery);
$exp = rand((($monsterrow["maxexp"]/6)*5),$monsterrow["maxexp"]);
if ($exp < 1) { $exp = 1; }
if ($userrow["difficulty"] == 2) { $exp = ceil($exp * $controlrow["diff2mod"]); }
if ($userrow["difficulty"] == 3) { $exp = ceil($exp * $controlrow["diff3mod"]); }
if ($userrow["expbonus"] != 0) { $exp += ceil(($userrow["expbonus"]/100)*$exp); }
$gold = rand((($monsterrow["maxgold"]/6)*5),$monsterrow["maxgold"]);
if ($gold < 1) { $gold = 1; }
if ($userrow["difficulty"] == 2) { $gold = ceil($gold * $controlrow["diff2mod"]); }
if ($userrow["difficulty"] == 3) { $gold = ceil($gold * $controlrow["diff3mod"]); }
if ($userrow["goldbonus"] != 0) { $gold += ceil(($userrow["goldbonus"]/100)*$exp); }
if ($userrow["experience"] + $exp < 16777215) { $newexp = $userrow["experience"] + $exp; $warnexp = ""; } else { $newexp = $userrow["experience"]; $exp = 0; $warnexp = "You have maxed out your experience points."; }
if ($userrow["gold"] + $gold < 16777215) { $newgold = $userrow["gold"] + $gold; $warngold = ""; } else { $newgold = $userrow["gold"]; $gold = 0; $warngold = "You have maxed out your experience points."; }
$levelquery = doquery("SELECT * FROM {{table}} WHERE id='".($userrow["level"]+1)."' LIMIT 1", "levels");
if (mysql_num_rows($levelquery) == 1) { $levelrow = mysql_fetch_array($levelquery); }
if ($userrow["level"] < 100) {
if ($newexp >= $levelrow[$userrow["charclass"]."_exp"]) {
$newhp = $userrow["maxhp"] + $levelrow[$userrow["charclass"]."_hp"];
$newmp = $userrow["maxmp"] + $levelrow[$userrow["charclass"]."_mp"];
$newtp = $userrow["maxtp"] + $levelrow[$userrow["charclass"]."_tp"];
$newstrength = $userrow["strength"] + $levelrow[$userrow["charclass"]."_strength"];
$newdexterity = $userrow["dexterity"] + $levelrow[$userrow["charclass"]."_dexterity"];
$newattack = $userrow["attackpower"] + $levelrow[$userrow["charclass"]."_strength"];
$newdefense = $userrow["defensepower"] + $levelrow[$userrow["charclass"]."_dexterity"];
$newlevel = $levelrow["id"];
if ($levelrow[$userrow["charclass"]."_spells"] != 0) {
$userspells = $userrow["spells"] . ",".$levelrow[$userrow["charclass"]."_spells"];
$newspell = "spells='$userspells',";
$spelltext = "You have learned a new spell.<br />";
} else { $spelltext = ""; $newspell=""; }
$page = "Congratulations. You have defeated the ".$monsterrow["name"].".<br />You gain $exp experience. $warnexp <br />You gain $gold gold. $warngold <br /><br /><b>You have gained a level!</b><br /><br />You gain ".$levelrow[$userrow["charclass"]."_hp"]." hit points.<br />You gain ".$levelrow[$userrow["charclass"]."_mp"]." magic points.<br />You gain ".$levelrow[$userrow["charclass"]."_tp"]." travel points.<br />You gain ".$levelrow[$userrow["charclass"]."_strength"]." strength.<br />You gain ".$levelrow[$userrow["charclass"]."_dexterity"]." dexterity.<br />$spelltext<br />You can now continue <a href=\"index.php\">exploring</a>.";
$title = "Courage and Wit have served thee well!";
$dropcode = "";
} else {
$newhp = $userrow["maxhp"];
$newmp = $userrow["maxmp"];
$newtp = $userrow["maxtp"];
$newstrength = $userrow["strength"];
$newdexterity = $userrow["dexterity"];
$newattack = $userrow["attackpower"];
$newdefense = $userrow["defensepower"];
$newlevel = $userrow["level"];
$newspell = "";
$page = "Congratulations. You have defeated the ".$monsterrow["name"].".<br />You gain $exp experience. $warnexp <br />You gain $gold gold. $warngold <br /><br />";
if (rand(1,30) == 1) {
$dropquery = doquery("SELECT * FROM {{table}} WHERE mlevel <= '".$monsterrow["level"]."' ORDER BY RAND() LIMIT 1", "drops");
$droprow = mysql_fetch_array($dropquery);
$dropcode = "dropcode='".$droprow["id"]."',";
$page .= "This monster has dropped an item. <a href=\"index.php?do=drop\">Click here</a> to reveal and equip the item, or you may also move on and continue <a href=\"index.php\">exploring</a>.";
} else {
$dropcode = "";
$page .= "You can now continue <a href=\"index.php\">exploring</a>.";
}
$title = "Victory!";
}
}
$updatequery = doquery("UPDATE {{table}} SET currentaction='Exploring',level='$newlevel',maxhp='$newhp',maxmp='$newmp',maxtp='$newtp',strength='$newstrength',dexterity='$newdexterity',attackpower='$newattack',defensepower='$newdefense', $newspell currentfight='0',currentmonster='0',currentmonsterhp='0',currentmonstersleep='0',currentmonsterimmune='0',currentuberdamage='0',currentuberdefense='0',$dropcode experience='$newexp',gold='$newgold' WHERE id='".$userrow["id"]."' LIMIT 1", "users");
display($page, $title);
}
function drop() {
global $userrow;
if ($userrow["dropcode"] == 0) { header("Location: index.php"); die(); }
$dropquery = doquery("SELECT * FROM {{table}} WHERE id='".$userrow["dropcode"]."' LIMIT 1", "drops");
$droprow = mysql_fetch_array($dropquery);
if (isset($_POST["submit"])) {
$slot = $_POST["slot"];
if ($slot == 0) { display("Please go back and select an inventory slot to continue.","Error"); }
if ($userrow["slot".$slot."id"] != 0) {
$slotquery = doquery("SELECT * FROM {{table}} WHERE id='".$userrow["slot".$slot."id"]."' LIMIT 1", "drops");
$slotrow = mysql_fetch_array($slotquery);
$old1 = explode(",",$slotrow["attribute1"]);
if ($slotrow["attribute2"] != "X") { $old2 = explode(",",$slotrow["attribute2"]); } else { $old2 = array(0=>"maxhp",1=>0); }
$new1 = explode(",",$droprow["attribute1"]);
if ($droprow["attribute2"] != "X") { $new2 = explode(",",$droprow["attribute2"]); } else { $new2 = array(0=>"maxhp",1=>0); }
$userrow[$old1[0]] -= $old1[1];
$userrow[$old2[0]] -= $old2[1];
if ($old1[0] == "strength") { $userrow["attackpower"] -= $old1[1]; }
if ($old1[0] == "dexterity") { $userrow["defensepower"] -= $old1[1]; }
if ($old2[0] == "strength") { $userrow["attackpower"] -= $old2[1]; }
if ($old2[0] == "dexterity") { $userrow["defensepower"] -= $old2[1]; }
$userrow[$new1[0]] += $new1[1];
$userrow[$new2[0]] += $new2[1];
if ($new1[0] == "strength") { $userrow["attackpower"] += $new1[1]; }
if ($new1[0] == "dexterity") { $userrow["defensepower"] += $new1[1]; }
if ($new2[0] == "strength") { $userrow["attackpower"] += $new2[1]; }
if ($new2[0] == "dexterity") { $userrow["defensepower"] += $new2[1]; }
if ($userrow["currenthp"] > $userrow["maxhp"]) { $userrow["currenthp"] = $userrow["maxhp"]; }
if ($userrow["currentmp"] > $userrow["maxmp"]) { $userrow["currentmp"] = $userrow["maxmp"]; }
if ($userrow["currenttp"] > $userrow["maxtp"]) { $userrow["currenttp"] = $userrow["maxtp"]; }
$newname = addslashes($droprow["name"]);
$query = doquery("UPDATE {{table}} SET slot".$_POST["slot"]."name='$newname',slot".$_POST["slot"]."id='".$droprow["id"]."',$old1[0]='".$userrow[$old1[0]]."',$old2[0]='".$userrow[$old2[0]]."',$new1[0]='".$userrow[$new1[0]]."',$new2[0]='".$userrow[$new2[0]]."',attackpower='".$userrow["attackpower"]."',defensepower='".$userrow["defensepower"]."',currenthp='".$userrow["currenthp"]."',currentmp='".$userrow["currentmp"]."',currenttp='".$userrow["currenttp"]."',dropcode='0' WHERE id='".$userrow["id"]."' LIMIT 1", "users");
} else {
$new1 = explode(",",$droprow["attribute1"]);
if ($droprow["attribute2"] != "X") { $new2 = explode(",",$droprow["attribute2"]); } else { $new2 = array(0=>"maxhp",1=>0); }
$userrow[$new1[0]] += $new1[1];
$userrow[$new2[0]] += $new2[1];
if ($new1[0] == "strength") { $userrow["attackpower"] += $new1[1]; }
if ($new1[0] == "dexterity") { $userrow["defensepower"] += $new1[1]; }
if ($new2[0] == "strength") { $userrow["attackpower"] += $new2[1]; }
if ($new2[0] == "dexterity") { $userrow["defensepower"] += $new2[1]; }
$newname = addslashes($droprow["name"]);
$query = doquery("UPDATE {{table}} SET slot".$_POST["slot"]."name='$newname',slot".$_POST["slot"]."id='".$droprow["id"]."',$new1[0]='".$userrow[$new1[0]]."',$new2[0]='".$userrow[$new2[0]]."',attackpower='".$userrow["attackpower"]."',defensepower='".$userrow["defensepower"]."',dropcode='0' WHERE id='".$userrow["id"]."' LIMIT 1", "users");
}
$page = "The item has been equipped. You can now continue <a href=\"index.php\">exploring</a>.";
display($page, "Item Drop");
}
$attributearray = array("maxhp"=>"Max HP",
"maxmp"=>"Max MP",
"maxtp"=>"Max TP",
"defensepower"=>"Defense Power",
"attackpower"=>"Attack Power",
"strength"=>"Strength",
"dexterity"=>"Dexterity",
"expbonus"=>"Experience Bonus",
"goldbonus"=>"Gold Bonus");
$page = "The monster dropped the following item: <b>".$droprow["name"]."</b><br /><br />";
$page .= "This item has the following attribute(s):<br />";
$attribute1 = explode(",",$droprow["attribute1"]);
$page .= $attributearray[$attribute1[0]];
if ($attribute1[1] > 0) { $page .= " +" . $attribute1[1] . "<br />"; } else { $page .= $attribute1[1] . "<br />"; }
if ($droprow["attribute2"] != "X") {
$attribute2 = explode(",",$droprow["attribute2"]);
$page .= $attributearray[$attribute2[0]];
if ($attribute2[1] > 0) { $page .= " +" . $attribute2[1] . "<br />"; } else { $page .= $attribute2[1] . "<br />"; }
}
$page .= "<br />Select an inventory slot from the list below to equip this item. If the inventory slot is already full, the old item will be discarded.";
$page .= "<form action=\"index.php?do=drop\" method=\"post\"><select name=\"slot\"><option value=\"0\">Choose One</option><option value=\"1\">Slot 1: ".$userrow["slot1name"]."</option><option value=\"2\">Slot 2: ".$userrow["slot2name"]."</option><option value=\"3\">Slot 3: ".$userrow["slot3name"]."</option></select> <input type=\"submit\" name=\"submit\" value=\"Submit\" /></form>";
$page .= "You may also choose to just continue <a href=\"index.php\">exploring</a> and give up this item.";
display($page, "Item 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.";
}
?>

102
forum.php
View File

@ -1,102 +0,0 @@
<?php // forum.php :: Internal forums script for the game.
include('lib.php');
include('cookies.php');
$link = opendb();
$userrow = checkcookies();
if ($userrow == false) { display("The forum is for registered players only.", "Forum"); die(); }
$controlquery = doquery("SELECT * FROM {{table}} WHERE id='1' LIMIT 1", "control");
$controlrow = mysql_fetch_array($controlquery);
// 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"]);
if ($do[0] == "thread") { showthread($do[1], $do[2]); }
elseif ($do[0] == "new") { newthread(); }
elseif ($do[0] == "reply") { reply(); }
elseif ($do[0] == "list") { donothing($do[1]); }
} else { donothing(0); }
function donothing($start=0) {
$query = doquery("SELECT * FROM {{table}} WHERE parent='0' ORDER BY newpostdate DESC LIMIT 20", "forum");
$page = "<table width=\"100%\"><tr><td style=\"padding:1px; background-color:black;\"><table width=\"100%\" style=\"margins:0px;\" cellspacing=\"1\" cellpadding=\"3\"><tr><th colspan=\"3\" style=\"background-color:#dddddd;\"><center><a href=\"forum.php?do=new\">New Thread</a></center></th></tr><tr><th width=\"50%\" style=\"background-color:#dddddd;\">Thread</th><th width=\"10%\" style=\"background-color:#dddddd;\">Replies</th><th style=\"background-color:#dddddd;\">Last Post</th></tr>\n";
$count = 1;
if (mysql_num_rows($query) == 0) {
$page .= "<tr><td style=\"background-color:#ffffff;\" colspan=\"3\"><b>No threads in forum.</b></td></tr>\n";
} else {
while ($row = mysql_fetch_array($query)) {
if ($count == 1) {
$page .= "<tr><td style=\"background-color:#ffffff;\"><a href=\"forum.php?do=thread:".$row["id"].":0\">".$row["title"]."</a></td><td style=\"background-color:#ffffff;\">".$row["replies"]."</td><td style=\"background-color:#ffffff;\">".$row["newpostdate"]."</td></tr>\n";
$count = 2;
} else {
$page .= "<tr><td style=\"background-color:#eeeeee;\"><a href=\"forum.php?do=thread:".$row["id"].":0\">".$row["title"]."</a></td><td style=\"background-color:#eeeeee;\">".$row["replies"]."</td><td style=\"background-color:#eeeeee;\">".$row["newpostdate"]."</td></tr>\n";
$count = 1;
}
}
}
$page .= "</table></td></tr></table>";
display($page, "Forum");
}
function showthread($id, $start) {
$query = doquery("SELECT * FROM {{table}} WHERE id='$id' OR parent='$id' ORDER BY id LIMIT $start,15", "forum");
$query2 = doquery("SELECT title FROM {{table}} WHERE id='$id' LIMIT 1", "forum");
$row2 = mysql_fetch_array($query2);
$page = "<table width=\"100%\"><tr><td style=\"padding:1px; background-color:black;\"><table width=\"100%\" style=\"margins:0px;\" cellspacing=\"1\" cellpadding=\"3\"><tr><td colspan=\"2\" style=\"background-color:#dddddd;\"><b><a href=\"forum.php\">Forum</a> :: ".$row2["title"]."</b></td></tr>\n";
$count = 1;
while ($row = mysql_fetch_array($query)) {
if ($count == 1) {
$page .= "<tr><td width=\"25%\" style=\"background-color:#ffffff; vertical-align:top;\"><span class=\"small\"><b>".$row["author"]."</b><br /><br />".prettyforumdate($row["postdate"])."</td><td style=\"background-color:#ffffff; vertical-align:top;\">".nl2br($row["content"])."</td></tr>\n";
$count = 2;
} else {
$page .= "<tr><td width=\"25%\" style=\"background-color:#eeeeee; vertical-align:top;\"><span class=\"small\"><b>".$row["author"]."</b><br /><br />".prettyforumdate($row["postdate"])."</td><td style=\"background-color:#eeeeee; vertical-align:top;\">".nl2br($row["content"])."</td></tr>\n";
$count = 1;
}
}
$page .= "</table></td></tr></table><br />";
$page .= "<table width=\"100%\"><tr><td><b>Reply To This Thread:</b><br /><form action=\"forum.php?do=reply\" method=\"post\"><input type=\"hidden\" name=\"parent\" value=\"$id\" /><input type=\"hidden\" name=\"title\" value=\"Re: ".$row2["title"]."\" /><textarea name=\"content\" rows=\"7\" cols=\"40\"></textarea><br /><input type=\"submit\" name=\"submit\" value=\"Submit\" /> <input type=\"reset\" name=\"reset\" value=\"Reset\" /></form></td></tr></table>";
display($page, "Forum");
}
function reply() {
global $userrow;
extract($_POST);
$query = doquery("INSERT INTO {{table}} SET id='',postdate=NOW(),newpostdate=NOW(),author='".$userrow["charname"]."',parent='$parent',replies='0',title='$title',content='$content'", "forum");
$query2 = doquery("UPDATE {{table}} SET newpostdate=NOW(),replies=replies+1 WHERE id='$parent' LIMIT 1", "forum");
header("Location: forum.php?do=thread:$parent:0");
die();
}
function newthread() {
global $userrow;
if (isset($_POST["submit"])) {
extract($_POST);
$query = doquery("INSERT INTO {{table}} SET id='',postdate=NOW(),newpostdate=NOW(),author='".$userrow["charname"]."',parent='0',replies='0',title='$title',content='$content'", "forum");
header("Location: forum.php");
die();
}
$page = "<table width=\"100%\"><tr><td><b>Make A New Post:</b><br /><br/ ><form action=\"forum.php?do=new\" method=\"post\">Title:<br /><input type=\"text\" name=\"title\" size=\"50\" maxlength=\"50\" /><br /><br />Message:<br /><textarea name=\"content\" rows=\"7\" cols=\"40\"></textarea><br /><br /><input type=\"submit\" name=\"submit\" value=\"Submit\" /> <input type=\"reset\" name=\"reset\" value=\"Reset\" /></form></td></tr></table>";
display($page, "Forum");
}
?>

View File

@ -1,33 +0,0 @@
<?php // heal.php :: Handles stuff from the Quick Spells menu. (Healing spells only... other spells are handled in fight.php.)
function healspells($id) {
global $userrow;
$userspells = explode(",",$userrow["spells"]);
$spellquery = doquery("SELECT * FROM {{table}} WHERE id='$id' LIMIT 1", "spells");
$spellrow = mysql_fetch_array($spellquery);
// All the various ways to error out.
$spell = false;
foreach ($userspells as $a => $b) {
if ($b == $id) { $spell = true; }
}
if ($spell != true) { display("You have not yet learned this spell. Please go back and try again.", "Error"); die(); }
if ($spellrow["type"] != 1) { display("This is not a healing spell. Please go back and try again.", "Error"); die(); }
if ($userrow["currentmp"] < $spellrow["mp"]) { display("You do not have enough Magic Points to cast this spell. Please go back and try again.", "Error"); die(); }
if ($userrow["currentaction"] == "Fighting") { display("You cannot use the Quick Spells list during a fight. Please go back and select the Healing Spell you wish to use from the Spells box on the main fighting screen to continue.", "Error"); die(); }
if ($userrow["currenthp"] == $userrow["maxhp"]) { display("Your Hit Points are already full. You don't need to use a Healing spell now.", "Error"); die(); }
$newhp = $userrow["currenthp"] + $spellrow["attribute"];
if ($userrow["maxhp"] < $newhp) { $spellrow["attribute"] = $userrow["maxhp"] - $userrow["currenthp"]; $newhp = $userrow["currenthp"] + $spellrow["attribute"]; }
$newmp = $userrow["currentmp"] - $spellrow["mp"];
$updatequery = doquery("UPDATE {{table}} SET currenthp='$newhp', currentmp='$newmp' WHERE id='".$userrow["id"]."' LIMIT 1", "users");
display("You have cast the ".$spellrow["name"]." spell, and gained ".$spellrow["attribute"]." Hit Points. You can now continue <a href=\"index.php\">exploring</a>.", "Healing Spell");
die();
}
?>

323
help.php
View File

@ -1,323 +0,0 @@
<?php
include('lib.php');
$link = opendb();
$controlquery = doquery("SELECT * FROM {{table}} WHERE id='1' LIMIT 1", "control");
$controlrow = mysql_fetch_array($controlquery);
ob_start("ob_gzhandler");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title><? echo $controlrow["gamename"]; ?> Help</title>
<style type="text/css">
body {
background-image: url(images/background.jpg);
color: black;
font: 11px verdana;
}
table {
border-style: none;
padding: 0px;
font: 11px verdana;
}
td {
border-style: none;
padding: 3px;
vertical-align: top;
}
td.top {
border-bottom: solid 2px black;
}
td.left {
width: 150px;
border-right: solid 2px black;
}
td.right {
width: 150px;
border-left: solid 2px black;
}
a {
color: #663300;
text-decoration: none;
font-weight: bold;
}
a:hover {
color: #330000;
}
.small {
font: 10px verdana;
}
.highlight {
color: red;
}
.light {
color: #999999;
}
.title {
border: solid 1px black;
background-color: #eeeeee;
font-weight: bold;
padding: 5px;
margin: 3px;
}
.copyright {
border: solid 1px black;
background-color: #eeeeee;
font: 10px verdana;
}
</style>
</head>
<body>
<a name="top"></a>
<h1><? echo $controlrow["gamename"]; ?> Help</h1>
[ <a href="index.php">Return to the game</a> ]
<br /><br /><hr />
<h3>Table of Contents</h3>
<ul>
<li /><a href="#intro">Introduction</a>
<li /><a href="#classes">Character Classes</a>
<li /><a href="#difficulties">Difficulty Levels</a>
<li /><a href="#intown">Playing The Game: In Town</a>
<li /><a href="#exploring">Playing The Game: Exploring & Fighting</a>
<li /><a href="#status">Playing The Game: Status Panels</a>
<li /><a href="#items">Spoilers: Items & Drops</a>
<li /><a href="#monsters">Spoilers: Monsters</a>
<li /><a href="#spells">Spoilers: Spells</a>
<li /><a href="#levels">Spoilers: Levels</a>
<li /><a href="#credits">Credits</a>
</ul>
<hr />
<h3><a name="intro"></a>Introduction</h3>
Firstly, I'd like to say thank you for playing my game. The <i>Dragon Knight</i> game engine is the result of several months of
planning, coding and testing. The original idea was to create a web-based tribute to the NES game, <i>Dragon
Warrior</i>. In its current iteration, only the underlying fighting system really resembles that game, as almost
everything else in DK has been made bigger and better. But you should still recognize bits and pieces as stemming
from <i>Dragon Warrior</i> and other RPGs of old.<br /><br />
This is the first game I've ever written, and it has definitely been a positive experience. It got difficult at
times, admittedly, but it was still a lot of fun to write, and even more fun to play. And I hope to use this
experience so that if I ever want to create another game it will be even better than this one.<br /><br />
If you are a site administrator, and would like to install a copy of DK on your own server, you may visit the
<a href="http://dragon.se7enet.com/dev.php" target="_new">development site</a> for <i>Dragon Knight</i>. This page
includes the downloadable game souce code, as well as some other resources that developers and administrators may
find valuable.<br /><br />
Once again, thanks for playing!<br /><br />
<i>Jamin Seven</i><br />
<i>Dragon Knight creator</i><br />
<a href="http://www.se7enet.com" target="_new">My Homepage</a><br />
<a href="http://dragon.se7enet.com/dev.php" target="_new">Dragon Knight Homepage</a><br ><br />
[ <a href="#top">Top</a> ]
<br /><br /><hr />
<h3><a name="classes"></a>Character Classes</h3>
There are three character classes in the game. The main differences between the classes are what spells you get
access to, the speed with which you level up, and the amount of HP/MP/strength/dexterity you gain per level. Below
is a basic outline of each of the character classes. For more detailed information about the characters, please
view the Levels table at the bottom of this page. Also, note that the outline below refers to the stock class setup
for the game. If your administrator has used his/her own class setup, this information may not be accurate.<br /><br />
<b><? echo $controlrow["class1name"]; ?></b>
<ul>
<li />Fast level-ups
<li />High hit points
<li />High magic points
<li />Low strength
<li />Low dexterity
<li />5 heal spells
<li />5 hurt spells
<li />3 sleep spells
<li />3 +defense spells
<li />0 +attack spells
</ul>
<b><? echo $controlrow["class2name"]; ?></b>
<ul>
<li />Medium level-ups
<li />Medium hit points
<li />Low magic points
<li />High strength
<li />Low dexterity
<li />3 heal spells
<li />3 hurt spells
<li />2 sleep spells
<li />3 +defense spells
<li />3 +attack spells
</ul>
<b><? echo $controlrow["class3name"]; ?></b>
<ul>
<li />Slow level-ups
<li />Medium hit points
<li />Medium magic points
<li />Low strength
<li />High dexterity
<li />4 heal spells
<li />4 hurt spells
<li />3 sleep spells
<li />2 +defense spells
<li />2 +attack spells
</ul>
[ <a href="#top">Top</a> ]
<br /><br /><hr />
<h3><a name="difficulties"></a>Difficulty Levels</h3>
<i><? echo $controlrow["gamename"]; ?></i> includes the ability to play using one of three difficulty levels.
All monster statistics in the game are set at a base number. However, using a difficulty multiplier, certain statistics
are increased. The amount of hit points a monster has goes up, which means it will take longer to kill. But the amount
of experience and gold you gain from killing it also goes up. So the game is a little bit harder, but it is also more
rewarding. The following are the three difficulty levels and their statistic multiplier, which applies to the monster's
HP, experience drop, and gold drop.
<ul>
<li /><? echo $controlrow["diff1name"] . ": <b>" . $controlrow["diff1mod"] . "</b>"; ?>
<li /><? echo $controlrow["diff2name"] . ": <b>" . $controlrow["diff2mod"] . "</b>"; ?>
<li /><? echo $controlrow["diff3name"] . ": <b>" . $controlrow["diff3mod"] . "</b>"; ?>
</ul>
[ <a href="#top">Top</a> ]
<br /><br /><hr />
<h3><a name="intown"></a>Playing The Game: In Town</h3>
When you begin a new game, the first thing you see is the Town screen. Towns serve four primary functions: healing, buying items,
buying maps, and displaying game information.<br /><br />
To heal yourself, click the "Rest at the Inn" link at the top of the town screen. Each town's Inn has a different price - some towns
are cheap, others are expensive. No matter what town you're in, the Inns always serve the same function: they restore your current
hit points, magic points, and travel points to their maximum amounts. Out in the field, you are free to use healing spells to restore
your hit points, but when you run low on magic points, the only way to restore them is at an Inn.<br /><br />
Buying weapons and armor is accomplished through the appropriately-named "Buy Weapons/Armor" link. Not every item is available in
every town, so in order to get the most powerful items, you'll need to explore some of the outer towns. Once you've clicked the link,
you are presented with a list of items available in this town's store. To the left of each item is an icon that represents its type:
weapon, armor or shield. The amount of attack/defense power, as well as the item's price, are displayed to the right of the item name.
You'll notice that some items have a red asterisk (<span class="highlight">*</span>) next to their names. These are items that come
with special attributes that modify other parts of your character profile. See the Items & Drops table at the bottom of this page for
more information about special items.<br /><br />
Maps are the third function in towns. Buying a map to a town places the town in your Travel To box in the left status panel. Once
you've purchased a town's map, you can click its name from your Travel To box and you will jump to that town. Travelling this way
costs travel points, though, and you'll only be able to visit towns if you have enough travel points.<br /><br />
The final function in towns is displaying game information and statistics. This includes the latest news post made by the game
administrator, a list of players who have been online recently, and the Babble Box.<br /><br />
[ <a href="#top">Top</a> ]
<br /><br /><hr />
<h3><a name="exploring"></a>Playing The Game: Exploring & Fighting</h3>
Once you're done in town, you are free to start exploring the world. Use the compass buttons on the left status panel to move around.
The game world is basically a big square, divided into four quadrants. Each quadrant is <? echo $controlrow["gamesize"]; ?> spaces
square. The first town is usually located at (0N,0E). Click the North button from the first town, and now you'll be at (1N,0E).
Likewise, if you now click the West button, you'll be at (1N,1W). Monster levels increase with every 5 spaces you move outward
from (0N,0E).<br /><br />
While you're exploring, you will occasionally run into monsters. As in pretty much any other RPG game, you and the monster take turns
hitting each other in an attempt to reduce each other's hit points to zero. Once you run into a monster, the Exploring screen changes
to the Fighting screen.<br /><br />
When a fight begins, you'll see the monster's name and hit points, and the game will ask you for your first command. You then get to
pick whether you want to fight, use a spell, or run away. Note, though, that sometimes the monster has the chance to hit you
first.<br /><br />
The Fight button is pretty straightforward: you attack the monster, and the amount of damage dealt is based on your attack power and
the monster's armor. On top of that, there are two other things that can happen: an Excellent Hit, which doubles your total attack
damage; and a monster dodge, which results in you doing no damage to the monster.<br /><br />
The Spell button allows you to pick an available spell and cast it. See the Spells list at the bottom of this page for more information
about spells.<br /><br />
Finally, there is the Run button, which lets you run away from a fight if the monster is too powerful. Be warned, though: it is
possible for the monster to block you from running and attack you. So if your hit points are low, you may fare better by staying
around monsters that you know can't do much damage to you.<br /><br />
Once you've had your turn, the monster also gets his turn. It is also possible for you to dodge the monster's attack and take no
damage.<br /><br />
The end result of a fight is either you or the monster being knocked down to zero hit points. If you win, the monster dies and will
give you a certain amount of experience and gold. There is also a chance that the monster will drop an item, which you can put into
one of the three inventory slots to give you extra points in your character profile. If you lose and die, half of your gold is taken
away - however, you are given back a few hit points to help you make it back to town (for example, if you don't have enough gold to
pay for an Inn, and need to kill a couple low-level monsters to get the money).<br /><br />
When the fight is over, you can continue exploring until you find another monster to beat into submission.<br /><br />
[ <a href="#top">Top</a> ]
<br /><br /><hr />
<h3><a name="status"></a>Playing The Game: Status Panels</h3>
There are two status panels on the game screen: left and right.<br /><br />
The left panel inclues your current location and play status (In Town, Exploring, Fighting), compass buttons for movement, and the
Travel To list for jumping between towns. At the bottom of the left panel is also a list of game functions.<br /><br />
The right panel displays some character statistics, your inventory, and quick spells.<br /><br />
The Character section shows the most important character statistics. It also displays the status bars for your current hit points,
magic points and travel points. These status bars are colored either green, yellow or red depending on your current amount of each
stat. There is also a link to pop up your list of extended statistics, which shows more detailed character information.<br /><br />
The Fast Spells section lists any Heal spells you've learned. You may use these links any time you are in town or exploring to cast
the heal spell. These may not be used during fights, however - you have to use the Spells box on the fight screen for that.
[ <a href="#top">Top</a> ]
<br /><br /><hr />
<h3><a name="items"></a>Spoilers: Items & Drops</h3>
<a href="help_items.php">Click here</a> for the Items & Drops spoiler page.<br /><br />
[ <a href="#top">Top</a> ]
<br /><br /><hr />
<h3><a name="monsters"></a>Spoilers: Monsters</h3>
<a href="help_monsters.php">Click here</a> for the Monsters spoiler page.<br /><br />
[ <a href="#top">Top</a> ]
<br /><br /><hr />
<h3><a name="spells"></a>Spoilers: Spells</h3>
<a href="help_spells.php">Click here</a> for the Spells spoiler page.<br /><br />
[ <a href="#top">Top</a> ]
<br /><br /><hr />
<h3><a name="levels"></a>Spoilers: Levels</h3>
<a href="help_levels.php">Click here</a> for the Levels spoiler page.<br /><br />
[ <a href="#top">Top</a> ]
<br /><br /><hr />
<h3><a name="credits"></a>Credits</h3>
<ul>
<li /><b>All program code and stock graphics for the game were created by Jamin Seven</b>.<br /><br />
<li />Major props go to a few people on the PHP manual site, for help with various chunks of code. The specific people are listed in the source code.<br /><br />
<li />Super monkey love goes to Enix and the developers of <i>Dragon Warrior</i>. If it weren't for you guys, my game never would have been made.<br /><br />
<li />Mega props go to Dalez from GameFAQs for his DW3 experience chart, which was where I got my experience levels from.<br /><br />
<li />Mad crazy ninja love goes to the following people for help and support throughout the development process:<br /><br />
<b>Ideas:</b> (whether they got used or not)
<ul>
<li />kushet
<li />lghtning
<li />Ebolamonkey3000
<li />Crimson Scythe
<li />SilDeath
</ul><br />
<b>Beta Testing:</b> (forums name if applicable, character name otherwise)
<ul>
<li />Ebolamonkey3000
<li />lisi
<li />Junglist
<li />Crimson Scythe
<li />Sk8erpunk69
<li />lghtning
<li />kushet
<li />SilDeath
<li />lowrider4life
<li />dubiin
<li />Sam Wise The Great
</ul><br />
<li />Apologies and lots of happy naked love to anyone I forgot.<br /><br />
<li />And of course, thanks to <b>you</b> for playing my game!<br /><br />
<li /><a href="../index.php?do=ninja">NINJA!</a>
</ul>
[ <a href="#top">Top</a> ]
<br /><br /><hr /><br />
Please visit the following sites for more information:<br />
<a href="http://www.se7enet.com" target="_new">Se7enet</a> (Jamin's homepage)<br />
<a href="http://dragon.se7enet.com/dev.php" target="_new">Dragon Knight</a> (official DK homepage)<br />
<a href="http://se7enet.com/forums" target="_new">Forums</a> (official DK forums)<br /><br />
All original coding and graphics for the <i>Dragon Knight</i> game engine are &copy; 2003-2005 by Jamin Seven.<br /><br />
[ <a href="#top">Top</a> ]
<br /><br />
<table class="copyright" width="100%"><tr>
<td width="50%" align="center">Powered by <a href="http://dragon.se7enet.com/dev.php" target="_new">Dragon Knight</a></td><td width="50%" align="center">&copy; 2003-2006 by renderse7en</td>
</tr></table>
</body>
</html>

View File

@ -1,155 +0,0 @@
<?php
include('lib.php');
$link = opendb();
$controlquery = doquery("SELECT * FROM {{table}} WHERE id='1' LIMIT 1", "control");
$controlrow = mysql_fetch_array($controlquery);
ob_start("ob_gzhandler");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title><? echo $controlrow["gamename"]; ?> Help</title>
<style type="text/css">
body {
background-image: url(images/background.jpg);
color: black;
font: 11px verdana;
}
table {
border-style: none;
padding: 0px;
font: 11px verdana;
}
td {
border-style: none;
padding: 3px;
vertical-align: top;
}
td.top {
border-bottom: solid 2px black;
}
td.left {
width: 150px;
border-right: solid 2px black;
}
td.right {
width: 150px;
border-left: solid 2px black;
}
a {
color: #663300;
text-decoration: none;
font-weight: bold;
}
a:hover {
color: #330000;
}
.small {
font: 10px verdana;
}
.highlight {
color: red;
}
.light {
color: #999999;
}
.title {
border: solid 1px black;
background-color: #eeeeee;
font-weight: bold;
padding: 5px;
margin: 3px;
}
.copyright {
border: solid 1px black;
background-color: #eeeeee;
font: 10px verdana;
}
</style>
</head>
<body>
<a name="top"></a>
<h1><? echo $controlrow["gamename"]; ?> Help: Items & Drops</h1>
[ <a href="help.php">Return to Help</a> | <a href="index.php">Return to the game</a> ]
<br /><br /><hr />
<table width="60%" style="border: solid 1px black" cellspacing="0" cellpadding="0">
<tr><td colspan="5" bgcolor="#ffffff"><center><b>Items</b></center></td></tr>
<tr><td><b>Type</b></td><td><b>Name</b></td><td><b>Cost</b></td><td><b>Attribute</b></td><td><b>Special</b></td></tr>
<?
$count = 1;
$itemsquery = doquery("SELECT * FROM {{table}} ORDER BY id", "items");
while ($itemsrow = mysql_fetch_array($itemsquery)) {
if ($count == 1) { $color = "bgcolor=\"#ffffff\""; $count = 2; } else { $color = ""; $count = 1; }
if ($itemsrow["type"] == 1) { $image = "weapon"; $power = "Attack"; } elseif ($itemsrow["type"] == 2) { $image = "armor"; $power = "Defense"; } else { $image = "shield"; $power = "Defense"; }
if ($itemsrow["special"] != "X") {
$special = explode(",",$itemsrow["special"]);
if ($special[0] == "maxhp") { $attr = "Max HP"; }
elseif ($special[0] == "maxmp") { $attr = "Max MP"; }
elseif ($special[0] == "maxtp") { $attr = "Max TP"; }
elseif ($special[0] == "goldbonus") { $attr = "Gold Bonus (%)"; }
elseif ($special[0] == "expbonus") { $attr = "Experience Bonus (%)"; }
elseif ($special[0] == "strength") { $attr = "Strength"; }
elseif ($special[0] == "dexterity") { $attr = "Dexterity"; }
elseif ($special[0] == "attackpower") { $attr = "Attack Power"; }
elseif ($special[0] == "defensepower") { $attr = "Defense Power"; }
else { $attr = $special[0]; }
if ($special[1] > 0) { $stat = "+" . $special[1]; } else { $stat = $special[1]; }
$bigspecial = "$attr $stat";
} else { $bigspecial = "<span class=\"light\">None</span>"; }
echo "<tr><td $color width=\"5%\"><img src=\"images/icon_$image.gif\" alt=\"$image\"></td><td $color width=\"30%\">".$itemsrow["name"]."</td><td $color width=\"20%\">".$itemsrow["buycost"]." Gold</td><td $color width=\"20%\">".$itemsrow["attribute"]." $power Power</td><td $color width=\"25%\">$bigspecial</td></tr>\n";
}
?>
</table>
<br />
<br />
<table width="60%" style="border: solid 1px black" cellspacing="0" cellpadding="0">
<tr><td colspan="4" bgcolor="#ffffff"><center><b>Drops</b></center></td></tr>
<tr><td><b>Name</b></td><td><b>Monster Level</b></td><td><b>Attribute 1</b></td><td><b>Attribute 2</b></td></tr>
<?
$count = 1;
$itemsquery = doquery("SELECT * FROM {{table}} ORDER BY id", "drops");
while ($itemsrow = mysql_fetch_array($itemsquery)) {
if ($count == 1) { $color = "bgcolor=\"#ffffff\""; $count = 2; } else { $color = ""; $count = 1; }
if ($itemsrow["attribute1"] != "X") {
$special1 = explode(",",$itemsrow["attribute1"]);
if ($special1[0] == "maxhp") { $attr1 = "Max HP"; }
elseif ($special1[0] == "maxmp") { $attr1 = "Max MP"; }
elseif ($special1[0] == "maxtp") { $attr1 = "Max TP"; }
elseif ($special1[0] == "goldbonus") { $attr1 = "Gold Bonus (%)"; }
elseif ($special1[0] == "expbonus") { $attr1 = "Experience Bonus (%)"; }
elseif ($special1[0] == "strength") { $attr1 = "Strength"; }
elseif ($special1[0] == "dexterity") { $attr1 = "Dexterity"; }
elseif ($special1[0] == "attackpower") { $attr1 = "Attack Power"; }
elseif ($special1[0] == "defensepower") { $attr1 = "Defense Power"; }
else { $attr1 = $special1[0]; }
if ($special1[1] > 0) { $stat1 = "+" . $special1[1]; } else { $stat1 = $special1[1]; }
$bigspecial1 = "$attr1 $stat1";
} else { $bigspecial1 = "<span class=\"light\">None</span>"; }
if ($itemsrow["attribute2"] != "X") {
$special2 = explode(",",$itemsrow["attribute2"]);
if ($special2[0] == "maxhp") { $attr2 = "Max HP"; }
elseif ($special2[0] == "maxmp") { $attr2 = "Max MP"; }
elseif ($special2[0] == "maxtp") { $attr2 = "Max TP"; }
elseif ($special2[0] == "goldbonus") { $attr2 = "Gold Bonus (%)"; }
elseif ($special2[0] == "expbonus") { $attr2 = "Experience Bonus (%)"; }
elseif ($special2[0] == "strength") { $attr2 = "Strength"; }
elseif ($special2[0] == "dexterity") { $attr2 = "Dexterity"; }
elseif ($special2[0] == "attackpower") { $attr2 = "Attack Power"; }
elseif ($special2[0] == "defensepower") { $attr2 = "Defense Power"; }
else { $attr2 = $special2[0]; }
if ($special2[1] > 0) { $stat2 = "+" . $special2[1]; } else { $stat2 = $special2[1]; }
$bigspecial2 = "$attr2 $stat2";
} else { $bigspecial2 = "<span class=\"light\">None</span>"; }
echo "<tr><td $color width=\"25%\">".$itemsrow["name"]."</td><td $color width=\"15%\">".$itemsrow["mlevel"]."</td><td $color width=\"30%\">$bigspecial1</td><td $color width=\"30%\">$bigspecial2</td></tr>\n";
}
?>
</table>
<br />
<table class="copyright" width="100%"><tr>
<td width="50%" align="center">Powered by <a href="http://dragon.se7enet.com/dev.php" target="_new">Dragon Knight</a></td><td width="50%" align="center">&copy; 2003-2006 by renderse7en</td>
</tr></table>
</body>
</html>

View File

@ -1,141 +0,0 @@
<?php
include('lib.php');
$link = opendb();
$controlquery = doquery("SELECT * FROM {{table}} WHERE id='1' LIMIT 1", "control");
$controlrow = mysql_fetch_array($controlquery);
ob_start("ob_gzhandler");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title><? echo $controlrow["gamename"]; ?> Help</title>
<style type="text/css">
body {
background-image: url(images/background.jpg);
color: black;
font: 11px verdana;
}
table {
border-style: none;
padding: 0px;
font: 11px verdana;
}
td {
border-style: none;
padding: 3px;
vertical-align: top;
}
td.top {
border-bottom: solid 2px black;
}
td.left {
width: 150px;
border-right: solid 2px black;
}
td.right {
width: 150px;
border-left: solid 2px black;
}
a {
color: #663300;
text-decoration: none;
font-weight: bold;
}
a:hover {
color: #330000;
}
.small {
font: 10px verdana;
}
.highlight {
color: red;
}
.light {
color: #999999;
}
.title {
border: solid 1px black;
background-color: #eeeeee;
font-weight: bold;
padding: 5px;
margin: 3px;
}
.copyright {
border: solid 1px black;
background-color: #eeeeee;
font: 10px verdana;
}
</style>
</head>
<body>
<a name="top"></a>
<h1><? echo $controlrow["gamename"]; ?> Help: Levels</h1>
[ <a href="help.php">Return to Help</a> | <a href="index.php">Return to the game</a> ]
<br /><br /><hr />
<table width="50%" style="border: solid 1px black" cellspacing="0" cellpadding="0">
<tr><td colspan="8" bgcolor="#ffffff"><center><b><? echo $controlrow["class1name"]; ?> Levels</b></center></td></tr>
<tr><td><b>Level</b><td><b>Exp.</b></td><td><b>HP</b></td><td><b>MP</b></td><td><b>TP</b></td><td><b>Strength</b></td><td><b>Dexterity</b></td><td><b>Spell</b></td></tr>
<?
$count = 1;
$itemsquery = doquery("SELECT id,1_exp,1_hp,1_mp,1_tp,1_strength,1_dexterity,1_spells FROM {{table}} ORDER BY id", "levels");
$spellsquery = doquery("SELECT * FROM {{table}} ORDER BY id", "spells");
$spells = array();
while ($spellsrow = mysql_fetch_array($spellsquery)) {
$spells[$spellsrow["id"]] = $spellsrow;
}
while ($itemsrow = mysql_fetch_array($itemsquery)) {
if ($count == 1) { $color = "bgcolor=\"#ffffff\""; $count = 2; } else { $color = ""; $count = 1; }
if ($itemsrow["1_spells"] != 0) { $spell = $spells[$itemsrow["1_spells"]]["name"]; } else { $spell = "<span class=\"light\">None</span>"; }
if ($itemsrow["id"] != 100) { echo "<tr><td $color width=\"12%\">".$itemsrow["id"]."</td><td $color width=\"12%\">".number_format($itemsrow["1_exp"])."</td><td $color width=\"12%\">".$itemsrow["1_hp"]."</td><td $color width=\"12%\">".$itemsrow["1_mp"]."</td><td $color width=\"12%\">".$itemsrow["1_tp"]."</td><td $color width=\"12%\">".$itemsrow["1_strength"]."</td><td $color width=\"12%\">".$itemsrow["1_dexterity"]."</td><td $color width=\"12%\">$spell</td></tr>\n"; }
}
?>
</table>
<br /><br />
<table width="50%" style="border: solid 1px black" cellspacing="0" cellpadding="0">
<tr><td colspan="8" bgcolor="#ffffff"><center><b><? echo $controlrow["class2name"]; ?> Levels</b></center></td></tr>
<tr><td><b>Level</b><td><b>Exp.</b></td><td><b>HP</b></td><td><b>MP</b></td><td><b>TP</b></td><td><b>Strength</b></td><td><b>Dexterity</b></td><td><b>Spell</b></td></tr>
<?
$count = 1;
$itemsquery = doquery("SELECT id,2_exp,2_hp,2_mp,2_tp,2_strength,2_dexterity,2_spells FROM {{table}} ORDER BY id", "levels");
$spellsquery = doquery("SELECT * FROM {{table}} ORDER BY id", "spells");
$spells = array();
while ($spellsrow = mysql_fetch_array($spellsquery)) {
$spells[$spellsrow["id"]] = $spellsrow;
}
while ($itemsrow = mysql_fetch_array($itemsquery)) {
if ($count == 1) { $color = "bgcolor=\"#ffffff\""; $count = 2; } else { $color = ""; $count = 1; }
if ($itemsrow["2_spells"] != 0) { $spell = $spells[$itemsrow["2_spells"]]["name"]; } else { $spell = "<span class=\"light\">None</span>"; }
if ($itemsrow["id"] != 100) { echo "<tr><td $color width=\"12%\">".$itemsrow["id"]."</td><td $color width=\"12%\">".number_format($itemsrow["2_exp"])."</td><td $color width=\"12%\">".$itemsrow["2_hp"]."</td><td $color width=\"12%\">".$itemsrow["2_mp"]."</td><td $color width=\"12%\">".$itemsrow["2_tp"]."</td><td $color width=\"12%\">".$itemsrow["2_strength"]."</td><td $color width=\"12%\">".$itemsrow["2_dexterity"]."</td><td $color width=\"12%\">$spell</td></tr>\n"; }
}
?>
</table>
<br /><br />
<table width="50%" style="border: solid 1px black" cellspacing="0" cellpadding="0">
<tr><td colspan="8" bgcolor="#ffffff"><center><b><? echo $controlrow["class3name"]; ?> Levels</b></center></td></tr>
<tr><td><b>Level</b><td><b>Exp.</b></td><td><b>HP</b></td><td><b>MP</b></td><td><b>TP</b></td><td><b>Strength</b></td><td><b>Dexterity</b></td><td><b>Spell</b></td></tr>
<?
$count = 1;
$itemsquery = doquery("SELECT id,3_exp,3_hp,3_mp,3_tp,3_strength,3_dexterity,3_spells FROM {{table}} ORDER BY id", "levels");
$spellsquery = doquery("SELECT * FROM {{table}} ORDER BY id", "spells");
$spells = array();
while ($spellsrow = mysql_fetch_array($spellsquery)) {
$spells[$spellsrow["id"]] = $spellsrow;
}
while ($itemsrow = mysql_fetch_array($itemsquery)) {
if ($count == 1) { $color = "bgcolor=\"#ffffff\""; $count = 2; } else { $color = ""; $count = 1; }
if ($itemsrow["3_spells"] != 0) { $spell = $spells[$itemsrow["3_spells"]]["name"]; } else { $spell = "<span class=\"light\">None</span>"; }
if ($itemsrow["id"] != 100) { echo "<tr><td $color width=\"12%\">".$itemsrow["id"]."</td><td $color width=\"12%\">".number_format($itemsrow["3_exp"])."</td><td $color width=\"12%\">".$itemsrow["3_hp"]."</td><td $color width=\"12%\">".$itemsrow["3_mp"]."</td><td $color width=\"12%\">".$itemsrow["3_tp"]."</td><td $color width=\"12%\">".$itemsrow["3_strength"]."</td><td $color width=\"12%\">".$itemsrow["3_dexterity"]."</td><td $color width=\"12%\">$spell</td></tr>\n"; }
}
?>
</table>
<br />
Experience points listed are total values up until that point. All other values are just the new amount that you gain for each level.
<br /><br />
<table class="copyright" width="100%"><tr>
<td width="50%" align="center">Powered by <a href="http://dragon.se7enet.com/dev.php" target="_new">Dragon Knight</a></td><td width="50%" align="center">&copy; 2003-2006 by renderse7en</td>
</tr></table>
</body>
</html>

View File

@ -1,96 +0,0 @@
<?php
include('lib.php');
$link = opendb();
$controlquery = doquery("SELECT * FROM {{table}} WHERE id='1' LIMIT 1", "control");
$controlrow = mysql_fetch_array($controlquery);
ob_start("ob_gzhandler");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title><? echo $controlrow["gamename"]; ?> Help</title>
<style type="text/css">
body {
background-image: url(images/background.jpg);
color: black;
font: 11px verdana;
}
table {
border-style: none;
padding: 0px;
font: 11px verdana;
}
td {
border-style: none;
padding: 3px;
vertical-align: top;
}
td.top {
border-bottom: solid 2px black;
}
td.left {
width: 150px;
border-right: solid 2px black;
}
td.right {
width: 150px;
border-left: solid 2px black;
}
a {
color: #663300;
text-decoration: none;
font-weight: bold;
}
a:hover {
color: #330000;
}
.small {
font: 10px verdana;
}
.highlight {
color: red;
}
.light {
color: #999999;
}
.title {
border: solid 1px black;
background-color: #eeeeee;
font-weight: bold;
padding: 5px;
margin: 3px;
}
.copyright {
border: solid 1px black;
background-color: #eeeeee;
font: 10px verdana;
}
</style>
</head>
<body>
<a name="top"></a>
<h1><? echo $controlrow["gamename"]; ?> Help: Monsters</h1>
[ <a href="help.php">Return to Help</a> | <a href="index.php">Return to the game</a> ]
<br /><br /><hr />
<table width="75%" style="border: solid 1px black" cellspacing="0" cellpadding="0">
<tr><td colspan="8" bgcolor="#ffffff"><center><b>Monsters</b></center></td></tr>
<tr><td><b>Name</b></td><td><b>Max HP</b></td><td><b>Max Damage</b></td><td><b>Armor</b></td><td><b>Level</b></td><td><b>Max Exp.</b></td><td><b>Max Gold</b></td><td><b>Immunity</b></td></tr>
<?
$count = 1;
$itemsquery = doquery("SELECT * FROM {{table}} ORDER BY id", "monsters");
while ($itemsrow = mysql_fetch_array($itemsquery)) {
if ($count == 1) { $color = "bgcolor=\"#ffffff\""; $count = 2; } else { $color = ""; $count = 1; }
if ($itemsrow["immune"] == 0) { $immune = "<span class=\"light\">None</span>"; } elseif ($itemsrow["immune"] == 1) { $immune = "Hurt"; } else { $immune = "Hurt & Sleep"; }
echo "<tr><td $color width=\"30%\">".$itemsrow["name"]."</td><td $color width=\"10%\">".$itemsrow["maxhp"]."</td><td $color width=\"10%\">".$itemsrow["maxdam"]."</td><td $color width=\"10%\">".$itemsrow["armor"]."</td><td $color width=\"10%\">".$itemsrow["level"]."</td><td $color width=\"10%\">".$itemsrow["maxexp"]."</td><td $color width=\"10%\">".$itemsrow["maxgold"]."</td><td $color width=\"20%\">$immune</td></tr>\n";
}
?>
</table>
<br />
<table class="copyright" width="100%"><tr>
<td width="50%" align="center">Powered by <a href="http://dragon.se7enet.com/dev.php" target="_new">Dragon Knight</a></td><td width="50%" align="center">&copy; 2003-2006 by renderse7en</td>
</tr></table>
</body>
</html>

View File

@ -1,106 +0,0 @@
<?php
include('lib.php');
$link = opendb();
$controlquery = doquery("SELECT * FROM {{table}} WHERE id='1' LIMIT 1", "control");
$controlrow = mysql_fetch_array($controlquery);
ob_start("ob_gzhandler");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title><? echo $controlrow["gamename"]; ?> Help</title>
<style type="text/css">
body {
background-image: url(images/background.jpg);
color: black;
font: 11px verdana;
}
table {
border-style: none;
padding: 0px;
font: 11px verdana;
}
td {
border-style: none;
padding: 3px;
vertical-align: top;
}
td.top {
border-bottom: solid 2px black;
}
td.left {
width: 150px;
border-right: solid 2px black;
}
td.right {
width: 150px;
border-left: solid 2px black;
}
a {
color: #663300;
text-decoration: none;
font-weight: bold;
}
a:hover {
color: #330000;
}
.small {
font: 10px verdana;
}
.highlight {
color: red;
}
.light {
color: #999999;
}
.title {
border: solid 1px black;
background-color: #eeeeee;
font-weight: bold;
padding: 5px;
margin: 3px;
}
.copyright {
border: solid 1px black;
background-color: #eeeeee;
font: 10px verdana;
}
</style>
</head>
<body>
<a name="top"></a>
<h1><? echo $controlrow["gamename"]; ?> Help: Spells</h1>
[ <a href="help.php">Return to Help</a> | <a href="index.php">Return to the game</a> ]
<br /><br /><hr />
<table width="50%" style="border: solid 1px black" cellspacing="0" cellpadding="0">
<tr><td colspan="8" bgcolor="#ffffff"><center><b>Spells</b></center></td></tr>
<tr><td><b>Name</b></td><td><b>Cost</b></td><td><b>Type</b></td><td><b>Attribute</b></td></tr>
<?
$count = 1;
$itemsquery = doquery("SELECT * FROM {{table}} ORDER BY id", "spells");
while ($itemsrow = mysql_fetch_array($itemsquery)) {
if ($count == 1) { $color = "bgcolor=\"#ffffff\""; $count = 2; } else { $color = ""; $count = 1; }
if ($itemsrow["type"] == 1) { $type = "Heal"; }
elseif ($itemsrow["type"] == 2) { $type = "Hurt"; }
elseif ($itemsrow["type"] == 3) { $type = "Sleep"; }
elseif ($itemsrow["type"] == 4) { $type = "+Damage (%)"; }
elseif ($itemsrow["type"] == 5) { $type = "+Defense (%)"; }
echo "<tr><td $color width=\"25%\">".$itemsrow["name"]."</td><td $color width=\"25%\">".$itemsrow["mp"]."</td><td $color width=\"25%\">$type</td><td $color width=\"25%\">".$itemsrow["attribute"]."</td></tr>\n";
}
?>
</table>
<ul>
<li /><b>Heal</b> spells always give you the maximum amount possible, until your current HP is full.
<li /><b>Hurt</b> spells deal X damage (not always the maximum) to the monster, regardless of the monster's armor.
<li /><b>Sleep</b> spells put the monster to sleep. The monster has an X in 15 chance of remaining asleep each turn.
<li /><b>+Damage</b> spells increase your total attack damage by X percent until the end of the fight.
<li /><b>+Defense</b> spells reduce the total damage you take from the monster by X percent until the end of each fight.
</ul>
<table class="copyright" width="100%"><tr>
<td width="50%" align="center">Powered by <a href="http://dragon.se7enet.com/dev.php" target="_new">Dragon Knight</a></td><td width="50%" align="center">&copy; 2003-2006 by renderse7en</td>
</tr></table>
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

288
index.php
View File

@ -1,288 +0,0 @@
<?php // index.php :: Primary program script, evil alien overlord, you decide.
if (file_exists('install.php')) { die("Please delete <b>install.php</b> from your Dragon Knight directory before continuing."); }
include('lib.php');
include('cookies.php');
$link = opendb();
$controlquery = doquery("SELECT * FROM {{table}} WHERE id='1' LIMIT 1", "control");
$controlrow = mysql_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('towns.php'); inn(); }
elseif ($do[0] == "buy") { include('towns.php'); buy(); }
elseif ($do[0] == "buy2") { include('towns.php'); buy2($do[1]); }
elseif ($do[0] == "buy3") { include('towns.php'); buy3($do[1]); }
elseif ($do[0] == "sell") { include('towns.php'); sell(); }
elseif ($do[0] == "maps") { include('towns.php'); maps(); }
elseif ($do[0] == "maps2") { include('towns.php'); maps2($do[1]); }
elseif ($do[0] == "maps3") { include('towns.php'); maps3($do[1]); }
elseif ($do[0] == "gotown") { include('towns.php'); travelto($do[1]); }
// Exploring functions.
elseif ($do[0] == "move") { include('explore.php'); move(); }
// Fighting functions.
elseif ($do[0] == "fight") { include('fight.php'); fight(); }
elseif ($do[0] == "victory") { include('fight.php'); victory(); }
elseif ($do[0] == "drop") { include('fight.php'); drop(); }
elseif ($do[0] == "dead") { include('fight.php'); dead(); }
// Misc functions.
elseif ($do[0] == "verify") { header("Location: users.php?do=verify"); die(); }
elseif ($do[0] == "spell") { include('heal.php'); healspells($do[1]); }
elseif ($do[0] == "showchar") { showchar(); }
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() {
global $userrow;
if ($userrow["currentaction"] == "In Town") {
$page = dotown();
$title = "In Town";
} elseif ($userrow["currentaction"] == "Exploring") {
$page = doexplore();
$title = "Exploring";
} elseif ($userrow["currentaction"] == "Fighting") {
$page = dofight();
$title = "Fighting";
}
display($page, $title);
}
function dotown() { // Spit out the main town page.
global $userrow, $controlrow, $numqueries;
$townquery = doquery("SELECT * FROM {{table}} WHERE latitude='".$userrow["latitude"]."' AND longitude='".$userrow["longitude"]."' LIMIT 1", "towns");
if (mysql_num_rows($townquery) == 0) { 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.
if ($controlrow["shownews"] == 1) {
$newsquery = doquery("SELECT * FROM {{table}} ORDER BY id DESC LIMIT 1", "news");
$newsrow = mysql_fetch_array($newsquery);
$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"] .= "</td></tr></table>\n";
} else { $townrow["news"] = ""; }
// Who's Online. Currently just members. Guests maybe later.
if ($controlrow["showonline"] == 1) {
$onlinequery = doquery("SELECT * FROM {{table}} WHERE UNIX_TIMESTAMP(onlinetime) >= '".(time()-600)."' ORDER BY charname", "users");
$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: ";
while ($onlinerow = mysql_fetch_array($onlinequery)) { $townrow["whosonline"] .= "<a href=\"index.php?do=onlinechar:".$onlinerow["id"]."\">".$onlinerow["charname"]."</a>" . ", "; }
$townrow["whosonline"] = rtrim($townrow["whosonline"], ", ");
$townrow["whosonline"] .= "</td></tr></table>\n";
} else { $townrow["whosonline"] = ""; }
if ($controlrow["showbabble"] == 1) {
$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"] .= "</td></tr></table>\n";
} else { $townrow["babblebox"] = ""; }
$page = gettemplate("towns");
$page = parsetemplate($page, $townrow);
return $page;
}
function doexplore() { // Just spit out a blank exploring page.
// Exploring without a GET string is normally when they first log in, or when they've just finished fighting.
$page = <<<END
<table width="100%">
<tr><td class="title"><img src="images/title_exploring.gif" alt="Exploring" /></td></tr>
<tr><td>
You are exploring the map, and nothing has happened. Continue exploring using the direction buttons or the Travel To menus.
</td></tr>
</table>
END;
return $page;
}
function dofight() { // Redirect to fighting.
header("Location: index.php?do=fight");
}
function showchar() {
global $userrow, $controlrow;
// Format various userrow stuffs.
$userrow["experience"] = number_format($userrow["experience"]);
$userrow["gold"] = number_format($userrow["gold"]);
if ($userrow["expbonus"] > 0) {
$userrow["plusexp"] = "<span class=\"light\">(+".$userrow["expbonus"]."%)</span>";
} elseif ($userrow["expbonus"] < 0) {
$userrow["plusexp"] = "<span class=\"light\">(".$userrow["expbonus"]."%)</span>";
} else { $userrow["plusexp"] = ""; }
if ($userrow["goldbonus"] > 0) {
$userrow["plusgold"] = "<span class=\"light\">(+".$userrow["goldbonus"]."%)</span>";
} elseif ($userrow["goldbonus"] < 0) {
$userrow["plusgold"] = "<span class=\"light\">(".$userrow["goldbonus"]."%)</span>";
} else { $userrow["plusgold"] = ""; }
$levelquery = doquery("SELECT ". $userrow["charclass"]."_exp FROM {{table}} WHERE id='".($userrow["level"]+1)."' LIMIT 1", "levels");
$levelrow = mysql_fetch_array($levelquery);
if ($userrow["level"] < 99) { $userrow["nextlevel"] = number_format($levelrow[$userrow["charclass"]."_exp"]); } else { $userrow["nextlevel"] = "<span class=\"light\">None</span>"; }
if ($userrow["charclass"] == 1) { $userrow["charclass"] = $controlrow["class1name"]; }
elseif ($userrow["charclass"] == 2) { $userrow["charclass"] = $controlrow["class2name"]; }
elseif ($userrow["charclass"] == 3) { $userrow["charclass"] = $controlrow["class3name"]; }
if ($userrow["difficulty"] == 1) { $userrow["difficulty"] = $controlrow["diff1name"]; }
elseif ($userrow["difficulty"] == 2) { $userrow["difficulty"] = $controlrow["diff2name"]; }
elseif ($userrow["difficulty"] == 3) { $userrow["difficulty"] = $controlrow["diff3name"]; }
$spellquery = doquery("SELECT id,name FROM {{table}}","spells");
$userspells = explode(",",$userrow["spells"]);
$userrow["magiclist"] = "";
while ($spellrow = mysql_fetch_array($spellquery)) {
$spell = false;
foreach($userspells as $a => $b) {
if ($b == $spellrow["id"]) { $spell = true; }
}
if ($spell == true) {
$userrow["magiclist"] .= $spellrow["name"]."<br />";
}
}
if ($userrow["magiclist"] == "") { $userrow["magiclist"] = "None"; }
// Make page tags for XHTML validation.
$xml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"
. "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"DTD/xhtml1-transitional.dtd\">\n"
. "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n";
$charsheet = gettemplate("showchar");
$page = $xml . gettemplate("minimal");
$array = array("content"=>parsetemplate($charsheet, $userrow), "title"=>"Character Information");
echo parsetemplate($page, $array);
die();
}
function onlinechar($id) {
global $controlrow;
$userquery = doquery("SELECT * FROM {{table}} WHERE id='$id' LIMIT 1", "users");
if (mysql_num_rows($userquery) == 1) { $userrow = mysql_fetch_array($userquery); } else { display("No such user.", "Error"); }
// Format various userrow stuffs.
$userrow["experience"] = number_format($userrow["experience"]);
$userrow["gold"] = number_format($userrow["gold"]);
if ($userrow["expbonus"] > 0) {
$userrow["plusexp"] = "<span class=\"light\">(+".$userrow["expbonus"]."%)</span>";
} elseif ($userrow["expbonus"] < 0) {
$userrow["plusexp"] = "<span class=\"light\">(".$userrow["expbonus"]."%)</span>";
} else { $userrow["plusexp"] = ""; }
if ($userrow["goldbonus"] > 0) {
$userrow["plusgold"] = "<span class=\"light\">(+".$userrow["goldbonus"]."%)</span>";
} elseif ($userrow["goldbonus"] < 0) {
$userrow["plusgold"] = "<span class=\"light\">(".$userrow["goldbonus"]."%)</span>";
} else { $userrow["plusgold"] = ""; }
$levelquery = doquery("SELECT ". $userrow["charclass"]."_exp FROM {{table}} WHERE id='".($userrow["level"]+1)."' LIMIT 1", "levels");
$levelrow = mysql_fetch_array($levelquery);
$userrow["nextlevel"] = number_format($levelrow[$userrow["charclass"]."_exp"]);
if ($userrow["charclass"] == 1) { $userrow["charclass"] = $controlrow["class1name"]; }
elseif ($userrow["charclass"] == 2) { $userrow["charclass"] = $controlrow["class2name"]; }
elseif ($userrow["charclass"] == 3) { $userrow["charclass"] = $controlrow["class3name"]; }
if ($userrow["difficulty"] == 1) { $userrow["difficulty"] = $controlrow["diff1name"]; }
elseif ($userrow["difficulty"] == 2) { $userrow["difficulty"] = $controlrow["diff2name"]; }
elseif ($userrow["difficulty"] == 3) { $userrow["difficulty"] = $controlrow["diff3name"]; }
$charsheet = gettemplate("onlinechar");
$page = parsetemplate($charsheet, $userrow);
display($page, "Character Information");
}
function showmap() {
global $userrow;
// Make page tags for XHTML validation.
$xml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"
. "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"DTD/xhtml1-transitional.dtd\">\n"
. "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n";
$page = $xml . gettemplate("minimal");
$array = array("content"=>"<center><img src=\"images/map.gif\" alt=\"Map\" /></center>", "title"=>"Map");
echo parsetemplate($page, $array);
die();
}
function babblebox() {
global $userrow;
if (isset($_POST["babble"])) {
$safecontent = makesafe($_POST["babble"]);
if ($safecontent == "" || $safecontent == " ") { //blank post. do nothing.
} else { $insert = doquery("INSERT INTO {{table}} SET id='',posttime=NOW(),author='".$userrow["charname"]."',babble='$safecontent'", "babble"); }
header("Location: index.php?do=babblebox");
die();
}
$babblebox = array("content"=>"");
$bg = 1;
$babblequery = doquery("SELECT * FROM {{table}} ORDER BY id DESC LIMIT 20", "babble");
while ($babblerow = mysql_fetch_array($babblequery)) {
if ($bg == 1) { $new = "<div style=\"width:98%; background-color:#eeeeee;\">[<b>".$babblerow["author"]."</b>] ".$babblerow["babble"]."</div>\n"; $bg = 2; }
else { $new = "<div style=\"width:98%; background-color:#ffffff;\">[<b>".$babblerow["author"]."</b>] ".stripslashes($babblerow["babble"])."</div>\n"; $bg = 1; }
$babblebox["content"] = $new . $babblebox["content"];
}
$babblebox["content"] .= "<center><form action=\"index.php?do=babblebox\" method=\"post\"><input type=\"text\" name=\"babble\" size=\"15\" maxlength=\"120\" /><br /><input type=\"submit\" name=\"submit\" value=\"Babble\" /> <input type=\"reset\" name=\"reset\" value=\"Clear\" /></form></center>";
// Make page tags for XHTML validation.
$xml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"
. "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"DTD/xhtml1-transitional.dtd\">\n"
. "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n";
$page = $xml . gettemplate("babblebox");
echo parsetemplate($page, $babblebox);
die();
}
function ninja() {
header("Location: http://www.se7enet.com/img/shirtninja.jpg");
}
?>

View File

@ -1,812 +0,0 @@
<?php // install.php :: creates/populates database tables on a new installation.
include('config.php');
include('lib.php');
$link = opendb();
$start = getmicrotime();
if (isset($_GET["page"])) {
$page = $_GET["page"];
if ($page == 2) { second(); }
elseif ($page == 3) { third(); }
elseif ($page == 4) { fourth(); }
elseif ($page == 5) { fifth(); }
else { first(); }
} else { first(); }
// Thanks to Predrag Supurovic from php.net for this function!
function dobatch ($p_query) {
$query_split = preg_split ("/[;]+/", $p_query);
foreach ($query_split as $command_line) {
$command_line = trim($command_line);
if ($command_line != '') {
$query_result = mysql_query($command_line);
if ($query_result == 0) {
break;
};
};
};
return $query_result;
}
function first() { // First page - show warnings and gather info.
$page = <<<END
<html>
<head>
<title>Dragon Knight Installation</title>
</head>
<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 /><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.
</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>
</body>
</html>
END;
echo $page;
die();
}
function second() { // Second page - set up the database tables.
global $dbsettings;
echo "<html><head><title>Dragon Knight Installation</title></head><body><b>Dragon Knight Installation: Page Two</b><br /><br />";
$prefix = $dbsettings["prefix"];
$babble = $prefix . "_babble";
$control = $prefix . "_control";
$drops = $prefix . "_drops";
$forum = $prefix . "_forum";
$items = $prefix . "_items";
$levels = $prefix . "_levels";
$monsters = $prefix . "_monsters";
$news = $prefix . "_news";
$spells = $prefix . "_spells";
$towns = $prefix . "_towns";
$users = $prefix . "_users";
if (isset($_POST["complete"])) { $full = true; } else { $full = false; }
$query = <<<END
CREATE TABLE `$babble` (
`id` int(10) unsigned NOT NULL auto_increment,
`posttime` time NOT NULL default '00:00:00',
`author` varchar(30) NOT NULL default '',
`babble` varchar(120) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM;
END;
if (dobatch($query) == 1) { echo "Babble Box table created.<br />"; } else { echo "Error creating Babble Box table."; }
unset($query);
$query = <<<END
CREATE TABLE `$control` (
`id` tinyint(3) unsigned NOT NULL auto_increment,
`gamename` varchar(50) NOT NULL default '',
`gamesize` smallint(5) unsigned NOT NULL default '0',
`gameopen` tinyint(3) unsigned NOT NULL default '0',
`gameurl` varchar(200) NOT NULL default '',
`adminemail` varchar(100) NOT NULL default '',
`forumtype` tinyint(3) unsigned NOT NULL default '0',
`forumaddress` varchar(200) NOT NULL default '',
`class1name` varchar(50) NOT NULL default '',
`class2name` varchar(50) NOT NULL default '',
`class3name` varchar(50) NOT NULL default '',
`diff1name` varchar(50) NOT NULL default '',
`diff1mod` float unsigned NOT NULL default '0',
`diff2name` varchar(50) NOT NULL default '',
`diff2mod` float unsigned NOT NULL default '0',
`diff3name` varchar(50) NOT NULL default '',
`diff3mod` float unsigned NOT NULL default '0',
`compression` tinyint(3) unsigned NOT NULL default '0',
`verifyemail` tinyint(3) unsigned NOT NULL default '0',
`shownews` tinyint(3) unsigned NOT NULL default '0',
`showbabble` tinyint(3) unsigned NOT NULL default '0',
`showonline` tinyint(3) unsigned NOT NULL default '0',
PRIMARY KEY (`id`)
) TYPE=MyISAM;
END;
if (dobatch($query) == 1) { echo "Control table created.<br />"; } else { echo "Error creating Control table."; }
unset($query);
$query = <<<END
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, 1);
END;
if (dobatch($query) == 1) { echo "Control table populated.<br />"; } else { echo "Error populating Control table."; }
unset($query);
$query = <<<END
CREATE TABLE `$drops` (
`id` mediumint(8) unsigned NOT NULL auto_increment,
`name` varchar(30) NOT NULL default '',
`mlevel` smallint(5) unsigned NOT NULL default '0',
`type` smallint(5) unsigned NOT NULL default '0',
`attribute1` varchar(30) NOT NULL default '',
`attribute2` varchar(30) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM;
END;
if (dobatch($query) == 1) { echo "Drops table created.<br />"; } else { echo "Error creating Drops table."; }
unset($query);
if ($full == true) {
$query = <<<END
INSERT INTO `$drops` VALUES (1, 'Life Pebble', 1, 1, 'maxhp,10', 'X');
INSERT INTO `$drops` VALUES (2, 'Life Stone', 10, 1, 'maxhp,25', 'X');
INSERT INTO `$drops` VALUES (3, 'Life Rock', 25, 1, 'maxhp,50', 'X');
INSERT INTO `$drops` VALUES (4, 'Magic Pebble', 1, 1, 'maxmp,10', 'X');
INSERT INTO `$drops` VALUES (5, 'Magic Stone', 10, 1, 'maxmp,25', 'X');
INSERT INTO `$drops` VALUES (6, 'Magic Rock', 25, 1, 'maxmp,50', 'X');
INSERT INTO `$drops` VALUES (7, 'Dragon\'s Scale', 10, 1, 'defensepower,25', 'X');
INSERT INTO `$drops` VALUES (8, 'Dragon\'s Plate', 30, 1, 'defensepower,50', 'X');
INSERT INTO `$drops` VALUES (9, 'Dragon\'s Claw', 10, 1, 'attackpower,25', 'X');
INSERT INTO `$drops` VALUES (10, 'Dragon\'s Tooth', 30, 1, 'attackpower,50', 'X');
INSERT INTO `$drops` VALUES (11, 'Dragon\'s Tear', 35, 1, 'strength,50', 'X');
INSERT INTO `$drops` VALUES (12, 'Dragon\'s Wing', 35, 1, 'dexterity,50', 'X');
INSERT INTO `$drops` VALUES (13, 'Demon\'s Sin', 35, 1, 'maxhp,-50', 'strength,50');
INSERT INTO `$drops` VALUES (14, 'Demon\'s Fall', 35, 1, 'maxmp,-50', 'strength,50');
INSERT INTO `$drops` VALUES (15, 'Demon\'s Lie', 45, 1, 'maxhp,-100', 'strength,100');
INSERT INTO `$drops` VALUES (16, 'Demon\'s Hate', 45, 1, 'maxmp,-100', 'strength,100');
INSERT INTO `$drops` VALUES (17, 'Angel\'s Joy', 25, 1, 'maxhp,25', 'strength,25');
INSERT INTO `$drops` VALUES (18, 'Angel\'s Rise', 30, 1, 'maxhp,50', 'strength,50');
INSERT INTO `$drops` VALUES (19, 'Angel\'s Truth', 35, 1, 'maxhp,75', 'strength,75');
INSERT INTO `$drops` VALUES (20, 'Angel\'s Love', 40, 1, 'maxhp,100', 'strength,100');
INSERT INTO `$drops` VALUES (21, 'Seraph\'s Joy', 25, 1, 'maxmp,25', 'dexterity,25');
INSERT INTO `$drops` VALUES (22, 'Seraph\'s Rise', 30, 1, 'maxmp,50', 'dexterity,50');
INSERT INTO `$drops` VALUES (23, 'Seraph\'s Truth', 35, 1, 'maxmp,75', 'dexterity,75');
INSERT INTO `$drops` VALUES (24, 'Seraph\'s Love', 40, 1, 'maxmp,100', 'dexterity,100');
INSERT INTO `$drops` VALUES (25, 'Ruby', 50, 1, 'maxhp,150', 'X');
INSERT INTO `$drops` VALUES (26, 'Pearl', 50, 1, 'maxmp,150', 'X');
INSERT INTO `$drops` VALUES (27, 'Emerald', 50, 1, 'strength,150', 'X');
INSERT INTO `$drops` VALUES (28, 'Topaz', 50, 1, 'dexterity,150', 'X');
INSERT INTO `$drops` VALUES (29, 'Obsidian', 50, 1, 'attackpower,150', 'X');
INSERT INTO `$drops` VALUES (30, 'Diamond', 50, 1, 'defensepower,150', 'X');
INSERT INTO `$drops` VALUES (31, 'Memory Drop', 5, 1, 'expbonus,10', 'X');
INSERT INTO `$drops` VALUES (32, 'Fortune Drop', 5, 1, 'goldbonus,10', 'X');
END;
if (dobatch($query) == 1) { echo "Drops table populated.<br />"; } else { echo "Error populating Drops table."; }
unset($query);
}
$query = <<<END
CREATE TABLE `$forum` (
`id` int(11) NOT NULL auto_increment,
`postdate` datetime NOT NULL default '0000-00-00 00:00:00',
`newpostdate` datetime NOT NULL default '0000-00-00 00:00:00',
`author` varchar(30) NOT NULL default '',
`parent` int(11) NOT NULL default '0',
`replies` int(11) NOT NULL default '0',
`title` varchar(100) NOT NULL default '',
`content` text NOT NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM;
END;
if (dobatch($query) == 1) { echo "Forum table created.<br />"; } else { echo "Error creating Forum table."; }
unset($query);
$query = <<<END
CREATE TABLE `$items` (
`id` smallint(5) unsigned NOT NULL auto_increment,
`type` tinyint(3) unsigned NOT NULL default '0',
`name` varchar(30) NOT NULL default '',
`buycost` smallint(5) unsigned NOT NULL default '0',
`attribute` smallint(5) unsigned NOT NULL default '0',
`special` varchar(50) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM;
END;
if (dobatch($query) == 1) { echo "Items table created.<br />"; } else { echo "Error creating Items table."; }
unset($query);
if ($full == true) {
$query = <<<END
INSERT INTO `$items` VALUES (1, 1, 'Stick', 10, 2, 'X');
INSERT INTO `$items` VALUES (2, 1, 'Branch', 30, 4, 'X');
INSERT INTO `$items` VALUES (3, 1, 'Club', 40, 5, 'X');
INSERT INTO `$items` VALUES (4, 1, 'Dagger', 90, 8, 'X');
INSERT INTO `$items` VALUES (5, 1, 'Hatchet', 150, 12, 'X');
INSERT INTO `$items` VALUES (6, 1, 'Axe', 200, 16, 'X');
INSERT INTO `$items` VALUES (7, 1, 'Brand', 300, 25, 'X');
INSERT INTO `$items` VALUES (8, 1, 'Poleaxe', 500, 35, 'X');
INSERT INTO `$items` VALUES (9, 1, 'Broadsword', 800, 45, 'X');
INSERT INTO `$items` VALUES (10, 1, 'Battle Axe', 1200, 50, 'X');
INSERT INTO `$items` VALUES (11, 1, 'Claymore', 2000, 60, 'X');
INSERT INTO `$items` VALUES (12, 1, 'Dark Axe', 3000, 100, 'expbonus,-5');
INSERT INTO `$items` VALUES (13, 1, 'Dark Sword', 4500, 125, 'expbonus,-10');
INSERT INTO `$items` VALUES (14, 1, 'Bright Sword', 6000, 100, 'expbonus,10');
INSERT INTO `$items` VALUES (15, 1, 'Magic Sword', 10000, 150, 'maxmp,50');
INSERT INTO `$items` VALUES (16, 1, 'Destiny Blade', 50000, 250, 'strength,50');
INSERT INTO `$items` VALUES (17, 2, 'Skivvies', 25, 2, 'goldbonus,10');
INSERT INTO `$items` VALUES (18, 2, 'Clothes', 50, 5, 'X');
INSERT INTO `$items` VALUES (19, 2, 'Leather Armor', 75, 10, 'X');
INSERT INTO `$items` VALUES (20, 2, 'Hard Leather Armor', 150, 25, 'X');
INSERT INTO `$items` VALUES (21, 2, 'Chain Mail', 300, 30, 'X');
INSERT INTO `$items` VALUES (22, 2, 'Bronze Plate', 900, 50, 'X');
INSERT INTO `$items` VALUES (23, 2, 'Iron Plate', 2000, 100, 'X');
INSERT INTO `$items` VALUES (24, 2, 'Magic Armor', 4000, 125, 'maxmp,50');
INSERT INTO `$items` VALUES (25, 2, 'Dark Armor', 5000, 150, 'expbonus,-10');
INSERT INTO `$items` VALUES (26, 2, 'Bright Armor', 10000, 175, 'expbonus,10');
INSERT INTO `$items` VALUES (27, 2, 'Destiny Raiment', 50000, 200, 'dexterity,50');
INSERT INTO `$items` VALUES (28, 3, 'Reed Shield', 50, 2, 'X');
INSERT INTO `$items` VALUES (29, 3, 'Buckler', 100, 4, 'X');
INSERT INTO `$items` VALUES (30, 3, 'Small Shield', 500, 10, 'X');
INSERT INTO `$items` VALUES (31, 3, 'Large Shield', 2500, 30, 'X');
INSERT INTO `$items` VALUES (32, 3, 'Silver Shield', 10000, 60, 'X');
INSERT INTO `$items` VALUES (33, 3, 'Destiny Aegis', 25000, 100, 'maxhp,50');
END;
if (dobatch($query) == 1) { echo "Items table populated.<br />"; } else { echo "Error populating Items table."; }
unset($query);
}
$query = <<<END
CREATE TABLE `$levels` (
`id` smallint(5) unsigned NOT NULL auto_increment,
`1_exp` mediumint(8) unsigned NOT NULL default '0',
`1_hp` smallint(5) unsigned NOT NULL default '0',
`1_mp` smallint(5) unsigned NOT NULL default '0',
`1_tp` smallint(5) unsigned NOT NULL default '0',
`1_strength` smallint(5) unsigned NOT NULL default '0',
`1_dexterity` smallint(5) unsigned NOT NULL default '0',
`1_spells` tinyint(3) unsigned NOT NULL default '0',
`2_exp` mediumint(8) unsigned NOT NULL default '0',
`2_hp` smallint(5) unsigned NOT NULL default '0',
`2_mp` smallint(5) unsigned NOT NULL default '0',
`2_tp` smallint(5) unsigned NOT NULL default '0',
`2_strength` smallint(5) unsigned NOT NULL default '0',
`2_dexterity` smallint(5) unsigned NOT NULL default '0',
`2_spells` tinyint(3) unsigned NOT NULL default '0',
`3_exp` mediumint(8) unsigned NOT NULL default '0',
`3_hp` smallint(5) unsigned NOT NULL default '0',
`3_mp` smallint(5) unsigned NOT NULL default '0',
`3_tp` smallint(5) unsigned NOT NULL default '0',
`3_strength` smallint(5) unsigned NOT NULL default '0',
`3_dexterity` smallint(5) unsigned NOT NULL default '0',
`3_spells` tinyint(3) unsigned NOT NULL default '0',
PRIMARY KEY (`id`)
) TYPE=MyISAM;
END;
if (dobatch($query) == 1) { echo "Levels table created.<br />"; } else { echo "Error creating Levels table."; }
unset($query);
if ($full == true) {
$query = <<<END
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);
INSERT INTO `$levels` VALUES (2, 15, 2, 5, 1, 0, 1, 1, 18, 2, 4, 1, 2, 1, 1, 20, 2, 5, 1, 0, 2, 1);
INSERT INTO `$levels` VALUES (3, 45, 3, 4, 2, 1, 2, 0, 54, 2, 3, 2, 3, 2, 0, 60, 2, 3, 2, 1, 3, 0);
INSERT INTO `$levels` VALUES (4, 105, 3, 3, 2, 1, 2, 6, 126, 2, 3, 2, 3, 2, 0, 140, 2, 4, 2, 1, 3, 0);
INSERT INTO `$levels` VALUES (5, 195, 2, 5, 2, 0, 1, 0, 234, 2, 4, 2, 2, 1, 6, 260, 2, 4, 2, 0, 2, 6);
INSERT INTO `$levels` VALUES (6, 330, 4, 5, 2, 2, 3, 0, 396, 3, 4, 2, 4, 3, 0, 440, 3, 5, 2, 2, 4, 0);
INSERT INTO `$levels` VALUES (7, 532, 3, 4, 2, 1, 2, 11, 639, 2, 3, 2, 3, 2, 0, 710, 2, 3, 2, 1, 3, 0);
INSERT INTO `$levels` VALUES (8, 835, 2, 4, 2, 0, 1, 0, 1003, 2, 3, 2, 2, 1, 11, 1115, 2, 4, 2, 0, 2, 11);
INSERT INTO `$levels` VALUES (9, 1290, 5, 3, 2, 3, 4, 2, 1549, 4, 2, 2, 5, 4, 0, 1722, 4, 2, 2, 3, 5, 0);
INSERT INTO `$levels` VALUES (10, 1973, 10, 3, 2, 4, 3, 0, 2369, 10, 2, 2, 6, 3, 0, 2633, 10, 3, 2, 4, 4, 0);
INSERT INTO `$levels` VALUES (11, 2997, 5, 2, 2, 3, 4, 0, 3598, 4, 1, 2, 5, 4, 2, 3999, 4, 1, 2, 3, 5, 2);
INSERT INTO `$levels` VALUES (12, 4533, 4, 2, 2, 2, 3, 7, 5441, 4, 1, 2, 4, 3, 0, 6047, 4, 2, 2, 2, 4, 0);
INSERT INTO `$levels` VALUES (13, 6453, 4, 3, 2, 2, 3, 0, 7745, 4, 2, 2, 4, 3, 0, 8607, 4, 2, 2, 2, 4, 0);
INSERT INTO `$levels` VALUES (14, 8853, 5, 4, 2, 3, 4, 17, 10625, 4, 3, 2, 5, 4, 7, 11807, 4, 4, 2, 3, 5, 7);
INSERT INTO `$levels` VALUES (15, 11853, 5, 5, 2, 3, 4, 0, 14225, 4, 4, 2, 5, 4, 0, 15808, 4, 4, 2, 3, 5, 0);
INSERT INTO `$levels` VALUES (16, 15603, 5, 3, 2, 3, 4, 0, 18725, 5, 2, 2, 5, 4, 0, 20807, 5, 3, 2, 3, 5, 0);
INSERT INTO `$levels` VALUES (17, 20290, 4, 2, 2, 2, 3, 12, 24350, 4, 1, 2, 4, 3, 0, 27057, 4, 1, 2, 2, 4, 0);
INSERT INTO `$levels` VALUES (18, 25563, 4, 2, 2, 2, 3, 0, 30678, 3, 1, 2, 4, 3, 14, 34869, 3, 2, 2, 2, 4, 17);
INSERT INTO `$levels` VALUES (19, 31495, 4, 5, 2, 2, 3, 0, 37797, 3, 4, 2, 4, 3, 0, 43657, 3, 4, 2, 2, 4, 0);
INSERT INTO `$levels` VALUES (20, 38169, 10, 6, 2, 3, 3, 0, 45805, 10, 5, 2, 5, 3, 0, 53543, 10, 6, 2, 3, 4, 0);
INSERT INTO `$levels` VALUES (21, 45676, 4, 4, 2, 2, 3, 0, 54814, 4, 3, 2, 4, 3, 0, 64664, 4, 3, 2, 2, 4, 0);
INSERT INTO `$levels` VALUES (22, 54121, 5, 5, 2, 3, 4, 0, 64949, 4, 4, 2, 5, 4, 12, 77175, 4, 5, 2, 3, 5, 12);
INSERT INTO `$levels` VALUES (23, 63622, 5, 3, 2, 3, 4, 0, 76350, 4, 2, 2, 5, 4, 0, 91250, 4, 2, 2, 3, 5, 0);
INSERT INTO `$levels` VALUES (24, 74310, 5, 5, 2, 3, 4, 0, 89176, 4, 4, 2, 5, 4, 0, 107083, 4, 5, 2, 3, 5, 0);
INSERT INTO `$levels` VALUES (25, 86334, 4, 4, 2, 2, 3, 3, 103605, 3, 3, 2, 4, 3, 17, 124895, 3, 3, 2, 2, 4, 14);
INSERT INTO `$levels` VALUES (26, 99861, 6, 3, 2, 4, 5, 0, 119837, 5, 2, 2, 6, 5, 0, 144933, 5, 3, 2, 4, 6, 0);
INSERT INTO `$levels` VALUES (27, 115078, 6, 2, 2, 4, 5, 0, 138098, 5, 1, 2, 6, 5, 0, 167475, 5, 1, 2, 4, 6, 0);
INSERT INTO `$levels` VALUES (28, 132197, 4, 2, 2, 2, 3, 0, 158641, 4, 1, 2, 4, 3, 0, 192835, 4, 2, 2, 2, 4, 0);
INSERT INTO `$levels` VALUES (29, 151456, 6, 3, 2, 4, 5, 0, 181751, 5, 2, 2, 6, 5, 3, 221365, 5, 2, 2, 4, 6, 3);
INSERT INTO `$levels` VALUES (30, 173121, 10, 4, 3, 4, 4, 0, 207749, 10, 3, 3, 6, 4, 0, 253461, 10, 4, 3, 4, 5, 0);
INSERT INTO `$levels` VALUES (31, 197494, 5, 5, 3, 3, 4, 8, 236996, 4, 3, 3, 5, 4, 0, 289568, 4, 3, 3, 3, 5, 0);
INSERT INTO `$levels` VALUES (32, 224913, 6, 4, 3, 4, 5, 0, 269898, 5, 3, 3, 6, 5, 0, 330188, 5, 4, 3, 4, 6, 0);
INSERT INTO `$levels` VALUES (33, 255758, 5, 4, 3, 3, 4, 0, 306912, 5, 3, 3, 5, 4, 0, 375885, 5, 3, 3, 3, 5, 0);
INSERT INTO `$levels` VALUES (34, 290458, 6, 4, 3, 4, 5, 0, 348552, 5, 3, 3, 6, 5, 8, 427294, 5, 4, 3, 4, 6, 8);
INSERT INTO `$levels` VALUES (35, 329495, 5, 3, 3, 3, 4, 0, 395397, 4, 2, 3, 5, 4, 0, 485126, 4, 2, 3, 3, 5, 0);
INSERT INTO `$levels` VALUES (36, 373412, 4, 3, 3, 2, 3, 18, 448097, 5, 2, 3, 4, 3, 0, 550188, 5, 3, 3, 2, 4, 0);
INSERT INTO `$levels` VALUES (37, 422818, 5, 4, 3, 3, 4, 0, 507384, 5, 3, 3, 5, 4, 0, 623383, 5, 3, 3, 3, 5, 0);
INSERT INTO `$levels` VALUES (38, 478399, 6, 5, 3, 4, 5, 0, 574081, 5, 4, 3, 6, 5, 15, 705726, 5, 5, 3, 4, 6, 18);
INSERT INTO `$levels` VALUES (39, 540927, 6, 4, 3, 4, 5, 0, 649115, 5, 3, 3, 6, 5, 0, 798362, 5, 3, 3, 4, 6, 0);
INSERT INTO `$levels` VALUES (40, 611271, 15, 3, 3, 5, 5, 13, 733528, 15, 2, 3, 7, 5, 0, 902577, 15, 3, 3, 5, 6, 0);
INSERT INTO `$levels` VALUES (41, 690408, 7, 3, 3, 5, 2, 0, 828492, 6, 2, 3, 7, 2, 0, 1019818, 6, 2, 3, 5, 3, 0);
INSERT INTO `$levels` VALUES (42, 779437, 7, 4, 3, 5, 6, 0, 935326, 6, 3, 3, 7, 6, 0, 1151714, 6, 4, 3, 5, 7, 0);
INSERT INTO `$levels` VALUES (43, 879592, 8, 5, 3, 6, 7, 0, 1055514, 7, 4, 3, 8, 7, 0, 1300096, 7, 4, 3, 6, 8, 0);
INSERT INTO `$levels` VALUES (44, 992268, 6, 3, 3, 4, 5, 0, 1190725, 5, 2, 3, 6, 5, 0, 1448478, 5, 3, 3, 4, 6, 0);
INSERT INTO `$levels` VALUES (45, 1119028, 5, 8, 3, 3, 4, 4, 1325936, 5, 8, 3, 5, 4, 18, 1596860, 5, 8, 3, 3, 5, 4);
INSERT INTO `$levels` VALUES (46, 1245788, 6, 5, 3, 4, 5, 0, 1461147, 5, 4, 3, 6, 5, 0, 1745242, 5, 5, 3, 4, 6, 0);
INSERT INTO `$levels` VALUES (47, 1372548, 7, 4, 3, 5, 6, 0, 1596358, 6, 3, 3, 7, 6, 0, 1893624, 6, 3, 3, 5, 7, 0);
INSERT INTO `$levels` VALUES (48, 1499308, 6, 4, 3, 4, 5, 0, 1731569, 5, 3, 3, 6, 5, 0, 2042006, 5, 4, 3, 4, 6, 0);
INSERT INTO `$levels` VALUES (49, 1626068, 5, 3, 3, 3, 4, 0, 1866780, 4, 2, 3, 5, 4, 0, 2190388, 4, 2, 3, 3, 5, 0);
INSERT INTO `$levels` VALUES (50, 1752828, 15, 3, 3, 5, 5, 0, 2001991, 15, 2, 3, 7, 5, 0, 2338770, 15, 3, 3, 5, 6, 0);
INSERT INTO `$levels` VALUES (51, 1879588, 6, 2, 3, 4, 5, 9, 2137202, 5, 1, 3, 6, 5, 13, 2487152, 5, 1, 3, 4, 6, 13);
INSERT INTO `$levels` VALUES (52, 2006348, 7, 2, 3, 5, 6, 0, 2272413, 6, 1, 3, 7, 6, 0, 2635534, 6, 2, 3, 5, 7, 0);
INSERT INTO `$levels` VALUES (53, 2133108, 8, 2, 3, 6, 7, 0, 2407624, 7, 1, 3, 8, 7, 0, 2783916, 7, 1, 3, 6, 8, 0);
INSERT INTO `$levels` VALUES (54, 2259868, 8, 4, 3, 6, 7, 0, 2542835, 7, 3, 3, 8, 7, 0, 2932298, 7, 4, 3, 6, 8, 0);
INSERT INTO `$levels` VALUES (55, 2386628, 7, 4, 3, 5, 6, 0, 2678046, 6, 3, 3, 7, 6, 0, 3080680, 6, 3, 3, 5, 7, 0);
INSERT INTO `$levels` VALUES (56, 2513388, 7, 4, 3, 5, 6, 0, 2813257, 6, 3, 3, 7, 6, 0, 3229062, 6, 4, 3, 5, 7, 9);
INSERT INTO `$levels` VALUES (57, 2640148, 6, 5, 3, 4, 5, 0, 2948468, 6, 4, 3, 6, 5, 0, 3377444, 6, 4, 3, 4, 6, 0);
INSERT INTO `$levels` VALUES (58, 2766908, 5, 5, 3, 3, 4, 0, 3083679, 5, 4, 3, 5, 4, 19, 3525826, 5, 5, 3, 3, 5, 0);
INSERT INTO `$levels` VALUES (59, 2893668, 8, 3, 3, 6, 7, 0, 3218890, 7, 2, 3, 8, 7, 0, 3674208, 7, 2, 3, 6, 8, 0);
INSERT INTO `$levels` VALUES (60, 3020428, 15, 4, 4, 6, 6, 19, 3354101, 15, 3, 4, 8, 6, 0, 3822590, 15, 4, 4, 6, 7, 15);
INSERT INTO `$levels` VALUES (61, 3147188, 8, 5, 4, 6, 7, 0, 3489312, 7, 4, 4, 8, 7, 0, 3970972, 7, 4, 4, 6, 8, 0);
INSERT INTO `$levels` VALUES (62, 3273948, 8, 4, 4, 6, 7, 0, 3624523, 7, 3, 4, 8, 7, 0, 4119354, 7, 4, 4, 6, 8, 0);
INSERT INTO `$levels` VALUES (63, 3400708, 9, 5, 4, 7, 8, 0, 3759734, 8, 4, 4, 9, 8, 0, 4267736, 8, 4, 4, 7, 9, 0);
INSERT INTO `$levels` VALUES (64, 3527468, 5, 5, 4, 3, 4, 0, 3894945, 5, 4, 4, 5, 4, 0, 4416118, 5, 5, 4, 3, 5, 0);
INSERT INTO `$levels` VALUES (65, 3654228, 6, 4, 4, 4, 5, 0, 4030156, 6, 3, 4, 6, 5, 0, 4564500, 6, 3, 4, 4, 6, 0);
INSERT INTO `$levels` VALUES (66, 3780988, 8, 4, 4, 6, 7, 0, 4165367, 8, 3, 4, 8, 7, 0, 4712882, 8, 4, 4, 6, 8, 0);
INSERT INTO `$levels` VALUES (67, 3907748, 7, 3, 4, 5, 6, 0, 4300578, 7, 2, 4, 7, 6, 0, 4861264, 7, 2, 4, 5, 7, 0);
INSERT INTO `$levels` VALUES (68, 4034508, 9, 3, 4, 7, 8, 0, 4435789, 8, 2, 4, 9, 8, 0, 5009646, 8, 3, 4, 7, 9, 0);
INSERT INTO `$levels` VALUES (69, 4161268, 5, 4, 4, 3, 4, 0, 4571000, 5, 3, 4, 5, 4, 0, 5158028, 5, 3, 4, 3, 5, 0);
INSERT INTO `$levels` VALUES (70, 4288028, 20, 4, 4, 6, 6, 5, 4706211, 20, 3, 4, 8, 6, 16, 5306410, 20, 4, 4, 6, 7, 0);
INSERT INTO `$levels` VALUES (71, 4414788, 5, 5, 4, 3, 4, 0, 4841422, 5, 4, 4, 5, 4, 0, 5454792, 5, 4, 4, 3, 5, 0);
INSERT INTO `$levels` VALUES (72, 4541548, 6, 2, 4, 4, 5, 0, 4976633, 5, 1, 4, 6, 5, 0, 5603174, 5, 2, 4, 4, 6, 0);
INSERT INTO `$levels` VALUES (73, 4668308, 8, 4, 4, 6, 7, 0, 5111844, 8, 3, 4, 8, 7, 0, 5751556, 8, 3, 4, 6, 8, 0);
INSERT INTO `$levels` VALUES (74, 4795068, 7, 5, 4, 5, 6, 0, 5247055, 6, 4, 4, 7, 6, 0, 5899938, 6, 5, 4, 5, 7, 0);
INSERT INTO `$levels` VALUES (75, 4921828, 5, 3, 4, 3, 4, 0, 5382266, 5, 2, 4, 5, 4, 0, 6048320, 5, 2, 4, 3, 5, 0);
INSERT INTO `$levels` VALUES (76, 5048588, 6, 3, 4, 4, 5, 0, 5517477, 6, 2, 4, 6, 5, 0, 6196702, 6, 3, 4, 4, 6, 0);
INSERT INTO `$levels` VALUES (77, 5175348, 6, 4, 4, 4, 5, 0, 5652688, 7, 3, 4, 6, 5, 0, 6345084, 7, 3, 4, 4, 6, 0);
INSERT INTO `$levels` VALUES (78, 5302108, 7, 4, 4, 5, 6, 0, 5787899, 7, 3, 4, 7, 6, 0, 6493466, 7, 4, 4, 5, 7, 0);
INSERT INTO `$levels` VALUES (79, 5428868, 8, 4, 4, 6, 7, 10, 5923110, 7, 3, 4, 8, 7, 0, 6641848, 7, 3, 4, 6, 8, 0);
INSERT INTO `$levels` VALUES (80, 5555628, 20, 5, 4, 6, 7, 0, 6058321, 20, 4, 4, 8, 7, 0, 6790230, 20, 5, 4, 6, 8, 0);
INSERT INTO `$levels` VALUES (81, 5682388, 7, 3, 4, 5, 6, 0, 6193532, 7, 2, 4, 7, 6, 0, 6938612, 7, 2, 4, 5, 7, 0);
INSERT INTO `$levels` VALUES (82, 5809148, 6, 4, 4, 4, 5, 0, 6328743, 5, 3, 4, 6, 5, 0, 7086994, 5, 4, 4, 4, 6, 0);
INSERT INTO `$levels` VALUES (83, 5935908, 6, 2, 4, 4, 5, 0, 6463954, 6, 1, 4, 6, 5, 0, 7235376, 6, 1, 4, 4, 6, 0);
INSERT INTO `$levels` VALUES (84, 6062668, 5, 4, 4, 3, 4, 0, 6599165, 5, 3, 4, 5, 4, 0, 7383758, 5, 4, 4, 3, 5, 0);
INSERT INTO `$levels` VALUES (85, 6189428, 7, 4, 4, 5, 6, 0, 6734376, 6, 3, 4, 7, 6, 0, 7532140, 6, 3, 4, 5, 7, 0);
INSERT INTO `$levels` VALUES (86, 6316188, 8, 5, 4, 6, 7, 0, 6869587, 8, 4, 4, 8, 7, 0, 7680522, 8, 5, 4, 6, 8, 0);
INSERT INTO `$levels` VALUES (87, 6442948, 8, 4, 4, 6, 7, 0, 7004798, 7, 3, 4, 8, 7, 0, 7828904, 7, 3, 4, 6, 8, 0);
INSERT INTO `$levels` VALUES (88, 6569708, 9, 5, 4, 7, 8, 0, 7140009, 8, 4, 4, 9, 8, 0, 7977286, 8, 5, 4, 7, 9, 0);
INSERT INTO `$levels` VALUES (89, 6696468, 5, 2, 4, 3, 4, 0, 7275220, 5, 1, 4, 5, 4, 0, 8125668, 5, 1, 4, 3, 5, 0);
INSERT INTO `$levels` VALUES (90, 6823228, 20, 2, 5, 7, 8, 0, 7410431, 20, 1, 5, 9, 8, 0, 8274050, 20, 2, 5, 7, 9, 0);
INSERT INTO `$levels` VALUES (91, 6949988, 5, 3, 5, 3, 4, 0, 7545642, 5, 2, 5, 5, 4, 0, 8422432, 5, 2, 5, 3, 5, 0);
INSERT INTO `$levels` VALUES (92, 7076748, 6, 3, 5, 4, 5, 0, 7680853, 4, 2, 5, 6, 5, 0, 8570814, 4, 3, 5, 4, 6, 0);
INSERT INTO `$levels` VALUES (93, 7203508, 8, 4, 5, 6, 7, 0, 7816064, 6, 2, 5, 8, 7, 0, 8719196, 6, 2, 5, 6, 8, 0);
INSERT INTO `$levels` VALUES (94, 7330268, 4, 4, 5, 3, 3, 0, 7951275, 4, 3, 5, 5, 3, 0, 8867578, 4, 4, 5, 3, 4, 0);
INSERT INTO `$levels` VALUES (95, 7457028, 3, 3, 5, 5, 2, 0, 8086486, 4, 2, 5, 7, 2, 0, 9015960, 4, 2, 5, 5, 3, 0);
INSERT INTO `$levels` VALUES (96, 7583788, 5, 3, 5, 4, 3, 0, 8221697, 5, 2, 5, 7, 3, 0, 9164342, 5, 3, 5, 4, 4, 0);
INSERT INTO `$levels` VALUES (97, 7710548, 5, 4, 5, 4, 5, 0, 8356908, 5, 3, 5, 7, 5, 0, 9312724, 5, 3, 5, 4, 6, 0);
INSERT INTO `$levels` VALUES (98, 7837308, 4, 5, 5, 4, 3, 0, 8492119, 4, 3, 5, 7, 3, 0, 9461106, 4, 4, 5, 4, 4, 0);
INSERT INTO `$levels` VALUES (99, 7964068, 50, 5, 5, 6, 5, 0, 8627330, 50, 3, 5, 9, 5, 0, 9609488, 50, 4, 5, 6, 6, 0);
INSERT INTO `$levels` VALUES (100, 16777215, 0, 0, 0, 0, 0, 0, 16777215, 0, 0, 0, 0, 0, 0, 16777215, 0, 0, 0, 0, 0, 0);
END;
if (dobatch($query) == 1) { echo "Levels table populated.<br />"; } else { echo "Error populating Levels table."; }
unset($query);
}
$query = <<<END
CREATE TABLE `$monsters` (
`id` smallint(5) unsigned NOT NULL auto_increment,
`name` varchar(50) NOT NULL default '',
`maxhp` smallint(5) unsigned NOT NULL default '0',
`maxdam` smallint(5) unsigned NOT NULL default '0',
`armor` smallint(5) unsigned NOT NULL default '0',
`level` smallint(5) unsigned NOT NULL default '0',
`maxexp` smallint(5) unsigned NOT NULL default '0',
`maxgold` smallint(5) unsigned NOT NULL default '0',
`immune` tinyint(3) unsigned NOT NULL default '0',
PRIMARY KEY (`id`)
) TYPE=MyISAM;
END;
if (dobatch($query) == 1) { echo "Monsters table created.<br />"; } else { echo "Error creating Monsters table."; }
unset($query);
if ($full == true) {
$query = <<<END
INSERT INTO `$monsters` VALUES (1, 'Blue Slime', 4, 3, 1, 1, 1, 1, 0);
INSERT INTO `$monsters` VALUES (2, 'Red Slime', 6, 5, 1, 1, 2, 1, 0);
INSERT INTO `$monsters` VALUES (3, 'Critter', 6, 5, 2, 1, 4, 2, 0);
INSERT INTO `$monsters` VALUES (4, 'Creature', 10, 8, 2, 2, 4, 2, 0);
INSERT INTO `$monsters` VALUES (5, 'Shadow', 10, 9, 3, 2, 6, 2, 1);
INSERT INTO `$monsters` VALUES (6, 'Drake', 11, 10, 3, 2, 8, 3, 0);
INSERT INTO `$monsters` VALUES (7, 'Shade', 12, 10, 3, 3, 10, 3, 1);
INSERT INTO `$monsters` VALUES (8, 'Drakelor', 14, 12, 4, 3, 10, 3, 0);
INSERT INTO `$monsters` VALUES (9, 'Silver Slime', 15, 100, 200, 30, 15, 1000, 2);
INSERT INTO `$monsters` VALUES (10, 'Scamp', 16, 13, 5, 4, 15, 5, 0);
INSERT INTO `$monsters` VALUES (11, 'Raven', 16, 13, 5, 4, 18, 6, 0);
INSERT INTO `$monsters` VALUES (12, 'Scorpion', 18, 14, 6, 5, 20, 7, 0);
INSERT INTO `$monsters` VALUES (13, 'Illusion', 20, 15, 6, 5, 20, 7, 1);
INSERT INTO `$monsters` VALUES (14, 'Nightshade', 22, 16, 6, 6, 24, 8, 0);
INSERT INTO `$monsters` VALUES (15, 'Drakemal', 22, 18, 7, 6, 24, 8, 0);
INSERT INTO `$monsters` VALUES (16, 'Shadow Raven', 24, 18, 7, 6, 26, 9, 1);
INSERT INTO `$monsters` VALUES (17, 'Ghost', 24, 20, 8, 6, 28, 9, 0);
INSERT INTO `$monsters` VALUES (18, 'Frost Raven', 26, 20, 8, 7, 30, 10, 0);
INSERT INTO `$monsters` VALUES (19, 'Rogue Scorpion', 28, 22, 9, 7, 32, 11, 0);
INSERT INTO `$monsters` VALUES (20, 'Ghoul', 29, 24, 9, 7, 34, 11, 0);
INSERT INTO `$monsters` VALUES (21, 'Magician', 30, 24, 10, 8, 36, 12, 0);
INSERT INTO `$monsters` VALUES (22, 'Rogue', 30, 25, 12, 8, 40, 13, 0);
INSERT INTO `$monsters` VALUES (23, 'Drakefin', 32, 26, 12, 8, 40, 13, 0);
INSERT INTO `$monsters` VALUES (24, 'Shimmer', 32, 26, 14, 8, 45, 15, 1);
INSERT INTO `$monsters` VALUES (25, 'Fire Raven', 34, 28, 14, 9, 45, 15, 0);
INSERT INTO `$monsters` VALUES (26, 'Dybbuk', 34, 28, 14, 9, 50, 17, 0);
INSERT INTO `$monsters` VALUES (27, 'Knave', 36, 30, 15, 9, 52, 17, 0);
INSERT INTO `$monsters` VALUES (28, 'Goblin', 36, 30, 15, 10, 54, 18, 0);
INSERT INTO `$monsters` VALUES (29, 'Skeleton', 38, 30, 18, 10, 58, 19, 0);
INSERT INTO `$monsters` VALUES (30, 'Dark Slime', 38, 32, 18, 10, 62, 21, 0);
INSERT INTO `$monsters` VALUES (31, 'Silver Scorpion', 30, 160, 350, 40, 63, 2000, 2);
INSERT INTO `$monsters` VALUES (32, 'Mirage', 40, 32, 20, 11, 64, 21, 1);
INSERT INTO `$monsters` VALUES (33, 'Sorceror', 41, 33, 22, 11, 68, 23, 0);
INSERT INTO `$monsters` VALUES (34, 'Imp', 42, 34, 22, 12, 70, 23, 0);
INSERT INTO `$monsters` VALUES (35, 'Nymph', 43, 35, 22, 12, 70, 23, 0);
INSERT INTO `$monsters` VALUES (36, 'Scoundrel', 43, 35, 22, 12, 75, 25, 0);
INSERT INTO `$monsters` VALUES (37, 'Megaskeleton', 44, 36, 24, 13, 78, 26, 0);
INSERT INTO `$monsters` VALUES (38, 'Grey Wolf', 44, 36, 24, 13, 82, 27, 0);
INSERT INTO `$monsters` VALUES (39, 'Phantom', 46, 38, 24, 14, 85, 28, 1);
INSERT INTO `$monsters` VALUES (40, 'Specter', 46, 38, 24, 14, 90, 30, 0);
INSERT INTO `$monsters` VALUES (41, 'Dark Scorpion', 48, 40, 26, 15, 95, 32, 1);
INSERT INTO `$monsters` VALUES (42, 'Warlock', 48, 40, 26, 15, 100, 33, 1);
INSERT INTO `$monsters` VALUES (43, 'Orc', 49, 42, 28, 15, 104, 35, 0);
INSERT INTO `$monsters` VALUES (44, 'Sylph', 49, 42, 28, 15, 106, 35, 0);
INSERT INTO `$monsters` VALUES (45, 'Wraith', 50, 45, 30, 16, 108, 36, 0);
INSERT INTO `$monsters` VALUES (46, 'Hellion', 50, 45, 30, 16, 110, 37, 0);
INSERT INTO `$monsters` VALUES (47, 'Bandit', 52, 45, 30, 16, 114, 38, 0);
INSERT INTO `$monsters` VALUES (48, 'Ultraskeleton', 52, 46, 32, 16, 116, 39, 0);
INSERT INTO `$monsters` VALUES (49, 'Dark Wolf', 54, 47, 36, 17, 120, 40, 1);
INSERT INTO `$monsters` VALUES (50, 'Troll', 56, 48, 36, 17, 120, 40, 0);
INSERT INTO `$monsters` VALUES (51, 'Werewolf', 56, 48, 38, 17, 124, 41, 0);
INSERT INTO `$monsters` VALUES (52, 'Hellcat', 58, 50, 38, 18, 128, 43, 0);
INSERT INTO `$monsters` VALUES (53, 'Spirit', 58, 50, 38, 18, 132, 44, 0);
INSERT INTO `$monsters` VALUES (54, 'Nisse', 60, 52, 40, 19, 132, 44, 0);
INSERT INTO `$monsters` VALUES (55, 'Dawk', 60, 54, 40, 19, 136, 45, 0);
INSERT INTO `$monsters` VALUES (56, 'Figment', 64, 55, 42, 19, 140, 47, 1);
INSERT INTO `$monsters` VALUES (57, 'Hellhound', 66, 56, 44, 20, 140, 47, 0);
INSERT INTO `$monsters` VALUES (58, 'Wizard', 66, 56, 44, 20, 144, 48, 0);
INSERT INTO `$monsters` VALUES (59, 'Uruk', 68, 58, 44, 20, 146, 49, 0);
INSERT INTO `$monsters` VALUES (60, 'Siren', 68, 400, 800, 50, 10000, 50, 2);
INSERT INTO `$monsters` VALUES (61, 'Megawraith', 70, 60, 46, 21, 155, 52, 0);
INSERT INTO `$monsters` VALUES (62, 'Dawkin', 70, 60, 46, 21, 155, 52, 0);
INSERT INTO `$monsters` VALUES (63, 'Grey Bear', 70, 62, 48, 21, 160, 53, 0);
INSERT INTO `$monsters` VALUES (64, 'Haunt', 72, 62, 48, 22, 160, 53, 0);
INSERT INTO `$monsters` VALUES (65, 'Hellbeast', 74, 64, 50, 22, 165, 55, 0);
INSERT INTO `$monsters` VALUES (66, 'Fear', 76, 66, 52, 23, 165, 55, 0);
INSERT INTO `$monsters` VALUES (67, 'Beast', 76, 66, 52, 23, 170, 57, 0);
INSERT INTO `$monsters` VALUES (68, 'Ogre', 78, 68, 54, 23, 170, 57, 0);
INSERT INTO `$monsters` VALUES (69, 'Dark Bear', 80, 70, 56, 24, 175, 58, 1);
INSERT INTO `$monsters` VALUES (70, 'Fire', 80, 72, 56, 24, 175, 58, 0);
INSERT INTO `$monsters` VALUES (71, 'Polgergeist', 84, 74, 58, 25, 180, 60, 0);
INSERT INTO `$monsters` VALUES (72, 'Fright', 86, 76, 58, 25, 180, 60, 0);
INSERT INTO `$monsters` VALUES (73, 'Lycan', 88, 78, 60, 25, 185, 62, 0);
INSERT INTO `$monsters` VALUES (74, 'Terra Elemental', 88, 80, 62, 25, 185, 62, 1);
INSERT INTO `$monsters` VALUES (75, 'Necromancer', 90, 80, 62, 26, 190, 63, 0);
INSERT INTO `$monsters` VALUES (76, 'Ultrawraith', 90, 82, 64, 26, 190, 63, 0);
INSERT INTO `$monsters` VALUES (77, 'Dawkor', 92, 82, 64, 26, 195, 65, 0);
INSERT INTO `$monsters` VALUES (78, 'Werebear', 92, 84, 65, 26, 195, 65, 0);
INSERT INTO `$monsters` VALUES (79, 'Brute', 94, 84, 65, 27, 200, 67, 0);
INSERT INTO `$monsters` VALUES (80, 'Large Beast', 96, 88, 66, 27, 200, 67, 0);
INSERT INTO `$monsters` VALUES (81, 'Horror', 96, 88, 68, 27, 210, 70, 0);
INSERT INTO `$monsters` VALUES (82, 'Flame', 100, 90, 70, 28, 210, 70, 0);
INSERT INTO `$monsters` VALUES (83, 'Lycanthor', 100, 90, 70, 28, 210, 70, 0);
INSERT INTO `$monsters` VALUES (84, 'Wyrm', 100, 92, 72, 28, 220, 73, 0);
INSERT INTO `$monsters` VALUES (85, 'Aero Elemental', 104, 94, 74, 29, 220, 73, 1);
INSERT INTO `$monsters` VALUES (86, 'Dawkare', 106, 96, 76, 29, 220, 73, 0);
INSERT INTO `$monsters` VALUES (87, 'Large Brute', 108, 98, 78, 29, 230, 77, 0);
INSERT INTO `$monsters` VALUES (88, 'Frost Wyrm', 110, 100, 80, 30, 230, 77, 0);
INSERT INTO `$monsters` VALUES (89, 'Knight', 110, 102, 80, 30, 240, 80, 0);
INSERT INTO `$monsters` VALUES (90, 'Lycanthra', 112, 104, 82, 30, 240, 80, 0);
INSERT INTO `$monsters` VALUES (91, 'Terror', 115, 108, 84, 31, 250, 83, 0);
INSERT INTO `$monsters` VALUES (92, 'Blaze', 118, 108, 84, 31, 250, 83, 0);
INSERT INTO `$monsters` VALUES (93, 'Aqua Elemental', 120, 110, 90, 31, 260, 87, 1);
INSERT INTO `$monsters` VALUES (94, 'Fire Wyrm', 120, 110, 90, 32, 260, 87, 0);
INSERT INTO `$monsters` VALUES (95, 'Lesser Wyvern', 122, 110, 92, 32, 270, 90, 0);
INSERT INTO `$monsters` VALUES (96, 'Doomer', 124, 112, 92, 32, 270, 90, 0);
INSERT INTO `$monsters` VALUES (97, 'Armor Knight', 130, 115, 95, 33, 280, 93, 0);
INSERT INTO `$monsters` VALUES (98, 'Wyvern', 134, 120, 95, 33, 290, 97, 0);
INSERT INTO `$monsters` VALUES (99, 'Nightmare', 138, 125, 100, 33, 300, 100, 0);
INSERT INTO `$monsters` VALUES (100, 'Fira Elemental', 140, 125, 100, 34, 310, 103, 1);
INSERT INTO `$monsters` VALUES (101, 'Megadoomer', 140, 128, 105, 34, 320, 107, 0);
INSERT INTO `$monsters` VALUES (102, 'Greater Wyvern', 145, 130, 105, 34, 335, 112, 0);
INSERT INTO `$monsters` VALUES (103, 'Advocate', 148, 132, 108, 35, 350, 117, 0);
INSERT INTO `$monsters` VALUES (104, 'Strong Knight', 150, 135, 110, 35, 365, 122, 0);
INSERT INTO `$monsters` VALUES (105, 'Liche', 150, 135, 110, 35, 380, 127, 0);
INSERT INTO `$monsters` VALUES (106, 'Ultradoomer', 155, 140, 115, 36, 395, 132, 0);
INSERT INTO `$monsters` VALUES (107, 'Fanatic', 160, 140, 115, 36, 410, 137, 0);
INSERT INTO `$monsters` VALUES (108, 'Green Dragon', 160, 140, 115, 36, 425, 142, 0);
INSERT INTO `$monsters` VALUES (109, 'Fiend', 160, 145, 120, 37, 445, 148, 0);
INSERT INTO `$monsters` VALUES (110, 'Greatest Wyvern', 162, 150, 120, 37, 465, 155, 0);
INSERT INTO `$monsters` VALUES (111, 'Lesser Devil', 164, 150, 120, 37, 485, 162, 0);
INSERT INTO `$monsters` VALUES (112, 'Liche Master', 168, 155, 125, 38, 505, 168, 0);
INSERT INTO `$monsters` VALUES (113, 'Zealot', 168, 155, 125, 38, 530, 177, 0);
INSERT INTO `$monsters` VALUES (114, 'Serafiend', 170, 155, 125, 38, 555, 185, 0);
INSERT INTO `$monsters` VALUES (115, 'Pale Knight', 175, 160, 130, 39, 580, 193, 0);
INSERT INTO `$monsters` VALUES (116, 'Blue Dragon', 180, 160, 130, 39, 605, 202, 0);
INSERT INTO `$monsters` VALUES (117, 'Obsessive', 180, 160, 135, 40, 630, 210, 0);
INSERT INTO `$monsters` VALUES (118, 'Devil', 184, 164, 135, 40, 666, 222, 0);
INSERT INTO `$monsters` VALUES (119, 'Liche Prince', 190, 168, 138, 40, 660, 220, 0);
INSERT INTO `$monsters` VALUES (120, 'Cherufiend', 195, 170, 140, 41, 690, 230, 0);
INSERT INTO `$monsters` VALUES (121, 'Red Dragon', 200, 180, 145, 41, 720, 240, 0);
INSERT INTO `$monsters` VALUES (122, 'Greater Devil', 200, 180, 145, 41, 750, 250, 0);
INSERT INTO `$monsters` VALUES (123, 'Renegade', 205, 185, 150, 42, 780, 260, 0);
INSERT INTO `$monsters` VALUES (124, 'Archfiend', 210, 190, 150, 42, 810, 270, 0);
INSERT INTO `$monsters` VALUES (125, 'Liche Lord', 210, 190, 155, 42, 850, 283, 0);
INSERT INTO `$monsters` VALUES (126, 'Greatest Devil', 215, 195, 160, 43, 890, 297, 0);
INSERT INTO `$monsters` VALUES (127, 'Dark Knight', 220, 200, 160, 43, 930, 310, 0);
INSERT INTO `$monsters` VALUES (128, 'Giant', 220, 200, 165, 43, 970, 323, 0);
INSERT INTO `$monsters` VALUES (129, 'Shadow Dragon', 225, 200, 170, 44, 1010, 337, 0);
INSERT INTO `$monsters` VALUES (130, 'Liche King', 225, 205, 170, 44, 1050, 350, 0);
INSERT INTO `$monsters` VALUES (131, 'Incubus', 230, 205, 175, 44, 1100, 367, 1);
INSERT INTO `$monsters` VALUES (132, 'Traitor', 230, 205, 175, 45, 1150, 383, 0);
INSERT INTO `$monsters` VALUES (133, 'Demon', 240, 210, 180, 45, 1200, 400, 0);
INSERT INTO `$monsters` VALUES (134, 'Dark Dragon', 245, 215, 180, 45, 1250, 417, 1);
INSERT INTO `$monsters` VALUES (135, 'Insurgent', 250, 220, 190, 46, 1300, 433, 0);
INSERT INTO `$monsters` VALUES (136, 'Leviathan', 255, 225, 190, 46, 1350, 450, 0);
INSERT INTO `$monsters` VALUES (137, 'Grey Daemon', 260, 230, 190, 46, 1400, 467, 0);
INSERT INTO `$monsters` VALUES (138, 'Succubus', 265, 240, 200, 47, 1460, 487, 1);
INSERT INTO `$monsters` VALUES (139, 'Demon Prince', 270, 240, 200, 47, 1520, 507, 0);
INSERT INTO `$monsters` VALUES (140, 'Black Dragon', 275, 250, 205, 47, 1580, 527, 1);
INSERT INTO `$monsters` VALUES (141, 'Nihilist', 280, 250, 205, 47, 1640, 547, 0);
INSERT INTO `$monsters` VALUES (142, 'Behemoth', 285, 260, 210, 48, 1700, 567, 0);
INSERT INTO `$monsters` VALUES (143, 'Demagogue', 290, 260, 210, 48, 1760, 587, 0);
INSERT INTO `$monsters` VALUES (144, 'Demon Lord', 300, 270, 220, 48, 1820, 607, 0);
INSERT INTO `$monsters` VALUES (145, 'Red Daemon', 310, 280, 230, 48, 1880, 627, 0);
INSERT INTO `$monsters` VALUES (146, 'Colossus', 320, 300, 240, 49, 1940, 647, 0);
INSERT INTO `$monsters` VALUES (147, 'Demon King', 330, 300, 250, 49, 2000, 667, 0);
INSERT INTO `$monsters` VALUES (148, 'Dark Daemon', 340, 320, 260, 49, 2200, 733, 1);
INSERT INTO `$monsters` VALUES (149, 'Titan', 360, 340, 270, 50, 2400, 800, 0);
INSERT INTO `$monsters` VALUES (150, 'Black Daemon', 400, 400, 280, 50, 3000, 1000, 1);
INSERT INTO `$monsters` VALUES (151, 'Lucifuge', 600, 600, 400, 50, 10000, 10000, 2);
END;
if (dobatch($query) == 1) { echo "Monsters table populated.<br />"; } else { echo "Error populating Monsters table."; }
unset($query);
}
$query = <<<END
CREATE TABLE `$news` (
`id` mediumint(8) unsigned NOT NULL auto_increment,
`postdate` datetime NOT NULL default '0000-00-00 00:00:00',
`content` text NOT NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM;
END;
if (dobatch($query) == 1) { echo "News table created.<br />"; } else { echo "Error creating News table."; }
unset($query);
$query = <<<END
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.');
END;
if (dobatch($query) == 1) { echo "News table populated.<br />"; } else { echo "Error populating News table."; }
unset($query);
$query = <<<END
CREATE TABLE `$spells` (
`id` smallint(5) unsigned NOT NULL auto_increment,
`name` varchar(30) NOT NULL default '',
`mp` smallint(5) unsigned NOT NULL default '0',
`attribute` smallint(5) unsigned NOT NULL default '0',
`type` smallint(5) unsigned NOT NULL default '0',
PRIMARY KEY (`id`)
) TYPE=MyISAM;
END;
if (dobatch($query) == 1) { echo "Spells table created.<br />"; } else { echo "Error creating Spells table."; }
unset($query);
if ($full == true) {
$query = <<<END
INSERT INTO `$spells` VALUES (1, 'Heal', 5, 10, 1);
INSERT INTO `$spells` VALUES (2, 'Revive', 10, 25, 1);
INSERT INTO `$spells` VALUES (3, 'Life', 25, 50, 1);
INSERT INTO `$spells` VALUES (4, 'Breath', 50, 100, 1);
INSERT INTO `$spells` VALUES (5, 'Gaia', 75, 150, 1);
INSERT INTO `$spells` VALUES (6, 'Hurt', 5, 15, 2);
INSERT INTO `$spells` VALUES (7, 'Pain', 12, 35, 2);
INSERT INTO `$spells` VALUES (8, 'Maim', 25, 70, 2);
INSERT INTO `$spells` VALUES (9, 'Rend', 40, 100, 2);
INSERT INTO `$spells` VALUES (10, 'Chaos', 50, 130, 2);
INSERT INTO `$spells` VALUES (11, 'Sleep', 10, 5, 3);
INSERT INTO `$spells` VALUES (12, 'Dream', 30, 9, 3);
INSERT INTO `$spells` VALUES (13, 'Nightmare', 60, 13, 3);
INSERT INTO `$spells` VALUES (14, 'Craze', 10, 10, 4);
INSERT INTO `$spells` VALUES (15, 'Rage', 20, 25, 4);
INSERT INTO `$spells` VALUES (16, 'Fury', 30, 50, 4);
INSERT INTO `$spells` VALUES (17, 'Ward', 10, 10, 5);
INSERT INTO `$spells` VALUES (18, 'Fend', 20, 25, 5);
INSERT INTO `$spells` VALUES (19, 'Barrier', 30, 50, 5);
END;
if (dobatch($query) == 1) { echo "Spells table populated.<br />"; } else { echo "Error populating Spells table."; }
unset($query);
}
$query = <<<END
CREATE TABLE `$towns` (
`id` tinyint(3) unsigned NOT NULL auto_increment,
`name` varchar(30) NOT NULL default '',
`latitude` smallint(6) NOT NULL default '0',
`longitude` smallint(6) NOT NULL default '0',
`innprice` tinyint(4) NOT NULL default '0',
`mapprice` smallint(6) NOT NULL default '0',
`travelpoints` smallint(5) unsigned NOT NULL default '0',
`itemslist` text NOT NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM;
END;
if (dobatch($query) == 1) { echo "Towns table created.<br />"; } else { echo "Error creating Towns table."; }
unset($query);
if ($full == true) {
$query = <<<END
INSERT INTO `$towns` VALUES (1, 'Midworld', 0, 0, 5, 0, 0, '1,2,3,17,18,19,28,29');
INSERT INTO `$towns` VALUES (2, 'Roma', 30, 30, 10, 25, 5, '2,3,4,18,19,29');
INSERT INTO `$towns` VALUES (3, 'Bris', 70, -70, 25, 50, 15, '2,3,4,5,18,19,20,29.30');
INSERT INTO `$towns` VALUES (4, 'Kalle', -100, 100, 40, 100, 30, '5,6,8,10,12,21,22,23,29,30');
INSERT INTO `$towns` VALUES (5, 'Narcissa', -130, -130, 60, 500, 50, '4,7,9,11,13,21,22,23,29,30,31');
INSERT INTO `$towns` VALUES (6, 'Hambry', 170, 170, 90, 1000, 80, '10,11,12,13,14,23,24,30,31');
INSERT INTO `$towns` VALUES (7, 'Gilead', 200, -200, 100, 3000, 110, '12,13,14,15,24,25,26,32');
INSERT INTO `$towns` VALUES (8, 'Endworld', -250, -250, 125, 9000, 160, '16,27,33');
END;
if (dobatch($query) == 1) { echo "Towns table populated.<br />"; } else { echo "Error populating Towns table."; }
unset($query);
}
$query = <<<END
CREATE TABLE `$users` (
`id` smallint(5) unsigned NOT NULL auto_increment,
`username` varchar(30) NOT NULL default '',
`password` varchar(32) NOT NULL default '',
`email` varchar(100) NOT NULL default '',
`verify` varchar(8) NOT NULL default '0',
`charname` varchar(30) NOT NULL default '',
`regdate` datetime NOT NULL default '0000-00-00 00:00:00',
`onlinetime` datetime NOT NULL default '0000-00-00 00:00:00',
`authlevel` tinyint(3) unsigned NOT NULL default '0',
`latitude` smallint(6) NOT NULL default '0',
`longitude` smallint(6) NOT NULL default '0',
`difficulty` tinyint(3) unsigned NOT NULL default '0',
`charclass` tinyint(4) unsigned NOT NULL default '0',
`currentaction` varchar(30) NOT NULL default 'In Town',
`currentfight` tinyint(4) unsigned NOT NULL default '0',
`currentmonster` smallint(6) unsigned NOT NULL default '0',
`currentmonsterhp` smallint(6) unsigned NOT NULL default '0',
`currentmonstersleep` tinyint(3) unsigned NOT NULL default '0',
`currentmonsterimmune` tinyint(4) NOT NULL default '0',
`currentuberdamage` tinyint(3) unsigned NOT NULL default '0',
`currentuberdefense` tinyint(3) unsigned NOT NULL default '0',
`currenthp` smallint(6) unsigned NOT NULL default '15',
`currentmp` smallint(6) unsigned NOT NULL default '0',
`currenttp` smallint(6) unsigned NOT NULL default '10',
`maxhp` smallint(6) unsigned NOT NULL default '15',
`maxmp` smallint(6) unsigned NOT NULL default '0',
`maxtp` smallint(6) unsigned NOT NULL default '10',
`level` smallint(5) unsigned NOT NULL default '1',
`gold` mediumint(8) unsigned NOT NULL default '100',
`experience` mediumint(8) unsigned NOT NULL default '0',
`goldbonus` smallint(5) NOT NULL default '0',
`expbonus` smallint(5) NOT NULL default '0',
`strength` smallint(5) unsigned NOT NULL default '5',
`dexterity` smallint(5) unsigned NOT NULL default '5',
`attackpower` smallint(5) unsigned NOT NULL default '5',
`defensepower` smallint(5) unsigned NOT NULL default '5',
`weaponid` smallint(5) unsigned NOT NULL default '0',
`armorid` smallint(5) unsigned NOT NULL default '0',
`shieldid` smallint(5) unsigned NOT NULL default '0',
`slot1id` smallint(5) unsigned NOT NULL default '0',
`slot2id` smallint(5) unsigned NOT NULL default '0',
`slot3id` smallint(5) unsigned NOT NULL default '0',
`weaponname` varchar(30) NOT NULL default 'None',
`armorname` varchar(30) NOT NULL default 'None',
`shieldname` varchar(30) NOT NULL default 'None',
`slot1name` varchar(30) NOT NULL default 'None',
`slot2name` varchar(30) NOT NULL default 'None',
`slot3name` varchar(30) NOT NULL default 'None',
`dropcode` mediumint(8) unsigned NOT NULL default '0',
`spells` varchar(50) NOT NULL default '0',
`towns` varchar(50) NOT NULL default '0',
PRIMARY KEY (`id`)
) TYPE=MyISAM;
END;
if (dobatch($query) == 1) { echo "Users table created.<br />"; } else { echo "Error creating Users table."; }
unset($query);
global $start;
$time = round((getmicrotime() - $start), 4);
echo "<br />Database setup complete in $time seconds.<br /><br /><a href=\"install.php?page=3\">Click here to continue with installation.</a></body></html>";
die();
}
function third() { // Third page: gather user info for admin account.
$page = <<<END
<html>
<head>
<title>Dragon Knight Installation</title>
</head>
<body>
<b>Dragon Knight Installation: Page Three</b><br /><br />
Now you must create an administrator account so you can use the control panel. Fill out the form below to create your account. You will be able to customize the class names through the control panel once your admin account is created.<br /><br />
<form action="install.php?page=4" method="post">
<table width="50%">
<tr><td width="20%" style="vertical-align:top;">Username:</td><td><input type="text" name="username" size="30" maxlength="30" /><br /><br /><br /></td></tr>
<tr><td style="vertical-align:top;">Password:</td><td><input type="password" name="password1" size="30" maxlength="30" /></td></tr>
<tr><td style="vertical-align:top;">Verify Password:</td><td><input type="password" name="password2" size="30" maxlength="30" /><br /><br /><br /></td></tr>
<tr><td style="vertical-align:top;">Email Address:</td><td><input type="text" name="email1" size="30" maxlength="100" /></td></tr>
<tr><td style="vertical-align:top;">Verify Email:</td><td><input type="text" name="email2" size="30" maxlength="100" /><br /><br /><br /></td></tr>
<tr><td style="vertical-align:top;">Character Name:</td><td><input type="text" name="charname" size="30" maxlength="30" /></td></tr>
<tr><td style="vertical-align:top;">Character Class:</td><td><select name="charclass"><option value="1">Mage</option><option value="2">Warrior</option><option value="3">Paladin</option></select></td></tr>
<tr><td style="vertical-align:top;">Difficulty:</td><td><select name="difficulty"><option value="1">Easy</option><option value="2">Medium</option><option value="3">Hard</option></select></td></tr>
<tr><td colspan="2"><input type="submit" name="submit" value="Submit" /> <input type="reset" name="reset" value="Reset" /></td></tr>
</table>
</form>
</body>
</html>
END;
echo $page;
die();
}
function fourth() { // Final page: insert new user row, congratulate the person on a job well done.
extract($_POST);
if (!isset($username)) { die("Username is required."); }
if (!isset($password1)) { die("Password is required."); }
if (!isset($password2)) { die("Verify Password is required."); }
if ($password1 != $password2) { die("Passwords don't match."); }
if (!isset($email1)) { die("Email is required."); }
if (!isset($email2)) { die("Verify Email is required."); }
if ($email1 != $email2) { die("Emails don't match."); }
if (!isset($charname)) { die("Character Name is required."); }
$password = md5($password1);
global $dbsettings;
$users = $dbsettings["prefix"] . "_users";
$query = mysql_query("INSERT INTO $users SET id='1',username='$username',password='$password',email='$email1',verify='1',charname='$charname',charclass='$charclass',regdate=NOW(),onlinetime=NOW(),authlevel='1'") or die(mysql_error());
$page = <<<END
<html>
<head>
<title>Dragon Knight Installation</title>
</head>
<body>
<b>Dragon Knight Installation: Page Four</b><br /><br />
Your admin account was created successfully. Installation is complete.<br /><br />
Be sure to delete install.php from your Dragon Knight directory for security purposes.<br /><br />
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.<br /><br/>
Thank you for using Dragon Knight!<br /><br />-----<br /><br />
<b>Optional:</b> Dragon Knight is a free product, and does not require registration of any sort. However, there is an
optional "call home" function in the installer, which notifies the author of your game installation. The ONLY information
transmitted with this function is the URL to your game. This is included mainly to satisfy the author's curiosity about
how many copies of the game are being installed and used. If you choose to submit your URL to the author, please
<a href="install.php?page=5">click here</a>.
</body>
</html>
END;
echo $page;
die();
}
function fifth() { // Call Home function.
$url = "http://".$_SERVER["SERVER_NAME"].$_SERVER["PHP_SELF"];
if (mail("jamin@se7enet.com", "Dragon Knight Call Home", "$url") != true) { 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>."); }
$page = <<<END
<html>
<head>
<title>Dragon Knight Installation</title>
</head>
<body>
<b>Dragon Knight Installation: Page Five</b><br /><br />
Thank you for submitting your URL!<br /><br />
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>
</html>
END;
echo $page;
die();
}
?>

286
lib.php
View File

@ -1,286 +0,0 @@
<?php // lib.php :: Common functions used throughout the program.
$starttime = getmicrotime();
$numqueries = 0;
$version = "1.1.11";
$build = "";
// Handling for servers with magic_quotes turned on.
// Example from php.net.
if (get_magic_quotes_gpc()) {
$_POST = array_map('stripslashes_deep', $_POST);
$_GET = array_map('stripslashes_deep', $_GET);
$_COOKIE = array_map('stripslashes_deep', $_COOKIE);
}
$_POST = array_map('addslashes_deep', $_POST);
$_POST = array_map('html_deep', $_POST);
$_GET = array_map('addslashes_deep', $_GET);
$_GET = array_map('html_deep', $_GET);
$_COOKIE = array_map('addslashes_deep', $_COOKIE);
$_COOKIE = array_map('html_deep', $_COOKIE);
function stripslashes_deep($value) {
$value = is_array($value) ?
array_map('stripslashes_deep', $value) :
stripslashes($value);
return $value;
}
function addslashes_deep($value) {
$value = is_array($value) ?
array_map('addslashes_deep', $value) :
addslashes($value);
return $value;
}
function html_deep($value) {
$value = is_array($value) ?
array_map('html_deep', $value) :
htmlspecialchars($value);
return $value;
}
function opendb() { // Open database connection.
include('config.php');
extract($dbsettings);
$link = mysql_connect($server, $user, $pass) or die(mysql_error());
mysql_select_db($name) or die(mysql_error());
return $link;
}
function doquery($query, $table) { // Something of a tiny little database abstraction layer.
include('config.php');
global $numqueries;
$sqlquery = mysql_query(str_replace("{{table}}", $dbsettings["prefix"] . "_" . $table, $query)) or die(mysql_error());
$numqueries++;
return $sqlquery;
}
function gettemplate($templatename) { // SQL query for the template.
$filename = "templates/" . $templatename . ".php";
include("$filename");
return $template;
}
function parsetemplate($template, $array) { // Replace template with proper content.
foreach($array as $a => $b) {
$template = str_replace("{{{$a}}}", $b, $template);
}
return $template;
}
function getmicrotime() { // Used for timing script operations.
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
function prettydate($uglydate) { // Change the MySQL date format (YYYY-MM-DD) into something friendlier.
return date("F j, Y", mktime(0,0,0,substr($uglydate, 5, 2),substr($uglydate, 8, 2),substr($uglydate, 0, 4)));
}
function prettyforumdate($uglydate) { // Change the MySQL date format (YYYY-MM-DD) into something friendlier.
return date("F j, Y", mktime(0,0,0,substr($uglydate, 5, 2),substr($uglydate, 8, 2),substr($uglydate, 0, 4)));
}
function is_email($email) { // Thanks to "mail(at)philipp-louis.de" from php.net!
return(preg_match("/^[-_.[:alnum:]]+@((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i",$email));
}
function makesafe($d) {
$d = str_replace("\t","",$d);
$d = str_replace("<","&#60;",$d);
$d = str_replace(">","&#62;",$d);
$d = str_replace("\n","",$d);
$d = str_replace("|","??",$d);
$d = str_replace(" "," &nbsp;",$d);
return $d;
}
function admindisplay($content, $title) { // Finalize page and output to browser.
global $numqueries, $userrow, $controlrow, $starttime, $version, $build;
if (!isset($controlrow)) {
$controlquery = doquery("SELECT * FROM {{table}} WHERE id='1' LIMIT 1", "control");
$controlrow = mysql_fetch_array($controlquery);
}
$template = gettemplate("admin");
// Make page tags for XHTML validation.
$xml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"
. "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"DTD/xhtml1-transitional.dtd\">\n"
. "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n";
$finalarray = array(
"title"=>$title,
"content"=>$content,
"totaltime"=>round(getmicrotime() - $starttime, 4),
"numqueries"=>$numqueries,
"version"=>$version,
"build"=>$build);
$page = parsetemplate($template, $finalarray);
$page = $xml . $page;
if ($controlrow["compression"] == 1) { ob_start("ob_gzhandler"); }
echo $page;
die();
}
function display($content, $title, $topnav=true, $leftnav=true, $rightnav=true, $badstart=false) { // Finalize page and output to browser.
global $numqueries, $userrow, $controlrow, $version, $build;
if (!isset($controlrow)) {
$controlquery = doquery("SELECT * FROM {{table}} WHERE id='1' LIMIT 1", "control");
$controlrow = mysql_fetch_array($controlquery);
}
if ($badstart == false) { global $starttime; } else { $starttime = $badstart; }
// Make page tags for XHTML validation.
$xml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"
. "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"DTD/xhtml1-transitional.dtd\">\n"
. "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n";
$template = gettemplate("primary");
if ($rightnav == true) { $rightnav = gettemplate("rightnav"); } else { $rightnav = ""; }
if ($leftnav == true) { $leftnav = gettemplate("leftnav"); } else { $leftnav = ""; }
if ($topnav == true) {
$topnav = "<a href=\"login.php?do=logout\"><img src=\"images/button_logout.gif\" alt=\"Log Out\" title=\"Log Out\" border=\"0\" /></a> <a href=\"help.php\"><img src=\"images/button_help.gif\" alt=\"Help\" title=\"Help\" border=\"0\" /></a>";
} else {
$topnav = "<a href=\"login.php?do=login\"><img src=\"images/button_login.gif\" alt=\"Log In\" title=\"Log In\" border=\"0\" /></a> <a href=\"users.php?do=register\"><img src=\"images/button_register.gif\" alt=\"Register\" title=\"Register\" border=\"0\" /></a> <a href=\"help.php\"><img src=\"images/button_help.gif\" alt=\"Help\" title=\"Help\" border=\"0\" /></a>";
}
if (isset($userrow)) {
// Get userrow again, in case something has been updated.
$userquery = doquery("SELECT * FROM {{table}} WHERE id='".$userrow["id"]."' LIMIT 1", "users");
unset($userrow);
$userrow = mysql_fetch_array($userquery);
// Current town name.
if ($userrow["currentaction"] == "In Town") {
$townquery = doquery("SELECT * FROM {{table}} WHERE latitude='".$userrow["latitude"]."' AND longitude='".$userrow["longitude"]."' LIMIT 1", "towns");
$townrow = mysql_fetch_array($townquery);
$userrow["currenttown"] = "Welcome to <b>".$townrow["name"]."</b>.<br /><br />";
} else {
$userrow["currenttown"] = "";
}
if ($controlrow["forumtype"] == 0) { $userrow["forumslink"] = ""; }
elseif ($controlrow["forumtype"] == 1) { $userrow["forumslink"] = "<a href=\"forum.php\">Forum</a><br />"; }
elseif ($controlrow["forumtype"] == 2) { $userrow["forumslink"] = "<a href=\"".$controlrow["forumaddress"]."\">Forum</a><br />"; }
// Format various userrow stuffs...
if ($userrow["latitude"] < 0) { $userrow["latitude"] = $userrow["latitude"] * -1 . "S"; } else { $userrow["latitude"] .= "N"; }
if ($userrow["longitude"] < 0) { $userrow["longitude"] = $userrow["longitude"] * -1 . "W"; } else { $userrow["longitude"] .= "E"; }
$userrow["experience"] = number_format($userrow["experience"]);
$userrow["gold"] = number_format($userrow["gold"]);
if ($userrow["authlevel"] == 1) { $userrow["adminlink"] = "<a href=\"admin.php\">Admin</a><br />"; } else { $userrow["adminlink"] = ""; }
// HP/MP/TP bars.
$stathp = ceil($userrow["currenthp"] / $userrow["maxhp"] * 100);
if ($userrow["maxmp"] != 0) { $statmp = ceil($userrow["currentmp"] / $userrow["maxmp"] * 100); } else { $statmp = 0; }
$stattp = ceil($userrow["currenttp"] / $userrow["maxtp"] * 100);
$stattable = "<table width=\"100\"><tr><td width=\"33%\">\n";
$stattable .= "<table cellspacing=\"0\" cellpadding=\"0\"><tr><td style=\"padding:0px; width:15px; height:100px; border:solid 1px black; vertical-align:bottom;\">\n";
if ($stathp >= 66) { $stattable .= "<div style=\"padding:0px; height:".$stathp."px; border-top:solid 1px black; background-image:url(images/bars_green.gif);\"><img src=\"images/bars_green.gif\" alt=\"\" /></div>"; }
if ($stathp < 66 && $stathp >= 33) { $stattable .= "<div style=\"padding:0px; height:".$stathp."px; border-top:solid 1px black; background-image:url(images/bars_yellow.gif);\"><img src=\"images/bars_yellow.gif\" alt=\"\" /></div>"; }
if ($stathp < 33) { $stattable .= "<div style=\"padding:0px; height:".$stathp."px; border-top:solid 1px black; background-image:url(images/bars_red.gif);\"><img src=\"images/bars_red.gif\" alt=\"\" /></div>"; }
$stattable .= "</td></tr></table></td><td width=\"33%\">\n";
$stattable .= "<table cellspacing=\"0\" cellpadding=\"0\"><tr><td style=\"padding:0px; width:15px; height:100px; border:solid 1px black; vertical-align:bottom;\">\n";
if ($statmp >= 66) { $stattable .= "<div style=\"padding:0px; height:".$statmp."px; border-top:solid 1px black; background-image:url(images/bars_green.gif);\"><img src=\"images/bars_green.gif\" alt=\"\" /></div>"; }
if ($statmp < 66 && $statmp >= 33) { $stattable .= "<div style=\"padding:0px; height:".$statmp."px; border-top:solid 1px black; background-image:url(images/bars_yellow.gif);\"><img src=\"images/bars_yellow.gif\" alt=\"\" /></div>"; }
if ($statmp < 33) { $stattable .= "<div style=\"padding:0px; height:".$statmp."px; border-top:solid 1px black; background-image:url(images/bars_red.gif);\"><img src=\"images/bars_red.gif\" alt=\"\" /></div>"; }
$stattable .= "</td></tr></table></td><td width=\"33%\">\n";
$stattable .= "<table cellspacing=\"0\" cellpadding=\"0\"><tr><td style=\"padding:0px; width:15px; height:100px; border:solid 1px black; vertical-align:bottom;\">\n";
if ($stattp >= 66) { $stattable .= "<div style=\"padding:0px; height:".$stattp."px; border-top:solid 1px black; background-image:url(images/bars_green.gif);\"><img src=\"images/bars_green.gif\" alt=\"\" /></div>"; }
if ($stattp < 66 && $stattp >= 33) { $stattable .= "<div style=\"padding:0px; height:".$stattp."px; border-top:solid 1px black; background-image:url(images/bars_yellow.gif);\"><img src=\"images/bars_yellow.gif\" alt=\"\" /></div>"; }
if ($stattp < 33) { $stattable .= "<div style=\"padding:0px; height:".$stattp."px; border-top:solid 1px black; background-image:url(images/bars_red.gif);\"><img src=\"images/bars_red.gif\" alt=\"\" /></div>"; }
$stattable .= "</td></tr></table></td>\n";
$stattable .= "</tr><tr><td>HP</td><td>MP</td><td>TP</td></tr></table>\n";
$userrow["statbars"] = $stattable;
// Now make numbers stand out if they're low.
if ($userrow["currenthp"] <= ($userrow["maxhp"]/5)) { $userrow["currenthp"] = "<blink><span class=\"highlight\"><b>*".$userrow["currenthp"]."*</b></span></blink>"; }
if ($userrow["currentmp"] <= ($userrow["maxmp"]/5)) { $userrow["currentmp"] = "<blink><span class=\"highlight\"><b>*".$userrow["currentmp"]."*</b></span></blink>"; }
$spellquery = doquery("SELECT id,name,type FROM {{table}}","spells");
$userspells = explode(",",$userrow["spells"]);
$userrow["magiclist"] = "";
while ($spellrow = mysql_fetch_array($spellquery)) {
$spell = false;
foreach($userspells as $a => $b) {
if ($b == $spellrow["id"] && $spellrow["type"] == 1) { $spell = true; }
}
if ($spell == true) {
$userrow["magiclist"] .= "<a href=\"index.php?do=spell:".$spellrow["id"]."\">".$spellrow["name"]."</a><br />";
}
}
if ($userrow["magiclist"] == "") { $userrow["magiclist"] = "None"; }
// Travel To list.
$townslist = explode(",",$userrow["towns"]);
$townquery2 = doquery("SELECT * FROM {{table}} ORDER BY id", "towns");
$userrow["townslist"] = "";
while ($townrow2 = mysql_fetch_array($townquery2)) {
$town = false;
foreach($townslist as $a => $b) {
if ($b == $townrow2["id"]) { $town = true; }
}
if ($town == true) {
$userrow["townslist"] .= "<a href=\"index.php?do=gotown:".$townrow2["id"]."\">".$townrow2["name"]."</a><br />\n";
}
}
} else {
$userrow = array();
}
$finalarray = array(
"dkgamename"=>$controlrow["gamename"],
"title"=>$title,
"content"=>$content,
"rightnav"=>parsetemplate($rightnav,$userrow),
"leftnav"=>parsetemplate($leftnav,$userrow),
"topnav"=>$topnav,
"totaltime"=>round(getmicrotime() - $starttime, 4),
"numqueries"=>$numqueries,
"version"=>$version,
"build"=>$build);
$page = parsetemplate($template, $finalarray);
$page = $xml . $page;
if ($controlrow["compression"] == 1) { ob_start("ob_gzhandler"); }
echo $page;
die();
}
?>

View File

@ -1,42 +0,0 @@
<?php // login.php :: Handles logins and cookies.
include('lib.php');
if (isset($_GET["do"])) {
if ($_GET["do"] == "login") { login(); }
elseif ($_GET["do"] == "logout") { logout(); }
}
function login() {
include('config.php');
$link = opendb();
if (isset($_POST["submit"])) {
$query = doquery("SELECT * FROM {{table}} WHERE username='".$_POST["username"]."' AND password='".md5($_POST["password"])."' LIMIT 1", "users");
if (mysql_num_rows($query) != 1) { die("Invalid username or password. Please go back and try again."); }
$row = mysql_fetch_array($query);
if (isset($_POST["rememberme"])) { $expiretime = time()+31536000; $rememberme = 1; } else { $expiretime = 0; $rememberme = 0; }
$cookie = $row["id"] . " " . $row["username"] . " " . md5($row["password"] . "--" . $dbsettings["secretword"]) . " " . $rememberme;
setcookie("dkgame", $cookie, $expiretime, "/", "", 0);
header("Location: index.php");
die();
}
$page = gettemplate("login");
$title = "Log In";
display($page, $title, false, false, false, false);
}
function logout() {
setcookie("dkgame", "", time()-100000, "/", "", 0);
header("Location: login.php?do=login");
die();
}
?>

129
public/css/admin.css Normal file
View File

@ -0,0 +1,129 @@
:root {
--font-size: 16px;
--font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
font-size: var(--font-size);
font-family: var(--font-family);
}
body {
padding: 2rem;
color: rgb(108, 108, 108);
background-color: rgb(245, 245, 245);
}
h1, h2, h3, h4, h5 {
color: rgb(30, 30, 30);
}
div#admin-container {
max-width: 1280px;
margin: 0 auto;
padding: 1rem;
}
header {
margin-bottom: 2rem;
}
main {
display: flex;
gap: 2rem;
margin-bottom: 2rem;
}
main > nav {
flex: 0 0 auto;
}
main > section {
flex: 1;
}
table {
width: 100%;
border-collapse: collapse;
outline-width: none;
font-family: var(--font-family);
border: 1px solid rgba(0, 0, 0, 0.1);
& > caption {
margin: 1rem;
}
& :is(td,th) {
border: 1px solid rgba(0, 0, 0, 0.4);
padding: 0.5rem 1rem;
}
& thead tr {
background: rgba(0, 0, 0, 0.1);
}
& tbody tr:nth-of-type(even) {
background: rgba(0, 0, 0, 0.1);
&:hover { background: rgba(0, 0, 0, 0.2); }
}
td:hover {
color: white;
background: rgba(0, 0, 0, 0.1);
}
tr:hover {
background: rgba(0, 0, 0, 0.2);
}
}
.table-wrapper {
width: 100%; /* Ensure the wrapper takes 100% of the parent's width */
max-height: 300px; /* Set the desired height limit */
overflow-x: auto; /* Enable horizontal scrolling if the table overflows */
overflow-y: auto; /* Enable vertical scrolling if needed */
display: block; /* Ensure block-level behavior */
-webkit-overflow-scrolling: touch; /* Smooth scrolling on touch devices */
}
a {
color: #015df7;
text-decoration: none;
cursor: pointer;
&:hover {
color: hsl(218, 99%, 29%);
text-decoration: underline;
}
}
.small {
font: 10px verdana;
}
.highlight {
color: red;
}
.light {
color: #999999;
}
.title {
border: solid 1px black;
background-color: #eeeeee;
font-weight: bold;
padding: 5px;
margin: 3px;
}
footer {
display: flex;
justify-content: space-around;
font-size: 0.8rem;
padding: 0.5rem;
margin: 2rem 0;
}

219
public/css/dk.css Normal file
View File

@ -0,0 +1,219 @@
:root {
--font-size: 12px;
}
* {
box-sizing: border-box;
}
html {
font-size: var(--font-size);
font-family: sans-serif;
}
body {
background-image: url('/img/backgrounds/classic.jpg');
scrollbar-gutter: stable both-edges;
&.skin-1 {
background-image: url('/img/backgrounds/snowstorm.jpg');
}
}
div#game-container {
max-width: 1280px;
margin: 0 auto;
padding: 1rem;
}
header {
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: solid 2px black;
padding-bottom: 0.5rem;
}
main {
width: 100%;
display: flex;
margin-bottom: 0.5rem;
}
main > section {
padding: 0.75rem;
}
main > section > section {
margin-bottom: 2rem;
}
main section#left {
width: 180px;
flex-shrink: 0;
border-right: solid 2px black;
}
main section#middle {
flex-grow: 1;
}
main section#right {
width: 180px;
flex-shrink: 0;
border-left: solid 2px black;
}
footer {
display: flex;
justify-content: space-around;
border: solid 1px black;
background-color: #eeeeee;
font-size: 0.8rem;
padding: 0.5rem;
}
table {
border-style: none;
padding: 0px;
font-size: var(--font-size);
}
td {
border-style: none;
padding: 3px;
vertical-align: top;
}
a {
color: #663300;
text-decoration: none;
font-weight: bold;
cursor: pointer;
}
a:hover {
color: #330000;
}
.small {
font-size: 0.8rem;
}
.highlight {
color: red;
}
.light {
color: #999999;
}
.title {
border: solid 1px black;
background-color: #eeeeee;
font-weight: bold;
padding: 5px;
font-size: 1.2rem;
font-family: serif;
margin-bottom: 0.5rem;
}
.copyright {
border: solid 1px black;
background-color: #eeeeee;
font: 10px verdana;
}
.move-compass {
width: 128px;
height: 128px;
display: flex;
flex-direction: column;
background-image: url('/img/compass.webp');
margin: 0.5rem auto;
}
.move-compass div.mid {
display: flex;
}
.move-compass button {
background-color: transparent;
border: none;
color: transparent; /* Hide the text */
background-size: cover; /* Ensure the background image fills the button */
cursor: pointer;
}
.move-compass button:hover {
background-color: rgba(225, 16, 16, 0.5);
}
.move-compass button.north {
width: 128px;
height: 40px;
}
.move-compass button.west {
width: 63px;
height: 50px;
}
.move-compass button.east {
width: 63px;
height: 50px;
}
.move-compass button.south {
width: 128px;
height: 38px;
}
div.town-content {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1rem;
}
div.town-content div.options, div.town-content div.news {
grid-column: span 2;
}
div.stat-table div.stat-row {
display: flex;
justify-content: space-around;
gap: 0.5rem;
}
div.stat-bar {
position: relative;
}
div.stat-bar > div {
width: 100%;
position: absolute;
bottom: 0;
}
#babblebox > .messages {
max-height: 200px;
overflow-y: auto;
}
#babblebox > .messages .message {
padding: 0.25rem;
background-color: #eee;
&:nth-child(even) {
background-color: white;
}
}
#babblebox > form {
margin-top: 0 !important;
& > input[type="text"] {
width: 100%;
margin-bottom: 0.5rem;
}
}

73
public/css/help.css Normal file
View File

@ -0,0 +1,73 @@
:root {
--font-size: 14px;
}
html {
font-size: var(--font-size);
font-family: sans-serif;
}
body {
background-image: url('/img/backgrounds/classic.jpg');
padding: 2rem;
}
table {
border-style: none;
padding: 0px;
}
tr:nth-child(even) {
background-color: white;
}
td {
border-style: none;
padding: 3px;
vertical-align: top;
}
td.top {
border-bottom: solid 2px black;
}
td.left {
width: 150px;
border-right: solid 2px black;
}
td.right {
width: 150px;
border-left: solid 2px black;
}
a {
color: #663300;
text-decoration: none;
font-weight: bold;
}
a:hover {
color: #330000;
}
.small {
font: 10px verdana;
}
.highlight {
color: red;
}
.light {
color: #999999;
}
.title {
border: solid 1px black;
background-color: #eeeeee;
font-weight: bold;
padding: 5px;
margin: 3px;
}
.copyright {
border: solid 1px black;
background-color: #eeeeee;
font: 10px verdana;
}
footer {
display: flex;
justify-content: space-around;
font-size: 0.8rem;
padding: 0.5rem;
margin-top: 2rem;
}

View File

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

View File

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 KiB

View File

Before

Width:  |  Height:  |  Size: 94 B

After

Width:  |  Height:  |  Size: 94 B

View File

Before

Width:  |  Height:  |  Size: 94 B

After

Width:  |  Height:  |  Size: 94 B

View File

Before

Width:  |  Height:  |  Size: 94 B

After

Width:  |  Height:  |  Size: 94 B

View File

Before

Width:  |  Height:  |  Size: 527 B

After

Width:  |  Height:  |  Size: 527 B

View File

Before

Width:  |  Height:  |  Size: 575 B

After

Width:  |  Height:  |  Size: 575 B

View File

Before

Width:  |  Height:  |  Size: 561 B

After

Width:  |  Height:  |  Size: 561 B

View File

Before

Width:  |  Height:  |  Size: 402 B

After

Width:  |  Height:  |  Size: 402 B

View File

Before

Width:  |  Height:  |  Size: 551 B

After

Width:  |  Height:  |  Size: 551 B

View File

Before

Width:  |  Height:  |  Size: 486 B

After

Width:  |  Height:  |  Size: 486 B

View File

Before

Width:  |  Height:  |  Size: 474 B

After

Width:  |  Height:  |  Size: 474 B

View File

Before

Width:  |  Height:  |  Size: 500 B

After

Width:  |  Height:  |  Size: 500 B

View File

Before

Width:  |  Height:  |  Size: 523 B

After

Width:  |  Height:  |  Size: 523 B

View File

Before

Width:  |  Height:  |  Size: 565 B

After

Width:  |  Height:  |  Size: 565 B

View File

Before

Width:  |  Height:  |  Size: 469 B

After

Width:  |  Height:  |  Size: 469 B

View File

Before

Width:  |  Height:  |  Size: 469 B

After

Width:  |  Height:  |  Size: 469 B

View File

Before

Width:  |  Height:  |  Size: 461 B

After

Width:  |  Height:  |  Size: 461 B

BIN
public/img/compass.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 147 B

After

Width:  |  Height:  |  Size: 147 B

View File

Before

Width:  |  Height:  |  Size: 121 B

After

Width:  |  Height:  |  Size: 121 B

View File

Before

Width:  |  Height:  |  Size: 112 B

After

Width:  |  Height:  |  Size: 112 B

View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Before

Width:  |  Height:  |  Size: 1005 B

After

Width:  |  Height:  |  Size: 1005 B

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

135
public/index.php Normal file
View File

@ -0,0 +1,135 @@
<?php
// index.php :: Primary program script, evil alien overlord, you decide.
require_once '../src/bootstrap.php';
// Do an early return with babblebox data if that's what's being requested
if ($uri[0] === 'babblebox' && (isset($uri[1]) && $uri[1] === 'messages')) {
echo babblebox_messages();
exit;
}
$r = new Router;
$r->get('/', 'index');
$r->post('/move', 'Explore\move');
$r->get('/spell/:id', 'healspells');
$r->get('/character', 'show_character_info');
$r->get('/character/:id', 'show_character_info');
$r->get('/showmap', 'show_map');
$r->form('/babblebox', 'babblebox');
$r->get('/babblebox/messages', 'babblebox_messages');
Towns\register_routes($r);
Fights\register_routes($r);
Users\register_routes($r);
Help\register_routes($r);
Forum\register_routes($r);
Install\register_routes($r);
Admin\register_routes($r);
/*
NINJA! 🥷
*/
$r->get('/ninja', function() {
exit('NINJA! 🥷');
});
// [code, handler, params, middleware]
$l = $r->lookup($_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI']);
if (is_int($l)) exit("Error: $l");
echo render_response($uri, $l['handler'](...$l['params'] ?? []));
exit;
/**
* Return a page for a couple generic actions.
*/
function index(): string
{
if (user()->currentaction === "In Town") {
$page = Towns\town();
} elseif (user()->currentaction === "Exploring") {
$page = Explore\explore();
} elseif (user()->currentaction === "Fighting") {
redirect('/fight');
}
return $page;
}
/**
* Show a character's info. Defaults to the currently logged in user.
*/
function show_character_info(int $id = 0): string
{
$user = $id !== 0 ? User::find($id) : user();
if ($user === false) exit('Failed to show info for user ID '.$id);
$level = db()->query("SELECT `{$user->charclass}_exp` FROM levels WHERE id=? LIMIT 1;", [$user->level + 1])->fetchArray(SQLITE3_ASSOC);
$spells = $user->spells();
$magic_list = 'None';
if (!empty($spells)) {
$magic_list = '';
foreach ($spells as $spell) $magic_list .= $spell['name'].'<br>';
}
$showchar = render('show_char', [
'char' => $user,
'level' => $level,
'magic_list' => $magic_list
]);
return render('layouts/minimal', ['content' => $showchar, 'title' => $user->username.' Information']);
}
/**
* Show the user their position on the current world map. Only works with a game size of 250 and the default towns 😅
*/
function show_map()
{
$pos = sprintf(
'<div style="position: absolute; width: 5px; height: 5px; border-radius: 1000px; border: solid 1px black; background-color: red; left: %dpx; top: %dpx;"></div>',
round(258 + user()->longitude * (500 / 500) - 3),
round(258 - user()->latitude * (500 / 500) - 3)
);
echo render('layouts/minimal', [
'content' => '<img src="/img/map.gif" alt="Map">'.$pos,
'title' => 'Map'
]);
}
/**
* Handle a POST request to send a new babblebox message.
*/
function babblebox()
{
if (is_post()) {
$content = trim($_POST["babble"]);
if (!empty($content)) {
db()->query('INSERT INTO babble (posttime, author, babble) VALUES (CURRENT_TIMESTAMP, ?, ?);',
[user()->username, $content]);
}
return babblebox_messages();
}
}
/**
* The handler that is polled by HTMX for new babblebox messages.
*/
function babblebox_messages(): string
{
if (user() === false) return '';
$query = db()->query('SELECT * FROM babble ORDER BY id ASC LIMIT 40;');
$has_chats = false;
$messages = '';
while ($row = $query->fetchArray(SQLITE3_ASSOC)) {
$has_chats = true;
$messages .= '<div class="message">[<b>' . $row['author'] . '</b>] ' . make_safe($row['babble']) . '</div>';
}
if (!$has_chats) $messages = 'There are no messages. :(';
return $messages;
}

1
public/js/htmx.js Normal file

File diff suppressed because one or more lines are too long

566
src/actions/admin.php Normal file
View File

@ -0,0 +1,566 @@
<?php
// admin.php :: primary administration script.
namespace Admin;
use Router;
use SQLite3Result;
function register_routes(Router $r): Router
{
if (user() !== false && user()->authlevel === 1) {
$r->get('/admin', 'Admin\donothing');
$r->form('/admin/main', 'Admin\primary');
$r->get('/admin/items', 'Admin\items');
$r->form('/admin/items/:id', 'Admin\edit_item');
$r->get('/admin/drops', 'Admin\drops');
$r->form('/admin/drops/:id', 'Admin\edit_drop');
$r->get('/admin/towns', 'Admin\towns');
$r->form('/admin/towns/:id', 'Admin\edit_town');
$r->get('/admin/monsters', 'Admin\monsters');
$r->form('/admin/monsters/:id', 'Admin\edit_monster');
$r->get('/admin/levels', 'Admin\levels');
$r->post('/admin/levels', 'Admin\edit_level');
$r->get('/admin/spells', 'Admin\spells');
$r->form('/admin/spells/:id', 'Admin\edit_spell');
$r->get('/admin/users', 'Admin\users');
$r->form('/admin/users/:id', 'Admin\edit_user');
$r->form('/admin/news', 'Admin\add_news');
}
return $r;
}
/**
* Home page for the admin panel.
*/
function donothing(): string
{
page_title('Admin');
return <<<HTML
Welcome to the administration section. Use the links on the left bar to control and edit various
elements of the game.
<br><br>
Please note that the control panel has been created mostly as a shortcut for certain individual settings. It is
meant for use primarily with editing one thing at a time. If you need to completely replace an entire table
(say, to replace all stock monsters with your own new ones), it is suggested that you use a more in-depth
database tool such as <a href="https://sqlitebrowser.org/" target="_new">SQLite Browser</a>.
<br><br>
Also, you should be aware that certain portions of the DK code are dependent on the formatting of certain
database results (for example, the special attributes on item drops). While I have attempted to point these out
throughout the admin script, you should definitely pay attention and be careful when editing some fields,
because mistakes in the database content may result in script errors or your game breaking completely.
HTML;
}
/**
* Main settings that get written to .env
*/
function primary(): string
{
if (is_post()) {
$form = validate($_POST, [
'gamename' => ['alphanum-spaces'],
'gamesize' => ['int', 'min:5'],
'class1name' => ['alpha-spaces'],
'class2name' => ['alpha-spaces'],
'class3name' => ['alpha-spaces'],
'gameopen' => ['bool'],
'verifyemail' => ['bool'],
'shownews' => ['bool'],
'showonline' => ['bool'],
'showbabble' => ['bool']
]);
if ($form['valid']) {
$form = $form['data'];
if (($form['gamesize'] % 5) != 0) exit('Map size must be divisible by five.');
// @todo
// write changes to .env
$page = 'Main settings updated.';
} else {
$error_list = ul_from_validate_errors($form['errors']);
$page = <<<HTML
<b>Errors:</b><br>
<div style="color: red;">{$error_list}</div><br>
Please go back and try again.
HTML;
}
} else {
$page = render('admin/main_settings');
}
page_title('Admin: Main Settings');
return $page;
}
/**
* Show the full list of items that can be edited.
*/
function items(): string
{
$items = db()->query('SELECT * FROM items ORDER BY id;');
$page = "<h2>Edit Items</h2>Click an item's name or ID to edit it.<br><br>\n";
$page .= build_bulk_table($items, 'name', '/admin/items');
page_title('Admin: Items');
return $page;
}
/**
* Shows the form for editing an item via GET, processes edits via POST
*/
function edit_item(int $id): string
{
$item = get_item($id);
if (is_post()) {
$page = handle_edit_form($id, 'items', validate($_POST, [
'name' => [],
'type' => ['int', 'in:1,2,3'],
'buycost' => ['int', 'min:0'],
'attribute' => ['int', 'min:0'],
'special' => ['default:X']
]));
} else {
$page = render('admin/edit_item', ['item' => $item]);
}
page_title('Admin: Editing '.$item['name']);
return $page;
}
/**
* Show the full list of drops that can be edited
*/
function drops()
{
$drops = db()->query('SELECT * FROM drops ORDER BY id;');
$page = "<h2>Edit Drops</h2>Click an item's name to edit it.<br><br>\n";
$page .= build_bulk_table($drops, 'name', '/admin/drops');
page_title('Admin: Drops');
return $page;
}
/**
* Show the form to edit drops via GET, process those edits via POST
*/
function edit_drop(int $id): string
{
$drop = get_drop($id);
if (is_post()) {
$page = handle_edit_form($id, 'drops', validate($_POST, [
'name' => [],
'mlevel' => ['int', 'min:1'],
'attribute1' => [],
'attribute2' => ['default:X'],
]));
} else {
$page = render('admin/edit_drop', ['drop' => $drop]);
}
page_title('Admin: Editing '.$drop['name']);
return $page;
}
/**
* Generate the list of towns that can be edited.
*/
function towns(): string
{
$towns = db()->query('SELECT * FROM towns ORDER BY id;');
$page = "<h2>Edit Towns</h2>Click an town's name or ID to edit it.<br><br>\n";
$page .= build_bulk_table($towns, 'name', '/admin/towns');
page_title('Admin: Towns');
return $page;
}
/**
* Save any changes to the town made.
*/
function edit_town(int $id): string
{
$town = get_town_by_id($id);
if (is_post()) {
$page = handle_edit_form($id, 'towns', validate($_POST, [
'name' => [],
'latitude' => ['int', 'min:0', 'max:'.env('game_size')],
'longitude' => ['int', 'min:0', 'max:'.env('game_size')],
'innprice' => ['int', 'min:0'],
'mapprice' => ['int', 'min:0'],
'travelpoints' => ['int', 'min:0'],
'itemslist' => ['optional']
]));
} else {
$page = render('admin/edit_town', ['town' => $town]);
}
page_title('Admin: Editing '.$town['name']);
return $page;
}
/**
* List the monsters available to edit.
*/
function monsters()
{
$max_level = db()->query('SELECT level FROM monsters ORDER BY level DESC LIMIT 1;')->fetchArray(SQLITE3_ASSOC)['level'];
$monsters = db()->query('SELECT * FROM monsters ORDER BY id;');
$page = "<h2>Edit Monsters</h2>";
if ((env('game_size') / 5) !== $max_level) {
$page .= "<span class=\"highlight\">Note:</span> Your highest monster level does not match with your entered map size. Highest monster level should be ".(env('game_size') / 5).", yours is $max_level. Please fix this before opening the game to the public.<br>";
} else {
$page .= "Monster level and map size match. No further actions are required for map compatibility.<br>";
}
$page .= "Click an monster's name or ID to edit it.<br><br>\n";
$page .= build_bulk_table($monsters, 'name', '/admin/monsters');
page_title('Admin: Monsters');
return $page;
}
/**
* Handle the actual editing of the monster.
*/
function edit_monster(int $id): string
{
$monster = get_monster($id);
if (is_post()) {
$page = handle_edit_form($id, 'monsters', validate($_POST, [
'name' => [],
'maxhp' => ['int', 'min:1'],
'maxdam' => ['int', 'min:0'],
'armor' => ['int', 'min:0'],
'level' => ['int', 'min:1'],
'maxexp' => ['int', 'min:0'],
'maxgold' => ['int', 'min:0'],
'immune' => ['in:0,1,2']
]));
} else {
$page = render('admin/edit_monster', ['monster' => $monster]);
}
page_title('Admin: Editing '.$monster['name']);
return $page;
}
/**
* List all spells available to edit.
*/
function spells(): string
{
$page = "<h2>Edit Spells</h2>Click an spell's name to edit it.<br><br>\n";
$spells = db()->query('SELECT * FROM spells ORDER BY id;');
$page .= build_bulk_table($spells, 'name', '/admin/spells');
page_title('Admin: Spells');
return $page;
}
/**
* Handle the editing of an individual spell.
*/
function edit_spell(int $id): string
{
$spell = get_spell($id);
if (is_post()) {
$page = handle_edit_form($id, 'spells', validate($_POST, [
'name' => [],
'mp' => ['int', 'min:0'],
'attribute' => ['int', 'min:0'],
'type' => ['in:1,2,3,4,5']
]));
} else {
$page = render('admin/edit_spell', ['spell' => $spell]);
}
page_title('Admin: Editing '.$spell['name']);
return $page;
}
/**
* List all editable levels.
*/
function levels(): string
{
$max_level = db()->query('SELECT id FROM levels ORDER BY id DESC LIMIT 1;')->fetchArray(SQLITE3_ASSOC)['id'];
$page = <<<HTML
<h2>Edit Levels</h2>
Select a level number from the dropdown box to edit it.<br><br>
<form action="/admin/levels" method="post" hx-post="/admin/levels" hx-target="#main">
<select name="level">
HTML;
for ($i = 2; $i < $max_level; $i++) $page .= "<option value=\"$i\">$i</option>\n";
$page .= <<<HTML
</select>
<button type="submit">Edit</button>
</form>
HTML;
page_title('Admin: Levels');
return $page;
}
/**
* Handle the editing of a level.
*/
function edit_level()
{
if (!isset($_POST['level'])) return 'No level to edit.';
$id = $_POST['level'];
$level = db()->query('SELECT * FROM levels WHERE id=? LIMIT 1;', [$id])->fetchArray(SQLITE3_ASSOC);
if (is_post() && isset($_POST['save'])) {
unset($_POST['save']);
unset($_POST['level']);
$page = handle_edit_form($id, 'levels', validate($_POST, [
'1_exp' => ['int', 'min:0'],
'1_hp' => ['int', 'min:0'],
'1_mp' => ['int', 'min:0'],
'1_tp' => ['int', 'min:0'],
'1_strength' => ['int', 'min:0'],
'1_dexterity' => ['int', 'min:0'],
'1_spells' => ['int', 'min:0'],
'2_exp' => ['int', 'min:0'],
'2_hp' => ['int', 'min:0'],
'2_mp' => ['int', 'min:0'],
'2_tp' => ['int', 'min:0'],
'2_strength' => ['int', 'min:0'],
'2_dexterity' => ['int', 'min:0'],
'2_spells' => ['int', 'min:0'],
'3_exp' => ['int', 'min:0'],
'3_hp' => ['int', 'min:0'],
'3_mp' => ['int', 'min:0'],
'3_tp' => ['int', 'min:0'],
'3_strength' => ['int', 'min:0'],
'3_dexterity' => ['int', 'min:0'],
'3_spells' => ['int', 'min:0']
]), 'Level <b>'.$id.'</b> updated.');
} else {
$page = render('admin/edit_level', ['level' => $level]);
}
page_title('Admin: Editing Level '.$id);
return $page;
}
function users()
{
$users = db()->query('SELECT * FROM users ORDER BY id;');
$page = "<h2>Edit Users</h2>Click a username or ID to edit the account.<br><br><div class=\"table-wrapper\">";
$page .= build_bulk_table($users, 'username', '/admin/users');
page_title('Admin: Users');
return $page . '</div>';
}
/**
* Handle editing a user.
*/
function edit_user(int $id): string
{
$user = db()->query('SELECT * FROM users WHERE id = ? LIMIT 1;', [$id])->fetchArray(SQLITE3_ASSOC);
if (is_post()) {
$form = validate($_POST, [
'username' => ['length:3-18', 'alpha-spaces', 'unique:users,username'],
'verify' => [],
'authlevel' => ['int'],
'email' => ['email', 'unique:users,email'],
'charclass' => ['in:1,2,3'],
'latitude' => ['int', 'min:0', 'max:'.env('game_size')],
'longitude' => ['int', 'min:0', 'max:'.env('game_size')],
'currentaction' => [],
'currentfight' => ['int'],
'currentmonster' => ['int'],
'currentmonsterhp' => ['int'],
'currentmonstersleep' => ['int'],
'currentmonsterimmune' => ['int'],
'currentuberdamage' => ['int'],
'currentuberdefense' => ['int'],
'currenthp' => ['int', 'min:0'],
'currentmp' => ['int', 'min:0'],
'currenttp' => ['int', 'min:0'],
'maxhp' => ['int', 'min:1'],
'maxmp' => ['int', 'min:1'],
'maxtp' => ['int', 'min:1'],
'level' => ['int', 'min:1'],
'gold' => ['int', 'min:0'],
'experience' => ['int', 'min:0'],
'goldbonus' => ['int'],
'expbonus' => ['int'],
'strength' => ['int'],
'dexterity' => ['int'],
'attackpower' => ['int'],
'defensepower' => ['int'],
'weaponid' => ['int'],
'armorid' => ['int'],
'shieldid' => ['int'],
'slot1id' => ['int'],
'slot2id' => ['int'],
'slot3id' => ['int'],
'weaponname' => ['default:None'],
'armorname' => ['default:None'],
'shieldname' => ['default:None'],
'slot1name' => ['default:None'],
'slot2name' => ['default:None'],
'slot3name' => ['default:None'],
'dropcode' => ['int', 'min:0', 'default:0'],
'spells' => ['optional'],
'towns' => ['optional']
]);
if ($form['valid']) {
save_data_row('users', $form['data'], $id);
$page = 'User <b>'.$user['username'].'</b> updated.';
} else {
$error_list = ul_from_validate_errors($form['errors']);
$page = <<<HTML
<b>Errors:</b><br>
<div style="color: red;">{$error_list}</div><br>
Please go back and try again.
HTML;
}
} else {
$page = render('admin/edit_user', ['user' => $user]);
}
page_title('Admin: Editing '.$user['username']);
return $page;
}
/**
* Handling adding news posts.
*/
function add_news()
{
if (is_post()) {
$c = trim($_POST['content'] ?? '');
$errors = [];
if (empty($c)) $errors[] = "Content is required.";
if (count($errors) === 0) {
db()->query('INSERT INTO news (author, content) VALUES (?, ?);', [user()->username, $c]);
$page = 'News post added.';
} else {
$error_list = implode('<br>', $errors);
$page = "<b>Errors:</b><br><div style=\"color:red;\">$error_list</div><br>Please go back and try again.";
}
} else {
$page = <<<HTML
<h2>Add a News Post</h2>
<form action="/admin/news" method="post" hx-post="/admin/news" hx-target="#main">
Type your post below and then click Submit to add it.<br>
<textarea name="content" rows="5" cols="50"></textarea><br>
<button type="submit">Submit</button>
<button type="reset">Clear</button>
</form>
HTML;
}
page_title('Admin: Add News');
return $page;
}
/**
* Build an HTML table containing all columns and rows of a given data structure. Takes a SQLiteResult3 of a SELECT
* query.
*/
function build_bulk_table(SQLite3Result $query_data, string $edit_column, string $edit_link): string
{
$data = [];
$data_count = 0;
while ($row = $query_data->fetchArray(SQLITE3_ASSOC)) $data[$data_count++] = $row;
if ($data_count === 0) return 'No data.';
$columns = array_diff(array_keys($data[0]), ['password']);
$html_parts = [
'<table><colgroup>',
str_repeat('<col>', count($columns)),
'</colgroup><thead><tr>'
];
foreach ($columns as $column) {
$html_parts[] = '<th>' .
make_safe($column === 'id' ? 'ID' : ucfirst($column)) .
'</th>';
}
$html_parts[] = '</tr></thead><tbody>';
$is_edit_column = array_flip(['id', $edit_column]);
foreach ($data as $row) {
$html_parts[] = '<tr>';
foreach ($columns as $column) {
$name = make_safe($row[$column]);
$html_parts[] = isset($is_edit_column[$column])
? "<td><a href=\"{$edit_link}/{$row['id']}\" hx-get=\"{$edit_link}/{$row['id']}\" hx-target=\"#main\">{$name}</a></td>"
: "<td>{$name}</td>";
}
$html_parts[] = '</tr>';
}
$html_parts[] = '</tbody></table>';
return implode('', $html_parts);
}
/**
* Save a row of data to it's table from the data supplied.
*/
function save_data_row(string $table, array $data, int $id): SQLite3Result|false
{
$data = array_filter($data, fn($value) => $value !== null && $value !== '');
if (empty($data)) return false;
$fields = implode(',', array_map(fn($key) => "`$key`=?", array_keys($data)));
$values = array_values($data);
$values[] = $id;
return db()->query("UPDATE $table SET $fields WHERE id=?", $values);
}
/**
* Handle the result of a generic edit form.
*/
function handle_edit_form(int $id, string $table, array $form, string $updated_message = ''): string
{
if ($form['valid']) {
save_data_row($table, $form['data'], $id);
$page = $updated_message ?: '<b>'.$form['data']['name'].'</b> updated.';
} else {
$error_list = ul_from_validate_errors($form['errors']);
$page = <<<HTML
<b>Errors:</b><br>
<div style="color: red;">{$error_list}</div><br>
Please go back and try again.
HTML;
}
return $page;
}

69
src/actions/explore.php Normal file
View File

@ -0,0 +1,69 @@
<?php
// explore.php :: Handles all map exploring, chances to fight, etc.
namespace Explore;
/**
* Just spit out a blank exploring page. Exploring without a GET string is normally when they first log in, or when
* they've just finished fighting.
*/
function explore()
{
page_title('Exploring');
return <<<HTML
<div class="title"><img src="/img/title_exploring.gif" alt="Exploring"></div>
You are exploring the map, and nothing has happened. Continue exploring using the direction buttons or the Travel To menus.
HTML;
}
function move() {
// Early exit if fighting
if (user()->currentaction == 'Fighting') redirect('/fight');
// Validate direction
$form = validate($_POST, ['direction' => ['in:north,west,east,south']]);
if (!$form['valid']) return ul_from_validate_errors($form['errors']);
// Current game state
$game_size = env('game_size');
$latitude = user()->latitude;
$longitude = user()->longitude;
$direction = $form['data']['direction'];
// Calculate new coordinates with boundary checks
switch ($direction) {
case 'north':
$latitude = min($latitude + 1, $game_size);
break;
case 'south':
$latitude = max($latitude - 1, -$game_size);
break;
case 'east':
$longitude = min($longitude + 1, $game_size);
break;
case 'west':
$longitude = max($longitude - 1, -$game_size);
break;
}
// Check for town
$town = get_town_by_xy($longitude, $latitude);
if ($town !== false) {
return \Towns\travelto($town['id'], false);
}
// Determine action (1 in 5 chance of fighting)
if (rand(1, 5) === 1) {
user()->currentaction = 'Fighting';
user()->currentfight = 1;
} else {
user()->currentaction = 'Exploring';
}
user()->latitude = $latitude;
user()->longitude = $longitude;
user()->save();
return index();
}

451
src/actions/fight.php Normal file
View File

@ -0,0 +1,451 @@
<?php
// fight.php :: Handles all fighting action.
namespace Fights;
use Router;
function register_routes(Router $r): Router
{
$r->form('/fight', 'Fights\fight');
$r->get('/victory', 'Fights\victory');
$r->form('/drop', 'Fights\drop');
$r->get('/dead', 'Fights\dead');
return $r;
}
/**
* One big long function that determines the outcome of the fight.
*/
function fight()
{
if (user()->currentaction !== 'Fighting') exit('Cheat attempt detected.<br><br>Get a life, loser.');
$page = ["magiclist" => "", "yourturn" => "", "monsterturn" => "", "monsterhp" => "", "command" => ""];
$playerisdead = 0;
// Generate spell list
$user_spells = user()->spells();
if (!empty($user_spells)) {
$page['magiclist'] = '<select name="userspell">';
foreach ($user_spells as $spell) {
$page['magiclist'] .= "<option value=\"{$spell['id']}\">{$spell['name']}</option>\n";
}
$page['magiclist'] .= '</select> <input type="submit" name="spell" value="Spell"><br><br>';
}
// Determine initial combat parameters
$chancetoswingfirst = rand(1, 10) + (int)ceil(sqrt(user()->dexterity));
if (user()->currentfight === 1) {
$maxlevel = (int)floor(max(abs(user()->latitude) + 5, abs(user()->longitude) + 5) / 5);
$minlevel = max(1, $maxlevel - 2);
$monster = db()->query('SELECT * FROM monsters WHERE level >= ? AND level <= ? ORDER BY RANDOM() LIMIT 1;', [
$minlevel, $maxlevel
])->fetchArray(SQLITE3_ASSOC);
user()->currentmonster = $monster["id"];
user()->currentmonsterhp = rand((int)(($monster["maxhp"]/5)*4), $monster["maxhp"]);
user()->currentmonstersleep = 0;
user()->currentmonsterimmune = $monster["immune"];
$chancetoswingfirst = ($chancetoswingfirst > (rand(1,7) + (int)ceil(sqrt($monster["maxdam"])))) ? 1 : 0;
}
// Get monster statistics
$monster = get_monster(user()->currentmonster);
$page['monstername'] = $monster['name'];
// Run action
if (isset($_POST["run"])) {
$chancetorun = rand(4,10) + (int)ceil(sqrt(user()->dexterity));
if ($chancetorun <= (rand(1,5) + (int)ceil(sqrt($monster["maxdam"])))) {
$page["yourturn"] = "You tried to run away, but were blocked in front!<br><br>";
$page["monsterhp"] = "Monster's HP: " . user()->currentmonsterhp . "<br><br>";
// Monster turn logic (similar to original function)
$page["monsterturn"] = handleMonsterTurn($userrow, $monster);
user()->currentaction = 'Exploring';
user()->save();
redirect('/');
}
}
// Fight action
if (isset($_POST["fight"])) {
// Player's attack
$min = (int)(user()->attackpower * 0.75);
$max = (int)(user()->attackpower / 3);
$tohit = (int)ceil(mt_rand(min($min, $max), max($min, $max)));
$toexcellent = rand(1,150);
if ($toexcellent <= sqrt(user()->strength)) {
$tohit *= 2;
$page["yourturn"] .= "Excellent hit!<br>";
}
$min = (int)($monster["armor"] * 0.75);
$max = (int)$monster["armor"];
$toblock = (int)ceil(rand(min($min, $max), max($min, $max)) / 3);
$tododge = rand(1, 100);
$monsterdamage = max(1, $tohit - $toblock);
if ($tododge <= sqrt($monster["armor"])) {
$monsterdamage = 0;
$page["yourturn"] .= "The monster is dodging. No damage has been scored.<br>";
}
if (user()->currentuberdamage != 0) {
$monsterdamage += (int)ceil($monsterdamage * (user()->currentuberdamage / 100));
}
user()->currentmonsterhp -= $monsterdamage;
$page["yourturn"] .= "You attack the monster for $monsterdamage damage.<br><br>";
$page["monsterhp"] = "Monster's HP: " . user()->currentmonsterhp . "<br><br>";
// Check for monster defeat
if (user()->currentmonsterhp <= 0) {
user()->currentmonsterhp = 0;
user()->save();
redirect('/victory');
}
// Monster's turn
$page["monsterturn"] = handleMonsterTurn($userrow, $monster);
}
// Spell action
if (isset($_POST["spell"])) {
$pickedspell = $_POST["userspell"];
if ($pickedspell == 0) return 'You must select a spell first. Please go back and try again.';
$newspellrow = get_spell($pickedspell);
$spell = in_array($pickedspell, explode(',', user()->spells));
if (!$spell) return 'You have not yet learned this spell. Please go back and try again.';
if (user()->currentmp < $newspellrow["mp"]) {
return 'You do not have enough Magic Points to cast this spell. Please go back and try again.';
}
// Spell type handling (similar to original function)
$page["yourturn"] = handleSpellCast($userrow, $newspellrow);
$page["monsterhp"] = "Monster's HP: " . user()->currentmonsterhp . "<br><br>";
// Check for monster defeat
if (user()->currentmonsterhp <= 0) {
user()->currentmonsterhp = 0;
user()->save();
redirect('/victory');
}
// Monster's turn
$page["monsterturn"] = handleMonsterTurn($userrow, $monster);
}
// Monster's turn if player lost first swing
if (!isset($_POST["run"]) && !isset($_POST["fight"]) && !isset($_POST["spell"]) && $chancetoswingfirst == 0) {
$page["yourturn"] = "The monster attacks before you are ready!<br><br>";
$page["monsterhp"] = "Monster's HP: " . user()->currentmonsterhp . "<br><br>";
$page["monsterturn"] = handleMonsterTurn($userrow, $monster);
}
// Prepare command or death message
if ($playerisdead != 1) {
$page["command"] = <<<HTML
Command?<br><br>
<form action="/fight" method="post" hx-post="/fight" hx-target="#middle">
<input type="submit" name="fight" value="Fight"><br><br>
{$page['magiclist']}
<input type="submit" name="run" value="Run"><br><br>
</form>
HTML;
user()->currentfight += 1;
} else {
$page["command"] = <<<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="/" hx-get="/" hx-target="#middle">town</a>, and we hope you fair better next time.
HTML;
}
user()->save();
// Finalize page and display it
$page = render('fight', ['page' => $page]);
return $page;
}
function victory()
{
if (user()->currentmonsterhp != 0) redirect('/fight');
if (user()->currentfight == 0) redirect('/');
$monsterrow = get_monster(user()->currentmonster);
$min = (int)(($monsterrow["maxexp"] / 6) * 5);
$max = (int)$monsterrow["maxexp"];
$exp = mt_rand(min($min, $max), max($min, $max));
if ($exp < 1) { $exp = 1; }
if (user()->expbonus != 0) { $exp += ceil((user()->expbonus/100)*$exp); }
$min = (int)(($monsterrow["maxgold"] / 6) * 5);
$max = (int)$monsterrow["maxgold"];
$gold = mt_rand(min($min, $max), max($min, $max));
if ($gold < 1) { $gold = 1; }
if (user()->goldbonus != 0) { $gold += ceil((user()->goldbonus/100)*$exp); }
if (user()->experience + $exp < 16777215) { $newexp = user()->experience += $exp; $warnexp = ""; } else { $newexp = user()->experience; $exp = 0; $warnexp = "You have maxed out your experience points."; }
if (user()->gold + $gold < 16777215) { $newgold = user()->gold += $gold; $warngold = ""; } else { $newgold = user()->gold; $gold = 0; $warngold = "You have maxed out your gold."; }
$levelrow = db()->query('SELECT * FROM levels WHERE id=? LIMIT 1;', [user()->level + 1])->fetchArray(SQLITE3_ASSOC);
if (user()->level < 100) {
if ($newexp >= $levelrow[user()->charclass."_exp"]) {
user()->maxhp += $levelrow[user()->charclass."_hp"];
user()->maxmp += $levelrow[user()->charclass."_mp"];
user()->maxtp += $levelrow[user()->charclass."_tp"];
user()->strength += $levelrow[user()->charclass."_strength"];
user()->dexterity += $levelrow[user()->charclass."_dexterity"];
user()->attackpower += $levelrow[user()->charclass."_strength"];
user()->defensepower += $levelrow[user()->charclass."_dexterity"];
user()->level += 1;
$newlevel = $levelrow["id"];
if ($levelrow[user()->charclass."_spells"] != 0) {
user()->spells .= ",".$levelrow[user()->charclass."_spells"];
$spelltext = "You have learned a new spell.<br>";
} else { $spelltext = ""; $newspell=""; }
$page = "Congratulations. You have defeated the ".$monsterrow["name"].".<br>You gain $exp experience. $warnexp <br>You gain $gold gold. $warngold <br><br><b>You have gained a level!</b><br><br>You gain ".$levelrow[user()->charclass."_hp"]." hit points.<br>You gain ".$levelrow[user()->charclass."_mp"]." magic points.<br>You gain ".$levelrow[user()->charclass."_tp"]." travel points.<br>You gain ".$levelrow[user()->charclass."_strength"]." strength.<br>You gain ".$levelrow[user()->charclass."_dexterity"]." dexterity.<br>$spelltext<br>You can now continue <a href=\"/\" hx-get=\"/\" hx-target=\"#middle\">exploring</a>.";
$title = "Courage and Wit have served thee well!";
$dropcode = "";
} else {
$page = "Congratulations. You have defeated the ".$monsterrow["name"].".<br>You gain $exp experience. $warnexp <br>You gain $gold gold. $warngold <br><br>";
if (rand(1, 30) === 1) {
$droprow = db()->query('SELECT * FROM drops WHERE mlevel <= ? ORDER BY RANDOM() LIMIT 1;', [$monsterrow['level']])->fetchArray(SQLITE3_ASSOC);
$dropcode = "dropcode='".$droprow["id"]."',";
$page .= "This monster has dropped an item. <a href=\"/drop\" hx-get=\"/drop\" hx-target=\"#middle\">Click here</a> to reveal and equip the item, or you may also move on and continue <a href=\"/\" hx-get=\"/\" hx-target=\"#middle\">exploring</a>.";
} else {
$dropcode = "";
$page .= 'You can now continue <a href="/" hx-get="/" hx-target="#middle">exploring</a>.';
}
$title = "Victory!";
}
}
user()->currentaction = 'Exploring';
user()->currentfight = 0;
user()->currentuberdamage = 0;
user()->currentuberdefense = 0;
user()->currentmonstersleep = 0;
user()->currentmonsterimmune = 0;
user()->save();
page_title($title);
return $page;
}
function drop()
{
if (user()->dropcode == 0) redirect('/');
$droprow = get_drop(user()->dropcode);
if (isset($_POST["submit"])) {
$slot = $_POST["slot"];
if ($slot === 0) return 'Please go back and select an inventory slot to continue.';
$slotstr = 'slot'.$slot.'id';
if (user()->$slotstr != 0) {
$slotrow = get_drop(user()->$slotstr);
$old1 = explode(",",$slotrow["attribute1"]);
if ($slotrow["attribute2"] != "X") { $old2 = explode(",",$slotrow["attribute2"]); } else { $old2 = array(0=>"maxhp",1=>0); }
$new1 = explode(",",$droprow["attribute1"]);
if ($droprow["attribute2"] != "X") { $new2 = explode(",",$droprow["attribute2"]); } else { $new2 = array(0=>"maxhp",1=>0); }
user()->$old1[0] -= $old1[1];
user()->$old2[0] -= $old2[1];
if ($old1[0] == "strength") { user()->attackpower -= $old1[1]; }
if ($old1[0] == "dexterity") { user()->defensepower -= $old1[1]; }
if ($old2[0] == "strength") { user()->attackpower -= $old2[1]; }
if ($old2[0] == "dexterity") { user()->defensepower -= $old2[1]; }
user()->$new1[0] += $new1[1];
user()->$new2[0] += $new2[1];
if ($new1[0] == "strength") { user()->attackpower += $new1[1]; }
if ($new1[0] == "dexterity") { user()->defensepower += $new1[1]; }
if ($new2[0] == "strength") { user()->attackpower += $new2[1]; }
if ($new2[0] == "dexterity") { user()->defensepower += $new2[1]; }
if (user()->currenthp > user()->maxhp) { user()->currenthp = user()->maxhp; }
if (user()->currentmp > user()->maxmp) { user()->currentmp = user()->maxmp; }
if (user()->currenttp > user()->maxtp) { user()->currenttp = user()->maxtp; }
$slot_s = 'slot'.$_POST["slot"];
$slot_name = "{$slot_s}name";
$slot_id = "{$slot_s}id";
user()->$slot_name = $droprow['name'];
user()->$slot_id = $droprow['id'];
} else {
$new1 = explode(",",$droprow["attribute1"]);
if ($droprow["attribute2"] != "X") { $new2 = explode(",",$droprow["attribute2"]); } else { $new2 = array(0=>"maxhp",1=>0); }
user()->$new1[0] += $new1[1];
user()->$new2[0] += $new2[1];
if ($new1[0] == "strength") { user()->attackpower += $new1[1]; }
if ($new1[0] == "dexterity") { user()->defensepower += $new1[1]; }
if ($new2[0] == "strength") { user()->attackpower += $new2[1]; }
if ($new2[0] == "dexterity") { user()->defensepower += $new2[1]; }
$slot_s = 'slot'.$_POST["slot"];
$slot_name = "{$slot_s}name";
$slot_id = "{$slot_s}id";
user()->$slot_name = $droprow['name'];
user()->$slot_id = $droprow['id'];
}
user()->save();
return 'The item has been equipped. You can now continue <a href="/" hx-get="/" hx-target="#middle">exploring</a>.';
}
$attributearray = array("maxhp"=>"Max HP",
"maxmp"=>"Max MP",
"maxtp"=>"Max TP",
"defensepower"=>"Defense Power",
"attackpower"=>"Attack Power",
"strength"=>"Strength",
"dexterity"=>"Dexterity",
"expbonus"=>"Experience Bonus",
"goldbonus"=>"Gold Bonus");
$page = "The monster dropped the following item: <b>".$droprow["name"]."</b><br><br>";
$page .= "This item has the following attribute(s):<br>";
$attribute1 = explode(",",$droprow["attribute1"]);
$page .= $attributearray[$attribute1[0]];
if ($attribute1[1] > 0) { $page .= " +" . $attribute1[1] . "<br>"; } else { $page .= $attribute1[1] . "<br>"; }
if ($droprow["attribute2"] != "X") {
$attribute2 = explode(",",$droprow["attribute2"]);
$page .= $attributearray[$attribute2[0]];
if ($attribute2[1] > 0) { $page .= " +" . $attribute2[1] . "<br>"; } else { $page .= $attribute2[1] . "<br>"; }
}
$page .= "<br>Select an inventory slot from the list below to equip this item. If the inventory slot is already full, the old item will be discarded.";
$page .= "<form action=\"/drop\" method=\"post\"><select name=\"slot\"><option value=\"0\">Choose One</option><option value=\"1\">Slot 1: ".user()->slot1name."</option><option value=\"2\">Slot 2: ".user()->slot2name."</option><option value=\"3\">Slot 3: ".user()->slot3name."</option></select> <input type=\"submit\" name=\"submit\" value=\"Submit\" /></form>";
$page .= "You may also choose to just continue <a href=\"/\" hx-get=\"/\" hx-target=\"#middle\">exploring</a> and give up this item.";
return $page;
}
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="/" hx-get="/" hx-target="#middle">town</a>, and we hope you fair better next time.
HTML;
}
function handleMonsterTurn(&$userrow, $monsterrow)
{
$pagearray = "";
if (user()->currentmonstersleep != 0) {
$chancetowake = rand(1,15);
if ($chancetowake > user()->currentmonstersleep) {
user()->currentmonstersleep = 0;
$pagearray .= "The monster has woken up.<br>";
} else {
$pagearray .= "The monster is still asleep.<br>";
}
}
if (user()->currentmonstersleep == 0) {
$tohit = (int)ceil(mt_rand((int)($monsterrow["maxdam"] * 0.5), (int)$monsterrow["maxdam"]));
$toblock = (int)ceil(mt_rand((int)(user()->defensepower * 0.75), (int)user()->defensepower) / 4);
$tododge = rand(1, 150);
if ($tododge <= sqrt(user()->dexterity)) {
$tohit = 0;
$pagearray .= "You dodge the monster's attack. No damage has been scored.<br>";
$persondamage = 0;
} else {
$persondamage = max(1, $tohit - $toblock);
if (user()->currentuberdefense != 0) {
$persondamage -= (int)ceil($persondamage * (user()->currentuberdefense/100));
}
$persondamage = max(1, $persondamage);
}
$pagearray .= "The monster attacks you for $persondamage damage.<br><br>";
user()->currenthp -= $persondamage;
if (user()->currenthp <= 0) {
$newgold = (int)ceil(user()->gold/2);
$newhp = (int)ceil(user()->maxhp/4);
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']
]);
dead();
}
}
return $pagearray;
}
function handleSpellCast(&$userrow, $newspellrow)
{
$pagearray = "";
switch ($newspellrow["type"]) {
case 1: // Heal spell
$newhp = min(user()->currenthp + $newspellrow["attribute"], user()->maxhp);
user()->currenthp = $newhp;
user()->currentmp -= $newspellrow["mp"];
$pagearray = "You have cast the {$newspellrow["name"]} spell, and gained {$newspellrow["attribute"]} Hit Points.<br><br>";
break;
case 2: // Hurt spell
if (user()->currentmonsterimmune == 0) {
$monsterdamage = mt_rand((int)(($newspellrow["attribute"]/6)*5), $newspellrow["attribute"]);
user()->currentmonsterhp -= $monsterdamage;
$pagearray = "You have cast the {$newspellrow["name"]} spell for $monsterdamage damage.<br><br>";
} else {
$pagearray = "You have cast the {$newspellrow["name"]} spell, but the monster is immune to it.<br><br>";
}
user()->currentmp -= $newspellrow["mp"];
break;
case 3: // Sleep spell
if (user()->currentmonsterimmune != 2) {
user()->currentmonstersleep = $newspellrow["attribute"];
$pagearray = "You have cast the {$newspellrow["name"]} spell. The monster is asleep.<br><br>";
} else {
$pagearray = "You have cast the {$newspellrow["name"]} spell, but the monster is immune to it.<br><br>";
}
user()->currentmp -= $newspellrow["mp"];
break;
case 4: // +Damage spell
user()->currentuberdamage = $newspellrow["attribute"];
user()->currentmp -= $newspellrow["mp"];
$pagearray = "You have cast the {$newspellrow["name"]} spell, and will gain {$newspellrow["attribute"]}% damage until the end of this fight.<br><br>";
break;
case 5: // +Defense spell
user()->currentuberdefense = $newspellrow["attribute"];
user()->currentmp -= $newspellrow["mp"];
$pagearray = "You have cast the {$newspellrow["name"]} spell, and will gain {$newspellrow["attribute"]}% defense until the end of this fight.<br><br>";
break;
}
return $pagearray;
}

115
src/actions/forum.php Normal file
View File

@ -0,0 +1,115 @@
<?php
// forum.php :: Internal forums script for the game.
namespace Forum;
use Router;
function register_routes(Router $r): Router
{
$r->get('/forum/thread/:x/:x', 'Forum\showthread');
$r->form('/forum/new', 'Forum\newthread');
$r->post('/forum/reply', 'Forum\reply');
$r->get('/forum/list/:x', 'Forum\donothing');
$r->get('/forum', 'Forum\donothing');
return $r;
}
function donothing($start = 0)
{
$query = db()->query('SELECT * FROM forum WHERE parent=0 ORDER BY newpostdate DESC LIMIT 20 OFFSET ?;', [20 * $start]);
$page = <<<HTML
<table width="100%">
<tr>
<td style="padding: 1px; background-color: black;">
<table width="100%" style="margins: 0px;" cellspacing="1" cellpadding="3">
<tr>
<th colspan="3" style="background-color: #ddd;">
<center><a href="/forum/new" hx-get="/forum/new" hx-target="#middle">New Thread</a></center>
</th>
</tr>
<tr>
<th width="50%" style="background-color:#dddddd;">Thread</th>
<th width="10%" style="background-color:#dddddd;">Replies</th>
<th style="background-color:#dddddd;">Last Post</th>
</tr>
HTML;
$hasRows = false;
while ($row = $query->fetchArray(SQLITE3_ASSOC)) {
$hasRows = true;
$page .= <<<HTML
<tr>
<td style="background-color: white;"><a href="/forum/thread/{$row['id']}/0" hx-get="/forum/thread/{$row['id']}/0" hx-target="#middle">{$row['title']}</a></td>
<td style="background-color: white;">{$row['replies']}</td>
<td style="background-color: white;">{$row['newpostdate']}</td>
</tr>
HTML;
}
if (!$hasRows) {
$page .= '<tr><td style="background-color:#ffffff;" colspan="3"><b>No threads in forum.</b></td></tr>';
}
$page .= '</table></td></tr></table>';
page_title('Forum');
return $page;
}
function showthread($id, $start)
{
$posts = db()->query('SELECT * FROM forum WHERE id=? OR parent=? ORDER BY id LIMIT 15 OFFSET ?;', [$id, $id, $start * 15]);
$title = db()->query('SELECT title FROM forum WHERE id=? LIMIT 1;', [$id])->fetchArray(SQLITE3_ASSOC);
$page = "<table width=\"100%\"><tr><td style=\"padding:1px; background-color:black;\"><table width=\"100%\" style=\"margins:0px;\" cellspacing=\"1\" cellpadding=\"3\"><tr><td colspan=\"2\" style=\"background-color:#dddddd;\"><b><a href=\"/forum\" hx-get=\"/forum\" hx-target=\"#middle\">Forum</a> :: ".$title['title']."</b></td></tr>\n";
while ($row = $posts->fetchArray(SQLITE3_ASSOC)) {
$page .= "<tr><td width=\"25%\" style=\"background-color:#ffffff; vertical-align:top;\"><span class=\"small\"><b>".$row["author"]."</b><br><br>".pretty_date($row["postdate"])."</td><td style=\"background-color:#ffffff; vertical-align:top;\">".nl2br($row["content"])."</td></tr>\n";
}
$page .= "</table></td></tr></table><br>";
$page .= "<table width=\"100%\"><tr><td><b>Reply To This Thread:</b><br><form action=\"/forum/reply\" method=\"post\" hx-post=\"/forum/reply\" hx-target=\"#middle\"><input type=\"hidden\" name=\"parent\" value=\"$id\" /><input type=\"hidden\" name=\"title\" value=\"Re: ".$title["title"]."\" /><textarea name=\"content\" rows=\"7\" cols=\"40\"></textarea><br><input type=\"submit\" name=\"submit\" value=\"Submit\" /> <input type=\"reset\" name=\"reset\" value=\"Reset\" /></form></td></tr></table>";
page_title('Forum: '.$title['title']);
return $page;
}
function reply()
{
$form = validate($_POST, [
'title' => [],
'content' => []
]);
if (!$form['valid']) exit(ul_from_validate_errors($form['errors']));
$form = $form['data'];
db()->query('INSERT INTO forum (author, title, content, parent) VALUES (?, ?, ?, ?);', [
user()->username, $form['title'], $form['content'], $form['parent']
]);
db()->query('UPDATE forum SET newpostdate=CURRENT_TIMESTAMP, replies=replies + 1 WHERE id=?;', [$form['parent']]);
return showthread($form['parent'], 0);
}
function newthread()
{
if (isset($_POST["submit"])) {
$form = validate($_POST, [
'title' => ['length:2-30'],
'content' => []
]);
if (!$form['valid']) exit(ul_from_validate_errors($form['errors']));
$form = $form['data'];
db()->query('INSERT INTO forum (author, title, content) VALUES (?, ?, ?);', [
user()->username, $form['title'], $form['content']
]);
redirect('/forum/thread/'.db()->lastInsertRowID().'/0');
}
page_title('Form: New Thread');
return "<table width=\"100%\"><tr><td><b>Make A New Post:</b><br><br/ ><form action=\"/forum/new\" method=\"post\" hx-post=\"/forum/new\" hx-target=\"#middle\">Title:<br><input type=\"text\" name=\"title\" size=\"50\" maxlength=\"50\" /><br><br>Message:<br><textarea name=\"content\" rows=\"7\" cols=\"40\"></textarea><br><br><input type=\"submit\" name=\"submit\" value=\"Submit\" /> <input type=\"reset\" name=\"reset\" value=\"Reset\" /></form></td></tr></table>";
}

34
src/actions/heal.php Normal file
View File

@ -0,0 +1,34 @@
<?php
// heal.php :: Handles stuff from the Quick Spells menu. (Healing spells only... other spells are handled in fight.php.)
function healspells(int $id): string
{
$user_spells = user()->spells();
$spell = get_spell($id);
$has_spell = false;
foreach ($user_spells as $us) if ($us['id'] === $id) $has_spell = true;
if ($has_spell !== true) {
$page = 'You have not yet learned this spell. Please go back and try again.';
} elseif ($spell['type'] !== 1) {
$page = 'This is not a healing spell. Please go back and try again.';
} elseif (user()->currentmp < $spell['mp']) {
$page = 'You do not have enough Magic Points to cast this spell. Please go back and try again.';
} elseif (user()->currentaction === 'Fighting') {
$page = 'You cannot use the Quick Spells list during a fight. Please go back and select the Healing Spell you wish to use from the Spells box on the main fighting screen to continue.';
} elseif (user()->currenthp == user()->maxhp) {
$page = 'Your HP is already full. You don\'t need to use a Healing spell now.';
} else {
$restored = user()->restore_hp($spell['attribute']);
user()->currentmp -= $spell['mp'];
user()->save();
$page = <<<HTML
You have cast the {$spell['name']} spell, and gained {$restored} HP. You can now continue <a href="/" hx-get="/" hx-target="#middle">exploring</a>.
HTML;
}
page_title('Casting '.$spell['name']);
return $page;
}

494
src/actions/help.php Normal file
View File

@ -0,0 +1,494 @@
<?php
namespace Help;
use Router;
function register_routes(Router $r): Router
{
$r->get('/help', 'Help\main');
$r->get('/help/items', 'Help\items');
$r->get('/help/spells', 'Help\spells');
$r->get('/help/monsters', 'Help\monsters');
$r->get('/help/levels', 'Help\levels');
return $r;
}
function main()
{
$page = <<<HTML
<h3>Table of Contents</h3>
<ul>
<li><a href="#intro">Introduction</a></li>
<li><a href="#classes">Character Classes</a></li>
<li><a href="#intown">Playing The Game: In Town</a></li>
<li><a href="#exploring">Playing The Game: Exploring & Fighting</a></li>
<li><a href="#status">Playing The Game: Status Panels</a></li>
<li><a href="#items">Spoilers: Items & Drops</a></li>
<li><a href="#monsters">Spoilers: Monsters</a></li>
<li><a href="#spells">Spoilers: Spells</a></li>
<li><a href="#levels">Spoilers: Levels</a></li>
<li><a href="#credits">Credits</a></li>
</ul>
<hr>
<h3><a name="intro"></a>Introduction</h3>
Firstly, I'd like to say thank you for playing my game. The <i>Dragon Knight</i> game engine is the result of several months of
planning, coding and testing. The original idea was to create a web-based tribute to the NES game, <i>Dragon
Warrior</i>. In its current iteration, only the underlying fighting system really resembles that game, as almost
everything else in DK has been made bigger and better. But you should still recognize bits and pieces as stemming
from <i>Dragon Warrior</i> and other RPGs of old.<br><br>
This is the first game I've ever written, and it has definitely been a positive experience. It got difficult at
times, admittedly, but it was still a lot of fun to write, and even more fun to play. And I hope to use this
experience so that if I ever want to create another game it will be even better than this one.<br><br>
If you are a site administrator, and would like to install a copy of DK on your own server, you may visit the
<a href="http://dragon.se7enet.com/dev.php" target="_new">development site</a> for <i>Dragon Knight</i>. This page
includes the downloadable game souce code, as well as some other resources that developers and administrators may
find valuable.<br><br>
Once again, thanks for playing!<br><br>
<i>Jamin Seven</i><br>
<i>Dragon Knight creator</i><br>
<a href="http://www.se7enet.com" target="_new">My Homepage</a><br>
<a href="http://dragon.se7enet.com/dev.php" target="_new">Dragon Knight Homepage</a><br ><br>
[ <a href="#top">Top</a> ]
<br><br><hr>
<h3><a name="classes"></a>Character Classes</h3>
There are three character classes in the game. The main differences between the classes are what spells you get
access to, the speed with which you level up, and the amount of HP/MP/strength/dexterity you gain per level. Below
is a basic outline of each of the character classes. For more detailed information about the characters, please
view the Levels table at the bottom of this page. Also, note that the outline below refers to the stock class setup
for the game. If your administrator has used his/her own class setup, this information may not be accurate.<br><br>
<b>{env('class_1_name')}</b>
<ul>
<li>Fast level-ups</li>
<li>High hit points</li>
<li>High magic points</li>
<li>Low strength</li>
<li>Low dexterity</li>
<li>5 heal spells</li>
<li>5 hurt spells</li>
<li>3 sleep spells</li>
<li>3 +defense spells</li>
<li>0 +attack spells</li>
</ul>
<b>{env('class_2_name')}</b>
<ul>
<li>Medium level-ups</li>
<li>Medium hit points</li>
<li>Low magic points</li>
<li>High strength</li>
<li>Low dexterity</li>
<li>3 heal spells</li>
<li>3 hurt spells</li>
<li>2 sleep spells</li>
<li>3 +defense spells</li>
<li>3 +attack spells</li>
</ul>
<b>{env('class_3_name')}</b>
<ul>
<li>Slow level-ups</li>
<li>Medium hit points</li>
<li>Medium magic points</li>
<li>Low strength</li>
<li>High dexterity</li>
<li>4 heal spells</li>
<li>4 hurt spells</li>
<li>3 sleep spells</li>
<li>2 +defense spells</li>
<li>2 +attack spells</li>
</ul>
[ <a href="#top">Top</a> ]
<br><br><hr>
<h3><a name="intown"></a>Playing The Game: In Town</h3>
When you begin a new game, the first thing you see is the Town screen. Towns serve four primary functions: healing, buying items,
buying maps, and displaying game information.<br><br>
To heal yourself, click the "Rest at the Inn" link at the top of the town screen. Each town's Inn has a different price - some towns
are cheap, others are expensive. No matter what town you're in, the Inns always serve the same function: they restore your current
hit points, magic points, and travel points to their maximum amounts. Out in the field, you are free to use healing spells to restore
your hit points, but when you run low on magic points, the only way to restore them is at an Inn.<br><br>
Buying weapons and armor is accomplished through the appropriately-named "Buy Weapons/Armor" link. Not every item is available in
every town, so in order to get the most powerful items, you'll need to explore some of the outer towns. Once you've clicked the link,
you are presented with a list of items available in this town's store. To the left of each item is an icon that represents its type:
weapon, armor or shield. The amount of attack/defense power, as well as the item's price, are displayed to the right of the item name.
You'll notice that some items have a red asterisk (<span class="highlight">*</span>) next to their names. These are items that come
with special attributes that modify other parts of your character profile. See the Items & Drops table at the bottom of this page for
more information about special items.<br><br>
Maps are the third function in towns. Buying a map to a town places the town in your Travel To box in the left status panel. Once
you've purchased a town's map, you can click its name from your Travel To box and you will jump to that town. Travelling this way
costs travel points, though, and you'll only be able to visit towns if you have enough travel points.<br><br>
The final function in towns is displaying game information and statistics. This includes the latest news post made by the game
administrator, a list of players who have been online recently, and the Babble Box.<br><br>
[ <a href="#top">Top</a> ]
<br><br><hr>
<h3><a name="exploring"></a>Playing The Game: Exploring & Fighting</h3>
Once you're done in town, you are free to start exploring the world. Use the compass buttons on the left status panel to move around.
The game world is basically a big square, divided into four quadrants. Each quadrant is {{gamesize}} spaces
square. The first town is usually located at (0N,0E). Click the North button from the first town, and now you'll be at (1N,0E).
Likewise, if you now click the West button, you'll be at (1N,1W). Monster levels increase with every 5 spaces you move outward
from (0N,0E).<br><br>
While you're exploring, you will occasionally run into monsters. As in pretty much any other RPG game, you and the monster take turns
hitting each other in an attempt to reduce each other's hit points to zero. Once you run into a monster, the Exploring screen changes
to the Fighting screen.<br><br>
When a fight begins, you'll see the monster's name and hit points, and the game will ask you for your first command. You then get to
pick whether you want to fight, use a spell, or run away. Note, though, that sometimes the monster has the chance to hit you
first.<br><br>
The Fight button is pretty straightforward: you attack the monster, and the amount of damage dealt is based on your attack power and
the monster's armor. On top of that, there are two other things that can happen: an Excellent Hit, which doubles your total attack
damage; and a monster dodge, which results in you doing no damage to the monster.<br><br>
The Spell button allows you to pick an available spell and cast it. See the Spells list at the bottom of this page for more information
about spells.<br><br>
Finally, there is the Run button, which lets you run away from a fight if the monster is too powerful. Be warned, though: it is
possible for the monster to block you from running and attack you. So if your hit points are low, you may fare better by staying
around monsters that you know can't do much damage to you.<br><br>
Once you've had your turn, the monster also gets his turn. It is also possible for you to dodge the monster's attack and take no
damage.<br><br>
The end result of a fight is either you or the monster being knocked down to zero hit points. If you win, the monster dies and will
give you a certain amount of experience and gold. There is also a chance that the monster will drop an item, which you can put into
one of the three inventory slots to give you extra points in your character profile. If you lose and die, half of your gold is taken
away - however, you are given back a few hit points to help you make it back to town (for example, if you don't have enough gold to
pay for an Inn, and need to kill a couple low-level monsters to get the money).<br><br>
When the fight is over, you can continue exploring until you find another monster to beat into submission.<br><br>
[ <a href="#top">Top</a> ]
<br><br><hr>
<h3><a name="status"></a>Playing The Game: Status Panels</h3>
There are two status panels on the game screen: left and right.<br><br>
The left panel inclues your current location and play status (In Town, Exploring, Fighting), compass buttons for movement, and the
Travel To list for jumping between towns. At the bottom of the left panel is also a list of game functions.<br><br>
The right panel displays some character statistics, your inventory, and quick spells.<br><br>
The Character section shows the most important character statistics. It also displays the status bars for your current hit points,
magic points and travel points. These status bars are colored either green, yellow or red depending on your current amount of each
stat. There is also a link to pop up your list of extended statistics, which shows more detailed character information.<br><br>
The Fast Spells section lists any Heal spells you've learned. You may use these links any time you are in town or exploring to cast
the heal spell. These may not be used during fights, however - you have to use the Spells box on the fight screen for that.
[ <a href="#top">Top</a> ]
<br><br><hr>
<h3><a name="items"></a>Spoilers: Items & Drops</h3>
<a href="/help/items">Click here</a> for the Items & Drops spoiler page.<br><br>
[ <a href="#top">Top</a> ]
<br><br><hr>
<h3><a name="monsters"></a>Spoilers: Monsters</h3>
<a href="/help/monsters">Click here</a> for the Monsters spoiler page.<br><br>
[ <a href="#top">Top</a> ]
<br><br><hr>
<h3><a name="spells"></a>Spoilers: Spells</h3>
<a href="/help/spells">Click here</a> for the Spells spoiler page.<br><br>
[ <a href="#top">Top</a> ]
<br><br><hr>
<h3><a name="levels"></a>Spoilers: Levels</h3>
<a href="/help/levels">Click here</a> for the Levels spoiler page.<br><br>
[ <a href="#top">Top</a> ]
<br><br><hr>
<h3><a name="credits"></a>Credits</h3>
<ul>
<li><b>All program code and stock graphics for the game were created by Jamin Seven</b>.<br><br></li>
<li>Major props go to a few people on the PHP manual site, for help with various chunks of code. The specific people are listed in the source code.<br><br></li>
<li>Super monkey love goes to Enix and the developers of <i>Dragon Warrior</i>. If it weren't for you guys, my game never would have been made.<br><br></li>
<li>Mega props go to Dalez from GameFAQs for his DW3 experience chart, which was where I got my experience levels from.<br><br></li>
<li>
Mad crazy ninja love goes to the following people for help and support throughout the development process:<br><br>
<b>Ideas:</b> (whether they got used or not)
<ul>
<li>kushet</li>
<li>lghtning</li>
<li>Ebolamonkey3000</li>
<li>Crimson Scythe</li>
<li>SilDeath</li>
</ul>
<b>Beta Testing:</b> (forums name if applicable, character name otherwise)
<ul>
<li>Ebolamonkey3000</li>
<li>lisi</li>
<li>Junglist</li>
<li>Crimson Scythe</li>
<li>Sk8erpunk69</li>
<li>lghtning</li>
<li>kushet</li>
<li>SilDeath</li>
<li>lowrider4life</li>
<li>dubiin</li>
<li>Sam Wise The Great</li>
</ul>
</li>
</ul>
Apologies and lots of happy naked love to anyone I forgot. <br><br>
And of course, thanks to <b>you</b> for playing my game! <br><br>
<a href="/ninja">NINJA!</a> <br><br>
[ <a href="#top">Top</a> ]
<br><br><hr><br>
Please visit the following sites for more information:<br>
<a href="http://www.se7enet.com" target="_new">Se7enet</a> (Jamin's homepage)<br>
<a href="http://dragon.se7enet.com/dev.php" target="_new">Dragon Knight</a> (official DK homepage)<br>
<a href="http://se7enet.com/forums" target="_new">Forums</a> (official DK forums)<br><br>
All original coding and graphics for the <i>Dragon Knight</i> game engine are &copy; 2003-2005 by Jamin Seven.<br><br>
[ <a href="#top">Top</a> ]
HTML;
return display_help($page);
}
function items()
{
$page = <<<HTML
<table width="60%" style="border: solid 1px black" cellspacing="0" cellpadding="0">
<tr><td colspan="5" bgcolor="#ffffff"><center><b>Items</b></center></td></tr>
<tr><td><b>Type</b></td><td><b>Name</b></td><td><b>Cost</b></td><td><b>Attribute</b></td><td><b>Special</b></td></tr>
HTML;
$items = db()->query('SELECT * FROM items ORDER BY id;');
$item_types = [1 => ['weapon', 'Attack'], 2 => ['armor', 'Defense'], 3 => ['shield', 'Defense']];
while ($item = $items->fetchArray(SQLITE3_ASSOC)) {
$image = $item_types[$item['type']][0];
$power = $item_types[$item['type']][1];
if ($item['special'] !== 'X') {
$special = explode(',', $item['special']);
$attr = special_to_string($special[0]);
$stat = (($special[1] > 0) ? '+' : '') . $special[1];
$bigspecial = "$attr $stat";
} else {
$bigspecial = '<span class="light">None</span>';
}
$page .= "<tr><td width=\"5%\"><img src=\"/img/icon_$image.gif\" alt=\"$image\"></td><td width=\"30%\">".$item["name"]."</td><td width=\"20%\">".$item["buycost"]." Gold</td><td width=\"20%\">".$item["attribute"]." $power Power</td><td width=\"25%\">$bigspecial</td></tr>\n";
}
$page .= <<<HTML
</table>
<br><br>
<table width="60%" style="border: solid 1px black" cellspacing="0" cellpadding="0">
<tr><td colspan="4" bgcolor="#ffffff"><center><b>Drops</b></center></td></tr>
<tr><td><b>Name</b></td><td><b>Monster Level</b></td><td><b>Attribute 1</b></td><td><b>Attribute 2</b></td></tr>
HTML;
$drops = db()->query('SELECT * FROM drops ORDER BY id;');
while ($drop = $drops->fetchArray(SQLITE3_ASSOC)) {
if ($drop["attribute1"] !== "X") {
$special = explode(',', $drop['attribute1']);
$attr = special_to_string($special[0]);
$stat = (($special[1] > 0) ? '+' : '') . $special[1];
$bigspecial1 = "$attr $stat";
} else {
$bigspecial1 = '<span class="light">None</span>';
}
if ($drop["attribute2"] !== "X") {
$special = explode(',', $drop['attribute2']);
$attr = special_to_string($special[0]);
$stat = (($special[1] > 0) ? '+' : '') . $special[1];
$bigspecial2 = "$attr $stat";
} else {
$bigspecial2 = '<span class="light">None</span>';
}
$page .= "<tr><td width=\"25%\">".$drop["name"]."</td><td width=\"15%\">".$drop["mlevel"]."</td><td width=\"30%\">$bigspecial1</td><td width=\"30%\">$bigspecial2</td></tr>\n";
}
$page .= '</table>';
return display_help($page);
}
function spells()
{
$page = <<<HTML
<table width="50%" style="border: solid 1px black" cellspacing="0" cellpadding="0">
<tr><td colspan="8" bgcolor="#ffffff"><center><b>Spells</b></center></td></tr>
<tr><td><b>Name</b></td><td><b>Cost</b></td><td><b>Type</b></td><td><b>Attribute</b></td></tr>
HTML;
$spells = db()->query('SELECT * FROM spells ORDER BY id;');
$spell_types = ['None', 'Heal', 'Hurt', 'Sleep', '+Damage (%)', '+Defense (%)'];
while ($spell = $spells->fetchArray(SQLITE3_ASSOC)) {
$page .= <<<HTML
<tr><td width="25%">{$spell["name"]}</td>
<td width="25%">{$spell["mp"]}</td>
<td width="25%">{$spell_types[$spell['type']]}</td>
<td width="25%">{$spell["attribute"]}</td></tr>
HTML;
}
$page .= <<<HTML
</table>
<ul>
<li><b>Heal</b> spells always give you the maximum amount possible, until your current HP is full.</li>
<li><b>Hurt</b> spells deal X damage (not always the maximum) to the monster, regardless of the monster's armor.</li>
<li><b>Sleep</b> spells put the monster to sleep. The monster has an X in 15 chance of remaining asleep each turn.</li>
<li><b>+Damage</b> spells increase your total attack damage by X percent until the end of the fight.</li>
<li><b>+Defense</b> spells reduce the total damage you take from the monster by X percent until the end of each fight.</li>
</ul>
HTML;
return display_help($page);
}
function monsters()
{
$page = <<<HTML
<table width="75%" style="border: solid 1px black" cellspacing="0" cellpadding="0">
<tr><td colspan="8" bgcolor="#ffffff"><center><b>Monsters</b></center></td></tr>
<tr><td><b>Name</b></td><td><b>Max HP</b></td><td><b>Max Damage</b></td><td><b>Armor</b></td><td><b>Level</b></td><td><b>Max Exp.</b></td><td><b>Max Gold</b></td><td><b>Immunity</b></td></tr>
HTML;
$monsters = db()->query('SELECT * FROM monsters ORDER BY id;');
$immunities = ['<span class="light">None</span>', 'Hurt', 'Hurt & Sleep'];
while ($m = $monsters->fetchArray(SQLITE3_ASSOC)) {
$immune = $immunities[$m['immune']] ?? 'Unknown';
$page .= "<tr><td width=\"30%\">".$m["name"]."</td><td width=\"10%\">".$m["maxhp"]."</td><td width=\"10%\">".$m["maxdam"]."</td><td width=\"10%\">".$m["armor"]."</td><td width=\"10%\">".$m["level"]."</td><td width=\"10%\">".$m["maxexp"]."</td><td width=\"10%\">".$m["maxgold"]."</td><td width=\"20%\">$immune</td></tr>\n";
}
return display_help($page.'</table>');
}
function levels()
{
$rows = [];
$levels = db()->query('SELECT * FROM levels ORDER BY id;');
while ($level = $levels->fetchArray(SQLITE3_ASSOC)) {
$class_data = [1 => [], 2 => [], 3 => []];
foreach ($level as $column => $value) {
if ($column === 'id') continue;
$parts = explode('_', $column);
$class_number = (int) $parts[0];
$attribute = $parts[1];
if (in_array($class_number, [1, 2, 3])) {
$class_data[$class_number][$level['id']][$attribute] = $value;
}
}
$rows[$level['id']] = $class_data;
}
$spells = [];
$spells_query = db()->query('SELECT * FROM spells ORDER BY id;');
while ($spell = $spells_query->fetchArray(SQLITE3_ASSOC)) {
$spells[$spell['id']] = $spell;
}
$page = <<<HTML
<table width="50%" style="border: solid 1px black" cellspacing="0" cellpadding="0">
<tr><td colspan="8" bgcolor="#ffffff"><center><b>{{class1name}} Levels</b></center></td></tr>
<tr><td><b>Level</b><td><b>Exp.</b></td><td><b>HP</b></td><td><b>MP</b></td><td><b>TP</b></td><td><b>Strength</b></td><td><b>Dexterity</b></td><td><b>Spell</b></td></tr>
HTML;
foreach ($rows as $level => $class_data) {
$level_data = $class_data[1][$level];
$spell_name = '';
if (!empty($level_data['spells'])) $spell_name = $spells[$level_data['spells']]['name'];
$page .= '<tr>';
$page .= '<td>' . $level . '</td>';
$page .= '<td>' . ($level_data['exp'] ?? '') . '</td>';
$page .= '<td>' . ($level_data['hp'] ?? '') . '</td>';
$page .= '<td>' . ($level_data['mp'] ?? '') . '</td>';
$page .= '<td>' . ($level_data['tp'] ?? '') . '</td>';
$page .= '<td>' . ($level_data['strength'] ?? '') . '</td>';
$page .= '<td>' . ($level_data['dexterity'] ?? '') . '</td>';
$page .= '<td>' . (!empty($spell_name) ? $spell_name : '<span class="light">None</span>') . '</td>';
$page .= '</tr>';
}
$page .= <<<HTML
</table>
<br><br>
<table width="50%" style="border: solid 1px black" cellspacing="0" cellpadding="0">
<tr><td colspan="8" bgcolor="#ffffff"><center><b>{{class2name}} Levels</b></center></td></tr>
<tr><td><b>Level</b><td><b>Exp.</b></td><td><b>HP</b></td><td><b>MP</b></td><td><b>TP</b></td><td><b>Strength</b></td><td><b>Dexterity</b></td><td><b>Spell</b></td></tr>
HTML;
foreach ($rows as $level => $class_data) {
$level_data = $class_data[2][$level];
$spell_name = '';
if (!empty($level_data['spells'])) $spell_name = $spells[$level_data['spells']]['name'];
$page .= '<tr>';
$page .= '<td>' . $level . '</td>';
$page .= '<td>' . ($level_data['exp'] ?? '') . '</td>';
$page .= '<td>' . ($level_data['hp'] ?? '') . '</td>';
$page .= '<td>' . ($level_data['mp'] ?? '') . '</td>';
$page .= '<td>' . ($level_data['tp'] ?? '') . '</td>';
$page .= '<td>' . ($level_data['strength'] ?? '') . '</td>';
$page .= '<td>' . ($level_data['dexterity'] ?? '') . '</td>';
$page .= '<td>' . (!empty($spell_name) ? $spell_name : '<span class="light">None</span>') . '</td>';
$page .= '</tr>';
}
$page .= <<<HTML
</table>
<br><br>
<table width="50%" style="border: solid 1px black" cellspacing="0" cellpadding="0">
<tr><td colspan="8" bgcolor="#ffffff"><center><b>{{class3name}} Levels</b></center></td></tr>
<tr><td><b>Level</b><td><b>Exp.</b></td><td><b>HP</b></td><td><b>MP</b></td><td><b>TP</b></td><td><b>Strength</b></td><td><b>Dexterity</b></td><td><b>Spell</b></td></tr>
HTML;
foreach ($rows as $level => $class_data) {
$level_data = $class_data[3][$level];
$spell_name = '';
if (!empty($level_data['spells'])) $spell_name = $spells[$level_data['spells']]['name'];
$page .= '<tr>';
$page .= '<td>' . $level . '</td>';
$page .= '<td>' . ($level_data['exp'] ?? '') . '</td>';
$page .= '<td>' . ($level_data['hp'] ?? '') . '</td>';
$page .= '<td>' . ($level_data['mp'] ?? '') . '</td>';
$page .= '<td>' . ($level_data['tp'] ?? '') . '</td>';
$page .= '<td>' . ($level_data['strength'] ?? '') . '</td>';
$page .= '<td>' . ($level_data['dexterity'] ?? '') . '</td>';
$page .= '<td>' . (!empty($spell_name) ? $spell_name : '<span class="light">None</span>') . '</td>';
$page .= '</tr>';
}
$page .= <<<HTML
</table>
<br>
Experience points listed are total values up until that point. All other values are just the new amount that you gain for each level.
HTML;
return display_help($page);
}
function display_help(string $content)
{
return render('layouts/help', [
'content' => $content,
'version' => VERSION,
'build' => BUILD
]);
}

767
src/actions/install.php Normal file
View File

@ -0,0 +1,767 @@
<?php
namespace Install;
use Router;
function register_routes(Router $r): Router
{
if (!file_exists('../.installed')) {
$r->get('/install', 'Install\first');
$r->get('/install/second', 'Install\second');
$r->get('/install/third', 'Install\third');
$r->post('/install/fourth', 'Install\fourth');
$r->get('/install/fifth', 'Install\fifth');
}
return $r;
}
/**
* First page - show warnings and gather info
*/
function first()
{
return <<<HTML
<html>
<head>
<title>Dragon Knight Installation</title>
</head>
<body>
<b>Dragon Knight Installation: Page One</b><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>
<a href="/install/second"><button>Install</button></a>
</body>
</html>
HTML;
}
/**
* Set up database tables.
*/
function second()
{
if (file_exists('../database.db')) unlink('../database.db');
$page = "<html><head><title>Dragon Knight Installation</title></head><body><b>Dragon Knight Installation: Page Two</b><br><br>";
$query = db()->exec(<<<SQL
CREATE TABLE babble (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`posttime` TEXT NOT NULL DEFAULT '00:00:00',
`author` TEXT NOT NULL DEFAULT '',
`babble` TEXT NOT NULL DEFAULT ''
);
SQL);
$page .= table_status_msg($query === true, 'Babble', 'create');
$query = db()->exec(<<<SQL
CREATE TABLE drops (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`name` TEXT NOT NULL DEFAULT '',
`mlevel` INTEGER NOT NULL DEFAULT 0,
`type` INTEGER NOT NULL DEFAULT 0,
`attribute1` TEXT NOT NULL DEFAULT '',
`attribute2` TEXT NOT NULL DEFAULT ''
);
SQL);
$page .= table_status_msg($query === true, 'Drops', 'create');
$query = db()->exec(<<<SQL
INSERT INTO drops VALUES
(1, 'Life Pebble', 1, 1, 'maxhp,10', 'X'),
(2, 'Life Stone', 10, 1, 'maxhp,25', 'X'),
(3, 'Life Rock', 25, 1, 'maxhp,50', 'X'),
(4, 'Magic Pebble', 1, 1, 'maxmp,10', 'X'),
(5, 'Magic Stone', 10, 1, 'maxmp,25', 'X'),
(6, 'Magic Rock', 25, 1, 'maxmp,50', 'X'),
(7, 'Dragon''s Scale', 10, 1, 'defensepower,25', 'X'),
(8, 'Dragon''s Plate', 30, 1, 'defensepower,50', 'X'),
(9, 'Dragon''s Claw', 10, 1, 'attackpower,25', 'X'),
(10, 'Dragon''s Tooth', 30, 1, 'attackpower,50', 'X'),
(11, 'Dragon''s Tear', 35, 1, 'strength,50', 'X'),
(12, 'Dragon''s Wing', 35, 1, 'dexterity,50', 'X'),
(13, 'Demon''s Sin', 35, 1, 'maxhp,-50', 'strength,50'),
(14, 'Demon''s Fall', 35, 1, 'maxmp,-50', 'strength,50'),
(15, 'Demon''s Lie', 45, 1, 'maxhp,-100', 'strength,100'),
(16, 'Demon''s Hate', 45, 1, 'maxmp,-100', 'strength,100'),
(17, 'Angel''s Joy', 25, 1, 'maxhp,25', 'strength,25'),
(18, 'Angel''s Rise', 30, 1, 'maxhp,50', 'strength,50'),
(19, 'Angel''s Truth', 35, 1, 'maxhp,75', 'strength,75'),
(20, 'Angel''s Love', 40, 1, 'maxhp,100', 'strength,100'),
(21, 'Seraph''s Joy', 25, 1, 'maxmp,25', 'dexterity,25'),
(22, 'Seraph''s Rise', 30, 1, 'maxmp,50', 'dexterity,50'),
(23, 'Seraph''s Truth', 35, 1, 'maxmp,75', 'dexterity,75'),
(24, 'Seraph''s Love', 40, 1, 'maxmp,100', 'dexterity,100'),
(25, 'Ruby', 50, 1, 'maxhp,150', 'X'),
(26, 'Pearl', 50, 1, 'maxmp,150', 'X'),
(27, 'Emerald', 50, 1, 'strength,150', 'X'),
(28, 'Topaz', 50, 1, 'dexterity,150', 'X'),
(29, 'Obsidian', 50, 1, 'attackpower,150', 'X'),
(30, 'Diamond', 50, 1, 'defensepower,150', 'X'),
(31, 'Memory Drop', 5, 1, 'expbonus,10', 'X'),
(32, 'Fortune Drop', 5, 1, 'goldbonus,10', 'X');
SQL);
$page .= table_status_msg($query === true, 'Drops', 'populate');
$query = db()->exec(<<<SQL
CREATE TABLE forum (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`postdate` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
`newpostdate` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
`author` TEXT NOT NULL DEFAULT '',
`parent` INTEGER NOT NULL DEFAULT 0,
`replies` INTEGER NOT NULL DEFAULT 0,
`title` TEXT NOT NULL DEFAULT '',
`content` TEXT NOT NULL
);
SQL);
$page .= table_status_msg($query === true, 'Forum', 'create');
$query = db()->exec(<<<SQL
CREATE TABLE items (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`type` INTEGER NOT NULL DEFAULT 0,
`name` TEXT NOT NULL DEFAULT '',
`buycost` INTEGER NOT NULL DEFAULT 0,
`attribute` INTEGER NOT NULL DEFAULT 0,
`special` TEXT NOT NULL DEFAULT ''
);
SQL);
$page .= table_status_msg($query === true, 'Items', 'create');
$query = db()->exec(<<<SQL
INSERT INTO items VALUES
(1, 1, 'Stick', 10, 2, 'X'),
(2, 1, 'Branch', 30, 4, 'X'),
(3, 1, 'Club', 40, 5, 'X'),
(4, 1, 'Dagger', 90, 8, 'X'),
(5, 1, 'Hatchet', 150, 12, 'X'),
(6, 1, 'Axe', 200, 16, 'X'),
(7, 1, 'Brand', 300, 25, 'X'),
(8, 1, 'Poleaxe', 500, 35, 'X'),
(9, 1, 'Broadsword', 800, 45, 'X'),
(10, 1, 'Battle Axe', 1200, 50, 'X'),
(11, 1, 'Claymore', 2000, 60, 'X'),
(12, 1, 'Dark Axe', 3000, 100, 'expbonus,-5'),
(13, 1, 'Dark Sword', 4500, 125, 'expbonus,-10'),
(14, 1, 'Bright Sword', 6000, 100, 'expbonus,10'),
(15, 1, 'Magic Sword', 10000, 150, 'maxmp,50'),
(16, 1, 'Destiny Blade', 50000, 250, 'strength,50'),
(17, 2, 'Skivvies', 25, 2, 'goldbonus,10'),
(18, 2, 'Clothes', 50, 5, 'X'),
(19, 2, 'Leather Armor', 75, 10, 'X'),
(20, 2, 'Hard Leather Armor', 150, 25, 'X'),
(21, 2, 'Chain Mail', 300, 30, 'X'),
(22, 2, 'Bronze Plate', 900, 50, 'X'),
(23, 2, 'Iron Plate', 2000, 100, 'X'),
(24, 2, 'Magic Armor', 4000, 125, 'maxmp,50'),
(25, 2, 'Dark Armor', 5000, 150, 'expbonus,-10'),
(26, 2, 'Bright Armor', 10000, 175, 'expbonus,10'),
(27, 2, 'Destiny Raiment', 50000, 200, 'dexterity,50'),
(28, 3, 'Reed Shield', 50, 2, 'X'),
(29, 3, 'Buckler', 100, 4, 'X'),
(30, 3, 'Small Shield', 500, 10, 'X'),
(31, 3, 'Large Shield', 2500, 30, 'X'),
(32, 3, 'Silver Shield', 10000, 60, 'X'),
(33, 3, 'Destiny Aegis', 25000, 100, 'maxhp,50');
SQL);
$page .= table_status_msg($query === true, 'Drops', 'populate');
$query = db()->exec(<<<SQL
CREATE TABLE classes (
'id' INTEGER PRIMARY KEY AUTOINCREMENT,
'name' TEXT NOT NULL,
'lore' TEXT NOT NULL,
'exp_rate' INTEGER NOT NULL DEFAULT 3,
'base_hp' INTEGER NOT NULL DEFAULT 15,
'base_mp' INTEGER NOT NULL DEFAULT 10,
'base_str' INTEGER NOT NULL DEFAULT 1,
'base_dex' INTEGER NOT NULL DEFAULT 1,
'hp_rate' INTEGER NOT NULL DEFAULT 2,
'mp_rate' INTEGER NOT NULL DEFAULT 2,
'str_rate' INTEGER NOT NULL DEFAULT 2,
'dex_rate' INTEGER NOT NULL DEFAULT 2,
);
SQL);
$page .= table_status_msg($query === true, 'Classes', 'create');
$query = db()->exec(<<<SQL
INSERT INTO classes VALUES
(1, 'Adventurer', '', 3, 15, 10, 4, 4, 2, 2, 2, 2),
(2, 'Mage', '', 1, 10, 15, 1, 7, 1, 3, 1, 2),
(2, 'Warrior', '', 2, 20, 5, 7, 1, 3, 1, 3, 1),
(3, 'Paladin', '', 5, 15, 15, 5, 5, 2, 2, 2, 2);
SQL);
$page .= table_status_msg($query === true, 'Classes', 'populate');
$query = db()->exec(<<<SQL
CREATE TABLE levels (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`1_exp` INTEGER NOT NULL DEFAULT 0,
`1_hp` INTEGER NOT NULL DEFAULT 0,
`1_mp` INTEGER NOT NULL DEFAULT 0,
`1_tp` INTEGER NOT NULL DEFAULT 0,
`1_strength` INTEGER NOT NULL DEFAULT 0,
`1_dexterity` INTEGER NOT NULL DEFAULT 0,
`1_spells` INTEGER NOT NULL DEFAULT 0,
`2_exp` INTEGER NOT NULL DEFAULT 0,
`2_hp` INTEGER NOT NULL DEFAULT 0,
`2_mp` INTEGER NOT NULL DEFAULT 0,
`2_tp` INTEGER NOT NULL DEFAULT 0,
`2_strength` INTEGER NOT NULL DEFAULT 0,
`2_dexterity` INTEGER NOT NULL DEFAULT 0,
`2_spells` INTEGER NOT NULL DEFAULT 0,
`3_exp` INTEGER NOT NULL DEFAULT 0,
`3_hp` INTEGER NOT NULL DEFAULT 0,
`3_mp` INTEGER NOT NULL DEFAULT 0,
`3_tp` INTEGER NOT NULL DEFAULT 0,
`3_strength` INTEGER NOT NULL DEFAULT 0,
`3_dexterity` INTEGER NOT NULL DEFAULT 0,
`3_spells` INTEGER NOT NULL DEFAULT 0
);
SQL);
$page .= table_status_msg($query === true, 'Levels', 'create');
$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),
(2, 15, 2, 5, 1, 0, 1, 1, 18, 2, 4, 1, 2, 1, 1, 20, 2, 5, 1, 0, 2, 1),
(3, 45, 3, 4, 2, 1, 2, 0, 54, 2, 3, 2, 3, 2, 0, 60, 2, 3, 2, 1, 3, 0),
(4, 105, 3, 3, 2, 1, 2, 6, 126, 2, 3, 2, 3, 2, 0, 140, 2, 4, 2, 1, 3, 0),
(5, 195, 2, 5, 2, 0, 1, 0, 234, 2, 4, 2, 2, 1, 6, 260, 2, 4, 2, 0, 2, 6),
(6, 330, 4, 5, 2, 2, 3, 0, 396, 3, 4, 2, 4, 3, 0, 440, 3, 5, 2, 2, 4, 0),
(7, 532, 3, 4, 2, 1, 2, 11, 639, 2, 3, 2, 3, 2, 0, 710, 2, 3, 2, 1, 3, 0),
(8, 835, 2, 4, 2, 0, 1, 0, 1003, 2, 3, 2, 2, 1, 11, 1115, 2, 4, 2, 0, 2, 11),
(9, 1290, 5, 3, 2, 3, 4, 2, 1549, 4, 2, 2, 5, 4, 0, 1722, 4, 2, 2, 3, 5, 0),
(10, 1973, 10, 3, 2, 4, 3, 0, 2369, 10, 2, 2, 6, 3, 0, 2633, 10, 3, 2, 4, 4, 0),
(11, 2997, 5, 2, 2, 3, 4, 0, 3598, 4, 1, 2, 5, 4, 2, 3999, 4, 1, 2, 3, 5, 2),
(12, 4533, 4, 2, 2, 2, 3, 7, 5441, 4, 1, 2, 4, 3, 0, 6047, 4, 2, 2, 2, 4, 0),
(13, 6453, 4, 3, 2, 2, 3, 0, 7745, 4, 2, 2, 4, 3, 0, 8607, 4, 2, 2, 2, 4, 0),
(14, 8853, 5, 4, 2, 3, 4, 17, 10625, 4, 3, 2, 5, 4, 7, 11807, 4, 4, 2, 3, 5, 7),
(15, 11853, 5, 5, 2, 3, 4, 0, 14225, 4, 4, 2, 5, 4, 0, 15808, 4, 4, 2, 3, 5, 0),
(16, 15603, 5, 3, 2, 3, 4, 0, 18725, 5, 2, 2, 5, 4, 0, 20807, 5, 3, 2, 3, 5, 0),
(17, 20290, 4, 2, 2, 2, 3, 12, 24350, 4, 1, 2, 4, 3, 0, 27057, 4, 1, 2, 2, 4, 0),
(18, 25563, 4, 2, 2, 2, 3, 0, 30678, 3, 1, 2, 4, 3, 14, 34869, 3, 2, 2, 2, 4, 17),
(19, 31495, 4, 5, 2, 2, 3, 0, 37797, 3, 4, 2, 4, 3, 0, 43657, 3, 4, 2, 2, 4, 0),
(20, 38169, 10, 6, 2, 3, 3, 0, 45805, 10, 5, 2, 5, 3, 0, 53543, 10, 6, 2, 3, 4, 0),
(21, 45676, 4, 4, 2, 2, 3, 0, 54814, 4, 3, 2, 4, 3, 0, 64664, 4, 3, 2, 2, 4, 0),
(22, 54121, 5, 5, 2, 3, 4, 0, 64949, 4, 4, 2, 5, 4, 12, 77175, 4, 5, 2, 3, 5, 12),
(23, 63622, 5, 3, 2, 3, 4, 0, 76350, 4, 2, 2, 5, 4, 0, 91250, 4, 2, 2, 3, 5, 0),
(24, 74310, 5, 5, 2, 3, 4, 0, 89176, 4, 4, 2, 5, 4, 0, 107083, 4, 5, 2, 3, 5, 0),
(25, 86334, 4, 4, 2, 2, 3, 3, 103605, 3, 3, 2, 4, 3, 17, 124895, 3, 3, 2, 2, 4, 14),
(26, 99861, 6, 3, 2, 4, 5, 0, 119837, 5, 2, 2, 6, 5, 0, 144933, 5, 3, 2, 4, 6, 0),
(27, 115078, 6, 2, 2, 4, 5, 0, 138098, 5, 1, 2, 6, 5, 0, 167475, 5, 1, 2, 4, 6, 0),
(28, 132197, 4, 2, 2, 2, 3, 0, 158641, 4, 1, 2, 4, 3, 0, 192835, 4, 2, 2, 2, 4, 0),
(29, 151456, 6, 3, 2, 4, 5, 0, 181751, 5, 2, 2, 6, 5, 3, 221365, 5, 2, 2, 4, 6, 3),
(30, 173121, 10, 4, 3, 4, 4, 0, 207749, 10, 3, 3, 6, 4, 0, 253461, 10, 4, 3, 4, 5, 0),
(31, 197494, 5, 5, 3, 3, 4, 8, 236996, 4, 3, 3, 5, 4, 0, 289568, 4, 3, 3, 3, 5, 0),
(32, 224913, 6, 4, 3, 4, 5, 0, 269898, 5, 3, 3, 6, 5, 0, 330188, 5, 4, 3, 4, 6, 0),
(33, 255758, 5, 4, 3, 3, 4, 0, 306912, 5, 3, 3, 5, 4, 0, 375885, 5, 3, 3, 3, 5, 0),
(34, 290458, 6, 4, 3, 4, 5, 0, 348552, 5, 3, 3, 6, 5, 8, 427294, 5, 4, 3, 4, 6, 8),
(35, 329495, 5, 3, 3, 3, 4, 0, 395397, 4, 2, 3, 5, 4, 0, 485126, 4, 2, 3, 3, 5, 0),
(36, 373412, 4, 3, 3, 2, 3, 18, 448097, 5, 2, 3, 4, 3, 0, 550188, 5, 3, 3, 2, 4, 0),
(37, 422818, 5, 4, 3, 3, 4, 0, 507384, 5, 3, 3, 5, 4, 0, 623383, 5, 3, 3, 3, 5, 0),
(38, 478399, 6, 5, 3, 4, 5, 0, 574081, 5, 4, 3, 6, 5, 15, 705726, 5, 5, 3, 4, 6, 18),
(39, 540927, 6, 4, 3, 4, 5, 0, 649115, 5, 3, 3, 6, 5, 0, 798362, 5, 3, 3, 4, 6, 0),
(40, 611271, 15, 3, 3, 5, 5, 13, 733528, 15, 2, 3, 7, 5, 0, 902577, 15, 3, 3, 5, 6, 0),
(41, 690408, 7, 3, 3, 5, 2, 0, 828492, 6, 2, 3, 7, 2, 0, 1019818, 6, 2, 3, 5, 3, 0),
(42, 779437, 7, 4, 3, 5, 6, 0, 935326, 6, 3, 3, 7, 6, 0, 1151714, 6, 4, 3, 5, 7, 0),
(43, 879592, 8, 5, 3, 6, 7, 0, 1055514, 7, 4, 3, 8, 7, 0, 1300096, 7, 4, 3, 6, 8, 0),
(44, 992268, 6, 3, 3, 4, 5, 0, 1190725, 5, 2, 3, 6, 5, 0, 1448478, 5, 3, 3, 4, 6, 0),
(45, 1119028, 5, 8, 3, 3, 4, 4, 1325936, 5, 8, 3, 5, 4, 18, 1596860, 5, 8, 3, 3, 5, 4),
(46, 1245788, 6, 5, 3, 4, 5, 0, 1461147, 5, 4, 3, 6, 5, 0, 1745242, 5, 5, 3, 4, 6, 0),
(47, 1372548, 7, 4, 3, 5, 6, 0, 1596358, 6, 3, 3, 7, 6, 0, 1893624, 6, 3, 3, 5, 7, 0),
(48, 1499308, 6, 4, 3, 4, 5, 0, 1731569, 5, 3, 3, 6, 5, 0, 2042006, 5, 4, 3, 4, 6, 0),
(49, 1626068, 5, 3, 3, 3, 4, 0, 1866780, 4, 2, 3, 5, 4, 0, 2190388, 4, 2, 3, 3, 5, 0),
(50, 1752828, 15, 3, 3, 5, 5, 0, 2001991, 15, 2, 3, 7, 5, 0, 2338770, 15, 3, 3, 5, 6, 0),
(51, 1879588, 6, 2, 3, 4, 5, 9, 2137202, 5, 1, 3, 6, 5, 13, 2487152, 5, 1, 3, 4, 6, 13),
(52, 2006348, 7, 2, 3, 5, 6, 0, 2272413, 6, 1, 3, 7, 6, 0, 2635534, 6, 2, 3, 5, 7, 0),
(53, 2133108, 8, 2, 3, 6, 7, 0, 2407624, 7, 1, 3, 8, 7, 0, 2783916, 7, 1, 3, 6, 8, 0),
(54, 2259868, 8, 4, 3, 6, 7, 0, 2542835, 7, 3, 3, 8, 7, 0, 2932298, 7, 4, 3, 6, 8, 0),
(55, 2386628, 7, 4, 3, 5, 6, 0, 2678046, 6, 3, 3, 7, 6, 0, 3080680, 6, 3, 3, 5, 7, 0),
(56, 2513388, 7, 4, 3, 5, 6, 0, 2813257, 6, 3, 3, 7, 6, 0, 3229062, 6, 4, 3, 5, 7, 9),
(57, 2640148, 6, 5, 3, 4, 5, 0, 2948468, 6, 4, 3, 6, 5, 0, 3377444, 6, 4, 3, 4, 6, 0),
(58, 2766908, 5, 5, 3, 3, 4, 0, 3083679, 5, 4, 3, 5, 4, 19, 3525826, 5, 5, 3, 3, 5, 0),
(59, 2893668, 8, 3, 3, 6, 7, 0, 3218890, 7, 2, 3, 8, 7, 0, 3674208, 7, 2, 3, 6, 8, 0),
(60, 3020428, 15, 4, 4, 6, 6, 19, 3354101, 15, 3, 4, 8, 6, 0, 3822590, 15, 4, 4, 6, 7, 15),
(61, 3147188, 8, 5, 4, 6, 7, 0, 3489312, 7, 4, 4, 8, 7, 0, 3970972, 7, 4, 4, 6, 8, 0),
(62, 3273948, 8, 4, 4, 6, 7, 0, 3624523, 7, 3, 4, 8, 7, 0, 4119354, 7, 4, 4, 6, 8, 0),
(63, 3400708, 9, 5, 4, 7, 8, 0, 3759734, 8, 4, 4, 9, 8, 0, 4267736, 8, 4, 4, 7, 9, 0),
(64, 3527468, 5, 5, 4, 3, 4, 0, 3894945, 5, 4, 4, 5, 4, 0, 4416118, 5, 5, 4, 3, 5, 0),
(65, 3654228, 6, 4, 4, 4, 5, 0, 4030156, 6, 3, 4, 6, 5, 0, 4564500, 6, 3, 4, 4, 6, 0),
(66, 3780988, 8, 4, 4, 6, 7, 0, 4165367, 8, 3, 4, 8, 7, 0, 4712882, 8, 4, 4, 6, 8, 0),
(67, 3907748, 7, 3, 4, 5, 6, 0, 4300578, 7, 2, 4, 7, 6, 0, 4861264, 7, 2, 4, 5, 7, 0),
(68, 4034508, 9, 3, 4, 7, 8, 0, 4435789, 8, 2, 4, 9, 8, 0, 5009646, 8, 3, 4, 7, 9, 0),
(69, 4161268, 5, 4, 4, 3, 4, 0, 4571000, 5, 3, 4, 5, 4, 0, 5158028, 5, 3, 4, 3, 5, 0),
(70, 4288028, 20, 4, 4, 6, 6, 5, 4706211, 20, 3, 4, 8, 6, 16, 5306410, 20, 4, 4, 6, 7, 0),
(71, 4414788, 5, 5, 4, 3, 4, 0, 4841422, 5, 4, 4, 5, 4, 0, 5454792, 5, 4, 4, 3, 5, 0),
(72, 4541548, 6, 2, 4, 4, 5, 0, 4976633, 5, 1, 4, 6, 5, 0, 5603174, 5, 2, 4, 4, 6, 0),
(73, 4668308, 8, 4, 4, 6, 7, 0, 5111844, 8, 3, 4, 8, 7, 0, 5751556, 8, 3, 4, 6, 8, 0),
(74, 4795068, 7, 5, 4, 5, 6, 0, 5247055, 6, 4, 4, 7, 6, 0, 5899938, 6, 5, 4, 5, 7, 0),
(75, 4921828, 5, 3, 4, 3, 4, 0, 5382266, 5, 2, 4, 5, 4, 0, 6048320, 5, 2, 4, 3, 5, 0),
(76, 5048588, 6, 3, 4, 4, 5, 0, 5517477, 6, 2, 4, 6, 5, 0, 6196702, 6, 3, 4, 4, 6, 0),
(77, 5175348, 6, 4, 4, 4, 5, 0, 5652688, 7, 3, 4, 6, 5, 0, 6345084, 7, 3, 4, 4, 6, 0),
(78, 5302108, 7, 4, 4, 5, 6, 0, 5787899, 7, 3, 4, 7, 6, 0, 6493466, 7, 4, 4, 5, 7, 0),
(79, 5428868, 8, 4, 4, 6, 7, 10, 5923110, 7, 3, 4, 8, 7, 0, 6641848, 7, 3, 4, 6, 8, 0),
(80, 5555628, 20, 5, 4, 6, 7, 0, 6058321, 20, 4, 4, 8, 7, 0, 6790230, 20, 5, 4, 6, 8, 0),
(81, 5682388, 7, 3, 4, 5, 6, 0, 6193532, 7, 2, 4, 7, 6, 0, 6938612, 7, 2, 4, 5, 7, 0),
(82, 5809148, 6, 4, 4, 4, 5, 0, 6328743, 5, 3, 4, 6, 5, 0, 7086994, 5, 4, 4, 4, 6, 0),
(83, 5935908, 6, 2, 4, 4, 5, 0, 6463954, 6, 1, 4, 6, 5, 0, 7235376, 6, 1, 4, 4, 6, 0),
(84, 6062668, 5, 4, 4, 3, 4, 0, 6599165, 5, 3, 4, 5, 4, 0, 7383758, 5, 4, 4, 3, 5, 0),
(85, 6189428, 7, 4, 4, 5, 6, 0, 6734376, 6, 3, 4, 7, 6, 0, 7532140, 6, 3, 4, 5, 7, 0),
(86, 6316188, 8, 5, 4, 6, 7, 0, 6869587, 8, 4, 4, 8, 7, 0, 7680522, 8, 5, 4, 6, 8, 0),
(87, 6442948, 8, 4, 4, 6, 7, 0, 7004798, 7, 3, 4, 8, 7, 0, 7828904, 7, 3, 4, 6, 8, 0),
(88, 6569708, 9, 5, 4, 7, 8, 0, 7140009, 8, 4, 4, 9, 8, 0, 7977286, 8, 5, 4, 7, 9, 0),
(89, 6696468, 5, 2, 4, 3, 4, 0, 7275220, 5, 1, 4, 5, 4, 0, 8125668, 5, 1, 4, 3, 5, 0),
(90, 6823228, 20, 2, 5, 7, 8, 0, 7410431, 20, 1, 5, 9, 8, 0, 8274050, 20, 2, 5, 7, 9, 0),
(91, 6949988, 5, 3, 5, 3, 4, 0, 7545642, 5, 2, 5, 5, 4, 0, 8422432, 5, 2, 5, 3, 5, 0),
(92, 7076748, 6, 3, 5, 4, 5, 0, 7680853, 4, 2, 5, 6, 5, 0, 8570814, 4, 3, 5, 4, 6, 0),
(93, 7203508, 8, 4, 5, 6, 7, 0, 7816064, 6, 2, 5, 8, 7, 0, 8719196, 6, 2, 5, 6, 8, 0),
(94, 7330268, 4, 4, 5, 3, 3, 0, 7951275, 4, 3, 5, 5, 3, 0, 8867578, 4, 4, 5, 3, 4, 0),
(95, 7457028, 3, 3, 5, 5, 2, 0, 8086486, 4, 2, 5, 7, 2, 0, 9015960, 4, 2, 5, 5, 3, 0),
(96, 7583788, 5, 3, 5, 4, 3, 0, 8221697, 5, 2, 5, 7, 3, 0, 9164342, 5, 3, 5, 4, 4, 0),
(97, 7710548, 5, 4, 5, 4, 5, 0, 8356908, 5, 3, 5, 7, 5, 0, 9312724, 5, 3, 5, 4, 6, 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),
(100, 16777215, 0, 0, 0, 0, 0, 0, 16777215, 0, 0, 0, 0, 0, 0, 16777215, 0, 0, 0, 0, 0, 0);
SQL);
$page .= table_status_msg($query === true, 'Levels', 'populate');
$query = db()->exec(<<<SQL
CREATE TABLE monsters (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`name` TEXT NOT NULL DEFAULT '',
`maxhp` INTEGER NOT NULL DEFAULT 0,
`maxdam` INTEGER NOT NULL DEFAULT 0,
`armor` INTEGER NOT NULL DEFAULT 0,
`level` INTEGER NOT NULL DEFAULT 0,
`maxexp` INTEGER NOT NULL DEFAULT 0,
`maxgold` INTEGER NOT NULL DEFAULT 0,
`immune` INTEGER NOT NULL DEFAULT 0
);
SQL);
$page .= table_status_msg($query === true, 'Monsters', 'create');
$query = db()->exec(<<<SQL
INSERT INTO monsters VALUES
(1, 'Blue Slime', 4, 3, 1, 1, 1, 1, 0),
(2, 'Red Slime', 6, 5, 1, 1, 2, 1, 0),
(3, 'Critter', 6, 5, 2, 1, 4, 2, 0),
(4, 'Creature', 10, 8, 2, 2, 4, 2, 0),
(5, 'Shadow', 10, 9, 3, 2, 6, 2, 1),
(6, 'Drake', 11, 10, 3, 2, 8, 3, 0),
(7, 'Shade', 12, 10, 3, 3, 10, 3, 1),
(8, 'Drakelor', 14, 12, 4, 3, 10, 3, 0),
(9, 'Silver Slime', 15, 100, 200, 30, 15, 1000, 2),
(10, 'Scamp', 16, 13, 5, 4, 15, 5, 0),
(11, 'Raven', 16, 13, 5, 4, 18, 6, 0),
(12, 'Scorpion', 18, 14, 6, 5, 20, 7, 0),
(13, 'Illusion', 20, 15, 6, 5, 20, 7, 1),
(14, 'Nightshade', 22, 16, 6, 6, 24, 8, 0),
(15, 'Drakemal', 22, 18, 7, 6, 24, 8, 0),
(16, 'Shadow Raven', 24, 18, 7, 6, 26, 9, 1),
(17, 'Ghost', 24, 20, 8, 6, 28, 9, 0),
(18, 'Frost Raven', 26, 20, 8, 7, 30, 10, 0),
(19, 'Rogue Scorpion', 28, 22, 9, 7, 32, 11, 0),
(20, 'Ghoul', 29, 24, 9, 7, 34, 11, 0),
(21, 'Magician', 30, 24, 10, 8, 36, 12, 0),
(22, 'Rogue', 30, 25, 12, 8, 40, 13, 0),
(23, 'Drakefin', 32, 26, 12, 8, 40, 13, 0),
(24, 'Shimmer', 32, 26, 14, 8, 45, 15, 1),
(25, 'Fire Raven', 34, 28, 14, 9, 45, 15, 0),
(26, 'Dybbuk', 34, 28, 14, 9, 50, 17, 0),
(27, 'Knave', 36, 30, 15, 9, 52, 17, 0),
(28, 'Goblin', 36, 30, 15, 10, 54, 18, 0),
(29, 'Skeleton', 38, 30, 18, 10, 58, 19, 0),
(30, 'Dark Slime', 38, 32, 18, 10, 62, 21, 0),
(31, 'Silver Scorpion', 30, 160, 350, 40, 63, 2000, 2),
(32, 'Mirage', 40, 32, 20, 11, 64, 21, 1),
(33, 'Sorceror', 41, 33, 22, 11, 68, 23, 0),
(34, 'Imp', 42, 34, 22, 12, 70, 23, 0),
(35, 'Nymph', 43, 35, 22, 12, 70, 23, 0),
(36, 'Scoundrel', 43, 35, 22, 12, 75, 25, 0),
(37, 'Megaskeleton', 44, 36, 24, 13, 78, 26, 0),
(38, 'Grey Wolf', 44, 36, 24, 13, 82, 27, 0),
(39, 'Phantom', 46, 38, 24, 14, 85, 28, 1),
(40, 'Specter', 46, 38, 24, 14, 90, 30, 0),
(41, 'Dark Scorpion', 48, 40, 26, 15, 95, 32, 1),
(42, 'Warlock', 48, 40, 26, 15, 100, 33, 1),
(43, 'Orc', 49, 42, 28, 15, 104, 35, 0),
(44, 'Sylph', 49, 42, 28, 15, 106, 35, 0),
(45, 'Wraith', 50, 45, 30, 16, 108, 36, 0),
(46, 'Hellion', 50, 45, 30, 16, 110, 37, 0),
(47, 'Bandit', 52, 45, 30, 16, 114, 38, 0),
(48, 'Ultraskeleton', 52, 46, 32, 16, 116, 39, 0),
(49, 'Dark Wolf', 54, 47, 36, 17, 120, 40, 1),
(50, 'Troll', 56, 48, 36, 17, 120, 40, 0),
(51, 'Werewolf', 56, 48, 38, 17, 124, 41, 0),
(52, 'Hellcat', 58, 50, 38, 18, 128, 43, 0),
(53, 'Spirit', 58, 50, 38, 18, 132, 44, 0),
(54, 'Nisse', 60, 52, 40, 19, 132, 44, 0),
(55, 'Dawk', 60, 54, 40, 19, 136, 45, 0),
(56, 'Figment', 64, 55, 42, 19, 140, 47, 1),
(57, 'Hellhound', 66, 56, 44, 20, 140, 47, 0),
(58, 'Wizard', 66, 56, 44, 20, 144, 48, 0),
(59, 'Uruk', 68, 58, 44, 20, 146, 49, 0),
(60, 'Siren', 68, 400, 800, 50, 10000, 50, 2),
(61, 'Megawraith', 70, 60, 46, 21, 155, 52, 0),
(62, 'Dawkin', 70, 60, 46, 21, 155, 52, 0),
(63, 'Grey Bear', 70, 62, 48, 21, 160, 53, 0),
(64, 'Haunt', 72, 62, 48, 22, 160, 53, 0),
(65, 'Hellbeast', 74, 64, 50, 22, 165, 55, 0),
(66, 'Fear', 76, 66, 52, 23, 165, 55, 0),
(67, 'Beast', 76, 66, 52, 23, 170, 57, 0),
(68, 'Ogre', 78, 68, 54, 23, 170, 57, 0),
(69, 'Dark Bear', 80, 70, 56, 24, 175, 58, 1),
(70, 'Fire', 80, 72, 56, 24, 175, 58, 0),
(71, 'Polgergeist', 84, 74, 58, 25, 180, 60, 0),
(72, 'Fright', 86, 76, 58, 25, 180, 60, 0),
(73, 'Lycan', 88, 78, 60, 25, 185, 62, 0),
(74, 'Terra Elemental', 88, 80, 62, 25, 185, 62, 1),
(75, 'Necromancer', 90, 80, 62, 26, 190, 63, 0),
(76, 'Ultrawraith', 90, 82, 64, 26, 190, 63, 0),
(77, 'Dawkor', 92, 82, 64, 26, 195, 65, 0),
(78, 'Werebear', 92, 84, 65, 26, 195, 65, 0),
(79, 'Brute', 94, 84, 65, 27, 200, 67, 0),
(80, 'Large Beast', 96, 88, 66, 27, 200, 67, 0),
(81, 'Horror', 96, 88, 68, 27, 210, 70, 0),
(82, 'Flame', 100, 90, 70, 28, 210, 70, 0),
(83, 'Lycanthor', 100, 90, 70, 28, 210, 70, 0),
(84, 'Wyrm', 100, 92, 72, 28, 220, 73, 0),
(85, 'Aero Elemental', 104, 94, 74, 29, 220, 73, 1),
(86, 'Dawkare', 106, 96, 76, 29, 220, 73, 0),
(87, 'Large Brute', 108, 98, 78, 29, 230, 77, 0),
(88, 'Frost Wyrm', 110, 100, 80, 30, 230, 77, 0),
(89, 'Knight', 110, 102, 80, 30, 240, 80, 0),
(90, 'Lycanthra', 112, 104, 82, 30, 240, 80, 0),
(91, 'Terror', 115, 108, 84, 31, 250, 83, 0),
(92, 'Blaze', 118, 108, 84, 31, 250, 83, 0),
(93, 'Aqua Elemental', 120, 110, 90, 31, 260, 87, 1),
(94, 'Fire Wyrm', 120, 110, 90, 32, 260, 87, 0),
(95, 'Lesser Wyvern', 122, 110, 92, 32, 270, 90, 0),
(96, 'Doomer', 124, 112, 92, 32, 270, 90, 0),
(97, 'Armor Knight', 130, 115, 95, 33, 280, 93, 0),
(98, 'Wyvern', 134, 120, 95, 33, 290, 97, 0),
(99, 'Nightmare', 138, 125, 100, 33, 300, 100, 0),
(100, 'Fira Elemental', 140, 125, 100, 34, 310, 103, 1),
(101, 'Megadoomer', 140, 128, 105, 34, 320, 107, 0),
(102, 'Greater Wyvern', 145, 130, 105, 34, 335, 112, 0),
(103, 'Advocate', 148, 132, 108, 35, 350, 117, 0),
(104, 'Strong Knight', 150, 135, 110, 35, 365, 122, 0),
(105, 'Liche', 150, 135, 110, 35, 380, 127, 0),
(106, 'Ultradoomer', 155, 140, 115, 36, 395, 132, 0),
(107, 'Fanatic', 160, 140, 115, 36, 410, 137, 0),
(108, 'Green Dragon', 160, 140, 115, 36, 425, 142, 0),
(109, 'Fiend', 160, 145, 120, 37, 445, 148, 0),
(110, 'Greatest Wyvern', 162, 150, 120, 37, 465, 155, 0),
(111, 'Lesser Devil', 164, 150, 120, 37, 485, 162, 0),
(112, 'Liche Master', 168, 155, 125, 38, 505, 168, 0),
(113, 'Zealot', 168, 155, 125, 38, 530, 177, 0),
(114, 'Serafiend', 170, 155, 125, 38, 555, 185, 0),
(115, 'Pale Knight', 175, 160, 130, 39, 580, 193, 0),
(116, 'Blue Dragon', 180, 160, 130, 39, 605, 202, 0),
(117, 'Obsessive', 180, 160, 135, 40, 630, 210, 0),
(118, 'Devil', 184, 164, 135, 40, 666, 222, 0),
(119, 'Liche Prince', 190, 168, 138, 40, 660, 220, 0),
(120, 'Cherufiend', 195, 170, 140, 41, 690, 230, 0),
(121, 'Red Dragon', 200, 180, 145, 41, 720, 240, 0),
(122, 'Greater Devil', 200, 180, 145, 41, 750, 250, 0),
(123, 'Renegade', 205, 185, 150, 42, 780, 260, 0),
(124, 'Archfiend', 210, 190, 150, 42, 810, 270, 0),
(125, 'Liche Lord', 210, 190, 155, 42, 850, 283, 0),
(126, 'Greatest Devil', 215, 195, 160, 43, 890, 297, 0),
(127, 'Dark Knight', 220, 200, 160, 43, 930, 310, 0),
(128, 'Giant', 220, 200, 165, 43, 970, 323, 0),
(129, 'Shadow Dragon', 225, 200, 170, 44, 1010, 337, 0),
(130, 'Liche King', 225, 205, 170, 44, 1050, 350, 0),
(131, 'Incubus', 230, 205, 175, 44, 1100, 367, 1),
(132, 'Traitor', 230, 205, 175, 45, 1150, 383, 0),
(133, 'Demon', 240, 210, 180, 45, 1200, 400, 0),
(134, 'Dark Dragon', 245, 215, 180, 45, 1250, 417, 1),
(135, 'Insurgent', 250, 220, 190, 46, 1300, 433, 0),
(136, 'Leviathan', 255, 225, 190, 46, 1350, 450, 0),
(137, 'Grey Daemon', 260, 230, 190, 46, 1400, 467, 0),
(138, 'Succubus', 265, 240, 200, 47, 1460, 487, 1),
(139, 'Demon Prince', 270, 240, 200, 47, 1520, 507, 0),
(140, 'Black Dragon', 275, 250, 205, 47, 1580, 527, 1),
(141, 'Nihilist', 280, 250, 205, 47, 1640, 547, 0),
(142, 'Behemoth', 285, 260, 210, 48, 1700, 567, 0),
(143, 'Demagogue', 290, 260, 210, 48, 1760, 587, 0),
(144, 'Demon Lord', 300, 270, 220, 48, 1820, 607, 0),
(145, 'Red Daemon', 310, 280, 230, 48, 1880, 627, 0),
(146, 'Colossus', 320, 300, 240, 49, 1940, 647, 0),
(147, 'Demon King', 330, 300, 250, 49, 2000, 667, 0),
(148, 'Dark Daemon', 340, 320, 260, 49, 2200, 733, 1),
(149, 'Titan', 360, 340, 270, 50, 2400, 800, 0),
(150, 'Black Daemon', 400, 400, 280, 50, 3000, 1000, 1),
(151, 'Lucifuge', 600, 600, 400, 50, 10000, 10000, 2);
SQL);
$page .= table_status_msg($query === true, 'Monsters', 'populate');
$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
);
SQL);
$page .= table_status_msg($query === true, 'News', 'create');
$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.');");
$page .= table_status_msg($query === true, 'News', 'populate');
$query = db()->exec(<<<SQL
CREATE TABLE spells (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`name` TEXT NOT NULL,
`mp` INTEGER NOT NULL DEFAULT 0,
`attribute` INTEGER NOT NULL DEFAULT 0,
`type` INTEGER NOT NULL DEFAULT 0
);
SQL);
$page .= table_status_msg($query === true, 'Spells', 'create');
$query = db()->exec(<<<SQL
INSERT INTO spells VALUES
(1, 'Heal', 5, 10, 1),
(2, 'Revive', 10, 25, 1),
(3, 'Life', 25, 50, 1),
(4, 'Breath', 50, 100, 1),
(5, 'Gaia', 75, 150, 1),
(6, 'Hurt', 5, 15, 2),
(7, 'Pain', 12, 35, 2),
(8, 'Maim', 25, 70, 2),
(9, 'Rend', 40, 100, 2),
(10, 'Chaos', 50, 130, 2),
(11, 'Sleep', 10, 5, 3),
(12, 'Dream', 30, 9, 3),
(13, 'Nightmare', 60, 13, 3),
(14, 'Craze', 10, 10, 4),
(15, 'Rage', 20, 25, 4),
(16, 'Fury', 30, 50, 4),
(17, 'Ward', 10, 10, 5),
(18, 'Fend', 20, 25, 5),
(19, 'Barrier', 30, 50, 5);
SQL);
$page .= table_status_msg($query === true, 'Spells', 'populate');
$query = db()->exec(<<<SQL
CREATE TABLE towns (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`name` TEXT NOT NULL,
`latitude` INTEGER NOT NULL DEFAULT 0,
`longitude` INTEGER NOT NULL DEFAULT 0,
`innprice` INTEGER NOT NULL DEFAULT 0,
`mapprice` INTEGER NOT NULL DEFAULT 0,
`travelpoints` INTEGER NOT NULL DEFAULT 0,
`itemslist` TEXT NOT NULL
);
SQL);
$page .= table_status_msg($query === true, 'Towns', 'create');
$query = db()->exec(<<<SQL
INSERT INTO towns VALUES
(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'),
(3, 'Bris', 70, -70, 25, 50, 15, '2,3,4,5,18,19,20,29.30'),
(4, 'Kalle', -100, 100, 40, 100, 30, '5,6,8,10,12,21,22,23,29,30'),
(5, 'Narcissa', -130, -130, 60, 500, 50, '4,7,9,11,13,21,22,23,29,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'),
(8, 'Endworld', -250, -250, 125, 9000, 160, '16,27,33');
SQL);
$page .= table_status_msg($query === true, 'Towns', 'populate');
$query = db()->exec(<<<SQL
CREATE TABLE users (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`username` TEXT NOT NULL,
`password` TEXT NOT NULL,
`email` TEXT NOT NULL,
`verify` TEXT NOT NULL default '',
`regdate` datetime NOT NULL default CURRENT_TIMESTAMP,
`onlinetime` datetime NOT NULL default CURRENT_TIMESTAMP,
`authlevel` INTEGER NOT NULL default 0,
`latitude` INTEGER NOT NULL default 0,
`longitude` INTEGER NOT NULL default 0,
`charclass` INTEGER NOT NULL default 0,
'class_id' INTEGER NOT NULL DEFAULT 1,
`currentaction` TEXT NOT NULL default 'In Town',
`currentfight` INTEGER NOT NULL default 0,
`currentmonster` INTEGER NOT NULL default 0,
`currentmonsterhp` INTEGER NOT NULL default 0,
`currentmonstersleep` INTEGER NOT NULL default 0,
`currentmonsterimmune` INTEGER NOT NULL default 0,
`currentuberdamage` INTEGER NOT NULL default 0,
`currentuberdefense` INTEGER NOT NULL default 0,
`currenthp` INTEGER NOT NULL default 15,
`currentmp` INTEGER NOT NULL default 0,
`currenttp` INTEGER NOT NULL default 10,
`maxhp` INTEGER NOT NULL default 15,
`maxmp` INTEGER NOT NULL default 0,
`maxtp` INTEGER NOT NULL default 10,
`level` INTEGER NOT NULL default 1,
`gold` INTEGER NOT NULL default 100,
`experience` INTEGER NOT NULL default 0,
`goldbonus` INTEGER NOT NULL default 0,
`expbonus` INTEGER NOT NULL default 0,
`strength` INTEGER NOT NULL default 5,
`dexterity` INTEGER NOT NULL default 5,
`attackpower` INTEGER NOT NULL default 5,
`defensepower` INTEGER NOT NULL default 5,
`weaponid` INTEGER NOT NULL default 0,
`armorid` INTEGER NOT NULL default 0,
`shieldid` INTEGER NOT NULL default 0,
`slot1id` INTEGER NOT NULL default 0,
`slot2id` INTEGER NOT NULL default 0,
`slot3id` INTEGER NOT NULL default 0,
`weaponname` TEXT NOT NULL default 'None',
`armorname` TEXT NOT NULL default 'None',
`shieldname` TEXT NOT NULL default 'None',
`slot1name` TEXT NOT NULL default 'None',
`slot2name` TEXT NOT NULL default 'None',
`slot3name` TEXT NOT NULL default 'None',
`dropcode` INTEGER NOT NULL default 0,
`spells` TEXT NOT NULL default '0',
`towns` TEXT NOT NULL default '0',
`game_skin` INTEGER NOT NULL DEFAULT 0
);
SQL);
$page .= table_status_msg($query === true, 'Users', 'create');
$time = round((microtime(true) - START), 4);
return $page . "<br>Database setup complete in $time seconds.<br><br><a href=\"/install/third\">Click here to continue with installation.</a></body></html>";
}
/**
* Gather user info for admin account.
*/
function third()
{
return <<<HTML
<html>
<head>
<title>Dragon Knight Installation</title>
</head>
<body>
<b>Dragon Knight Installation: Page Three</b><br><br>
Now you must create an administrator account so you can use the control panel. Fill out the form below to create your account. You will be able to customize the class names through the control panel once your admin account is created.<br><br>
<form action="/install/fourth" method="post">
<table width="50%">
<tr><td width="20%" style="vertical-align:top;">Username:</td><td><input type="text" name="username" /><br><br><br></td></tr>
<tr><td style="vertical-align:top;">Password:</td><td><input type="password" name="password" /></td></tr>
<tr><td style="vertical-align:top;">Verify Password:</td><td><input type="password" name="confirm_password" /><br><br><br></td></tr>
<tr><td style="vertical-align:top;">Email Address:</td><td><input type="text" name="email" /></td></tr>
<tr><td style="vertical-align:top;">Verify Email:</td><td><input type="text" name="confirm_email" /><br><br><br></td></tr>
<tr><td style="vertical-align:top;">Character Class:</td><td><select name="charclass"><option value="1">Mage</option><option value="2">Warrior</option><option value="3">Paladin</option></select></td></tr>
<tr><td colspan="2"><input type="submit" name="submit" value="Submit" /> <input type="reset" name="reset" value="Reset" /></td></tr>
</table>
</form>
</body>
</html>
HTML;
}
/**
* Final page: insert new user row, congratulate the person on a job well done.
*/
function fourth()
{
$form = validate($_POST, [
'username' => ['length:3-18', 'alpha-spaces'],
'email' => ['email'],
'confirm_email' => ['confirm'],
'password' => ['length:6-255'],
'confirm_password' => ['confirm']
]);
if (!$form['valid']) exit(ul_from_validate_errors($form['errors']));
$form = $form['data'];
if (db()->query(
"INSERT INTO users (username, password, email, verify, charclass, authlevel) VALUES (?, ?, ?, 'g2g', ?, 1)",
[$form['username'], password_hash($form['password'], PASSWORD_ARGON2ID), $form['email'], $form['charclass']]
) === false) {
exit("Failed to create user.");
}
file_put_contents('../.installed', date('Y-m-d H:i:s'));
return <<<HTML
<html>
<head>
<title>Dragon Knight Installation</title>
</head>
<body>
<b>Dragon Knight Installation: Page Four</b><br><br>
Your admin account was created successfully. Installation is complete.<br><br>
Be sure to delete install.php from your Dragon Knight directory for security purposes.<br><br>
You are now ready to <a href="/">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.<br><br/>
Thank you for using Dragon Knight!<br><br>-----<br><br>
<b>Optional:</b> Dragon Knight is a free product, and does not require registration of any sort. However, there is an
optional "call home" function in the installer, which notifies the author of your game installation. The ONLY information
transmitted with this function is the URL to your game. This is included mainly to satisfy the author's curiosity about
how many copies of the game are being installed and used. If you choose to submit your URL to the author, please
<a href="/install/fifth">click here</a>.
</body>
</html>
HTML;
}
/**
* Call Home function.
*/
function fifth()
{
if (mail("sky@sharkk.net", "Dragon Knight Call Home", $_SERVER["SERVER_NAME"].$_SERVER["PHP_SELF"]) !== true) {
exit('Dragon Knight was unable to send your URL. Please go back and try again, or just continue on to <a href=\"/\">the game</a>.');
}
return <<<HTML
<html>
<head>
<title>Dragon Knight Installation</title>
</head>
<body>
<b>Dragon Knight Installation: Page Five</b><br><br>
Thank you for submitting your URL!<br><br>
You are now ready to <a href="/">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>
</html>
HTML;
}
function table_status_msg(bool $condition, string $table_name, string $verb): string
{
$verb = match($verb) {
'create' => ['created', 'creating'],
'populate' => ['populated', 'populating']
};
if ($condition === false) {
return "Error {$verb[1]} $table_name table. (".db()->lastErrorMsg().")<br>";
}
return "$table_name table {$verb[0]}.<br>";
}

401
src/actions/towns.php Normal file
View File

@ -0,0 +1,401 @@
<?php
// towns.php :: Handles all actions you can do in town.
namespace Towns;
use Router;
function register_routes(Router $r): Router
{
$r->form('/inn', 'Towns\inn');
$r->get('/shop', 'Towns\shop');
$r->form('/buy/:id', 'Towns\buy');
// $r->get('/sell', 'Towns\sell');
$r->get('/maps', 'Towns\maps');
$r->form('/maps/:id', 'Towns\buy_map');
$r->get('/gotown/:id', 'Towns\travelto');
return $r;
}
/**
* Spit out the main town page.
*/
function town()
{
$town = get_town_by_xy(user()->longitude, user()->latitude);
if ($town === false) exit('There is an error with your user account, or with the town data. Please try again.');
$page = ['news' => '', 'whos_online' => ''];
// News box. Grab latest news entry and display it. Something a little more graceful coming soon maybe.
if (env('show_news')) {
$news = db()->query('SELECT * FROM news ORDER BY id DESC LIMIT 1;')->fetchArray(SQLITE3_ASSOC);
$news_date = pretty_date($news["postdate"]);
$news_content = nl2br($news["content"]);
$page['news'] = <<<HTML
<div class="title">Latest News</div>
<span class="light">$news_date</span><br>
$news_content
HTML;
}
// Who's Online. Currently just members. Guests maybe later.
if (env('show_online')) {
$onlinequery = db()->query(<<<SQL
SELECT id, username
FROM users
WHERE onlinetime >= datetime('now', '-600 seconds')
ORDER BY username;
SQL);
$online_count = 0;
$online_rows = [];
while ($onlinerow = $onlinequery->fetchArray(SQLITE3_ASSOC)) {
$online_count++;
$online_rows[] = "<a href=\"javascript:opencharpopup({$onlinerow['id']})\">".$onlinerow["username"]."</a>";
}
$online_rows = implode(', ', $online_rows);
$page['whos_online'] = <<<HTML
<div class="title">Who's Online</div>
There are <b>$online_count</b> user(s) online within the last 10 minutes: $online_rows
HTML;
}
page_title($town['name']);
return render('towns', ['town' => $town, 'news' => $page['news'], 'whos_online' => $page['whos_online']]);
}
/**
* Staying at the inn resets all expendable stats to their max values.
* GET/POST /inn
*/
function inn()
{
$town = get_town_by_xy(user()->longitude, user()->latitude);
if ($town === false) { exit('Cheat attempt detected.<br><br>Get a life, loser.'); }
if (user()->gold < $town['innprice']) {
$page = <<<HTML
You do not have enough gold to stay at this Inn tonight. <br><br>
You may return to <a hx-get="/" hx-target="#middle">town</a>, or use the direction buttons on the left to start exploring.
HTML;
} elseif (is_post() && $_POST['rest']) {
user()->gold -= $town['innprice'];
user()->restore_points()->save();
$page = <<<HTML
You wake up feeling refreshed and ready for action. <br><br>
You may return to <a hx-get="/" hx-target="#middle">town</a>, or use the direction buttons on the left to start exploring.
HTML;
} elseif (is_post() && !$_POST['rest']) {
redirect('/');
} else {
$page = <<<HTML
Resting at the inn will refill your current HP, MP, and TP to their maximum levels.<br><br>
A night's sleep at this Inn will cost you <b>{$town['innprice']} gold</b>. Is that ok?<br><br>
<form hx-post="/inn" hx-target="#middle">
<button name="rest" value="1">Yes</button>
<button name="rest" value="0">No</button>
</form>
HTML;
}
page_title($town['name'] . ' Inn');
return $page;
}
/**
* Displays a list of available items for purchase from the town the user is currently in. If the user is not in a town,
* redirects to home.
* GET /shop
*/
function shop()
{
$town = get_town_by_xy(user()->longitude, user()->latitude);
if ($town === false) exit('Cheat attempt detected.<br><br>Get a life, loser.');
$page = <<<HTML
Buying weapons will increase your Attack Power. Buying armor and shields will increase your Defense Power.<br><br>
Click an item name to purchase it.<br><br>
The following items are available at this town:<br><br>
<table>
HTML;
$items = db()->query('SELECT * FROM items WHERE id IN (' . $town["itemslist"] . ');');
while ($item = $items->fetchArray(SQLITE3_ASSOC)) {
$attrib = ($item["type"] == 1) ? "Attack Power:" : "Defense Power:";
$page .= '<tr><td width="4%">';
$page .= match ($item["type"]) {
1 => '<img src="/img/icon_weapon.gif" alt="weapon">',
2 => '<img src="/img/icon_armor.gif" alt="armor">',
3 => '<img src="/img/icon_shield.gif" alt="shield">'
};
$page .= '</td>';
if (user()->weaponid === $item["id"] || user()->armorid === $item["id"] || user()->shieldid === $item["id"]) {
$page .= <<<HTML
<td width="32%"><span class="light">{$item["name"]}</span></td>
<td width="32%"><span class="light">$attrib {$item['attribute']}</span></td>
<td width="32%"><span class="light">Already purchased</span></td>
HTML;
} else {
$specialdot = $item['special'] !== 'X' ? '<span class="highlight">&#42;</span>' : '';
$page .= <<<HTML
<td width="32%"><b><a hx-get="/buy/{$item['id']}" hx-target="#middle">{$item['name']}</a>$specialdot</b></td>
<td width="32%">$attrib <b>{$item['attribute']}</b></td>
<td width="32%">Price: <b>{$item['buycost']} gold</b></td>
HTML;
}
$page .= '</tr>';
}
$page .= <<<HTML
</table><br>
If you've changed your mind, you may also return back to <a hx-get="/" hx-target="#middle">town</a>.
HTML;
page_title($town['name'] . ' Shop');
return $page;
}
/**
* Confirm user's intent to purchase item.
*/
function buy(int $id)
{
$town = get_town_by_xy(user()->longitude, user()->latitude);
if ($town === false) redirect('/');
if (!in_array($id, explode(',', $town['itemslist']))) redirect('/shop');
$item = get_item($id);
$can_afford = user()->gold >= $item['buycost'];
if (!$can_afford) {
$page = <<<HTML
You do not have enough gold to buy <b>{$item['name']}</b>.<br><br>
You may return to <a hx-get="/" hx-target="#middle">town</a>, <a hx-get="/shop" hx-target="#middle">shop</a>,
or use the direction buttons on the left to start exploring.
HTML;
} elseif (is_post() && !$_POST['buy']) {
redirect('/shop');
} elseif (is_post() && $_POST['buy']) {
$type_mapping = [
1 => ['id' => 'weaponid', 'name' => 'weaponname', 'power' => 'attackpower'],
2 => ['id' => 'armorid', 'name' => 'armorname', 'power' => 'defensepower'],
3 => ['id' => 'shieldid', 'name' => 'shieldname', 'power' => 'defensepower']
];
if (!isset($type_mapping[$item["type"]])) { // should never happen
return 'Error! Invalid item type...<br>'.var_dump($item);
}
// Retrieve current equipped item or create a default
$current_equip_id = user()->{$type_mapping[$item["type"]]['id']};
if ($current_equip_id != 0) {
$item2 = get_item($current_equip_id);
} else {
$item2 = ["attribute" => 0, "buycost" => 0, "special" => "X"];
}
// Process special item effects
$specialFields = [];
$specialValues = [];
$powerAdjustments = 0;
foreach ([$item, $item2] as $index => $process_item) {
if ($process_item["special"] != "X") {
$special = explode(",", $process_item["special"]);
$toChange = $special[0];
$changeAmount = $index === 0 ? $special[1] : -$special[1];
user()->$toChange += $changeAmount;
$specialFields[] = "$toChange = ?";
$specialValues[] = user()->$toChange;
// Adjust attack or defense power
if ($toChange == "strength" || $toChange == "dexterity") {
$powerType = $toChange == "strength" ? "attackpower" : "defensepower";
$powerAdjustments += $changeAmount;
}
}
}
// Determine power and type-specific updates
$currentType = $type_mapping[$item['type']];
$powerField = $currentType['power'];
user()->$powerField += $item['attribute'] - $item2['attribute'];
// Calculate new gold with trade-in value
user()->gold += ceil($item2['buycost'] / 2) - $item['buycost'];
// Ensure current HP/MP/TP don't exceed max values
user()->currenthp = min(user()->currenthp, user()->maxhp);
user()->currentmp = min(user()->currentmp, user()->maxmp);
user()->currenttp = min(user()->currenttp, user()->maxtp);
// Update item info in user
user()->{$type_mapping[$item['type']]['id']} = $item['id'];
user()->{$type_mapping[$item['type']]['name']} = $item['name'];
user()->save();
$page = <<<HTML
Thank you for purchasing <b>{$item['name']}</b>.<br><br>
You may return to <a hx-get="/" hx-target="#middle">town</a>, <a hx-get="/shop" hx-target="#middle">shop</a>, or use the direction buttons on the
left to start exploring.
HTML;
} else {
$type_to_row_mapping = [1 => 'weaponid', 2 => 'armorid', 3 => 'shieldid'];
$current_equipped_id = user()->{$type_to_row_mapping[$item['type']]} ?? 0;
if ($current_equipped_id != 0) {
$item2 = get_item($current_equipped_id);
$sell_price = ceil($item2['buycost'] / 2);
$page = <<<HTML
If you are buying the {$item['name']}, then I will buy your {$item2['name']} for $sell_price gold. Is that ok?<br><br>
<form hx-post="/buy/$id" hx-target="#middle">
<button name="buy" value="1">Yes</button>
<button name="buy" value="0">No</button>
</form>
HTML;
} else {
$page = <<<HTML
You are buying {$item['name']} for {$item['buycost']} gold, is that ok?<br><br>
<form hx-post="/buy/$id" hx-target="#middle">
<button name="buy" value="1">Yes</button>
<button name="buy" value="0">No</button>
</form>
HTML;
}
}
page_title('Buying '.$item['name']);
return $page;
}
/**
* List maps the user can buy.
*/
function maps()
{
$page = <<<HTML
Buying maps will put the town in your Travel To box, and it won't cost you as many TP to get there.<br><br>
Click a town name to purchase its map.<br><br>
<table>
HTML;
$mapped = explode(',', user()->towns);
$towns = db()->query('SELECT * FROM towns ORDER BY id;');
while ($town = $towns->fetchArray(SQLITE3_ASSOC)) {
$latitude = ($town["latitude"] >= 0) ? $town["latitude"] . "N," : ($town["latitude"] * -1) . "S,";
$longitude = ($town["longitude"] >= 0) ? $town["longitude"] . "E" : ($town["longitude"] * -1) . "W";
if (in_array($town['id'], $mapped)) {
$page .= <<<HTML
<tr>
<td width="25%"><span class="light">{$town['name']}</span></td>
<td width="25%"><span class="light">Already mapped.</span></td>
<td width="35%"><span class="light">Location: $latitude $longitude</span></td>
<td width="15%"><span class="light">TP: {$town['travelpoints']}</span></td>
</tr>
HTML;
} else {
$page .= <<<HTML
<tr>
<td width="25%"><a href="/maps/{$town['id']}">{$town['name']}</a></td>
<td width="25%">Price: {$town['mapprice']} gold</td>
<td width="50%" colspan="2">Buy map to reveal details.</td>
</tr>
HTML;
}
}
$page .= <<<HTML
</table><br>
If you've changed your mind, you may also return back to <a hx-get="/" hx-target="#middle">town</a>.
HTML;
page_title('Maps');
return $page;
}
function buy_map(int $id): string
{
$town = get_town_by_id($id);
if ($town === false) redirect('/maps');
if (user()->gold < $town['mapprice']) {
$page = <<<HTML
You do not have enough gold to buy this map.<br><br>
You may return to <a hx-get="/" hx-target="#middle">town</a>, <a hx-get="/maps" hx-target="#middle">store</a>, or use the direction buttons on the left to start exploring.
HTML;
} elseif (is_post() && $_POST['buy']) {
user()->towns .= ",$id";
user()->gold -= $town['mapprice'];
user()->save();
$page = <<<HTML
Thank you for purchasing this map.<br><br>
You may return to <a hx-get="/" hx-target="#middle">town</a>, <a hx-get="/maps" hx-target="#middle">map shop</a>, or use the direction buttons on the left to start exploring.
HTML;
} elseif (is_post() && !$_POST['buy']) {
redirect('/maps');
} else {
$page = <<<HTML
You are buying the <b>{$town['name']}</b> map for {$town['mapprice']} gold. Is that ok?<br><br>
<form action="/maps/$id" method="post">
<button name="buy" value="1">Yes</button>
<button name="buy" value="0">No</button>
</form>
HTML;
}
page_title('Buying '.$town['name'].' Map');
return $page;
}
/**
* Send a user to a town from the Travel To menu.
*/
function travelto(int $id, bool $use_points = true): string
{
if (user()->currentaction == "Fighting") redirect('/fight');
$town = get_town_by_id($id);
$cost = $use_points ? $town['travelpoints'] : 0;
$mapped = explode(',', user()->towns);
$travelled = false;
if ($use_points && !in_array($id, $mapped)) {
// trying to teleport to this town when it is not mapped
redirect('/');
} elseif (user()->currenttp < $cost) {
$page = 'You do not have enough TP to travel here. Please <a href="/" hx-get="/" hx-target="#middle">go back</a> and try again when you get more TP.';
} elseif ((user()->latitude == $town['latitude']) && (user()->longitude == $town['longitude'])) {
if (!in_array($id, $mapped)) {
// add town to user's mapped if they travelled here
user()->towns .= ",$id";
$travelled = true;
$page = <<<HTML
You have discovered <b>{$town['name']}</b>! It has been added to your mapped towns.<br><br>
You may now <a href="/" hx-get="/" hx-target="#middle">enter this town</a>.
HTML;
} else {
$page = 'You are already in this town. <a href="/" hx-get="/" hx-target="#middle">Click here</a> to return.';
}
} else {
user()->latitude = $town['latitude'];
user()->longitude = $town['longitude'];
user()->currenttp -= $cost;
$travelled = true;
$page = 'You have travelled to <b>'.$town['name'].'</b>. You may now <a href="/" hx-get="/" hx-target="#middle">enter this town</a>.';
}
if ($travelled) {
user()->currentaction = 'In Town';
user()->save();
}
page_title('Travelling to '.$town['name']);
return $page;
}

226
src/actions/users.php Normal file
View File

@ -0,0 +1,226 @@
<?php
namespace Users;
use Router;
function register_routes(Router $r): Router
{
$r->form('/login', 'Users\login');
$r->get('/logout', 'Users\logout');
$r->form('/register', 'Users\register');
$r->form('/lostpassword', 'Users\lostpassword');
$r->post('/changepassword', 'Users\changepassword');
$r->form('/verify', 'Users\verify');
$r->form('/settings', 'Users\settings');
return $r;
}
/**
* Displays the login page, and processes login requests.
*/
function login()
{
global $auth;
if (is_post()) {
$form = validate($_POST, [
'username' => ['length:3-18', 'alpha-spaces'],
'password' => ['length:6-255']
]);
if (!$form['valid']) exit(ul_from_validate_errors($form['errors']));
$good = $auth->login($form['data']['username'], $form['data']['password']);
if (!$good) exit('Invalid username or password. Please go back and try again.');
redirect('/');
}
page_title('Login');
return render('login');
}
/**
* Delete the current cookie and redirect to home.
*/
function logout()
{
global $auth;
$auth->logout();
redirect('/login');
}
/**
* Register a new account.
*/
function register()
{
if (isset($_POST["submit"])) {
$form = validate($_POST, [
'username' => ['length:3-18', 'alpha-spaces', 'unique:users,username'],
'email' => ['email', 'unique:users,email'],
'confirm_email' => ['confirm'],
'password' => ['length:6-255'],
'confirm_password' => ['confirm'],
'charclass' => ['in:1,2,3']
]);
if (!$form['valid']) {
$err = ul_from_validate_errors($form['errors']);
$page = "The following error(s) occurred when your account was being made:<br><span style=\"color:red;\">$err</span><br>Please go back and try again.";
} else {
$form = $form['data'];
$password = password_hash($form['password'], PASSWORD_ARGON2ID);
$token = env('verify_email') ? token(8) : 'g2g';
db()->query('INSERT INTO users (verify, username, password, email, charclass) VALUES (?, ?, ?, ?, ?)', [
$token, $form['username'], $password, $form['email'], $form['charclass']
]);
if (env('verify_email')) {
if (sendregmail($form['email'], $token)) {
$page = "Your account was created successfully.<br><br>You should receive an Account Verification email shortly. You will need the verification code contained in that email before you are allowed to log in. Once you have received the email, please visit the <a href=\"users.php?do=verify\">Verification Page</a> to enter your code and start playing.";
} else {
$page = "Your account was created successfully.<br><br>However, there was a problem sending your verification email. Please check with the game administrator to help resolve this problem.";
}
} else {
$page = "Your account was created succesfully.<br><br>You may now continue to the <a href=\"/login\">Login Page</a> and continue playing ".env('game_name')."!";
}
}
} else {
if (env('verify_email')) {
$verify_text = "<br><span class=\"small\">A verification code will be sent to the address above, and you will not be able to log in without first entering the code. Please be sure to enter your correct email address.</span>";
} else {
$verify_text = "";
}
$page = render('register', ['verify_text' => $verify_text]);
}
page_title('Register');
return $page;
}
function verify()
{
if (isset($_POST["submit"])) {
$u = trim($_POST['username'] ?? '');
$e = trim($_POST['email'] ?? '');
$t = trim($_POST['token'] ?? '');
$query = db()->query('SELECT id FROM users WHERE username=? AND email=? AND verify=? LIMIT 1;', [$u, $e, $t]);
if ($query === false) exit('Verification failed. Go back, double-check your details, and try again.');
db()->query("UPDATE users SET verify='g2g' WHERE username=?;", [$u]);
return "Your account was verified successfully.<br><br>You may now continue to the <a href=\"/login\">Login Page</a> and start playing the game.<br><br>Thanks for playing!";
}
return render('verify');
}
function lostpassword()
{
if (isset($_POST["submit"])) {
$e = trim($_POST['email'] ?? '');
if (!db()->exists('users', 'email', $e)) exit("No account with that email address.");
$newpass = token(16);
$hashed = password_hash($newpass, PASSWORD_ARGON2ID);
db()->query('UPDATE users SET password=? WHERE email=?;', [$hashed, $e]);
if (sendpassemail($e, $newpass)) {
return "Your new password was emailed to the address you provided.<br><br>Once you receive it, you may <a href=\"/login\">Log In</a> and continue playing.<br><br>Thank you.";
} else {
return "There was an error sending your new password.<br><br>Please check with the game administrator for more information.<br><br>We apologize for the inconvience.";
}
}
return render('lostpassword');
}
function changepassword()
{
global $auth;
if (isset($_POST["submit"])) {
$u = trim($_POST['username'] ?? '');
$p = $_POST['password'] ?? '';
$np = $_POST['new_password'] ?? '';
$np2 = $_POST['new_password2'] ?? '';
$user = db()->query("SELECT password FROM users WHERE username=? LIMIT 1;", [$u]);
$user = $user->fetchArray(SQLITE3_ASSOC);
if ($user === false) exit("No account with that username.");
if (!password_verify($p, $user['password'])) exit("The old password you provided was incorrect.");
if (empty($np) || strlen($np) < 6) {
$errors[] = 'New password is required and must be at least 6 characters long.';
}
if ($np2 !== $np) {
$errors[] = 'Verify New Password must match.';
}
$realnewpass = password_hash($np, PASSWORD_ARGON2ID);
db()->query('UPDATE users SET password=? WHERE username=?;', [$realnewpass, $u]);
$auth->logout();
return "Your password was changed successfully.<br><br>You have been logged out of the game to avoid errors.<br><br>Please <a href=\"/login\">log back in</a> to continue playing.";
}
}
function settings()
{
if (is_post()) {
$form = validate($_POST, [
'game_skin' => ['in:0,1']
]);
if (!$form['valid']) exit(ul_from_validate_errors($form['errors']));
$form = $form['data'];
user()->game_skin = $form['game_skin'];
user()->save();
$alert = '<div class="alert">Settings updated</div>';
return $alert . render('settings');
}
return render('settings');
}
function sendpassemail($emailaddress, $password)
{
$email = <<<HTML
You or someone using your email address submitted a Lost Password application on the {env('game_name')} server, located at {env('game_url')}.
We have issued you a new password so you can log back into the game.
Your new password is: $password
Thanks for playing.
HTML;
return send_email($emailaddress, env('game_name')." Lost Password", $email);
}
function sendregmail($emailaddress, $vercode)
{
$verurl = env('game_url') . "/verify";
$email = <<<HTML
You or someone using your email address recently signed up for an account on the {env('game_name')} server, located at {env('game_url')}.
This email is sent to verify your registration email. In order to begin using your account, you must verify your email address.
Please visit the Verification Page ($verurl) and enter the code below to activate your account.
Verification code: $vercode
If you were not the person who signed up for the game, please disregard this message. You will not be emailed again.
HTML;
return send_email($emailaddress, env('game_name')." Account Verification", $email);
}

104
src/auth.php Normal file
View File

@ -0,0 +1,104 @@
<?php
/*
This is an experimental new class for handling user auth. The idea is to rely as much as possible on PHP's native
session handling. When authenticated, the class will store use data in GLOBALS state.
*/
class Auth
{
/**
* Set up the auth manager; adjust PHP session settings on the fly to improve security. Starts the session for
* this request.
*/
public function __construct()
{
// enhance the native session's sessid cryptography
ini_set('session.sid_length', 64);
ini_set('session.sid_bits_per_character', 6);
session_set_cookie_params([
'lifetime' => 2592000, // 30 days
'path' => '/',
'secure' => true,
'httponly' => true,
'samesite' => 'Strict'
]);
session_start();
$this->validate();
}
private function validate(): void
{
// Check for IP address change
if (!isset($_SESSION['ip_address'])) {
$_SESSION['ip_address'] = $_SERVER['REMOTE_ADDR'];
} elseif ($_SESSION['ip_address'] !== $_SERVER['REMOTE_ADDR']) {
$this->destroy(); // Possible hijacking
exit;
}
// Check for User-Agent change
if (!isset($_SESSION['user_agent'])) {
$_SESSION['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
} elseif ($_SESSION['user_agent'] !== $_SERVER['HTTP_USER_AGENT']) {
$this->destroy(); // Possible hijacking
exit;
}
// Regenerate session ID periodically for security
if (!isset($_SESSION['last_regeneration'])) {
$_SESSION['last_regeneration'] = time();
} elseif (time() - $_SESSION['last_regeneration'] > 300) { // Every 5 minutes
$this->regenerate();
}
}
public function login(string $username, string $password): bool
{
$user = get_user($username);
if ($user === false) return false;
if (password_verify($password, $user['password'])) {
$_SESSION['authenticated'] = true;
$_SESSION['user_id'] = $user['id'];
$_SESSION['login_time'] = time();
$this->regenerate();
return true;
}
return false;
}
public function good(): bool
{
return isset($_SESSION['authenticated']) && $_SESSION['authenticated'] === true;
}
public function logout(): void
{
$this->destroy();
}
private function regenerate(): void
{
session_regenerate_id(true);
$_SESSION['last_regeneration'] = time();
}
public function destroy(): void
{
$_SESSION = [];
if (ini_get("session.use_cookies")) {
$params = session_get_cookie_params();
setcookie(session_name(), '', time() - 42000, $params['path'], $params['domain'], $params['secure'], $params['httponly']);
}
session_destroy();
}
}

76
src/bootstrap.php Normal file
View File

@ -0,0 +1,76 @@
<?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'] = [];
/**
* These are table names whose data we want to be able to edit in the admin panel in bulk.
*/
define('ADMIN_BULK_DATA_STRUCTS', [
'users', 'items', 'drops', 'towns', 'monsters', 'levels', 'spells'
]);
if (!file_exists('../.installed') && $uri[0] !== 'install') { // need to install the game
redirect('/install');
} elseif (file_exists(('../.installed')) && $uri[0] === 'install') { // game is installed, go play!
redirect('/');
} elseif (file_exists(('../.installed')) && $uri[0] !== 'install') { // boostrap the game
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('/');
}
// Update default page layout based on root endpoint
page_layout('layouts/primary');
if ($uri[0] === 'admin') page_layout('layouts/admin');
if ($uri[0] === 'help') page_layout('layouts/help');
user()->update_online_time();
} else {
$auth->logout();
redirect('/login');
}
}

96
src/database.php Normal file
View File

@ -0,0 +1,96 @@
<?php
/**
* An extension to the SQLite3 class to add our own logging and binding semantics!
*/
class Database extends SQLite3
{
public int $count = 0;
public array $log = [];
public float $query_time = 0;
/**
* Make a big, chonky connection to our SQLite database.
*/
public function __construct(string $db_path)
{
parent::__construct($db_path);
parent::exec('PRAGMA cache_size = 32000');
parent::exec('PRAGMA journal_mode = WAL');
parent::exec('PRAGMA temp_store = MEMORY');
}
/**
* Query the database. Uses prepared statements, and your choise of placeholder syntax. (:key or ?) Logs
* the query in the class.
*/
public function query(string $query, array $params = []): SQLite3Result|false
{
$p = strpos($query, '?') !== false;
try {
$stmt = $this->prepare($query);
foreach ($params ?? [] as $k => $v) $stmt->bindValue($p ? $k + 1 : $k, $v, $this->getSQLiteType($v));
} catch (Exception $e) {
exit("Failed to prepare query ($query): ".$this->lastErrorMsg());
}
$start = microtime(true);
$error = '';
$r = $stmt->execute();
$this->log($query, microtime(true) - $start, $error);
return $r;
}
/**
* Perform a result-less query on the database.
*/
public function exec(string $query): bool
{
$start = microtime(true);
$r = parent::exec($query);
$this->log($query, microtime(true) - $start);
return $r;
}
/**
* Determines whether a given value exists in a given column in a given table. Can optionally make it
* case-sensitive!
*/
public function exists(string $table, string $column, mixed $value, bool $case_insensitive = true): bool
{
if ($case_insensitive) {
$query = "SELECT 1 FROM $table WHERE $column = :v COLLATE NOCASE LIMIT 1";
} else {
$query = "SELECT 1 FROM $table WHERE $column = :v LIMIT 1";
}
$result = $this->query($query, [':v' => $value]);
return $result->fetchArray(SQLITE3_NUM) !== false;
}
/**
* Log the query, including the time it took. Increment the query counter.
*/
private function log(string $query, float $time_taken, string $error = ''): void
{
$this->count++;
$this->query_time += $time_taken;
$this->log[] = [$query, $time_taken, $error];
}
/**
* Return the correct SQLite3 type for the given value.
*/
private function getSQLiteType(mixed $value): int
{
return match (true) {
is_int($value) => SQLITE3_INTEGER,
is_float($value) => SQLITE3_FLOAT,
is_null($value) => SQLITE3_NULL,
default => SQLITE3_TEXT
};
}
}

546
src/lib.php Normal file
View File

@ -0,0 +1,546 @@
<?php
require_once __DIR__ . '/database.php';
define('VERSION', '1.2.5');
define('BUILD', 'Reawaken');
define('START', microtime(true));
/**
* Open or get SQLite database connection.
*/
function db(): Database
{
return $GLOBALS['database'] ??= new Database(__DIR__ . '/../database.db');
}
/**
* Redirect to a different URL, exit.
*/
function redirect(string $location): void
{
if (is_htmx()) {
$target = isset($_SERVER['HTTP_HX_TARGET']) ? '#'.$_SERVER['HTTP_HX_TARGET'] : '#middle';
$json = json_encode(['path' => $location, 'target' => $target]);
header("HX-Location: $json");
} else {
header("Location: $location");
}
exit;
}
/**
* Render a view with the given data. Can be used redundantly within the template.
*/
function render(string $path_to_base_view, array $data = []): string|false
{
ob_start();
extract($data);
require "../templates/$path_to_base_view.php";
return ob_get_clean();
}
/**
* Replace tags with given content.
*/
function parse(string $template, array $array): string
{
return strtr($template, array_combine(
array_map(fn($key) => "{{{$key}}}", array_keys($array)),
array_values($array)
));
}
/**
* Change the SQLite3 datetime format (YYYY-MM-DD HH:MM:SS) into something friendlier.
*/
function pretty_date(string $uglydate): string
{
return date("l, F j, Y", mktime(
0,
0,
0,
substr($uglydate, 5, 2), // Month
substr($uglydate, 8, 2), // Day
substr($uglydate, 0, 4) // Year
));
}
/**
* Use htmlentities with UTF-8 encoding to ensure we're only outputting healthy, safe and effective HTML.
*/
function make_safe(string $content): string
{
return htmlentities($content, ENT_QUOTES, 'UTF-8');
}
/**
* Finalize admin page and output to browser.
*/
function display_admin($content, $title)
{
echo render('layouts/admin', [
"title" => $title,
"content" => $content
]);
exit;
}
/**
* Determine what game skin to use. If a user is logged in then it uses their setting, otherwise defaults to 0 (retro).
*/
function game_skin(): int
{
return user() !== false ? user()->game_skin : 0;
}
/**
* Get a town's data by it's coordinates.
*/
function get_town_by_xy(int $x, int $y): array|false
{
$cache_tag = "town-$x-$y";
if (!isset($GLOBALS['cache'][$cache_tag])) {
$query = db()->query('SELECT * FROM towns WHERE longitude = ? AND latitude = ? LIMIT 1;', [$x, $y]);
if ($query === false) return false;
$GLOBALS['cache'][$cache_tag] = $query->fetchArray(SQLITE3_ASSOC);
}
return $GLOBALS['cache'][$cache_tag];
}
/**
* Get a town's data by it's ID.
*/
function get_town_by_id(int $id): array|false
{
$query = db()->query('SELECT * FROM towns WHERE id = ? LIMIT 1;', [$id]);
if ($query === false) return false;
return $query->fetchArray(SQLITE3_ASSOC);
}
/**
* Get a user's data by their ID, username or email.
*/
function get_user(int|string $id, string $data = '*'): array|false
{
$query = db()->query(
"SELECT $data FROM users WHERE id=? OR username=? COLLATE NOCASE OR email=? COLLATE NOCASE LIMIT 1;",
[$id, $id, $id]
);
if ($query === false) return false;
return $query->fetchArray(SQLITE3_ASSOC);
}
/**
* Get an item by it's ID.
*/
function get_item(int $id): array|false
{
$query = db()->query('SELECT * FROM items WHERE id=? LIMIT 1;', [$id]);
if ($query === false) return 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.
*/
function get_spell(int $id): array|false
{
$query = db()->query('SELECT * FROM spells WHERE id=? LIMIT 1;', [$id]);
if ($query === false) return 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.
*/
function special_to_string(string $special): string
{
return match ($special) {
'maxhp' => 'Max HP',
'maxmp' => 'Max MP',
'maxtp' => 'Max TP',
'goldbonus' => 'Gold Bonus (%)',
'expbonus' => 'Experience Bonus (%)',
'strength' => 'Strength',
'dexterity' => 'Dexterity',
'attackpower' => 'Attack Power',
'defensepower' => 'Defense Power',
default => $special
};
}
/**
* Generate a pretty dope token.
*/
function token($length = 32): string
{
return bin2hex(random_bytes($length));
}
/**
* Validate any given array of data against rules. Returns [valid, data, error]. Data contains the trimmed
* values from the input array. Note: all fields with rules are assumed to be required, unless the optional
* rule is used.
*
* Example: ['required', 'no-trim', 'length:5-20', 'alphanum-spaces']
*/
function validate(array $input_data, array $rules): array
{
$data = [];
$errors = [];
foreach ($rules as $field => $field_rules) {
$value = $input_data[$field] ?? null;
$field_name = ucfirst(str_replace('_', ' ', $field));
$is_required = true;
$default_value = null;
if (in_array('optional', $field_rules)) {
$is_required = false;
}
foreach ($field_rules as $rule) {
if (strpos($rule, 'default:') === 0) {
$default_value = substr($rule, 8);
break;
}
}
if (($value === null || $value === '') && $default_value !== null) {
$value = $default_value;
}
if (($value === null || $value === '') && !$is_required) continue;
if ($is_required && ($value === null || $value === '')) {
$errors[$field][] = "{$field_name} is required.";
continue;
}
if (!in_array('no-trim', $field_rules)) {
$value = trim($value);
}
$data[$field] = $value;
foreach ($field_rules as $rule) {
// Parse rule and arguments
if (strpos($rule, ':') !== false) {
list($rule_name, $rule_args) = explode(':', $rule, 2);
} else {
$rule_name = $rule;
$rule_args = null;
}
if ($rule_name === 'optional') continue;
switch ($rule_name) {
case 'bool':
if (!isset($input_data[$field]) || empty($value)) {
$value = false;
} else {
$value = filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
if ($value === null) {
$errors[$field][] = "{$field_name} must be a valid boolean value.";
}
}
break;
case 'length':
list($min, $max) = explode('-', $rule_args);
$len = strlen((string)$value);
if ($len < $min || $len > $max) {
$errors[$field][] = "{$field_name} must be between {$min} and {$max} characters.";
}
break;
case 'alphanum':
if (!preg_match('/^[a-zA-Z0-9]+$/', $value)) {
$errors[$field][] = "{$field_name} must contain only letters and numbers.";
}
break;
case 'alpha':
if (!preg_match('/^[a-zA-Z]+$/', $value)) {
$errors[$field][] = "{$field_name} must contain only letters and numbers.";
}
break;
case 'alphanum-spaces':
if (!preg_match('/^[a-zA-Z0-9\s_]+$/', $value)) {
$errors[$field][] = "{$field_name} must contain only letters, numbers, spaces, and underscores.";
}
break;
case 'alpha-spaces':
if (!preg_match('/^[a-zA-Z\s_]+$/', $value)) {
$errors[$field][] = "{$field_name} must contain only letters, numbers, spaces, and underscores.";
}
break;
case 'email':
if (!filter_var($value, FILTER_VALIDATE_EMAIL)) {
$errors[$field][] = "{$field_name} must be a valid email address.";
}
break;
case 'int':
if (filter_var($value, FILTER_VALIDATE_INT) === false) {
$errors[$field][] = "{$field_name} must be an integer.";
}
break;
case 'min':
if ($value < $rule_args) {
$errors[$field][] = "{$field_name} must be at least {$rule_args}.";
}
break;
case 'max':
if ($value > $rule_args) {
$errors[$field][] = "{$field_name} must be no more than {$rule_args}.";
}
break;
case 'regex':
if (!preg_match($rule_args, $value)) {
$errors[$field][] = "{$field_name} does not match the required pattern.";
}
break;
case 'in':
$options = explode(',', $rule_args);
if (!in_array($value, $options)) {
$errors[$field][] = "{$field_name} must be one of: " . implode(', ', $options);
}
break;
case 'confirm':
$field_to_confirm = substr($field, 8);
$confirm_value = $data[$field_to_confirm] ?? '';
$confirm_field_name = ucfirst(str_replace('_', ' ', $field_to_confirm));
if ($value !== $confirm_value) {
$errors[$field][] = "{$field_name} must match {$confirm_field_name}.";
}
break;
case 'unique':
list($table, $column) = explode(',', $rule_args, 2);
if (db()->exists($table, $column, $value)) {
$errors[$field][] = "{$field_name} must be unique.";
}
break;
}
}
}
foreach ($input_data as $field => $value) {
if (!isset($data[$field])) $data[$field] = trim($value);
}
return [
'valid' => empty($errors),
'data' => $data,
'errors' => $errors
];
}
/**
* Generates a ul list from `validate()`'s errors.
*/
function ul_from_validate_errors(array $errors): string
{
$string = '<ul>';
foreach ($errors as $field => $errors) {
$string .= '<li>';
foreach ($errors as $error) $string .= $error;
$string .= '</li>';
}
return $string . '</ul>';
}
/**
* Load the environment variables from the .env file.
*/
function env_load(string $filePath): void
{
if (!file_exists($filePath)) throw new Exception("The .env file does not exist. (el)");
$lines = file($filePath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($lines as $line) {
$line = trim($line);
// Skip lines that are empty after trimming or are comments
if ($line === '' || str_starts_with($line, '#')) continue;
// Skip lines without an '=' character
if (strpos($line, '=') === false) continue;
[$name, $value] = explode('=', $line, 2);
$name = trim($name);
$value = trim($value, " \t\n\r\0\x0B\"'"); // Trim whitespace and quotes
if (!array_key_exists($name, $_SERVER) && !array_key_exists($name, $_ENV)) {
putenv("$name=$value");
$_ENV[$name] = $value;
$_SERVER[$name] = $value;
}
}
}
/**
* Retrieve an environment variable.
*/
function env(string $key, mixed $default = null): mixed
{
$v = $_ENV[$key] ?? $_SERVER[$key] ?? (getenv($key) ?: $default);
return match(true) {
$v === 'true' => true,
$v === 'false' => false,
is_numeric($v) => (int) $v,
is_float($v) => (float) $v,
default => $v
};
}
/**
* Get the data on spells from a given list of IDs.
*/
function get_spells_from_list(array|string $spell_ids): array|false
{
if (is_string($spell_ids)) $spell_ids = explode(',', $spell_ids);
$placeholders = implode(',', array_fill(0, count($spell_ids), '?'));
$query = db()->query("SELECT id, name, type FROM spells WHERE id IN($placeholders)", $spell_ids);
if ($query === false) return false;
$rows = [];
while ($row = $query->fetchArray(SQLITE3_ASSOC)) $rows[] = $row;
return !empty($rows) ? $rows : false;
}
function generate_stat_bar(int $current, int $max): string
{
$percent = $max > 0 ? round(max(0, $current) / $max * 100, 4) : 0;
if ($percent < 0) $percent = 0;
if ($percent > 100) $percent = 100;
$color = $percent >= 66 ? 'green' : ($percent >= 33 ? 'yellow' : 'red');
return <<<HTML
<div class="stat-bar" style="width: 15px; height: 100px; border: solid 1px black;">
<div style="height: $percent%; background-image: url(/img/bars_$color.gif);"></div>
</div>
HTML;
}
function create_stat_table(): string
{
$stat_table = '<div class="stat-table">' .
'<div class="stat-row">' .
'<div class="stat-col">' . generate_stat_bar((int)user()->currenthp, (int)user()->maxhp) . '<div>HP</div></div>' .
'<div class="stat-col">' . generate_stat_bar((int)user()->currentmp, (int)user()->maxmp) . '<div>MP</div></div>' .
'<div class="stat-col">' . generate_stat_bar((int)user()->currenttp, (int)user()->maxtp) . '<div>TP</div></div>' .
'</div>' .
'</div>';
return $stat_table;
}
/**
* Returns the user in the GLOBALS state, if there is one. If not, populates it if there is a SESSION user_id.
*/
function user(): User|false
{
$GLOBALS['state']['user'] ??= (isset($_SESSION['user_id']) ? User::find($_SESSION['user_id']) : false);
return $GLOBALS['state']['user'];
}
/**
* Determine whether a request is from HTMX. If HTMX is trying to restore history, we will say no in order to render
* full pages.
*/
function is_htmx(): bool
{
if (isset($_SERVER['HTTP_HX_HISTORY_RESTORE_REQUEST']) && $_SERVER['HTTP_HX_HISTORY_RESTORE_REQUEST'] === 'true') return false;
return isset($_SERVER['HTTP_HX_REQUEST']) && $_SERVER['HTTP_HX_REQUEST'] === 'true';
}
/**
* Return whether the request is POST.
*/
function is_post(): bool
{
return $_SERVER['REQUEST_METHOD'] === 'POST';
}
/**
* Get the current page title per updates. Optionally set a new title.
*/
function page_title(string $new_title = ''): string
{
if ($new_title) return $GLOBALS['state']['new-page-title'] = $new_title;
return $GLOBALS['state']['new-page-title'] ?? env('game_name');
}
/**
* Render the response for the browser based on the request context. The main point is to seperate the handling
* of HTMX responses from normal responses.
*/
function render_response(array $uri, string $content): string
{
if ($uri[0] === 'babblebox') return $content;
if (is_htmx()) {
header('HX-Push-Url: '.$_SERVER['REQUEST_URI']);
$content .= '<title>'.page_title().'</title>';
$content .= Render\debug_db_info();
if (env('debug', false)) {
$content .= Render\debug_query_log();
}
if ($GLOBALS['state']['user-state-changed'] ?? false) {
$content .= Render\right_nav();
$content .= Render\left_nav();
}
}
return Render\content($content, page_layout());
}
/**
* Get/set page layout through GLOBALS state.
*/
function page_layout(string $layout = ''): string
{
if ($layout === '') return $GLOBALS['state']['page-layout'] ?? 'layouts/primary';
return $GLOBALS['state']['page-layout'] = $layout;
}

109
src/mail.php Normal file
View File

@ -0,0 +1,109 @@
<?php
/**
* Send an email or log email details
*
* @param string $to Recipient email address
* @param string $subject Email subject
* @param string $message Email body
* @param array $options Optional configuration options
* @return bool Success status of email sending or logging
*/
function send_email(string $to, string $subject, string $message, array $options = []): bool
{
// Default configuration
$config = array_merge([
'from' => env('admin_email', 'noreply@'.$_SERVER['SERVER_NAME']),
'log_path' => '../logs/email.log',
'method' => 'smtp', // 'smtp' or 'log'
'smtp_host' => env('smtp_host', 'localhost'),
'smtp_port' => env('smtp_port', 25),
'smtp_username' => env('smtp_username', null),
'smtp_password' => env('smtp_password', null),
'smtp_encryption' => env('smtp_encryption', null)
], $options);
// Always send to log during debug
if (env('debug', false)) $config['method'] = 'log';
// Validate input
if (empty($to) || empty($subject) || empty($message)) {
error_log('Email sending failed: Missing required parameters');
return false;
}
// Prepare email headers
$headers = [
'From: ' . $config['from'],
'X-Mailer: PHP/' . phpversion()
];
// Choose sending method
switch ($config['method']) {
case 'log':
// Log email details to file
$logMessage = sprintf(
"[%s] To: %s, Subject: %s, Message:\n\n %s\n\n\n\n",
date('Y-m-d H:i:s'),
$to,
$subject,
$message
);
// Attempt to log to file
if (file_put_contents($config['log_path'], $logMessage, FILE_APPEND) === false) {
error_log('Failed to write to log file: ' . $config['log_path']);
return false;
}
return true;
case 'smtp':
default:
// Attempt to send via SMTP
try {
// Prepare SMTP connection
$smtpConfig = [
'host' => $config['smtp_host'],
'port' => $config['smtp_port'],
'username' => $config['smtp_username'],
'password' => $config['smtp_password'],
'encryption' => $config['smtp_encryption']
];
// Send email using PHP's mail function (basic SMTP)
$result = mail(
$to,
$subject,
$message,
implode("\r\n", $headers)
);
if (!$result) {
error_log('SMTP email sending failed');
return false;
}
return true;
} catch (Exception $e) {
error_log('Email sending error: ' . $e->getMessage());
return false;
}
}
}
// Example usage:
// Send via SMTP
// send_email('recipient@example.com', 'Test Subject', 'Email body text');
// Send via log
// send_email('recipient@example.com', 'Test Subject', 'Email body text', ['method' => 'log']);
// Customize SMTP settings
// send_email('recipient@example.com', 'Test Subject', 'Email body text', [
// 'method' => 'smtp',
// 'smtp_host' => 'smtp.yourserver.com',
// 'smtp_port' => 587,
// 'smtp_username' => 'your_username',
// 'smtp_password' => 'your_password',
// 'smtp_encryption' => 'tls'
// ]);

98
src/math.php Normal file
View File

@ -0,0 +1,98 @@
<?php
namespace Math;
/*
Internal math functions, such as to calculate EXP, HP, stats, etc.
*/
/**
* Calculates the ***total*** EXP required at a particular level in order to level up.
*/
function calculate_exp(int $level, int $growth_rate): int
{
if ($level < 1) throw new \InvalidArgumentException("Level must be 1 or greater");
// Growth rates:
// 0 = Erratic
// 1 = Fast
// 2 = Medium Fast
// 3 = Medium Slow
// 4 = Slow
// 5 = Fluctuating
if ($growth_rate < 0 || $growth_rate > 5) throw new \InvalidArgumentException("Growth rate must be between 0 and 5");
return match($growth_rate) {
0 => calculate_erratic_exp($level),
1 => (4 * pow($level, 3)) / 5,
2 => pow($level, 3),
3 => ((6 * pow($level, 3)) / 5) - (15 * pow($level, 2)) + (100 * $level) - 140,
4 => (5 * pow($level, 3)) / 4,
5 => calculate_fluctuating_exp($level),
};
}
/**
* Calculate the ***total*** EXP for a given level in the Erratic formula.
*/
function calculate_erratic_exp(int $level): int
{
if ($level <= 50) {
return (pow($level, 3) * (100 - $level)) / 50;
} elseif ($level <= 68) {
return (pow($level, 3) * (150 - $level)) / 100;
} elseif ($level <= 98) {
return (pow($level, 3) * ((1911 - (10 * $level)) / 3)) / 500;
} else {
return (pow($level, 3) * (160 - $level)) / 100;
}
}
/**
* Calculate the ***total*** EXP for a given level in the Fluctuating formula.
*/
function calculate_fluctuating_exp(int $level): int
{
if ($level <= 15) {
return pow($level, 3) * ((((($level + 1) / 3) + 24) / 50));
} elseif ($level <= 36) {
return pow($level, 3) * (($level + 14) / 50);
} else {
return pow($level, 3) * ((($level / 2) + 32) / 50);
}
}
/**
* Calculate a points total from a base. Modes: 1 (weak), 2 (normal), 3 (strong)
*/
function calculate_points(int $base_points, int $level, int $mode = 2): int
{
if ($level < 1) throw new \InvalidArgumentException("Level must be 1 or greater");
$growth_multiplier = match($mode) {
1 => 0.15,
2 => 0.3,
3 => 0.6,
default => throw new \InvalidArgumentException("Invalid mode. Use 1 (weak), 2 (normal), or 3 (strong)")
};
return floor((2 * $base_points * $level * $growth_multiplier) / 100) + $level + 10;
}
/**
* Calculate a stat total from a base. Modes: 1 (weak), 2 (normal), 3 (strong)
*/
function calculate_stat(int $base_stat, int $level, int $mode = 2): int
{
if ($level < 1) throw new \InvalidArgumentException("Level must be 1 or greater");
$growth_multiplier = match($mode) {
1 => 0.15,
2 => 0.3,
3 => 0.6,
default => throw new \InvalidArgumentException("Invalid mode. Use 1 (weak), 2 (normal), or 3 (strong)")
};
return floor((2 * $base_stat * $level * $growth_multiplier) / 100) + 5;
}

46
src/models/model.php Normal file
View File

@ -0,0 +1,46 @@
<?php
class Model
{
protected string $table_name = '';
protected array $original_data = [];
protected array $changes = [];
public function __construct(array $data)
{
$this->original_data = $data;
$this->changes = [];
}
public function __get(string $key): mixed
{
return array_key_exists($key, $this->changes) ? $this->changes[$key] : $this->original_data[$key] ?? false;
}
public function __set(string $key, mixed $value): void
{
if (array_key_exists($key, $this->original_data)) {
if ($value !== $this->original_data[$key]) $this->changes[$key] = $value;
} else {
throw new InvalidArgumentException("Attempted to write to $key, which doesn't exist in the data for this model.");
}
}
public function save(): bool
{
if (empty($this->changes)) return true;
$placeholders = [];
$values = [];
foreach ($this->changes as $key => $value) {
$placeholders[] = "$key=?";
$values[] = $value;
}
$values[] = $this->id;
$query = 'UPDATE ' . $this->table_name . ' SET ' . implode(', ', $placeholders) . ' WHERE id = ?;';
$result = db()->query($query, $values);
return $result === false ? false : true;
}
}

85
src/models/user.php Normal file
View File

@ -0,0 +1,85 @@
<?php
class User extends Model
{
protected string $table_name = 'users';
/**
* Find a user by their ID, username or email. Returns false on any failure.
*/
public static function find(int|string $id): User|false
{
$query = db()->query(
"SELECT * FROM users WHERE id=? OR username=? COLLATE NOCASE OR email=? COLLATE NOCASE LIMIT 1;",
[$id, $id, $id]
);
if ($query === false) return false;
$data = $query->fetchArray(SQLITE3_ASSOC);
if ($data === false) return false;
return new User($data);
}
/**
* Return a list of spells from this user's spell list.
*/
public function spells(): array|false
{
return get_spells_from_list($this->spells);
}
/**
* Restore all HP, MP, and TP values to their max.
*/
public function restore_points(): User
{
$this->currenthp = $this->maxhp;
$this->currentmp = $this->maxmp;
$this->currenttp = $this->maxtp;
return $this;
}
/**
* Sends a manual update to online time for this user.
*/
public function update_online_time(): void
{
if ($this->onlinetime && strtotime($this->onlinetime) > strtotime('-9 minutes')) return;
db()->query('UPDATE users SET onlinetime=CURRENT_TIMESTAMP WHERE id=?;', [$this->id]);
}
/**
* Heal HP by a given amount. Caps to max HP. Returns number of points restored.
*/
function restore_hp(int $amount): int
{
$initial_hp = $this->currenthp;
$this->currenthp += $amount;
if ($this->currenthp > $this->maxhp) $this->currenthp = $this->maxhp;
return $this->currenthp - $initial_hp;
}
/**
* Save works just as it does on the Model class. In our case, though, user state changing may necessitate
* OOB swaps for parts of the UI that have user data displayed. Left and right nav, for example. In these cases,
* we set a flag in GLOBALS state to signify this.
*/
public function save(): bool
{
if (empty($this->changes)) return true;
$placeholders = [];
$values = [];
foreach ($this->changes as $key => $value) {
$placeholders[] = "$key=?";
$values[] = $value;
}
$values[] = $this->id;
$query = 'UPDATE ' . $this->table_name . ' SET ' . implode(', ', $placeholders) . ' WHERE id = ?;';
$result = db()->query($query, $values);
if ($result === false) return false;
$GLOBALS['state']['user-state-changed'] = true;
return true;
}
}

62
src/render.php Normal file
View File

@ -0,0 +1,62 @@
<?php
namespace Render;
/*
This file contains functions to render various UI elements. The goal is to begin shifting elements in the game
to HTMX/AJAX for more fluid gameplay.
*/
/**
* Prepare content for final render. If the request is HTMX-based, will return just the content passed to it. Otherwise
* it will render() onto $layout with some additional bits.
*/
function content(string $content, string $layout = 'layouts/primary'): string
{
if (is_htmx()) return $content;
return render($layout, ['content' => $content]);
}
function debug_db_info(): string {
$total_time = round(microtime(true) - START, 4);
$htmx = is_htmx() ? ' (htmx)' : '';
return '<div id="debug-db-info" hx-swap-oob="true">'. $total_time . ' Seconds, ' . db()->count . ' Queries'.$htmx.'</div>';
}
function right_nav(): string
{
if (user() === false) return '';
// Flashy numbers if they're low
$hp = (user()->currenthp <= (user()->maxhp / 5)) ? "<blink><span class=\"highlight\"><b>*" . user()->currenthp . "*</b></span></blink>" : user()->currenthp;
$mp = (user()->currentmp <= (user()->maxmp / 5)) ? "<blink><span class=\"highlight\"><b>*" . user()->currentmp . "*</b></span></blink>" : user()->currentmp;
$template = render('right_nav', ['hp' => $hp, 'mp' => $mp]);
if (is_htmx()) $template = '<section id="right" hx-swap-oob="true">'.$template."</section>";
return $template;
}
function left_nav(): string
{
if (user() === false) return '';
$template = render('left_nav');
if (is_htmx()) $template = '<section id="left" hx-swap-oob="true">'.$template."</section>";
return $template;
}
function babblebox(): string
{
return render('babblebox', ['messages' => babblebox_messages()]);
}
function debug_query_log(): string
{
$html = '<pre id="debug-query-log" hx-swap-oob="true">';
foreach (db()->log as $record) {
$query_string = str_replace(["\r\n", "\n", "\r"], ' ', $record[0]);
$error_string = !empty($record[2]) ? '// '.$record[2] : '';
$html .= '<div>['.round($record[1], 2)."s] {$query_string}{$error_string}</div>";
}
return $html . '</pre>';
}

187
src/router.php Normal file
View File

@ -0,0 +1,187 @@
<?php
/**
* A radix-trie based URI router. Seperates URIs into chunks, then turns those chunks into an efficiently parsed
* trie. Supports URI variables!
*/
class Router
{
/**
* List of valid HTTP verbs.
*/
private const VALID_METHODS = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS'];
/**
* The tree of currently registered routes.
*/
private array $routes = [];
/**
* Store the last inserted node so we can register middleware and attributes to it.
*/
private array $last_inserted_node;
/**
* Add a route to the route tree. The route must be a URI path, and contain dynamic segments
* using a colon prefix. (:id, :slug, etc)
*
* Example:
* `$r->add($routes, 'GET', '/posts/:id', function($id) { echo "Viewing post $id"; });`
*/
public function add(string $method, string $route, callable $handler): Router
{
$this->validateMethod($method);
$this->validateRoute($route);
$segments = $route === '/' ? [''] : explode('/', trim($route, '/'));
$node = &$this->routes;
foreach ($segments as $segment) {
$segment = str_starts_with($segment, ':') ? ':x' : $segment;
if ($segment === '') continue;
$node = &$node[$segment];
}
$node[$method] = [
'handler' => $handler,
'middleware' => []
];
$this->last_inserted_node = &$node[$method];
return $this;
}
/**
* Perform a lookup in the route tree for a given method and URI. Returns an array with a result code,
* a handler if found, and any dynamic parameters. Codes are 200 for success, 404 for not found, and
* 405 for method not allowed.
*
* @return array ['code', 'handler', 'params']
*/
public function lookup(string $method, string $uri): array|int
{
$node = $this->routes;
$params = [];
if ($uri === '/') return $node[$method] ?? 405;
foreach (explode('/', trim($uri, '/')) as $segment) {
if (isset($node[$segment])) {
$node = $node[$segment];
continue;
}
if (isset($node[':x'])) {
$params[] = $segment;
$node = $node[':x'];
continue;
}
return 404;
}
$node[$method]['params'] = $params;
return $node[$method] ?? 405;
}
/**
* Add a middleware function to the last inserted node's stack.
*/
public function middleware(callable $middleware): Router
{
$this->last_inserted_node['middleware'][] = $middleware;
return $this;
}
/**
* Shorthand to register a GET route.
*/
public function get(string $route, callable $handler): Router
{
return $this->add('GET', $route, $handler);
}
/**
* Shorthand to register a POST route.
*/
public function post(string $route, callable $handler): Router
{
return $this->add('POST', $route, $handler);
}
/**
* Shorthand to register a PUT route.
*/
public function put(string $route, callable $handler): Router
{
return $this->add('PUT', $route, $handler);
}
/**
* Shorthand to register a DELETE route.
*/
public function delete(string $route, callable $handler): Router
{
return $this->add('DELETE', $route, $handler);
}
/**
* Shorthand to register a PATCH route.
*/
public function patch(string $route, callable $handler): Router
{
return $this->add('PATCH', $route, $handler);
}
/**
* Register multiple verbs to the same route.
*/
public function many(array $methods, string $route, callable $handler): Router
{
foreach ($methods as $method) $this->add($method, $route, $handler);
return $this;
}
/**
* Register all verbs to the same route.
*/
public function any(string $route, callable $handler): Router
{
foreach (SELF::VALID_METHODS as $method) $this->add($method, $route, $handler);
return $this;
}
/**
* Some pages function entirely as forms; thus we can shorthand a GET/POST route.
*/
public function form(string $route, callable $handler): Router
{
return $this->many(['GET', 'POST'], $route, $handler);
}
/**
* Validate the given method against valid HTTP verbs.
*/
private function validateMethod(string $method): void
{
if (!in_array($method, self::VALID_METHODS)) {
throw new InvalidArgumentException("Invalid HTTP method: $method");
}
}
/**
* Validate that a new route follows expected formatting.
*/
private function validateRoute(string $route): void
{
if ($route === '') {
throw new InvalidArgumentException("Route cannot be empty");
}
// Ensure route starts with a slash
if (!str_starts_with($route, '/')) {
throw new InvalidArgumentException("Route must start with a '/'");
}
}
}

View File

@ -1,78 +0,0 @@
<?php
$template = <<<THEVERYENDOFYOU
<head>
<title>{{title}}</title>
<style type="text/css">
body {
color: black;
font: 11px verdana;
}
table {
border-style: none;
padding: 0px;
font: 11px verdana;
}
td {
border-style: none;
padding: 3px;
vertical-align: top;
}
a {
color: #663300;
text-decoration: none;
font-weight: bold;
}
a:hover {
color: #330000;
}
.small {
font: 10px verdana;
}
.highlight {
color: red;
}
.light {
color: #999999;
}
.title {
border: solid 1px black;
background-color: #eeeeee;
font-weight: bold;
padding: 5px;
margin: 3px;
}
.copyright {
border: solid 1px black;
background-color: #eeeeee;
font: 10px verdana;
}
</style>
</head>
<body><center>
<table width="90%"><tr>
<td width="150" style="border-right: solid 1px black;">
<b><u>DK Administration</u></b><br /><br />
<b>Links:</b><br />
<a href="admin.php">Admin Home</a><br />
<a href="index.php">Game Home</a><br /><br />
<b>Primary Data:</b><br />
<a href="admin.php?do=main">Main Settings</a><br />
<a href="admin.php?do=news">Add News Post</a><br />
<a href="admin.php?do=users">Edit Users</a><br /><br />
<b>Game Data:</b><br />
<a href="admin.php?do=items">Edit Items</a><br />
<a href="admin.php?do=drops">Edit Drops</a><br />
<a href="admin.php?do=towns">Edit Towns</a><br />
<a href="admin.php?do=monsters">Edit Monsters</a><br />
<a href="admin.php?do=levels">Edit Levels</a><br />
<a href="admin.php?do=spells">Edit Spells</a><br />
</td><td>
{{content}}
</td></tr></table>
<br />
<table class="copyright" width="90%"><tr>
<td width="25%" align="center">Powered by <a href="http://dragon.se7enet.com/dev.php" target="_new">Dragon Knight</a></td><td width="25%" align="center">&copy; 2003-2006 by renderse7en</td><td width="25%" align="center">{{totaltime}} Seconds, {{numqueries}} Queries</td><td width="25%" align="center">Version {{version}} {{build}}</td>
</center></body>
</html>
THEVERYENDOFYOU;
?>

View File

@ -0,0 +1,49 @@
<h2>Editing <?= $drop['name'] ?></h2>
<form action="/admin/drops/<?= $drop['id'] ?>" method="post" hx-post="/admin/drops/<?= $drop['id'] ?>" hx-target="#main">
<table width="90%">
<tr><td width="20%">ID:</td><td><?= $drop['id'] ?></td></tr>
<tr><td width="20%">Name:</td><td><input type="text" name="name" value="<?= $drop['name'] ?>"></td></tr>
<tr>
<td width="20%">Monster Level:</td>
<td>
<input type="number" name="mlevel" value="<?= $drop['mlevel'] ?>"><br>
<span class="small">Minimum monster level that will drop this item.</span>
</td>
</tr>
<tr>
<td width="20%">Attribute 1:</td>
<td>
<input type="text" name="attribute1" value="<?= $drop['attribute1'] ?>"><br>
<span class="small">Must be a special code. First attribute cannot be disabled. Edit this field very
carefully because mistakes to formatting or field names can create problems in the game.</span>
</td>
</tr>
<tr>
<td width="20%">Attribute 2:</td>
<td>
<input type="text" name="attribute2" value="<?= $drop['attribute2'] ?>"><br>
<span class="small">Should be either a special code or <span class="highlight">X</span> to
disable. Edit this field very carefully because mistakes to formatting or field names can create
problems in the game.</span>
</td>
</tr>
</table>
<button type="submit">Save</button>
<button type="reset">Reset</button>
</form>
<br>
<h3>Special Codes</h3>
Special codes are used in the two attribute fields to give the item properties. The first attribute field must contain a special code, but the second one may be left empty ("X") if you wish. Special codes are in the format <span class="highlight">attribute,value</span>. <span class="highlight">Attribute</span> can be any database field from the Users table - however, it is suggested that you only use the ones from the list below, otherwise things can get freaky. <span class="highlight">Value</span> may be any positive or negative whole number. For example, if you want a weapon to give an additional 50 max hit points, the special code would be <span class="highlight">maxhp,50</span>.<br><br>
Suggested user fields for special codes:<br>
maxhp - max hit points<br>
maxmp - max magic points<br>
maxtp - max travel points<br>
goldbonus - gold bonus, in percent<br>
expbonus - experience bonus, in percent<br>
strength - strength (which also adds to attackpower)<br>
dexterity - dexterity (which also adds to defensepower)<br>
attackpower - total attack power<br>
defensepower - total defense power

View File

@ -0,0 +1,55 @@
<h2>Edit <?= $item['name'] ?></h2>
<form action="/admin/items/<?= $item['id'] ?>" method="post" hx-post="/admin/items/<?= $item['id'] ?>" hx-target="#main">
<table>
<tr><td width="20%">ID:</td><td><?= $item['id'] ?></td></tr>
<tr>
<td width="20%">Name:</td>
<td><input type="text" name="name" value="<?= $item['name'] ?>"></td>
</tr>
<tr>
<td width="20%">Type:</td>
<td><select name="type">
<option value="1" <?= $item['type'] === 1 ? 'selected' : '' ?>>Weapon</option>
<option value="2" <?= $item['type'] === 2 ? 'selected' : '' ?>>Armor</option>
<option value="3" <?= $item['type'] === 3 ? 'selected' : '' ?>>Shield</option>
</select></td>
</tr>
<tr>
<td width="20%">Cost:</td>
<td><input type="text" name="buycost" value="<?= $item['buycost'] ?>"> gold</td>
</tr>
<tr>
<td width="20%">Attribute:</td>
<td>
<input type="number" name="attribute" value="<?= $item['attribute'] ?>"><br>
<span class="small">How much the item adds to total attackpower (weapons) or defensepower (armor/shields).</span>
</td>
</tr>
<tr>
<td width="20%">Special:</td>
<td>
<input type="text" name="special" value="<?= $item['special'] ?>"><br>
<span class="small">Should be either a special code or <span class="highlight">X</span> to disable. Edit
this field very carefully because mistakes to formatting or field names can create problems in the game.</span>
</td>
</tr>
</table>
<button type="submit">Save</button>
<button type="reset">Reset</button>
</form>
<br>
<h3>Special Codes</h3>
Special codes can be added in the item's Special field to give it extra user attributes. Special codes are in the format <span class="highlight">attribute,value</span>. <span class="highlight">Attribute</span> can be any database field from the Users table - however, it is suggested that you only use the ones from the list below, otherwise things can get freaky. <span class="highlight">Value</span> may be any positive or negative whole number. For example, if you want a weapon to give an additional 50 max hit points, the special code would be <span class="highlight">maxhp,50</span>.<br><br>
Suggested user fields for special codes:<br>
maxhp - max hit points<br>
maxmp - max magic points<br>
maxtp - max travel points<br>
goldbonus - gold bonus, in percent<br>
expbonus - experience bonus, in percent<br>
strength - strength (which also adds to attackpower)<br>
dexterity - dexterity (which also adds to defensepower)<br>
attackpower - total attack power<br>
defensepower - total defense power

View File

@ -0,0 +1,33 @@
<h2>Edit Level <?= $level['id'] ?></h2>
Experience values for each level should be the cumulative total amount of experience up to this point. All other values should be only the new amount to add this level.<br><br>
<form action="/admin/levels" method="post" hx-post="/admin/levels" hx-target="#main">
<input type="hidden" name="save" value="true">
<input type="hidden" name="level" value="<?= $level['id'] ?>">
<table>
<colgroup><col><col></colgroup>
<tbody>
<tr>
<td>ID:</td>
<td><?= $level['id'] ?></td>
</tr>
<tr><td colspan="2"></td></tr>
<?php foreach ([1, 2, 3] as $n): ?>
<?php $class_name = env("class_{$n}_name"); ?>
<tr><td><?= $class_name ?> EXP</td> <td><input type="number" name="<?= $n ?>_exp" value="<?= $level["{$n}_exp"] ?>"></td></tr>
<tr><td><?= $class_name ?> HP</td> <td><input type="number" name="<?= $n ?>_hp" value="<?= $level["{$n}_hp"] ?>"></td></tr>
<tr><td><?= $class_name ?> MP</td> <td><input type="number" name="<?= $n ?>_mp" value="<?= $level["{$n}_mp"] ?>"></td></tr>
<tr><td><?= $class_name ?> TP</td> <td><input type="number" name="<?= $n ?>_tp" value="<?= $level["{$n}_tp"] ?>"></td></tr>
<tr><td><?= $class_name ?> Strength</td> <td><input type="number" name="<?= $n ?>_strength" value="<?= $level["{$n}_strength"] ?>"></td></tr>
<tr><td><?= $class_name ?> Dexterity</td><td><input type="number" name="<?= $n ?>_dexterity" value="<?= $level["{$n}_dexterity"] ?>"></td></tr>
<tr><td><?= $class_name ?> Spells</td> <td><input type="number" name="<?= $n ?>_spells" value="<?= $level["{$n}_spells"] ?>"></td></tr>
<?= $n !== 3 ? '<tr><td colspan="2"></td></tr>' : '' ?>
<?php endforeach; ?>
</tbody>
</table>
<button type="submit">Save</button>
<button type="reset">Reset</button>
</form>

View File

@ -0,0 +1,74 @@
<h2>Edit <?= $monster['name'] ?></h2>
<form action="/admin/monsters/<?= $monster['id'] ?>"
method="post"
hx-post="/admin/monsters/<?= $monster['id'] ?>"
hx-target="#main">
<table>
<colgroup><col><col></colgroup>
<tbody>
<tr>
<td>ID</td>
<td><?= $monster['id'] ?></td>
</tr>
<tr>
<td>Name</td>
<td><input type="text" name="name" value="<?= $monster['name'] ?>"></td>
</tr>
<tr>
<td>Max HP</td>
<td><input type="number" name="maxhp" value="<?= $monster['maxhp'] ?>"></td>
</tr>
<tr>
<td>Max Damage</td>
<td>
<input type="number" name="maxdam" value="<?= $monster['maxdam'] ?>"><br>
<span class="small">Compares to player's attack power.</span>
</td>
</tr>
<tr>
<td>Armor</td>
<td>
<input type="number" name="armor" value="<?= $monster['armor'] ?>"><br>
<span class="small">Compares to player's defense power.</span>
</td>
</tr>
<tr>
<td>Monster Level</td>
<td>
<input type="number" name="level" value="<?= $monster['level'] ?>"><br>
<span class="small">Determines spawn location and item drops.</span>
</td>
</tr>
<tr>
<td>Max EXP</td>
<td>
<input type="number" name="maxexp" value="<?= $monster['maxexp'] ?>"><br>
<span class="small">Max experience gained from defeating monster.</span>
</td>
</tr>
<tr>
<td>Max Gold</td>
<td>
<input type="number" name="maxgold" value="<?= $monster['maxgold'] ?>"><br>
<span class="small">Max gold gained from defeating monster.</span>
</td>
</tr>
<tr>
<td>Immunity</td>
<td>
<select name="immune">
<option value="0" <?= $monster['immune'] == 0 ? 'selected' : '' ?>>None</option>
<option value="1" <?= $monster['immune'] == 1 ? 'selected' : '' ?>>Hurt Spells</option>
<option value="2" <?= $monster['immune'] == 2 ? 'selected' : '' ?>>Hurt & Sleep Spells</option>
</select>
<br>
<span class="small">Some monsters may not be hurt by certain spells.</span>
</td>
</tr>
</tbody>
</table>
<button type="submit">Save</button>
<button type="reset">Reset</button>
</form>

View File

@ -0,0 +1,56 @@
<h2>Edit <?= $spell['name'] ?></h2>
<form action="/admin/spells/<?= $spell['id'] ?>" method="post", hx-post="/admin/spells/<?= $spell['id'] ?>" hx-target="#main">
<table>
<colgroup><col><col></colgroup>
<tbody>
<tr>
<td>ID</td>
<td><?= $spell['id'] ?></td>
</tr>
<tr>
<td>Name</td>
<td><input type="text" name="name" value="<?= $spell['name'] ?>"></td>
</tr>
<tr>
<td>MP</td>
<td>
<input type="number" name="mp" value="<?= $spell['mp'] ?>">
<br>
<span class="small">MP required to cast spell.</span>
</td>
</tr>
<tr>
<td>Attribute</td>
<td>
<input type="number" name="attribute" value="<?= $spell['attribute'] ?>">
<br>
<span class="small">Numeric value of the spell's effect. Ties with type, below.</span>
</td>
</tr>
<tr>
<td>Type</td>
<td>
<select name="type">
<option value="1" <?= $spell['type'] == 1 ? 'selected' : '' ?>>Heal</option>
<option value="2" <?= $spell['type'] == 2 ? 'selected' : '' ?>>Hurt</option>
<option value="3" <?= $spell['type'] == 3 ? 'selected' : '' ?>>Sleep</option>
<option value="4" <?= $spell['type'] == 4 ? 'selected' : '' ?>>Uber Attack</option>
<option value="5" <?= $spell['type'] == 5 ? 'selected' : '' ?>>Uber Defense</option>
</select>
<br>
<span class="small">
- Heal gives player back [attribute] hit points.<br>
- Hurt deals [attribute] damage to monster.<br>
- Sleep keeps monster from attacking ([attribute] is monster's chance out of 15 to stay asleep each turn).<br>
- Uber Attack increases total attack damage by [attribute] percent.<br>
- Uber Defense increases total defense from attack by [attribute] percent.
</span>
</td>
</tr>
</tbody>
</table>
<button type="submit">Save</button>
<button type="reset">Reset</button>
</form>

View File

@ -0,0 +1,58 @@
<h2>Edit <?= $town['name'] ?></h2>
<form action="/admin/towns/<?= $town['id'] ?>" method="post" hx-post="/admin/towns/<?= $town['id'] ?>" hx-target="#main">
<table>
<colgroup><col><col></colgroup>
<tbody>
<tr>
<td>ID</td> <td><?= $town['id'] ?></td>
</tr>
<tr>
<td>Name</td>
<td><input type="text" name="name" value="<?= $town['name'] ?>"></td>
</tr>
<tr>
<td>Latitude</td>
<td>
<input type="number" name="latitude" value="<?= $town['latitude'] ?>"><br>
<span class="small">Positive or negative integer.</span>
</td>
</tr>
<tr>
<td>Longitude</td>
<td>
<input type="number" name="longitude" value="<?= $town['longitude'] ?>" /><br>
<span class="small">Positive or negative integer.</span>
</td>
</tr>
<tr>
<td>Inn Price</td>
<td><input type="number" name="innprice" value="<?= $town['innprice'] ?>"> gold</td>
</tr>
<tr>
<td>Map Price</td>
<td>
<input type="number" name="mapprice" value="<?= $town['mapprice'] ?>"> gold<br>
<span class="small">How much it costs to buy the map to this town.</span>
</td>
</tr>
<tr>
<td>Travel Points</td>
<td>
<input type="number" name="travelpoints" value="<?= $town['travelpoints'] ?>"><br>
<span class="small">How many TP are consumed when travelling to this town.</span>
</td>
</tr>
<tr>
<td>Items List</td>
<td>
<input type="text" name="itemslist" value="<?= $town['itemslist'] ?>"><br>
<span class="small">Comma-separated list of item ID numbers available for purchase at this town.
(Example: <span class="highlight">1,2,3,6,9,10,13,20</span>)</span>
</td>
</tr>
</tbody>
</table>
<button type="submit">Save</button>
<button type="reset">Reset</button>
</form>

View File

@ -0,0 +1,89 @@
<h2>Edit <?= $user['username'] ?></h2>
<form action="/admin/users/<?= $user['id'] ?>" method="post" hx-post="/admin/users/<?= $user['id'] ?>" hx-target="#main">
<table>
<colgroup><col><col></colgroup>
<tbody>
<tr><td>ID</td><td><?= $user['id'] ?></td></tr>
<tr><td>Username</td><td><input type="text" name="username" value="<?= $user['username'] ?>"></td></tr>
<tr><td>Email</td><td><input type="text" name="email" value="<?= $user['email'] ?>"></td></tr>
<tr><td>Register Date</td><td><?= pretty_date($user['regdate']) ?></td></tr>
<tr><td>Last Online</td><td><?= pretty_date($user['onlinetime']) ?></td></tr>
<tr><td>Auth Level</td><td>
<select name="authlevel">
<option value="0" <?= $user['authlevel'] == 0 ? 'selected' : '' ?>>User</option>
<option value="1" <?= $user['authlevel'] == 1 ? 'selected' : '' ?>>Admin</option>
<option value="2" <?= $user['authlevel'] == 2 ? 'selected' : '' ?>>Blocked</option>
</select><br>
<span class="small">Set to "Blocked" to temporarily (or permanently) ban a user.</span>
</td></tr>
<tr><td colspan="2"></td></tr>
<tr><td>Latitude</td><td><input type="number" name="latitude" value="<?= $user['latitude'] ?>" /></td></tr>
<tr><td>Longitude</td><td><input type="number" name="longitude" value="<?= $user['longitude'] ?>" /></td></tr>
<tr><td>Character Class</td><td>
<select name="charclass">
<option value="1" <?= $user['charclass'] == 1 ? 'selected' : '' ?>><?= env('class_1_name') ?></option>
<option value="2" <?= $user['charclass'] == 2 ? 'selected' : '' ?>><?= env('class_2_name') ?></option>
<option value="3" <?= $user['charclass'] == 3 ? 'selected' : '' ?>><?= env('class_3_name') ?></option>
</select>
</td></tr>
<tr><td colspan="2"></td></tr>
<tr><td>Current Action</td><td><input type="text" name="currentaction" value="<?= $user['currentaction'] ?>" /></td></tr>
<tr><td>Current Fight</td><td><input type="number" name="currentfight" value="<?= $user['currentfight'] ?>" /></td></tr>
<tr><td>Current Monster</td><td><input type="number" name="currentmonster" value="<?= $user['currentmonster'] ?>" /></td></tr>
<tr><td>Current Monster HP</td><td><input type="number" name="currentmonsterhp" value="<?= $user['currentmonsterhp'] ?>" /></td></tr>
<tr><td>Current Monster Sleep</td><td><input type="number" name="currentmonsterimmune" value="<?= $user['currentmonsterimmune'] ?>" /></td></tr>
<tr><td>Current Monster Immune</td><td><input type="number" name="currentmonstersleep" value="<?= $user['currentmonstersleep'] ?>" /></td></tr>
<tr><td>Current Uber Damage</td><td><input type="number" name="currentuberdamage" value="<?= $user['currentuberdamage'] ?>" /></td></tr>
<tr><td>Current Uber Defense</td><td><input type="number" name="currentuberdefense" value="<?= $user['currentuberdefense'] ?>" /></td></tr>
<tr><td colspan="2"></td></tr>
<tr><td>Current HP</td><td><input type="number" name="currenthp" value="<?= $user['currenthp'] ?>" /></td></tr>
<tr><td>Current MP</td><td><input type="number" name="currentmp" value="<?= $user['currentmp'] ?>" /></td></tr>
<tr><td>Current TP</td><td><input type="number" name="currenttp" value="<?= $user['currenttp'] ?>" /></td></tr>
<tr><td>Max HP</td><td><input type="number" name="maxhp" value="<?= $user['maxhp'] ?>" /></td></tr>
<tr><td>Max MP</td><td><input type="number" name="maxmp" value="<?= $user['maxmp'] ?>" /></td></tr>
<tr><td>Max TP</td><td><input type="number" name="maxtp" value="<?= $user['maxtp'] ?>" /></td></tr>
<tr><td colspan="2"></td></tr>
<tr><td>Level</td><td><input type="number" name="level" value="<?= $user['level'] ?>" /></td></tr>
<tr><td>Gold</td><td><input type="number" name="gold" value="<?= $user['gold'] ?>" /></td></tr>
<tr><td>Experience</td><td><input type="number" name="experience" value="<?= $user['experience'] ?>" /></td></tr>
<tr><td>Gold Bonus</td><td><input type="number" name="goldbonus" value="<?= $user['goldbonus'] ?>" /></td></tr>
<tr><td>EXP Bonus</td><td><input type="number" name="expbonus" value="<?= $user['expbonus'] ?>" /></td></tr>
<tr><td>Strength</td><td><input type="number" name="strength" value="<?= $user['strength'] ?>" /></td></tr>
<tr><td>Dexterity</td><td><input type="number" name="dexterity" value="<?= $user['dexterity'] ?>" /></td></tr>
<tr><td>Attack Power</td><td><input type="number" name="attackpower" value="<?= $user['attackpower'] ?>" /></td></tr>
<tr><td>Defense Power</td><td><input type="number" name="defensepower" value="<?= $user['defensepower'] ?>" /></td></tr>
<tr><td colspan="2"></td></tr>
<tr><td>Weapon ID</td><td><input type="number" name="weaponid" value="<?= $user['weaponid'] ?>"></td></tr>
<tr><td>Armor ID</td><td><input type="number" name="armorid" value="<?= $user['armorid'] ?>"></td></tr>
<tr><td>Shield ID</td><td><input type="number" name="shieldid" value="<?= $user['shieldid'] ?>"></td></tr>
<tr><td>Slot 1 ID</td><td><input type="number" name="slot1id" value="<?= $user['slot1id'] ?>"></td></tr>
<tr><td>Slot 2 ID</td><td><input type="number" name="slot2id" value="<?= $user['slot2id'] ?>"></td></tr>
<tr><td>Slot 3 ID</td><td><input type="number" name="slot3id" value="<?= $user['slot3id'] ?>"></td></tr>
<tr><td>Weapon Name</td><td><input type="text" name="weaponname" value="<?= $user['weaponname'] ?>"></td></tr>
<tr><td>Armor Name</td><td><input type="text" name="armorname" value="<?= $user['armorname'] ?>"></td></tr>
<tr><td>Shield Name</td><td><input type="text" name="shieldname" value="<?= $user['shieldname'] ?>"></td></tr>
<tr><td>Slot 1 Name</td><td><input type="text" name="slot1name" value="<?= $user['slot1name'] ?>"></td></tr>
<tr><td>Slot 2 Name</td><td><input type="text" name="slot2name" value="<?= $user['slot2name'] ?>"></td></tr>
<tr><td>Slot 3 Name</td><td><input type="text" name="slot3name" value="<?= $user['slot3name'] ?>"></td></tr>
<tr><td colspan="2"></td></tr>
<tr><td>Drop Code</td><td><input type="number" name="dropcode" value="<?= $user['dropcode'] ?>"></td></tr>
<tr><td>Spells</td><td><input type="text" name="spells" value="<?= $user['spells'] ?>"></td></tr>
<tr><td>Towns</td><td><input type="text" name="towns" value="<?= $user['towns'] ?>"></td></tr>
</tbody>
</table>
<button type="submit">Save</button>
<button type="reset">Reset</button>
</form>

View File

@ -0,0 +1,110 @@
<h2>Main Settings</h2>
<p>These options control several major settings for the game engine.</p>
<p>Note that these particular settings are written to the .env file in the root directory, and not the database.</p>
<br>
<form action="/admin/main" method="post" hx-post="/admin/main" hx-target="#main">
<table>
<tr>
<td width="20%"><span class="highlight">Game Open:</span></td>
<td>
<select name="gameopen">
<option value="1" <?= env('game_open') ? 'selected' : '' ?>>Open</option>
<option value="0" <?= !env('game_open') ? 'selected' : '' ?>>Closed</option>
</select><br>
<span class="small">Close the game if you are upgrading or working on settings and don't want to
cause odd errors for end-users. Closing the game will completely halt all activity.</span>
</td>
</tr>
<tr>
<td width="20%">Game Name:</td>
<td>
<input type="text" name="gamename" value="<?= env('game_name') ?>"><br>
<span class="small">Change this if you want to change to call your game something different.</span>
</td>
</tr>
<tr>
<td width="20%">Game URL:</td>
<td>
<input type="text" name="gameurl" value="<?= env('game_url') ?>"><br>
<span class="small">Please specify the full URL to your game installation
("https://www.dragonknight.com/"). This gets used in the registration email sent to users. If
you leave this field blank or incorrect, users may not be able to register correctly.</span>
</td>
</tr>
<tr>
<td width="20%">Admin Email:</td>
<td>
<input type="text" name="adminemail" value="<?= env('admin_email') ?>"><br>
<span class="small">Please specify your email address. This gets used when the game has to send an
email to users.</span>
</td>
</tr>
<tr>
<td width="20%">Map Size:</td>
<td>
<input type="number" name="gamesize" value="<?= env('game_size') ?>"><br>
<span class="small">
Default is 250. This is the size of each map quadrant. Note that monster
levels increase every 5 spaces, so you should ensure that you have at least (map size / 5)
monster levels total, otherwise there will be parts of the map without any monsters, or some
monsters won't ever get used. Ex: with a map size of 250, you should have 50 monster levels total.
</span>
</td>
</tr>
<tr>
<td width="20%">Email Verification:</td>
<td>
<select name="verifyemail">
<option value="0" <?= !env('verify_email') ? 'selected' : '' ?>>Disabled</option>
<option value="1" <?= env('verify_email') ? 'selected' : '' ?>>Enabled</option>
</select><br>
<span class="small">Make users verify their email address for added security.</span>
</td>
</tr>
<tr>
<td width="20%">Show News:</td>
<td>
<select name="shownews">
<option value="0" <?= !env('show_news') ? 'selected' : '' ?>>No</option>
<option value="1" <?= env('show_news') ? 'selected' : '' ?>>Yes</option>
</select><br>
<span class="small">Toggle display of the Latest News box in towns.
</td>
</tr>
<tr>
<td width="20%">Show Who's Online:</td>
<td>
<select name="showonline">
<option value="0" <?= !env('show_online') ? 'selected' : '' ?>>No</option>
<option value="1" <?= env('show_online') ? 'selected' : '' ?>>Yes</option>
</select><br>
<span class="small">Toggle display of the Who's Online box in towns.</span>
</td>
</tr>
<tr>
<td width="20%">Show Babblebox:</td>
<td>
<select name="showbabble">
<option value="0" <?= !env('show_babble') ? 'selected' : '' ?>>No</option>
<option value="1" <?= env('show_babble') ? 'selected' : '' ?>>Yes</option>
</select><br>
<span class="small">Toggle display of the Babble Box in towns.</span>
</td>
</tr>
<tr>
<td width="20%">Class 1 Name:</td>
<td><input type="text" name="class1name" value="<?= env('class_1_name') ?>"><br></td>
</tr>
<tr>
<td width="20%">Class 2 Name:</td>
<td><input type="text" name="class2name" value="<?= env('class_2_name') ?>"><br></td>
</tr>
<tr>
<td width="20%">Class 3 Name:</td>
<td><input type="text" name="class3name" value="<?= env('class_3_name') ?>"><br></td>
</tr>
</table>
<button type="submit">Save</button>
<button type="reset">Reset</button>
</form>

View File

@ -1,34 +1,29 @@
<?php
$template = <<<THEVERYENDOFYOU
<head>
<title>shoutbox</title>
<style type="text/css">
body {
background-image: url(images/background.jpg);
color: black;
font: 11px verdana;
margins: 0px;
padding: 0px;
}
div {
padding: 2px;
border: solid 1px black;
margin: 2px;
text-align: left;
}
a {
color: #663300;
text-decoration: none;
font-weight: bold;
}
a:hover {
color: #330000;
}
</style>
</head>
<body onload="window.scrollTo(0,99999)">
{{content}}
</body>
</html>
THEVERYENDOFYOU;
?>
<div id="babblebox">
<div class="messages" hx-get="/babblebox/messages" hx-trigger="every 5s">
<?= $messages ?>
</div>
<form hx-post="/babblebox" hx-target="#babblebox > .messages" style="margin-top: 1rem;">
<input type="text" name="babble" maxlength="255"><br>
<input type="submit" name="submit" value="Babble">
<input type="reset" name="reset" value="Clear">
</form>
<script>
let chatBox = document.querySelector('#babblebox > .messages')
let isUserAtBottom = true
if (chatBox !== null) {
chatBox.scrollTop = chatBox.scrollHeight;
const isAtBottom = () => chatBox.scrollHeight - chatBox.scrollTop === chatBox.clientHeight
const scrollChatToBottom = () => {
if (isUserAtBottom) chatBox.scrollTop = chatBox.scrollHeight;
}
const observer = new MutationObserver(scrollChatToBottom)
observer.observe(chatBox, { childList: true, subtree: true })
chatBox.addEventListener('scroll', () => isUserAtBottom = isAtBottom())
}
</script>
</div>

View File

@ -1,14 +0,0 @@
<?php
$template = <<<THEVERYENDOFYOU
<form action="users.php?do=changepassword" method="post">
<table width="100%">
<tr><td colspan="2">Use the form below to change your password. All fields are required. New passwords must be 10 alphanumeric characters or less.</td></tr>
<tr><td width="20%">Username:</td><td><input type="text" name="username" size="30" maxlength="30" /></td></tr>
<tr><td>Old Password:</td><td><input type="password" name="oldpass" size="20" /></td></tr>
<tr><td>New Password:</td><td><input type="password" name="newpass1" size="20" maxlength="10" /></td></tr>
<tr><td>Verify New Password:</td><td><input type="password" name="newpass2" size="20" maxlength="10" /><br /><br /><br /></td></tr>
<tr><td colspan="2"><input type="submit" name="submit" value="Submit" /> <input type="reset" name="reset" value="Reset" /></td></tr>
</table>
</form>
THEVERYENDOFYOU;
?>

View File

@ -1,14 +1,10 @@
<?php
$template = <<<THEVERYENDOFYOU
<table width="100%">
<tr><td class="title"><img src="images/title_fighting.gif" alt="Fighting" /></td></tr>
<tr><td>
You are fighting a <b>{{monstername}}</b><br /><br />
{{monsterhp}}
{{yourturn}}
{{monsterturn}}
{{command}}
</td></tr>
<tr><td class="title"><img src="/img/title_fighting.gif" alt="Fighting" /></td></tr>
<tr><td>
You are fighting a <b><?= $page['monstername'] ?></b><br><br>
<?= $page['monsterhp'] ?>
<?= $page['yourturn'] ?>
<?= $page['monsterturn'] ?>
<?= $page['command'] ?>
</td></tr>
</table>
THEVERYENDOFYOU;
?>

View File

@ -0,0 +1,50 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?= page_title() ?></title>
<link rel="stylesheet" href="/css/admin.css">
<script src="/js/htmx.js"></script>
</head>
<body>
<div id="admin-container">
<header>
<h1><?= env('game_name') ?></h1>
<h3>Admin</h3>
</header>
<main>
<nav>
<a href="/admin" hx-get="/admin" hx-target="#main">Admin Home</a><br>
<a href="/">Game Home</a><br><br>
<br>
<a href="/admin/main" hx-get="/admin/main" hx-target="#main">Main Settings</a><br>
<a href="/admin/news" hx-get="/admin/news" hx-target="#main">Add News Post</a><br>
<a href="/admin/users" hx-get="/admin/users" hx-target="#main">Edit Users</a><br><br>
<br>
<a href="/admin/items" hx-get="/admin/items" hx-target="#main">Edit Items</a><br>
<a href="/admin/drops" hx-get="/admin/drops" hx-target="#main">Edit Drops</a><br>
<a href="/admin/towns" hx-get="/admin/towns" hx-target="#main">Edit Towns</a><br>
<a href="/admin/monsters" hx-get="/admin/monsters" hx-target="#main">Edit Monsters</a><br>
<a href="/admin/levels" hx-get="/admin/levels" hx-target="#main">Edit Levels</a><br>
<a href="/admin/spells" hx-get="/admin/spells" hx-target="#main">Edit Spells</a><br>
</nav>
<section id="main">
<?= $content ?>
</section>
</main>
<footer>
<div>Powered by <a href="/" target="_new">Dragon Knight</a></div>
<div>&copy; 2024 Sharkk</div>
<?= Render\debug_db_info(); ?>
<div>Version <?= VERSION ?> <?= BUILD ?></div>
</footer>
<?php if (env('debug', false)) echo Render\debug_query_log(); ?>
</div>
</body>
</html>

View File

@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?= env('game_name', 'Dragon Knight') ?> Help</title>
<link rel="stylesheet" href="/css/help.css">
</head>
<body>
<a name="top"></a>
<h1><?= env('game_name', 'Dragon Knight') ?> Help</h1>
[ <a href="/help">Back to Help</a> ]<br>
[ <a href="/">Return to Game</a> ]
<br><br><hr>
<?= $content ?>
<br><br>
<footer>
<div>Powered by <a href="/" target="_new">Dragon Knight</a></div>
<div>&copy; 2024 Sharkk</div>
<div>Version <?= $version ?> <?= $build ?></div>
</footer>
</body>
</html>

Some files were not shown because too many files have changed in this diff Show More