bug fixes

This commit is contained in:
Sky Johnson 2024-08-08 13:13:06 -05:00
parent 6f782914ca
commit edb4504a5c
4 changed files with 77 additions and 70 deletions

View File

@ -37,10 +37,10 @@ $userrow = dorow(doquery("SELECT * FROM <<users>> WHERE id='".$acctrow["activech
if ($userrow != false) { $userrow = array_map("stripslashes", $userrow); } if ($userrow != false) { $userrow = array_map("stripslashes", $userrow); }
// World row. // World row.
$worldrow = dorow(doquery("SELECT * FROM <<worlds>> WHERE id='".$userrow["world"]."' LIMIT 1")); $worldrow = dorow(doquery("SELECT * FROM <<worlds>> WHERE id='".($userrow["world"] ?? 1)."' LIMIT 1"));
// Town row. // Town row.
if ($userrow["currentaction"] == "In Town") { if (isset($userrow["currentaction"]) && $userrow["currentaction"] == "In Town") {
$townrow = dorow(doquery("SELECT * FROM <<towns>> WHERE world='".$userrow["world"]."' AND longitude='".$userrow["longitude"]."' AND latitude='".$userrow["latitude"]."' LIMIT 1")); $townrow = dorow(doquery("SELECT * FROM <<towns>> WHERE world='".$userrow["world"]."' AND longitude='".$userrow["longitude"]."' AND latitude='".$userrow["latitude"]."' LIMIT 1"));
} else { } else {
$townrow = false; $townrow = false;
@ -62,4 +62,4 @@ $fightrow = array(
"track"=>"", "track"=>"",
"message"=>""); "message"=>"");
?> ?>

View File

@ -216,7 +216,7 @@ function display($title, $content, $panels = true) { // Finalize page and output
$row = array(); $row = array();
$row["gamename"] = $controlrow["gamename"]; $row["gamename"] = $controlrow["gamename"];
$row["pagetitle"] = $title; $row["pagetitle"] = $title;
$row["background"] = "background" . $userrow["world"]; $row["background"] = (isset($userrow['world'])) ? "background" . $userrow["world"] : "background";
$row["version"] = $version; $row["version"] = $version;
$row["content"] = $content; $row["content"] = $content;
$row["moddedby"] = $controlrow["moddedby"]; $row["moddedby"] = $controlrow["moddedby"];

View File

@ -15,42 +15,42 @@
// (see our website for that). // (see our website for that).
function panelleft() { function panelleft() {
global $controlrow, $userrow, $acctrow, $townrow, $worldrow; global $controlrow, $userrow, $acctrow, $townrow, $worldrow;
$row = array(); $row = array();
// Action handling. // Action handling.
if ($userrow["currentaction"] == "In Town") { if ($userrow["currentaction"] == "In Town") {
$row["action"] = "In Town:"; $row["action"] = "In Town:";
$row["townname"] = $townrow["name"]; $row["townname"] = $townrow["name"];
} else { } else {
$row["action"] = $userrow["currentaction"]; $row["action"] = $userrow["currentaction"];
$row["townname"] = ""; $row["townname"] = "";
} }
// World handling. // World handling.
$row["worldname"] = $worldrow["name"]; $row["worldname"] = $worldrow["name"];
// Location handling. // Location handling.
if ($userrow["latitude"] < 0) { if ($userrow["latitude"] < 0) {
$row["latitude"] = ($userrow["latitude"] * -1) . "S"; $row["latitude"] = ($userrow["latitude"] * -1) . "S";
} else { } else {
$row["latitude"] = $userrow["latitude"] . "N"; $row["latitude"] = $userrow["latitude"] . "N";
} }
if ($userrow["longitude"] < 0) { if ($userrow["longitude"] < 0) {
$row["longitude"] = ($userrow["longitude"] * -1) . "W"; $row["longitude"] = ($userrow["longitude"] * -1) . "W";
} else { } else {
$row["longitude"] = $userrow["longitude"] . "E"; $row["longitude"] = $userrow["longitude"] . "E";
} }
// Minimap option. // Minimap option.
if ($acctrow["minimap"] == 0) { if ($acctrow["minimap"] == 0) {
$row["minimap"] = "<a href=\"javascript:void(0)\" onClick=\"Javascript:window.open('index.php?do=showmap','','width=550,height=550,toolbar=no, location=no,directories=no,status=yes,menubar=no,scrollbars=no,copyhistory=yes, resizable=yes');\">View Map</a><br /><br />"; $row["minimap"] = "<a href=\"javascript:void(0)\" onClick=\"Javascript:window.open('index.php?do=showmap','','width=550,height=550,toolbar=no, location=no,directories=no,status=yes,menubar=no,scrollbars=no,copyhistory=yes, resizable=yes');\">View Map</a><br /><br />";
} else { } else {
$row["minimap"] = <<<THEVERYENDOFYOU $row["minimap"] = <<<THEVERYENDOFYOU
<div style="border: solid 1px black; width: 106px; height: 106px; padding: 0px; margin: 0px 0px 5px 0px;"> <div style="border: solid 1px black; width: 106px; height: 106px; padding: 0px; margin: 0px 0px 5px 0px;">
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="106" height="106" id="mapmini" align="middle"> <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="106" height="106" id="mapmini" align="middle">
@ -59,12 +59,12 @@ $row["minimap"] = <<<THEVERYENDOFYOU
</object> </object>
</div> </div>
THEVERYENDOFYOU; THEVERYENDOFYOU;
} }
// Travel To handling. // Travel To handling.
$row["travelto"] = ""; $row["travelto"] = "";
// First we build the query string. // First we build the query string.
$townstring = "("; $townstring = "(";
$townslist = explode(",",$userrow["townslist"]); $townslist = explode(",",$userrow["townslist"]);
@ -73,32 +73,32 @@ THEVERYENDOFYOU;
} }
$townstring = rtrim($townstring, " OR "); $townstring = rtrim($townstring, " OR ");
$townstring .= ") AND world='".$userrow["world"]."'"; $townstring .= ") AND world='".$userrow["world"]."'";
// Then we do the query. // Then we do the query.
$traveltoquery = dorow(doquery("SELECT id,name FROM <<towns>> WHERE $townstring ORDER BY id"), "id"); $traveltoquery = dorow(doquery("SELECT id,name FROM <<towns>> WHERE $townstring ORDER BY id"), "id");
// Finally we build the link list. // Finally we build the link list.
foreach ($traveltoquery as $a => $b) { foreach ($traveltoquery as $a => $b) {
$row["travelto"] .= "<a href=\"index.php?do=travel:".$b["id"]."\">".$b["name"]."</a><br />\n"; $row["travelto"] .= "<a href=\"index.php?do=travel:".$b["id"]."\">".$b["name"]."</a><br />\n";
} }
// And then we're done with this panel. // And then we're done with this panel.
return parsetemplate(gettemplate("panels_left"), $row); return parsetemplate(gettemplate("panels_left"), $row);
} }
function panelright() { function panelright() {
global $controlrow; global $controlrow;
$row["babblebox"] = ""; $row["babblebox"] = "";
$row["whosonline"] = ""; $row["whosonline"] = "";
// Babblebox. // Babblebox.
if ($controlrow["showshout"] == 1) { if ($controlrow["showshout"] == 1) {
$row["babblebox"] = "<div class=\"big\"><b>Babblebox</b></div>"; $row["babblebox"] = "<div class=\"big\"><b>Babblebox</b></div>";
$row["babblebox"] .= "<iframe src=\"index.php?do=babblebox\" name=\"sbox\" width=\"100%\" height=\"200\" 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><br /><br />"; $row["babblebox"] .= "<iframe src=\"index.php?do=babblebox\" name=\"sbox\" width=\"100%\" height=\"200\" 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><br /><br />";
} }
// Who's Online. // Who's Online.
if ($controlrow["showonline"] == 1) { if ($controlrow["showonline"] == 1) {
$row["whosonline"] = "<div class=\"big\"><b>Who's Online</b></div>"; $row["whosonline"] = "<div class=\"big\"><b>Who's Online</b></div>";
@ -106,61 +106,65 @@ function panelright() {
$number = count($users); $number = count($users);
$row["whosonline"] .= "There are <b>$number</b> user(s) online within the last 10 minutes: "; $row["whosonline"] .= "There are <b>$number</b> user(s) online within the last 10 minutes: ";
foreach ($users as $a => $b) { foreach ($users as $a => $b) {
if ($b["guild"] != 0) { if ($b["guild"] != 0) {
$charname = "[<span style=\"color: ".$b["tagcolor"].";\">".$b["guildtag"]."</span>]<span style=\"color: ".$b["namecolor"].";\">".$b["charname"]."</span>"; $charname = "[<span style=\"color: ".$b["tagcolor"].";\">".$b["guildtag"]."</span>]<span style=\"color: ".$b["namecolor"].";\">".$b["charname"]."</span>";
} else { } else {
$charname = $b["charname"]; $charname = $b["charname"];
} }
$row["whosonline"] .= "<a href=\"users.php?do=profile&uid=".$b["id"]."\">$charname</a>, "; $row["whosonline"] .= "<a href=\"users.php?do=profile&uid=".$b["id"]."\">$charname</a>, ";
} }
$row["whosonline"] = rtrim($row["whosonline"], ", "); $row["whosonline"] = rtrim($row["whosonline"], ", ");
} }
// And then we're done with this panel. // And then we're done with this panel.
return parsetemplate(gettemplate("panels_right"), $row); return parsetemplate(gettemplate("panels_right"), $row);
} }
function paneltop($loggedin = true) { function paneltop($loggedin = true) {
global $acctrow, $userrow; global $acctrow, $userrow;
if ($loggedin == true || isset($acctrow)) { if ($loggedin == true || isset($acctrow)) {
if ($userrow == false) { $userrow["charname"] = "No Characters Yet"; $userrow["guild"] = 0; } if (empty($userrow) || !isset($userrow) || $userrow === false) {
$userrow = [];
$userrow["charname"] = "No Characters Yet";
$userrow["guild"] = 0;
}
//if ($acctrow["authlevel"] == 255) { $admin = " (<a href=\"admin/index.php\">Admin</a>)"; } else { $admin = ""; } //if ($acctrow["authlevel"] == 255) { $admin = " (<a href=\"admin/index.php\">Admin</a>)"; } else { $admin = ""; }
$admin = ""; $admin = "";
if ($userrow["guild"] != 0) { if ($userrow["guild"] != 0) {
$charname = "[<span style=\"color: ".$userrow["tagcolor"].";\">".$userrow["guildtag"]."</span>]<span style=\"color: ".$userrow["namecolor"].";\">".$userrow["charname"]."</span>"; $charname = "[<span style=\"color: ".$userrow["tagcolor"].";\">".$userrow["guildtag"]."</span>]<span style=\"color: ".$userrow["namecolor"].";\">".$userrow["charname"]."</span>";
} else { } else {
$charname = $userrow["charname"]; $charname = $userrow["charname"];
} }
$top = "<div class=\"big\">\n<center><b>$charname</b>$admin<br />\n"; $top = "<div class=\"big\">\n<center><b>$charname</b>$admin<br />\n";
$top .= "[ <a href=\"login.php?do=logout\">Log Out</a> | <a href=\"users.php?do=settings\">Account</a> | <a href=\"users.php?do=characters\">Characters</a> | <a href=\"help.php\">Help</a> ]\n"; $top .= "[ <a href=\"login.php?do=logout\">Log Out</a> | <a href=\"users.php?do=settings\">Account</a> | <a href=\"users.php?do=characters\">Characters</a> | <a href=\"help.php\">Help</a> ]\n";
$top .= "</center></div>\n"; $top .= "</center></div>\n";
} else { } else {
$top = "<div class=\"big\">\n<center><b>Not Logged In</b><br />\n"; $top = "<div class=\"big\">\n<center><b>Not Logged In</b><br />\n";
$top .= "[ <a href=\"login.php?do=login\">Log In</a> | <a href=\"users.php?do=register\">Register</a> | <a href=\"help.php\">Help</a> ]\n"; $top .= "[ <a href=\"login.php?do=login\">Log In</a> | <a href=\"users.php?do=register\">Register</a> | <a href=\"help.php\">Help</a> ]\n";
$top .= "</center></div>\n"; $top .= "</center></div>\n";
} }
return $top; return $top;
} }
function panelbottom() { function panelbottom() {
global $userrow, $spells; global $userrow, $spells;
$row = array(); $row = array();
if ($userrow["charpicture"] != "") { if ($userrow["charpicture"] != "") {
$row["charpicture"] = $userrow["charpicture"]; $row["charpicture"] = $userrow["charpicture"];
} else { } else {
$row["charpicture"] = "images/users/nopicture.gif"; $row["charpicture"] = "images/users/nopicture.gif";
} }
// Do quickspell stuff. // Do quickspell stuff.
$quickhealid = 0; $quickhealid = 0;
$quickhealvalue = 0; $quickhealvalue = 0;
@ -168,20 +172,20 @@ function panelbottom() {
for ($i=1; $i<11; $i++) { for ($i=1; $i<11; $i++) {
if ($userrow["spell".$i."id"] != 0) { if ($userrow["spell".$i."id"] != 0) {
if ($spells[$userrow["spell".$i."id"]]["fname"] == "heal") { if ($spells[$userrow["spell".$i."id"]]["fname"] == "heal") {
if ($spells[$userrow["spell".$i."id"]]["value"] > $quickhealvalue) { if ($spells[$userrow["spell".$i."id"]]["value"] > $quickhealvalue) {
$quickhealvalue = $spells[$userrow["spell".$i."id"]]["value"]; $quickhealvalue = $spells[$userrow["spell".$i."id"]]["value"];
$quickhealid = $spells[$userrow["spell".$i."id"]]["id"]; $quickhealid = $spells[$userrow["spell".$i."id"]]["id"];
} }
} }
} }
} }
} }
if ($quickhealid != 0) { if ($quickhealid != 0) {
$row["quickheal"] = "<a href=\"index.php?do=quickheal&id=$quickhealid\" class=\"red\">(Heal)</a>"; $row["quickheal"] = "<a href=\"index.php?do=quickheal&id=$quickhealid\" class=\"red\">(Heal)</a>";
} else { } else {
$row["quickheal"] = ""; $row["quickheal"] = "";
} }
// Do the rest of it. // Do the rest of it.
$row["level"] = $userrow["level"]; $row["level"] = $userrow["level"];
if ($userrow["levelup"] > 0) { $row["levelup"] = "<a href=\"users.php?do=levelup\" class=\"red\">(".$userrow["levelup"]." LP)</a>"; } else { $row["levelup"] = ""; } if ($userrow["levelup"] > 0) { $row["levelup"] = "<a href=\"users.php?do=levelup\" class=\"red\">(".$userrow["levelup"]." LP)</a>"; } else { $row["levelup"] = ""; }
@ -195,26 +199,26 @@ function panelbottom() {
$row["hpbar"] = statusbars("hp", $userrow["currenthp"], $userrow["maxhp"]); $row["hpbar"] = statusbars("hp", $userrow["currenthp"], $userrow["maxhp"]);
$row["mpbar"] = statusbars("mp", $userrow["currentmp"], $userrow["maxmp"]); $row["mpbar"] = statusbars("mp", $userrow["currentmp"], $userrow["maxmp"]);
$row["tpbar"] = statusbars("tp", $userrow["currenttp"], $userrow["maxtp"]); $row["tpbar"] = statusbars("tp", $userrow["currenttp"], $userrow["maxtp"]);
return parsetemplate(gettemplate("panels_bottom"),$row); return parsetemplate(gettemplate("panels_bottom"),$row);
} }
function panelmiddle() { function panelmiddle() {
global $userrow, $townrow, $worldrow; global $userrow, $townrow, $worldrow;
return gettemplate("panels_middle"); return gettemplate("panels_middle");
} }
function statusbars($stat, $current, $max) { function statusbars($stat, $current, $max) {
$row = array(); $row = array();
switch ($stat) { switch ($stat) {
case "hp": case "hp":
$row["bigname"] = "Hit Points"; $row["bigname"] = "Hit Points";
$row["littlename"] = "HP"; $row["littlename"] = "HP";
@ -232,16 +236,16 @@ function statusbars($stat, $current, $max) {
$row["littlename"] = "Exp"; $row["littlename"] = "Exp";
break; break;
} }
$row["width"] = ceil(($current / $max) * 100); $row["width"] = ceil(($current / $max) * 100);
if ($row["width"] >= 66) { $row["color"] = "green"; } if ($row["width"] >= 66) { $row["color"] = "green"; }
if ($row["width"] < 66 && $row["width"] >= 33) { $row["color"] = "yellow"; } if ($row["width"] < 66 && $row["width"] >= 33) { $row["color"] = "yellow"; }
if ($row["width"] < 33) { $row["color"] = "red"; } if ($row["width"] < 33) { $row["color"] = "red"; }
$row["current"] = $current; $row["current"] = $current;
$row["max"] = $max; $row["max"] = $max;
return parsetemplate(gettemplate("statusbars"),$row); return parsetemplate(gettemplate("statusbars"),$row);
} }
?> ?>

View File

@ -358,6 +358,7 @@ function charnew() {
$characternamequery = doquery("SELECT charname FROM <<users>> WHERE charname='$charname' LIMIT 1"); $characternamequery = doquery("SELECT charname FROM <<users>> WHERE charname='$charname' LIMIT 1");
if (mysql_num_rows($characternamequery) > 0) { $errors++; $errorlist .= "Character Name already taken - unique Character Name required.<br />"; } if (mysql_num_rows($characternamequery) > 0) { $errors++; $errorlist .= "Character Name already taken - unique Character Name required.<br />"; }
// Upload new charpicture, if required. // Upload new charpicture, if required.
if ($_FILES["intavatar"]["error"] != 4) { if ($_FILES["intavatar"]["error"] != 4) {
@ -377,7 +378,9 @@ function charnew() {
if (!move_uploaded_file($_FILES["intavatar"]["tmp_name"], $uploadfile)) { die("Unable to upload avatar."); } if (!move_uploaded_file($_FILES["intavatar"]["tmp_name"], $uploadfile)) { die("Unable to upload avatar."); }
$newcharpicture = $controlrow["avatarurl"] . $acctrow["username"] . $randomext . $type; $newcharpicture = $controlrow["avatarurl"] . $acctrow["username"] . $randomext . $type;
} } else {
$newcharpicture = $controlrow["avatarurl"] . "nopicture.gif";
}
// Process everything else important. // Process everything else important.
if (!is_numeric($charclass)) { $errors++; $errorlist .= "Invalid character class.<br />"; } if (!is_numeric($charclass)) { $errors++; $errorlist .= "Invalid character class.<br />"; }