Completely move functions to new routing and namespaces
This commit is contained in:
parent
5ea0de2ae1
commit
5235239c1c
|
@ -11,7 +11,7 @@ $controlrow = get_control_row();
|
|||
// Login (or verify) if not logged in.
|
||||
if (($userrow = checkcookies()) === false) {
|
||||
if (isset($_GET['do']) && $_GET['do'] === 'verify') redirect('users.php?do=verify');
|
||||
redirect('login.php?do=login');
|
||||
redirect('/login');
|
||||
}
|
||||
|
||||
if ($userrow["authlevel"] !== 1) exit("You must have administrator privileges to use the control panel.");
|
||||
|
|
|
@ -15,7 +15,7 @@ if (($userrow = checkcookies()) === false) {
|
|||
exit;
|
||||
}
|
||||
|
||||
header("Location: login.php?do=login");
|
||||
header("Location: /login");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
|
568
public/help.php
568
public/help.php
|
@ -1,568 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once '../src/lib.php';
|
||||
|
||||
if (!file_exists('../.installed')) redirect('install.php');
|
||||
|
||||
$controlrow = get_control_row();
|
||||
|
||||
$page = $_GET['page'] ?? '';
|
||||
if (!in_array($page, ['main', 'items', 'levels', 'monsters', 'spells'])) $page = 'main';
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title><?= $controlrow["gamename"] ?> Help</title>
|
||||
<style type="text/css">
|
||||
body {
|
||||
background-image: url('/img/background.jpg');
|
||||
color: black;
|
||||
font: 11px verdana;
|
||||
}
|
||||
table {
|
||||
border-style: none;
|
||||
padding: 0px;
|
||||
font: 11px verdana;
|
||||
}
|
||||
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;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<a name="top"></a>
|
||||
<h1><?= $controlrow["gamename"] ?> Help</h1>
|
||||
[ <a href="/">Return to the game</a> ]
|
||||
|
||||
<br><br><hr>
|
||||
|
||||
<?php
|
||||
// @MAIN
|
||||
if ($page === 'main'):
|
||||
?>
|
||||
<h3>Table of Contents</h3>
|
||||
<ul>
|
||||
<li /><a href="#intro">Introduction</a>
|
||||
<li /><a href="#classes">Character Classes</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><?= $controlrow["class1name"] ?></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><?= $controlrow["class2name"] ?></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><?= $controlrow["class3name"] ?></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 <?= $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.php?page=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.php?page=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.php?page=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.php?page=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 © 2003-2005 by Jamin Seven.<br><br>
|
||||
[ <a href="#top">Top</a> ]
|
||||
|
||||
<?php
|
||||
endif;
|
||||
// @MAIN END
|
||||
?>
|
||||
|
||||
<?php
|
||||
// @ITEMS
|
||||
if ($page === 'items'):
|
||||
?>
|
||||
|
||||
<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>
|
||||
<?php
|
||||
$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>';
|
||||
}
|
||||
|
||||
echo "<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";
|
||||
}
|
||||
?>
|
||||
</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>
|
||||
<?php
|
||||
$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>';
|
||||
}
|
||||
|
||||
echo "<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";
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
endif;
|
||||
// @ITEMS END
|
||||
?>
|
||||
|
||||
<?php
|
||||
// @SPELLS
|
||||
if ($page === 'spells'):
|
||||
?>
|
||||
|
||||
<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>
|
||||
<?php
|
||||
$spells = db()->query('SELECT * FROM spells ORDER BY id;');
|
||||
$spell_types = ['None', 'Heal', 'Hurt', 'Sleep', '+Damage (%)', '+Defense (%)'];
|
||||
while ($spell = $spells->fetchArray(SQLITE3_ASSOC)) {
|
||||
echo <<<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;
|
||||
}
|
||||
?>
|
||||
</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>
|
||||
|
||||
<?php
|
||||
endif;
|
||||
// @SPELLS END
|
||||
?>
|
||||
|
||||
<?php
|
||||
// @MONSTERS
|
||||
if ($page === 'monsters'):
|
||||
?>
|
||||
|
||||
<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>
|
||||
<?php
|
||||
$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';
|
||||
echo "<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";
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
endif;
|
||||
// @MONSTERS END
|
||||
?>
|
||||
|
||||
<?php
|
||||
// @LEVELS
|
||||
if ($page === '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;
|
||||
}
|
||||
?>
|
||||
|
||||
<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>
|
||||
<?php
|
||||
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'];
|
||||
|
||||
echo '<tr>';
|
||||
echo '<td>' . $level . '</td>';
|
||||
echo '<td>' . ($level_data['exp'] ?? '') . '</td>';
|
||||
echo '<td>' . ($level_data['hp'] ?? '') . '</td>';
|
||||
echo '<td>' . ($level_data['mp'] ?? '') . '</td>';
|
||||
echo '<td>' . ($level_data['tp'] ?? '') . '</td>';
|
||||
echo '<td>' . ($level_data['strength'] ?? '') . '</td>';
|
||||
echo '<td>' . ($level_data['dexterity'] ?? '') . '</td>';
|
||||
echo '<td>' . (!empty($spell_name) ? $spell_name : '<span class="light">None</span>') . '</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
?>
|
||||
</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>
|
||||
<?php
|
||||
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'];
|
||||
|
||||
echo '<tr>';
|
||||
echo '<td>' . $level . '</td>';
|
||||
echo '<td>' . ($level_data['exp'] ?? '') . '</td>';
|
||||
echo '<td>' . ($level_data['hp'] ?? '') . '</td>';
|
||||
echo '<td>' . ($level_data['mp'] ?? '') . '</td>';
|
||||
echo '<td>' . ($level_data['tp'] ?? '') . '</td>';
|
||||
echo '<td>' . ($level_data['strength'] ?? '') . '</td>';
|
||||
echo '<td>' . ($level_data['dexterity'] ?? '') . '</td>';
|
||||
echo '<td>' . (!empty($spell_name) ? $spell_name : '<span class="light">None</span>') . '</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
?>
|
||||
</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>
|
||||
<?php
|
||||
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'];
|
||||
|
||||
echo '<tr>';
|
||||
echo '<td>' . $level . '</td>';
|
||||
echo '<td>' . ($level_data['exp'] ?? '') . '</td>';
|
||||
echo '<td>' . ($level_data['hp'] ?? '') . '</td>';
|
||||
echo '<td>' . ($level_data['mp'] ?? '') . '</td>';
|
||||
echo '<td>' . ($level_data['tp'] ?? '') . '</td>';
|
||||
echo '<td>' . ($level_data['strength'] ?? '') . '</td>';
|
||||
echo '<td>' . ($level_data['dexterity'] ?? '') . '</td>';
|
||||
echo '<td>' . (!empty($spell_name) ? $spell_name : '<span class="light">None</span>') . '</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
?>
|
||||
</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.
|
||||
|
||||
<?php
|
||||
endif;
|
||||
// @LEVELS END
|
||||
?>
|
||||
|
||||
<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">© 2003-2006 by renderse7en</td>
|
||||
</tr></table>
|
||||
</body>
|
||||
</html>
|
|
@ -4,37 +4,42 @@
|
|||
|
||||
require_once '../src/lib.php';
|
||||
require_once '../src/router.php';
|
||||
require_once '../src/users.php';
|
||||
require_once '../src/help.php';
|
||||
|
||||
if (!file_exists('../.installed')) redirect('install.php');
|
||||
|
||||
$controlrow = get_control_row();
|
||||
|
||||
// Login (or verify) if not logged in.
|
||||
if (($userrow = checkcookies()) === false) {
|
||||
if (isset($_GET['do']) && $_GET['do'] === 'verify') {
|
||||
header("Location: users.php?do=verify");
|
||||
exit;
|
||||
}
|
||||
|
||||
header("Location: login.php?do=login");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Close game.
|
||||
if ((bool) $controlrow["gameopen"] === false) {
|
||||
if (!$controlrow["gameopen"]) {
|
||||
display("The game is currently closed for maintanence. Please check back later.", "Game Closed");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Force verify if the user isn't verified yet.
|
||||
if ((bool) $controlrow["verifyemail"] && (bool) $userrow["verify"] === false) {
|
||||
// Login (or verify) if not logged in.
|
||||
if (($userrow = checkcookies()) === false) {
|
||||
$uri = uri();
|
||||
if (!in_array($uri[0], ['login', 'register', 'verify', 'lostpassword', 'help'])) {
|
||||
redirect('/login');
|
||||
}
|
||||
} else {
|
||||
// Block user if he/she has been banned.
|
||||
if ($userrow["authlevel"] === 2) {
|
||||
exit("Your account has been banned.");
|
||||
}
|
||||
|
||||
// Force verify if the user isn't verified yet.
|
||||
if ($controlrow["verifyemail"] && (bool) $userrow["verify"] === false) {
|
||||
redirect('/verify');
|
||||
header("Location: users.php?do=verify");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// Block user if he/she has been banned.
|
||||
if ($userrow["authlevel"] === 2) {
|
||||
exit("Your account has been blocked.");
|
||||
// Close game.
|
||||
if (!$controlrow["gameopen"]) {
|
||||
display("The game is currently closed for maintanence. Please check back later.", "Game Closed");
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once '../src/towns.php';
|
||||
|
@ -58,35 +63,19 @@ $r->get('/', function() {
|
|||
}
|
||||
|
||||
display($page, $title);
|
||||
});
|
||||
})->middleware('auth_only');
|
||||
|
||||
$r->get('/ninja', function() {
|
||||
exit('NINJA! 🥷');
|
||||
});
|
||||
|
||||
$r->get('/inn', 'inn');
|
||||
$r->post('/inn', 'inn');
|
||||
$r->get('/buy', 'buy');
|
||||
$r->get('/buy2/:id', 'buy2');
|
||||
$r->post('/buy3/:id', 'buy3');
|
||||
// $r->get('/sell', 'sell');
|
||||
$r->get('/maps', 'maps');
|
||||
$r->get('/maps2/:id', 'maps2');
|
||||
$r->post('/maps3/:id', 'maps3');
|
||||
$r->get('/gotown/:id', 'travelto');
|
||||
Towns\register_routes($r);
|
||||
Fights\register_routes($r);
|
||||
Users\register_routes($r);
|
||||
Help\register_routes($r);
|
||||
|
||||
$r->post('/move', 'move');
|
||||
|
||||
$r->get('/fight', 'fight');
|
||||
$r->post('/fight', 'fight');
|
||||
$r->get('/victory', 'victory');
|
||||
$r->get('/drop', 'drop');
|
||||
$r->post('/drop', 'drop');
|
||||
$r->get('/dead', 'dead');
|
||||
|
||||
$r->get('/verify', function() {
|
||||
redirect('users.php?do=verify');
|
||||
});
|
||||
$r->get('/spell/:id', 'healspells');
|
||||
$r->get('/showchar', 'showchar');
|
||||
$r->get('/onlinechar/:id', 'onlinechar');
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
<?php
|
||||
|
||||
// login.php :: Handles logins and cookies.
|
||||
|
||||
require_once '../src/lib.php';
|
||||
|
||||
if (!file_exists('../.installed')) redirect('install.php');
|
||||
|
||||
match ($_GET['do'] ?? 'login') {
|
||||
'login' => login(),
|
||||
'logout' => logout()
|
||||
};
|
||||
|
||||
function login()
|
||||
{
|
||||
if (checkcookies() !== false) redirect('/');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$form = validate($_POST, [
|
||||
'username' => ['length:3-18', 'alpha-spaces'],
|
||||
'password' => ['length:6-255'],
|
||||
'remember' => ['bool']
|
||||
]);
|
||||
|
||||
if (!$form['valid']) {
|
||||
exit(ul_from_validate_errors($form['errors']));
|
||||
}
|
||||
|
||||
$form = $form['data'];
|
||||
|
||||
$query = db()->query('SELECT id, username, password FROM users WHERE username = ? COLLATE NOCASE LIMIT 1;', [$form['username']]);
|
||||
$row = $query ? $query->fetchArray(SQLITE3_ASSOC) : false;
|
||||
|
||||
if ($row === false || !password_verify($_POST['password'] ?? '', $row['password']))
|
||||
die("Invalid username or password. Please go back and try again.");
|
||||
|
||||
$expiretime = $form['remember'] ? time() + 31536000 : 0;
|
||||
$rememberme = $form['remember'] ? 1 : 0;
|
||||
$cookie = implode(' ', [$row['id'], $row['username'], $row['password'], $rememberme]);
|
||||
|
||||
set_cookie("dkgame", $cookie, $expiretime);
|
||||
redirect('/');
|
||||
}
|
||||
|
||||
$page = gettemplate("login");
|
||||
$title = "Log In";
|
||||
display($page, $title, false, false, false, false);
|
||||
}
|
||||
|
||||
|
||||
function logout()
|
||||
{
|
||||
set_cookie("dkgame", "", -3600);
|
||||
redirect('login.php?do=login');
|
||||
}
|
|
@ -2,6 +2,21 @@
|
|||
|
||||
// fight.php :: Handles all fighting action.
|
||||
|
||||
namespace Fights;
|
||||
|
||||
use Router;
|
||||
|
||||
function register_routes(Router $r): Router
|
||||
{
|
||||
$r->get('/fight', 'Fights\fight');
|
||||
$r->post('/fight', 'Fights\fight');
|
||||
$r->get('/victory', 'Fights\victory');
|
||||
$r->get('/drop', 'Fights\drop');
|
||||
$r->post('/drop', 'Fights\drop');
|
||||
$r->get('/dead', 'Fights\dead');
|
||||
return $r;
|
||||
}
|
||||
|
||||
/**
|
||||
* One big long function that determines the outcome of the fight.
|
||||
*/
|
||||
|
|
500
src/help.php
Normal file
500
src/help.php
Normal file
|
@ -0,0 +1,500 @@
|
|||
<?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()
|
||||
{
|
||||
global $controlrow;
|
||||
|
||||
$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>{{class1name}}</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>{{class2name}}</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>{{class3name}}</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 © 2003-2005 by Jamin Seven.<br><br>
|
||||
[ <a href="#top">Top</a> ]
|
||||
HTML;
|
||||
|
||||
display_help(parsetemplate($page, $controlrow));
|
||||
}
|
||||
|
||||
function items()
|
||||
{
|
||||
global $controlrow;
|
||||
|
||||
$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>';
|
||||
|
||||
display_help($page);
|
||||
}
|
||||
|
||||
|
||||
function spells()
|
||||
{
|
||||
global $controlrow;
|
||||
|
||||
$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;
|
||||
|
||||
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";
|
||||
}
|
||||
|
||||
display_help($page.'</table>');
|
||||
}
|
||||
|
||||
function levels()
|
||||
{
|
||||
global $controlrow;
|
||||
|
||||
$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;
|
||||
|
||||
display_help(parsetemplate($page, $controlrow));
|
||||
}
|
||||
|
||||
function display_help(string $content)
|
||||
{
|
||||
global $controlrow;
|
||||
$template = parsetemplate(gettemplate('help'), $controlrow);
|
||||
echo parsetemplate($template, ['content' => $content]);
|
||||
}
|
39
src/lib.php
39
src/lib.php
|
@ -96,7 +96,7 @@ function admindisplay($content, $title)
|
|||
|
||||
function display($content, $title, $topnav=true, $leftnav=true, $rightnav=true, $badstart=false) { // Finalize page and output to browser.
|
||||
|
||||
global $numqueries, $userrow, $controlrow, $version, $build;
|
||||
global $userrow, $controlrow;
|
||||
if (!isset($controlrow)) {
|
||||
$query = db()->query('SELECT * FROM control WHERE id=1 LIMIT 1;');
|
||||
$controlrow = $query->fetchArray(SQLITE3_ASSOC);
|
||||
|
@ -106,12 +106,19 @@ function display($content, $title, $topnav=true, $leftnav=true, $rightnav=true,
|
|||
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=\"/img/button_logout.gif\" alt=\"Log Out\" title=\"Log Out\" border=\"0\" /></a> <a href=\"help.php\"><img src=\"/img/button_help.gif\" alt=\"Help\" title=\"Help\" border=\"0\" /></a>";
|
||||
$topnav = <<<HTML
|
||||
<a href='/logout'><img src='/img/button_logout.gif' alt='Log Out' title='Log Out'></a>
|
||||
<a href='/help'><img src='/img/button_help.gif' alt='Help' title='Help'></a>
|
||||
HTML;
|
||||
} else {
|
||||
$topnav = "<a href=\"login.php?do=login\"><img src=\"/img/button_login.gif\" alt=\"Log In\" title=\"Log In\" border=\"0\" /></a> <a href=\"users.php?do=register\"><img src=\"/img/button_register.gif\" alt=\"Register\" title=\"Register\" border=\"0\" /></a> <a href=\"help.php\"><img src=\"/img/button_help.gif\" alt=\"Help\" title=\"Help\" border=\"0\" /></a>";
|
||||
$topnav = <<<HTML
|
||||
<a href='/login'><img src='/img/button_login.gif' alt='Log In' title='Log In'></a>
|
||||
<a href='users.php?do=register'><img src='/img/button_register.gif' alt='Register' title='Register'></a>
|
||||
<a href='/help'><img src='/img/button_help.gif' alt='Help' title='Help'></a>
|
||||
HTML;
|
||||
}
|
||||
|
||||
if (isset($userrow)) {
|
||||
if (isset($userrow) && $userrow !== false) {
|
||||
|
||||
// Get userrow again, in case something has been updated.
|
||||
$userquery = db()->query('SELECT * FROM users WHERE id = ? LIMIT 1;', [$userrow['id']]);
|
||||
|
@ -526,3 +533,27 @@ function ul_from_validate_errors(array $errors): string
|
|||
}
|
||||
return $string . '</ul>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the URI, broken up into chunks.
|
||||
*/
|
||||
function uri(): array
|
||||
{
|
||||
return explode('/', trim($_SERVER['REQUEST_URI'], '/'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect to login if not authenticated.
|
||||
*/
|
||||
function auth_only(): void
|
||||
{
|
||||
if (!checkcookies()) redirect('/login');
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect to home if authenticated.
|
||||
*/
|
||||
function guest_only(): void
|
||||
{
|
||||
if (checkcookies()) redirect('/login');
|
||||
}
|
||||
|
|
|
@ -2,6 +2,25 @@
|
|||
|
||||
// towns.php :: Handles all actions you can do in town.
|
||||
|
||||
namespace Towns;
|
||||
|
||||
use Router;
|
||||
|
||||
function register_routes(Router $r): Router
|
||||
{
|
||||
$r->get('/inn', 'Towns\inn');
|
||||
$r->post('/inn', 'Towns\inn');
|
||||
$r->get('/buy', 'Towns\buy');
|
||||
$r->get('/buy2/:id', 'Towns\buy2');
|
||||
$r->post('/buy3/:id', 'Towns\buy3');
|
||||
// $r->get('/sell', 'Towns\sell');
|
||||
$r->get('/maps', 'Towns\maps');
|
||||
$r->get('/maps2/:id', 'Towns\maps2');
|
||||
$r->post('/maps3/:id', 'Towns\maps3');
|
||||
$r->get('/gotown/:id', 'Towns\travelto');
|
||||
return $r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Staying at the inn resets all expendable stats to their max values.
|
||||
*/
|
||||
|
|
|
@ -1,20 +1,72 @@
|
|||
<?php
|
||||
|
||||
// users.php :: Handles user account functions.
|
||||
namespace Users;
|
||||
|
||||
require_once '../src/lib.php';
|
||||
use Router;
|
||||
|
||||
if (!file_exists('../.installed')) redirect('install.php');
|
||||
function register_routes(Router $r): Router
|
||||
{
|
||||
$r->get('/login', 'Users\login');
|
||||
$r->post('/login', 'Users\login');
|
||||
$r->get('/logout', 'Users\logout');
|
||||
$r->get('/register', 'Users\register');
|
||||
$r->post('/register', 'Users\register');
|
||||
$r->get('/lostpassword', 'Users\lostpassword');
|
||||
$r->post('/lostpassword', 'Users\lostpassword');
|
||||
$r->get('/changepassword', 'Users\changepassword');
|
||||
$r->post('/changepassword', 'Users\changepassword');
|
||||
$r->get('/verify', 'Users\verify');
|
||||
$r->post('/verify', 'Users\verify');
|
||||
return $r;
|
||||
}
|
||||
|
||||
$controlrow = get_control_row();
|
||||
/**
|
||||
* Displays the login page, and processes login requests.
|
||||
*/
|
||||
function login()
|
||||
{
|
||||
if (checkcookies() !== false) redirect('/');
|
||||
|
||||
$do = $_GET['do'] ?? 'register';
|
||||
match ($do) {
|
||||
'verify' => verify(),
|
||||
'lostpassword' => lostpassword(),
|
||||
'changepassword' => changepassword(),
|
||||
default => register()
|
||||
};
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$form = validate($_POST, [
|
||||
'username' => ['length:3-18', 'alpha-spaces'],
|
||||
'password' => ['length:6-255'],
|
||||
'remember' => ['bool']
|
||||
]);
|
||||
|
||||
if (!$form['valid']) {
|
||||
exit(ul_from_validate_errors($form['errors']));
|
||||
}
|
||||
|
||||
$form = $form['data'];
|
||||
|
||||
$query = db()->query('SELECT id, username, password FROM users WHERE username = ? COLLATE NOCASE LIMIT 1;', [$form['username']]);
|
||||
$row = $query ? $query->fetchArray(SQLITE3_ASSOC) : false;
|
||||
|
||||
if ($row === false || !password_verify($_POST['password'] ?? '', $row['password']))
|
||||
die("Invalid username or password. Please go back and try again.");
|
||||
|
||||
$expiretime = $form['remember'] ? time() + 31536000 : 0;
|
||||
$rememberme = $form['remember'] ? 1 : 0;
|
||||
$cookie = implode(' ', [$row['id'], $row['username'], $row['password'], $rememberme]);
|
||||
|
||||
set_cookie("dkgame", $cookie, $expiretime);
|
||||
redirect('/');
|
||||
}
|
||||
|
||||
$page = gettemplate("login");
|
||||
$title = "Log In";
|
||||
display($page, $title, false, false, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the current cookie and redirect to home.
|
||||
*/
|
||||
function logout()
|
||||
{
|
||||
set_cookie("dkgame", "", -3600);
|
||||
redirect('/login');
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new account.
|
||||
|
@ -51,7 +103,7 @@ function register()
|
|||
$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.php?do=login\">Login Page</a> and continue playing ".$controlrow["gamename"]."!";
|
||||
$page = "Your account was created succesfully.<br><br>You may now continue to the <a href=\"/login\">Login Page</a> and continue playing ".$controlrow["gamename"]."!";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -79,10 +131,10 @@ function verify()
|
|||
|
||||
db()->query("UPDATE users SET verify='g2g' WHERE username=?;", [$u]);
|
||||
|
||||
display("Your account was verified successfully.<br><br>You may now continue to the <a href=\"login.php?do=login\">Login Page</a> and start playing the game.<br><br>Thanks for playing!","Verify Email",false,false,false);
|
||||
display("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!","Verify Email",false,false,false);
|
||||
}
|
||||
|
||||
$topnav = "<a href=\"login.php?do=login\"><img src=\"/img/button_login.gif\" alt=\"Log In\" border=\"0\" /></a><a href=\"users.php?do=register\"><img src=\"/img/button_register.gif\" alt=\"Register\" border=\"0\" /></a><a href=\"help.php\"><img src=\"/img/button_help.gif\" alt=\"Help\" border=\"0\" /></a>";
|
||||
$topnav = "<a href=\"/login\"><img src=\"/img/button_login.gif\" alt=\"Log In\" border=\"0\" /></a><a href=\"users.php?do=register\"><img src=\"/img/button_register.gif\" alt=\"Register\" border=\"0\" /></a><a href=\"/help\"><img src=\"/img/button_help.gif\" alt=\"Help\" border=\"0\" /></a>";
|
||||
display(gettemplate("verify"), "Verify Email", false, false, false);
|
||||
}
|
||||
|
||||
|
@ -99,13 +151,13 @@ function lostpassword()
|
|||
db()->query('UPDATE users SET password=? WHERE email=?;', [$hashed, $e]);
|
||||
|
||||
if (sendpassemail($e, $newpass)) {
|
||||
display("Your new password was emailed to the address you provided.<br><br>Once you receive it, you may <a href=\"login.php?do=login\">Log In</a> and continue playing.<br><br>Thank you.","Lost Password",false,false,false);
|
||||
display("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.","Lost Password",false,false,false);
|
||||
} else {
|
||||
display("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.","Lost Password",false,false,false);
|
||||
}
|
||||
}
|
||||
|
||||
$topnav = "<a href=\"login.php?do=login\"><img src=\"/img/button_login.gif\" alt=\"Log In\" border=\"0\" /></a><a href=\"users.php?do=register\"><img src=\"/img/button_register.gif\" alt=\"Register\" border=\"0\" /></a><a href=\"help.php\"><img src=\"/img/button_help.gif\" alt=\"Help\" border=\"0\" /></a>";
|
||||
$topnav = "<a href=\"/login\"><img src=\"/img/button_login.gif\" alt=\"Log In\" border=\"0\" /></a><a href=\"users.php?do=register\"><img src=\"/img/button_register.gif\" alt=\"Register\" border=\"0\" /></a><a href=\"/help\"><img src=\"/img/button_help.gif\" alt=\"Help\" border=\"0\" /></a>";
|
||||
display(gettemplate("lostpassword"), "Lost Password", false, false, false);
|
||||
|
||||
}
|
||||
|
@ -137,10 +189,10 @@ function changepassword()
|
|||
|
||||
set_cookie('dkgame', '', -3600);
|
||||
|
||||
display("Your password was changed successfully.<br><br>You have been logged out of the game to avoid errors.<br><br>Please <a href=\"login.php?do=login\">log back in</a> to continue playing.","Change Password",false,false,false);
|
||||
display("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.","Change Password",false,false,false);
|
||||
}
|
||||
|
||||
$topnav = "<a href=\"login.php?do=login\"><img src=\"/img/button_login.gif\" alt=\"Log In\" border=\"0\" /></a><a href=\"users.php?do=register\"><img src=\"/img/button_register.gif\" alt=\"Register\" border=\"0\" /></a><a href=\"help.php\"><img src=\"/img/button_help.gif\" alt=\"Help\" border=\"0\" /></a>";
|
||||
$topnav = "<a href=\"/login\"><img src=\"/img/button_login.gif\" alt=\"Log In\" border=\"0\" /></a><a href=\"users.php?do=register\"><img src=\"/img/button_register.gif\" alt=\"Register\" border=\"0\" /></a><a href=\"/help\"><img src=\"/img/button_help.gif\" alt=\"Help\" border=\"0\" /></a>";
|
||||
display(gettemplate("changepassword"), "Change Password", false, false, false);
|
||||
}
|
||||
|
85
templates/help.php
Normal file
85
templates/help.php
Normal file
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
|
||||
$template = <<<HTML
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>{{gamename}} Help</title>
|
||||
<style type="text/css">
|
||||
body {
|
||||
background-image: url('/img/background.jpg');
|
||||
color: black;
|
||||
font: 11px verdana;
|
||||
}
|
||||
table {
|
||||
border-style: none;
|
||||
padding: 0px;
|
||||
font: 11px verdana;
|
||||
}
|
||||
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;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<a name="top"></a>
|
||||
<h1>{{gamename}} Help</h1>
|
||||
[ <a href="/">Return to the game</a> ]
|
||||
|
||||
<br><br><hr>
|
||||
|
||||
{{content}}
|
||||
|
||||
<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">© 2003-2006 by renderse7en</td>
|
||||
</tr></table>
|
||||
</body>
|
||||
</html>
|
||||
HTML;
|
|
@ -29,7 +29,7 @@ $template = <<<HTML
|
|||
{{forumslink}}
|
||||
{{adminlink}}
|
||||
<a href="users.php?do=changepassword">Change Password</a><br>
|
||||
<a href="login.php?do=logout">Log Out</a><br>
|
||||
<a href="help.php">Help</a>
|
||||
<a href="/logout">Log Out</a><br>
|
||||
<a href="/help">Help</a>
|
||||
</section>
|
||||
HTML;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
$template = <<<HTML
|
||||
<form action="login.php?do=login" method="post">
|
||||
<form action="/login" method="post">
|
||||
<table width="75%">
|
||||
<tr>
|
||||
<td width="30%">Username:</td>
|
||||
|
|
|
@ -8,7 +8,7 @@ $template = <<<THEVERYENDOFYOU
|
|||
<tr><td>Email Address:</td><td><input type="text" name="email1" size="30" maxlength="100" /></td></tr>
|
||||
<tr><td>Verify Email:</td><td><input type="text" name="email2" size="30" maxlength="100" />{{verifytext}}<br><br><br></td></tr>
|
||||
<tr><td>Character Class:</td><td><select name="charclass"><option value="1">{{class1name}}</option><option value="2">{{class2name}}</option><option value="3">{{class3name}}</option></select></td></tr>
|
||||
<tr><td colspan="2">See <a href="help.php">Help</a> for more information about character classes.<br><br></td></tr>
|
||||
<tr><td colspan="2">See <a href="/help">Help</a> for more information about character classes.<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>
|
||||
|
|
Loading…
Reference in New Issue
Block a user