v1.1.0
### 1.1.0 (2.27.2004) ### ### Thanks to Miker, Yop, Mantagnana & Maebius for bug reports & feature ideas. :) - Added option to verify registration emails. - Added options to turn off display of news/online/babblebox in towns. - Added gameurl and adminemail fields to control table. - Added ability to ban a user without deleting the account. - Added rules for passwords (alphanumeric, maxlength=10). - Added page where users can change their passwords. - Added a page for lost passwords. - Fixed bugs in users.php to use doquery() instead of mysql_query(). - Fixed bug in installer program when creating the admin user account. - Changed the way towns and spells are handled in the user account. - Removed some deprecated code from the onlinechar() function.
This commit is contained in:
parent
0c62ab23f2
commit
27eb6c15a7
|
@ -57,7 +57,7 @@ function main() {
|
|||
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' WHERE id='1' LIMIT 1", "control");
|
||||
$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");
|
||||
display("Settings updated.","Main Settings");
|
||||
} else {
|
||||
display("<b>Errors:</b><br /><div style=\"color:red;\">$errorlist</div><br />Please go back and try again.", "Main Settings");
|
||||
|
@ -73,10 +73,16 @@ These options control several major settings for the overall game engine.<br /><
|
|||
<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>
|
||||
|
@ -95,6 +101,14 @@ END;
|
|||
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"] = ""; }
|
||||
|
||||
|
@ -741,16 +755,16 @@ function edituser($id) {
|
|||
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
|
||||
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");
|
||||
display("User updated.","Edit Users");
|
||||
|
@ -781,7 +795,7 @@ $page = <<<END
|
|||
<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></select></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;"> </td></tr>
|
||||
|
||||
|
@ -850,6 +864,7 @@ 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"] = ""; }
|
||||
|
|
|
@ -10,7 +10,7 @@ $dbsettings = Array(
|
|||
|
||||
// These are used for display purposes only. Technically you could change them, but it's not going to
|
||||
// do anything special. And I'd prefer if you didn't, just to keep things all nice and standardized.
|
||||
$version = "1.0.4";
|
||||
$version = "1.1.0";
|
||||
$build = "";
|
||||
|
||||
?>
|
17
fight.php
17
fight.php
|
@ -10,9 +10,14 @@ function fight() { // One big long function that determines the outcome of the f
|
|||
$userspells = explode(",",$userrow["spells"]);
|
||||
$spellquery = doquery("SELECT id,name FROM {{table}}", "spells");
|
||||
while ($spellrow = mysql_fetch_array($spellquery)) {
|
||||
if ($userspells[$spellrow["id"]] == 1) {
|
||||
$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"];
|
||||
|
@ -180,7 +185,11 @@ function fight() { // One big long function that determines the outcome of the f
|
|||
|
||||
$newspellquery = doquery("SELECT * FROM {{table}} WHERE id='$pickedspell' LIMIT 1", "spells");
|
||||
$newspellrow = mysql_fetch_array($newspellquery);
|
||||
if ($userspells[$pickedspell] != 1) { display("You have not yet learned this spell. Please go back and try again.", "Error"); die(); }
|
||||
$spell = false;
|
||||
foreach($userspells as $a => $b) {
|
||||
if ($b == $pickedspell) { $spell = true; }
|
||||
}
|
||||
if ($pickedspell != 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.
|
||||
|
@ -379,9 +388,7 @@ function victory() {
|
|||
$newlevel = $levelrow["id"];
|
||||
|
||||
if ($levelrow[$userrow["charclass"]."_spells"] != 0) {
|
||||
$userspells = explode(",",$userrow["spells"]);
|
||||
$userspells[$levelrow[$userrow["charclass"]."_spells"]] = 1;
|
||||
$userspells = implode(",",$userspells);
|
||||
$userspells = $userrow["spells"] .= ",".$levelrow[$userrow["charclass"]."_spells"];
|
||||
$newspell = "spells='$userspells',";
|
||||
$spelltext = "You have learned a new spell.<br />";
|
||||
} else { $spelltext = ""; $newspell=""; }
|
||||
|
|
6
heal.php
6
heal.php
|
@ -9,7 +9,11 @@ function healspells($id) {
|
|||
$spellrow = mysql_fetch_array($spellquery);
|
||||
|
||||
// All the various ways to error out.
|
||||
if ($userspells[$id] != 1) { display("You have not yet learned this spell. Please go back and try again.", "Error"); die(); }
|
||||
$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(); }
|
||||
|
|
69
index.php
69
index.php
|
@ -4,12 +4,23 @@ if (file_exists('install.php')) { die("Please delete <b>install.php</b> from you
|
|||
include('lib.php');
|
||||
include('login.php');
|
||||
$link = opendb();
|
||||
$userrow = checkcookies();
|
||||
if ($userrow == false) { header("Location: login.php?do=login"); die(); }
|
||||
$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"]);
|
||||
|
@ -35,6 +46,7 @@ if (isset($_GET["do"])) {
|
|||
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]); }
|
||||
|
@ -65,22 +77,36 @@ function donothing() {
|
|||
|
||||
function dotown() { // Spit out the main town page.
|
||||
|
||||
global $userrow, $numqueries;
|
||||
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.
|
||||
$newsquery = doquery("SELECT * FROM {{table}} ORDER BY id DESC LIMIT 1", "news");
|
||||
$newsrow = mysql_fetch_array($newsquery);
|
||||
$townrow["news"] = "<span class=\"light\">[".prettydate($newsrow["postdate"])."]</span><br />".nl2br($newsrow["content"]);
|
||||
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.
|
||||
$onlinequery = doquery("SELECT * FROM {{table}} WHERE UNIX_TIMESTAMP(onlinetime) >= '".(time()-600)."' ORDER BY charname", "users");
|
||||
$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"], ", ");
|
||||
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);
|
||||
|
@ -146,8 +172,12 @@ function showchar() {
|
|||
$userspells = explode(",",$userrow["spells"]);
|
||||
$userrow["magiclist"] = "";
|
||||
while ($spellrow = mysql_fetch_array($spellquery)) {
|
||||
if ($userspells[$spellrow["id"]] == 1) {
|
||||
$userrow["magiclist"] .= $spellrow["name"] . "<br />";
|
||||
$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"; }
|
||||
|
@ -197,21 +227,6 @@ function onlinechar($id) {
|
|||
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)) {
|
||||
if ($userspells[$spellrow["id"]] == 1) {
|
||||
$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("onlinechar");
|
||||
$page = parsetemplate($charsheet, $userrow);
|
||||
display($page, "Character Information");
|
||||
|
|
15
install.php
15
install.php
|
@ -94,6 +94,8 @@ CREATE TABLE `$control` (
|
|||
`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 '',
|
||||
|
@ -106,14 +108,19 @@ CREATE TABLE `$control` (
|
|||
`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);
|
||||
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);
|
||||
|
@ -691,8 +698,8 @@ CREATE TABLE `$users` (
|
|||
`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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0',
|
||||
`towns` varchar(50) NOT NULL default '0,1,0,0,0,0,0,0,0',
|
||||
`spells` varchar(50) NOT NULL default '0,',
|
||||
`towns` varchar(50) NOT NULL default '0,',
|
||||
PRIMARY KEY (`id`)
|
||||
) TYPE=MyISAM;
|
||||
END;
|
||||
|
@ -752,7 +759,7 @@ function fourth() { // Final page: insert new user row, congratulate the person
|
|||
|
||||
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',regdate=NOW(),onlinetime=NOW(),authlevel='1'") or die(mysql_error());
|
||||
$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>
|
||||
|
|
14
lib.php
14
lib.php
|
@ -172,7 +172,11 @@ function display($content, $title, $topnav=true, $leftnav=true, $rightnav=true,
|
|||
$userspells = explode(",",$userrow["spells"]);
|
||||
$userrow["magiclist"] = "";
|
||||
while ($spellrow = mysql_fetch_array($spellquery)) {
|
||||
if ($userspells[$spellrow["id"]] == 1 && $spellrow["type"] == 1) {
|
||||
$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 />";
|
||||
}
|
||||
}
|
||||
|
@ -183,7 +187,13 @@ function display($content, $title, $topnav=true, $leftnav=true, $rightnav=true,
|
|||
$townquery2 = doquery("SELECT * FROM {{table}} ORDER BY id", "towns");
|
||||
$userrow["townslist"] = "";
|
||||
while ($townrow2 = mysql_fetch_array($townquery2)) {
|
||||
if ($townslist[$townrow2["id"]] == 1) { $userrow["townslist"] .= "<a href=\"index.php?do=gotown:".$townrow2["id"]."\">".$townrow2["name"]."</a><br />\n"; }
|
||||
$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 {
|
||||
|
|
14
templates/changepassword.php
Normal file
14
templates/changepassword.php
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?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;
|
||||
?>
|
|
@ -31,6 +31,7 @@ Travel To:<br />
|
|||
<tr><td>
|
||||
{{forumslink}}
|
||||
{{adminlink}}
|
||||
<a href="users.php?do=changepassword">Change Password</a><br />
|
||||
<a href="login.php?do=logout">Log Out</a><br />
|
||||
<a href="help.php">Help</a>
|
||||
</td></tr>
|
||||
|
|
|
@ -6,7 +6,7 @@ $template = <<<THEVERYENDOFYOU
|
|||
<tr><td>Password:</td><td><input type="password" size="30" name="password" /></td></tr>
|
||||
<tr><td>Remember me?</td><td><input type="checkbox" name="rememberme" value="yes" /> Yes</td></tr>
|
||||
<tr><td colspan="2"><input type="submit" name="submit" value="Log In" /></td></tr>
|
||||
<tr><td colspan="2">Checking the "Remember Me" option will store your login information in a cookie so you don't have to enter it next time you get online.<br /><br />Want to play? You gotta <a href="users.php?do=register">register your own character.</a></td></tr>
|
||||
<tr><td colspan="2">Checking the "Remember Me" option will store your login information in a cookie so you don't have to enter it next time you get online.<br /><br />Want to play? You gotta <a href="users.php?do=register">register your own character.</a><br /><br />You may also <a href="users.php?do=changepassword">change your password</a>, or <a href="users.php?do=lostpassword">request a new one</a> if you've lost yours.</td></tr>
|
||||
</table>
|
||||
</form>
|
||||
THEVERYENDOFYOU;
|
||||
|
|
11
templates/lostpassword.php
Normal file
11
templates/lostpassword.php
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
$template = <<<THEVERYENDOFYOU
|
||||
<form action="users.php?do=lostpassword" method="post">
|
||||
<table width="80%">
|
||||
<tr><td colspan="2">If you've lost your password, enter your email address below and you will be sent a new one.</td></tr>
|
||||
<tr><td width="20%">Email Address:</td><td><input type="text" name="email" size="30" maxlength="100" /></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;
|
||||
?>
|
|
@ -2,11 +2,11 @@
|
|||
$template = <<<THEVERYENDOFYOU
|
||||
<form action="users.php?do=register" method="post">
|
||||
<table width="80%">
|
||||
<tr><td width="20%">Username:</td><td><input type="text" name="username" size="30" maxlength="30" /><br /><br /><br /></td></tr>
|
||||
<tr><td>Password:</td><td><input type="password" name="password1" size="30" maxlength="30" /></td></tr>
|
||||
<tr><td>Verify Password:</td><td><input type="password" name="password2" size="30" maxlength="30" /><br /><br /><br /></td></tr>
|
||||
<tr><td width="20%">Username:</td><td><input type="text" name="username" size="30" maxlength="30" /><br />Usernames must be 30 alphanumeric characters or less.<br /><br /><br /></td></tr>
|
||||
<tr><td>Password:</td><td><input type="password" name="password1" size="30" maxlength="10" /></td></tr>
|
||||
<tr><td>Verify Password:</td><td><input type="password" name="password2" size="30" maxlength="10" /><br />Passwords must be 10 alphanumeric characters or less.<br /><br /><br /></td></tr>
|
||||
<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" /><br /><br /><br /></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 Name:</td><td><input type="text" name="charname" size="30" maxlength="30" /></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>Difficulty:</td><td><select name="difficulty"><option value="1">{{diff1name}}</option><option value="2">{{diff2name}}</option><option value="3">{{diff3name}}</option></select></td></tr>
|
||||
|
|
|
@ -11,15 +11,14 @@ $template = <<<THEVERYENDOFYOU
|
|||
</ul>
|
||||
</td></tr>
|
||||
<tr><td><center>
|
||||
<table width="95%">
|
||||
<tr><td class="title">Latest News</td></tr>
|
||||
<tr><td>{{news}}</td></tr>
|
||||
</table>
|
||||
{{news}}
|
||||
<br />
|
||||
<table width="95%">
|
||||
<tr><td class="title" width="50%">Who's Online</td><td class="title">Babble Box</td></tr>
|
||||
<tr><td>{{whosonline}}<br /><br /></td>
|
||||
<td><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></td></tr>
|
||||
<tr><td width="50%">
|
||||
{{whosonline}}
|
||||
</td><td>
|
||||
{{babblebox}}
|
||||
</td></tr>
|
||||
</table>
|
||||
</td></tr>
|
||||
</table>
|
||||
|
|
14
templates/verify.php
Normal file
14
templates/verify.php
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
$template = <<<THEVERYENDOFYOU
|
||||
<form action="users.php?do=verify" method="post">
|
||||
<table width="80%">
|
||||
<tr><td colspan="2">Thank you for registering a character. Please enter your username, email address, and the verification code
|
||||
that was emailed to you to unlock your character.</td></tr>
|
||||
<tr><td width="20%">Username:</td><td><input type="text" name="username" size="30" maxlength="30" /></td></tr>
|
||||
<tr><td>Email Address:</td><td><input type="text" name="email" size="30" maxlength="100" /></td></tr>
|
||||
<tr><td>Verification Code:</td><td><input type="text" name="verify" size="10" maxlength="8" /><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;
|
||||
?>
|
15
towns.php
15
towns.php
|
@ -349,11 +349,16 @@ function travelto($id, $usepoints=true) { // Send a user to a town from the Trav
|
|||
|
||||
// If they got here by exploring, add this town to their map.
|
||||
$mapped = explode(",",$userrow["towns"]);
|
||||
if ($mapped[$id] == 0) {
|
||||
$mapped[$id] = 1;
|
||||
$mapped = "towns='".implode(",",$mapped)."',";
|
||||
} else {
|
||||
$mapped = "";
|
||||
$town = false;
|
||||
foreach($mapped as $a => $b) {
|
||||
if ($b == $id) { $town = true; }
|
||||
}
|
||||
$mapped = implode(",",$mapped);
|
||||
if ($town == false) {
|
||||
$mapped .= ",$id";
|
||||
$mapped = "towns='".$mapped."',";
|
||||
} else {
|
||||
$mapped = "towns='".$mapped."',";
|
||||
}
|
||||
|
||||
$updatequery = doquery("UPDATE {{table}} SET currentaction='In Town',$mapped currenttp='$newtp',latitude='$newlat',longitude='$newlon' WHERE id='$newid' LIMIT 1", "users");
|
||||
|
|
96
upgrade_to_110.php
Normal file
96
upgrade_to_110.php
Normal file
|
@ -0,0 +1,96 @@
|
|||
<?
|
||||
|
||||
include('config.php');
|
||||
include('lib.php');
|
||||
$link = opendb();
|
||||
$prefix = $dbsettings["prefix"];
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
if (isset($_POST["submit"])) {
|
||||
|
||||
$control = $prefix . "_control";
|
||||
$users = $prefix . "_users";
|
||||
$query = <<<END
|
||||
DROP TABLE IF EXISTS `$control`;
|
||||
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 upgraded.<br />"; } else { echo "Error upgrading Control table."; }
|
||||
unset($query);
|
||||
|
||||
$query = <<<END
|
||||
INSERT INTO `$control` VALUES (1, 'Dragon Knight', 250, 0, '', '', 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 = mysql_query("SELECT * FROM $users ORDER BY id") or die(mysql_error());
|
||||
$errors = 0; $errorlist = "";
|
||||
while ($row = mysql_fetch_array($query)) {
|
||||
$id = $row["id"];
|
||||
$oldspells = explode(",",$row["spells"]);
|
||||
$newspells = "0,";
|
||||
$oldtowns = explode(",",$row["towns"]);
|
||||
$newtowns = "0,";
|
||||
foreach($oldspells as $a => $b) {
|
||||
if ($b == 1) { $newspells .= "$a,"; }
|
||||
}
|
||||
$newspells = rtrim($newspells,",");
|
||||
foreach($oldtowns as $c => $d) {
|
||||
if ($d == 1) { $newtowns .= "$c,"; }
|
||||
}
|
||||
$newtowns = rtrim($newtowns,",");
|
||||
$update = mysql_query("UPDATE $users SET spells='$newspells',towns='$newtowns',verify='1' WHERE id='$id' LIMIT 1");
|
||||
if ($update == false) { $errors++; $errorlist .= mysql_error() . "<br />"; } else { echo "User $id upgraded.<br />"; }
|
||||
}
|
||||
if ($errors != 0) {
|
||||
echo "<br /><b><span style=\"color:red\">The following errors occurred while upgrading the users list:</span></b><br />$errorlist";
|
||||
} else {
|
||||
echo "<br /><b>The upgrade completed successfully. Please log in to the game and visit the control panel to update your main game settings.<br /><br />You should also delete this file from your Dragon Knight directory for security reasons.</b>";
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
echo "Click the button below to run the upgrade script.<br /><form action=\"upgrade_to_110.php\" method=\"post\"><input type=\"submit\" name=\"submit\" value=\"Upgrade\" /></form>";
|
||||
die();
|
||||
|
||||
}
|
||||
|
||||
?>
|
184
users.php
184
users.php
|
@ -7,6 +7,9 @@ if (isset($_GET["do"])) {
|
|||
|
||||
$do = $_GET["do"];
|
||||
if ($do == "register") { register(); }
|
||||
elseif ($do == "verify") { verify(); }
|
||||
elseif ($do == "lostpassword") { lostpassword(); }
|
||||
elseif ($do == "changepassword") { changepassword(); }
|
||||
|
||||
}
|
||||
|
||||
|
@ -24,33 +27,43 @@ function register() { // Register a new account.
|
|||
// Process username.
|
||||
if ($username == "") { $errors++; $errorlist .= "Username field is required.<br />"; }
|
||||
if (preg_match("/[^A-z0-9_\-]/", $username)==1) { $errors++; $errorlist .= "Username must be alphanumeric.<br />"; } // Thanks to "Carlos Pires" from php.net!
|
||||
$usernamequery = mysql_query("SELECT username FROM dk_users WHERE username='$username' LIMIT 1");
|
||||
$usernamequery = doquery("SELECT username FROM {{table}} WHERE username='$username' LIMIT 1","users");
|
||||
if (mysql_num_rows($usernamequery) > 0) { $errors++; $errorlist .= "Username already taken - unique username required.<br />"; }
|
||||
|
||||
// Process email address.
|
||||
if ($email1 == "" || $email2 == "") { $errors++; $errorlist .= "Email fields are required.<br />"; }
|
||||
if ($email1 != $email2) { $errors++; $errorlist .= "Emails don't match.<br />"; }
|
||||
if (! is_email($email1)) { $errors++; $errorlist .= "Email isn't valid.<br />"; }
|
||||
$emailquery = mysql_query("SELECT email FROM dk_users WHERE email='$email1' LIMIT 1");
|
||||
$emailquery = doquery("SELECT email FROM {{table}} WHERE email='$email1' LIMIT 1","users");
|
||||
if (mysql_num_rows($emailquery) > 0) { $errors++; $errorlist .= "Email already taken - unique email address required.<br />"; }
|
||||
|
||||
// Process password.
|
||||
if (preg_match("/[^A-z0-9_\-]/", $password1)==1) { $errors++; $errorlist .= "Password must be alphanumeric.<br />"; } // Thanks to "Carlos Pires" from php.net!
|
||||
if ($password1 != $password2) { $errors++; $errorlist .= "Passwords don't match.<br />"; }
|
||||
$password = md5($password1);
|
||||
|
||||
if ($errors == 0) {
|
||||
|
||||
$verifycode = "";
|
||||
for ($i=0; $i<8; $i++) {
|
||||
$verifycode .= chr(rand(65,90));
|
||||
if ($controlrow["verifyemail"] == 1) {
|
||||
$verifycode = "";
|
||||
for ($i=0; $i<8; $i++) {
|
||||
$verifycode .= chr(rand(65,90));
|
||||
}
|
||||
} else {
|
||||
$verifycode='1';
|
||||
}
|
||||
|
||||
$query = doquery("INSERT INTO {{table}} SET id='',regdate=NOW(),verify='$verifycode',username='$username',password='$password',email='$email1',charname='$charname',charclass='$charclass',difficulty='$difficulty'", "users") or die(mysql_error());
|
||||
//if (sendregmail($email1, $verifycode)) {
|
||||
$page = "Your account was created successfully.<br /><br />You may now continue to the <a href=\"login.php?do=login\">Log In</a> page and start playing ".$controlrow["gamename"]."!";
|
||||
//} 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.<br /><br />You may now continue to the <a href=\"login.php?do=login\">Log In</a> page and start playing ".$controlrow["gamename"]."!";
|
||||
//}
|
||||
|
||||
if ($controlrow["verifyemail"] == 1) {
|
||||
if (sendregmail($email1, $verifycode) == true) {
|
||||
$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.php?do=login\">Login Page</a> and continue playing ".$controlrow["gamename"]."!";
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
|
@ -61,6 +74,11 @@ function register() { // Register a new account.
|
|||
} else {
|
||||
|
||||
$page = gettemplate("register");
|
||||
if ($controlrow["verifyemail"] == 1) {
|
||||
$controlrow["verifytext"] = "<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 {
|
||||
$controlrow["verifytext"] = "";
|
||||
}
|
||||
$page = parsetemplate($page, $controlrow);
|
||||
|
||||
}
|
||||
|
@ -70,30 +88,150 @@ function register() { // Register a new account.
|
|||
|
||||
}
|
||||
|
||||
function sendregmail($emailaddress, $vercode) {
|
||||
function verify() {
|
||||
|
||||
include('config.php');
|
||||
extract($appsettings);
|
||||
if (isset($_POST["submit"])) {
|
||||
extract($_POST);
|
||||
$userquery = doquery("SELECT username,email,verify FROM {{table}} WHERE username='$username' LIMIT 1","users");
|
||||
if (mysql_num_rows($userquery) != 1) { die("No account with that username."); }
|
||||
$userrow = mysql_fetch_array($userquery);
|
||||
if ($userrow["verify"] == 1) { die("Your account is already verified."); }
|
||||
if ($userrow["email"] != $email) { die("Incorrect email address."); }
|
||||
if ($userrow["verify"] != $verify) { die("Incorrect verification code."); }
|
||||
// If we've made it this far, should be safe to update their account.
|
||||
$updatequery = doquery("UPDATE {{table}} SET verify='1' WHERE username='$username' LIMIT 1","users");
|
||||
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);
|
||||
}
|
||||
$page = gettemplate("verify");
|
||||
$topnav = "<a href=\"login.php?do=login\"><img src=\"images/button_login.gif\" alt=\"Log In\" border=\"0\" /></a><a href=\"users.php?do=register\"><img src=\"images/button_register.gif\" alt=\"Register\" border=\"0\" /></a><a href=\"help.php\"><img src=\"images/button_help.gif\" alt=\"Help\" border=\"0\" /></a>";
|
||||
display($page, "Verify Email", false, false, false);
|
||||
|
||||
$headers = "";
|
||||
$headers .= "From: $adminname<$adminemail>\n";
|
||||
$headers .= "X-Sender: <$adminemail>\n";
|
||||
$headers .= "Return-Path: $adminname<$adminemail>\n";
|
||||
$headers .= "X-Mailer: PHP\n";
|
||||
}
|
||||
|
||||
function lostpassword() {
|
||||
|
||||
if (isset($_POST["submit"])) {
|
||||
extract($_POST);
|
||||
$userquery = doquery("SELECT email FROM {{table}} WHERE email='$email' LIMIT 1","users");
|
||||
if (mysql_num_rows($userquery) != 1) { die("No account with that email address."); }
|
||||
$newpass = "";
|
||||
for ($i=0; $i<8; $i++) {
|
||||
$newpass .= chr(rand(65,90));
|
||||
}
|
||||
$md5newpass = md5($newpass);
|
||||
$updatequery = doquery("UPDATE {{table}} SET password='$md5newpass' WHERE email='$email' LIMIT 1","users");
|
||||
if (sendpassemail($email,$newpass) == true) {
|
||||
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);
|
||||
} 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);
|
||||
}
|
||||
die();
|
||||
}
|
||||
$page = gettemplate("lostpassword");
|
||||
$topnav = "<a href=\"login.php?do=login\"><img src=\"images/button_login.gif\" alt=\"Log In\" border=\"0\" /></a><a href=\"users.php?do=register\"><img src=\"images/button_register.gif\" alt=\"Register\" border=\"0\" /></a><a href=\"help.php\"><img src=\"images/button_help.gif\" alt=\"Help\" border=\"0\" /></a>";
|
||||
display($page, "Lost Password", false, false, false);
|
||||
|
||||
}
|
||||
|
||||
function changepassword() {
|
||||
|
||||
if (isset($_POST["submit"])) {
|
||||
extract($_POST);
|
||||
$userquery = doquery("SELECT * FROM {{table}} WHERE username='$username' LIMIT 1","users");
|
||||
if (mysql_num_rows($userquery) != 1) { die("No account with that username."); }
|
||||
$userrow = mysql_fetch_array($userquery);
|
||||
if ($userrow["password"] != md5($oldpass)) { die("The old password you provided was incorrect."); }
|
||||
if (preg_match("/[^A-z0-9_\-]/", $newpass1)==1) { die("New password must be alphanumeric."); } // Thanks to "Carlos Pires" from php.net!
|
||||
if ($newpass1 != $newpass2) { die("New passwords don't match."); }
|
||||
$realnewpass = md5($newpass1);
|
||||
$updatequery = doquery("UPDATE {{table}} SET password='$realnewpass' WHERE username='$username' LIMIT 1","users");
|
||||
if (isset($_COOKIE["dkgame"])) { setcookie("dkgame", "", time()-100000, "/", "", 0); }
|
||||
display("Your password was changed successfully.<br /><br />You have been logged out of the game to avoid cookie errors.<br /><br />Please <a href=\"login.php?do=login\">log back in</a> to continue playing.","Change Password",false,false,false);
|
||||
die();
|
||||
}
|
||||
$page = gettemplate("changepassword");
|
||||
$topnav = "<a href=\"login.php?do=login\"><img src=\"images/button_login.gif\" alt=\"Log In\" border=\"0\" /></a><a href=\"users.php?do=register\"><img src=\"images/button_register.gif\" alt=\"Register\" border=\"0\" /></a><a href=\"help.php\"><img src=\"images/button_help.gif\" alt=\"Help\" border=\"0\" /></a>";
|
||||
display($page, "Change Password", false, false, false);
|
||||
|
||||
}
|
||||
|
||||
function sendpassemail($emailaddress, $password) {
|
||||
|
||||
$controlquery = doquery("SELECT * FROM {{table}} WHERE id='1' LIMIT 1", "control");
|
||||
$controlrow = mysql_fetch_array($controlquery);
|
||||
extract($controlrow);
|
||||
|
||||
$email = <<<END
|
||||
You or someone using your email address recently signed up for an account on the $gamename server, located at $gameurl.
|
||||
You or someone using your email address submitted a Lost Password application on the $gamename server, located at $gameurl.
|
||||
|
||||
This email is sent to verify your registration email. Next time you log into the game, please visit the User Settings page and enter the following code into the Account Verification field:
|
||||
$vercode
|
||||
We have issued you a new password so you can log back into the game.
|
||||
|
||||
If you were not the person who signed up for the game, please disregard this message. You will not be emailed again.
|
||||
Your new password is: $password
|
||||
|
||||
Thanks for playing.
|
||||
END;
|
||||
|
||||
$status = mail($emailaddress, "$gamename Account Verification", $email, $headers);
|
||||
$status = mymail($emailaddress, "$gamename Lost Password", $email);
|
||||
return $status;
|
||||
|
||||
}
|
||||
|
||||
function sendregmail($emailaddress, $vercode) {
|
||||
|
||||
$controlquery = doquery("SELECT * FROM {{table}} WHERE id='1' LIMIT 1", "control");
|
||||
$controlrow = mysql_fetch_array($controlquery);
|
||||
extract($controlrow);
|
||||
$verurl = $gameurl . "?do=verify";
|
||||
|
||||
$email = <<<END
|
||||
You or someone using your email address recently signed up for an account on the $gamename server, located at $gameurl.
|
||||
|
||||
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.
|
||||
END;
|
||||
|
||||
$status = mymail($emailaddress, "$gamename Account Verification", $email);
|
||||
return $status;
|
||||
|
||||
}
|
||||
|
||||
function mymail($to, $title, $body, $from = '') { // thanks to arto dot PLEASE dot DO dot NOT dot SPAM at artoaaltonen dot fi.
|
||||
|
||||
$controlquery = doquery("SELECT * FROM {{table}} WHERE id='1' LIMIT 1", "control");
|
||||
$controlrow = mysql_fetch_array($controlquery);
|
||||
extract($controlrow);
|
||||
|
||||
$from = trim($from);
|
||||
|
||||
if (!$from) {
|
||||
$from = 'Dragon Knight <$adminemail>';
|
||||
}
|
||||
|
||||
$rp = '$adminemail';
|
||||
$org = '$gameurl';
|
||||
$mailer = 'PHP';
|
||||
|
||||
$head = '';
|
||||
$head .= "Content-Type: text/plain \r\n";
|
||||
$head .= "Date: ". date('r'). " \r\n";
|
||||
$head .= "Return-Path: $rp \r\n";
|
||||
$head .= "From: $from \r\n";
|
||||
$head .= "Sender: $from \r\n";
|
||||
$head .= "Reply-To: $from \r\n";
|
||||
$head .= "Organization: $org \r\n";
|
||||
$head .= "X-Sender: $from \r\n";
|
||||
$head .= "X-Priority: 3 \r\n";
|
||||
$head .= "X-Mailer: $mailer \r\n";
|
||||
|
||||
$body = str_replace("\r\n", "\n", $body);
|
||||
$body = str_replace("\n", "\r\n", $body);
|
||||
|
||||
return mail($to, $title, $body, $head);
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
Loading…
Reference in New Issue
Block a user