From edb4504a5c8c3a8c46a3d7848a398361424a1c7b Mon Sep 17 00:00:00 2001 From: Sky Johnson Date: Thu, 8 Aug 2024 13:13:06 -0500 Subject: [PATCH] bug fixes --- globals.php | 6 +-- lib.php | 2 +- panels.php | 134 +++++++++++++++++++++++++++------------------------- users.php | 5 +- 4 files changed, 77 insertions(+), 70 deletions(-) diff --git a/globals.php b/globals.php index 5f14663..e962dcb 100644 --- a/globals.php +++ b/globals.php @@ -37,10 +37,10 @@ $userrow = dorow(doquery("SELECT * FROM <> WHERE id='".$acctrow["activech if ($userrow != false) { $userrow = array_map("stripslashes", $userrow); } // World row. -$worldrow = dorow(doquery("SELECT * FROM <> WHERE id='".$userrow["world"]."' LIMIT 1")); +$worldrow = dorow(doquery("SELECT * FROM <> WHERE id='".($userrow["world"] ?? 1)."' LIMIT 1")); // Town row. -if ($userrow["currentaction"] == "In Town") { +if (isset($userrow["currentaction"]) && $userrow["currentaction"] == "In Town") { $townrow = dorow(doquery("SELECT * FROM <> WHERE world='".$userrow["world"]."' AND longitude='".$userrow["longitude"]."' AND latitude='".$userrow["latitude"]."' LIMIT 1")); } else { $townrow = false; @@ -62,4 +62,4 @@ $fightrow = array( "track"=>"", "message"=>""); -?> \ No newline at end of file +?> diff --git a/lib.php b/lib.php index dee10f0..509f215 100644 --- a/lib.php +++ b/lib.php @@ -216,7 +216,7 @@ function display($title, $content, $panels = true) { // Finalize page and output $row = array(); $row["gamename"] = $controlrow["gamename"]; $row["pagetitle"] = $title; - $row["background"] = "background" . $userrow["world"]; + $row["background"] = (isset($userrow['world'])) ? "background" . $userrow["world"] : "background"; $row["version"] = $version; $row["content"] = $content; $row["moddedby"] = $controlrow["moddedby"]; diff --git a/panels.php b/panels.php index 338ed54..8898c91 100644 --- a/panels.php +++ b/panels.php @@ -15,42 +15,42 @@ // (see our website for that). function panelleft() { - + global $controlrow, $userrow, $acctrow, $townrow, $worldrow; $row = array(); - + // Action handling. - if ($userrow["currentaction"] == "In Town") { + if ($userrow["currentaction"] == "In Town") { $row["action"] = "In Town:"; $row["townname"] = $townrow["name"]; - } else { - $row["action"] = $userrow["currentaction"]; + } else { + $row["action"] = $userrow["currentaction"]; $row["townname"] = ""; } - + // World handling. $row["worldname"] = $worldrow["name"]; - + // Location handling. - if ($userrow["latitude"] < 0) { - $row["latitude"] = ($userrow["latitude"] * -1) . "S"; - } else { + if ($userrow["latitude"] < 0) { + $row["latitude"] = ($userrow["latitude"] * -1) . "S"; + } else { $row["latitude"] = $userrow["latitude"] . "N"; } - - if ($userrow["longitude"] < 0) { - $row["longitude"] = ($userrow["longitude"] * -1) . "W"; - } else { + + if ($userrow["longitude"] < 0) { + $row["longitude"] = ($userrow["longitude"] * -1) . "W"; + } else { $row["longitude"] = $userrow["longitude"] . "E"; } - + // Minimap option. - if ($acctrow["minimap"] == 0) { - + if ($acctrow["minimap"] == 0) { + $row["minimap"] = "View Map

"; - + } else { - + $row["minimap"] = << @@ -59,12 +59,12 @@ $row["minimap"] = << THEVERYENDOFYOU; - + } - + // Travel To handling. $row["travelto"] = ""; - + // First we build the query string. $townstring = "("; $townslist = explode(",",$userrow["townslist"]); @@ -73,32 +73,32 @@ THEVERYENDOFYOU; } $townstring = rtrim($townstring, " OR "); $townstring .= ") AND world='".$userrow["world"]."'"; - + // Then we do the query. $traveltoquery = dorow(doquery("SELECT id,name FROM <> WHERE $townstring ORDER BY id"), "id"); - + // Finally we build the link list. foreach ($traveltoquery as $a => $b) { $row["travelto"] .= "".$b["name"]."
\n"; } - + // And then we're done with this panel. return parsetemplate(gettemplate("panels_left"), $row); - + } function panelright() { - + global $controlrow; $row["babblebox"] = ""; $row["whosonline"] = ""; - + // Babblebox. if ($controlrow["showshout"] == 1) { $row["babblebox"] = "
Babblebox
"; $row["babblebox"] .= "

"; } - + // Who's Online. if ($controlrow["showonline"] == 1) { $row["whosonline"] = "
Who's Online
"; @@ -106,61 +106,65 @@ function panelright() { $number = count($users); $row["whosonline"] .= "There are $number user(s) online within the last 10 minutes: "; foreach ($users as $a => $b) { - if ($b["guild"] != 0) { + if ($b["guild"] != 0) { $charname = "[".$b["guildtag"]."]".$b["charname"].""; - } else { + } else { $charname = $b["charname"]; } $row["whosonline"] .= "$charname, "; } $row["whosonline"] = rtrim($row["whosonline"], ", "); } - + // And then we're done with this panel. return parsetemplate(gettemplate("panels_right"), $row); - + } function paneltop($loggedin = true) { - + global $acctrow, $userrow; 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 = " (Admin)"; } else { $admin = ""; } $admin = ""; - if ($userrow["guild"] != 0) { + if ($userrow["guild"] != 0) { $charname = "[".$userrow["guildtag"]."]".$userrow["charname"].""; - } else { + } else { $charname = $userrow["charname"]; } $top = "
\n
$charname$admin
\n"; $top .= "[ Log Out | Account | Characters | Help ]\n"; $top .= "
\n"; - + } else { - + $top = "
\n
Not Logged In
\n"; $top .= "[ Log In | Register | Help ]\n"; $top .= "
\n"; - + } - + return $top; - + } function panelbottom() { - + global $userrow, $spells; $row = array(); - + if ($userrow["charpicture"] != "") { $row["charpicture"] = $userrow["charpicture"]; } else { $row["charpicture"] = "images/users/nopicture.gif"; } - + // Do quickspell stuff. $quickhealid = 0; $quickhealvalue = 0; @@ -168,20 +172,20 @@ function panelbottom() { for ($i=1; $i<11; $i++) { if ($userrow["spell".$i."id"] != 0) { if ($spells[$userrow["spell".$i."id"]]["fname"] == "heal") { - if ($spells[$userrow["spell".$i."id"]]["value"] > $quickhealvalue) { - $quickhealvalue = $spells[$userrow["spell".$i."id"]]["value"]; - $quickhealid = $spells[$userrow["spell".$i."id"]]["id"]; + if ($spells[$userrow["spell".$i."id"]]["value"] > $quickhealvalue) { + $quickhealvalue = $spells[$userrow["spell".$i."id"]]["value"]; + $quickhealid = $spells[$userrow["spell".$i."id"]]["id"]; } } } } } - if ($quickhealid != 0) { + if ($quickhealid != 0) { $row["quickheal"] = "(Heal)"; } else { $row["quickheal"] = ""; } - + // Do the rest of it. $row["level"] = $userrow["level"]; if ($userrow["levelup"] > 0) { $row["levelup"] = "(".$userrow["levelup"]." LP)"; } else { $row["levelup"] = ""; } @@ -195,26 +199,26 @@ function panelbottom() { $row["hpbar"] = statusbars("hp", $userrow["currenthp"], $userrow["maxhp"]); $row["mpbar"] = statusbars("mp", $userrow["currentmp"], $userrow["maxmp"]); $row["tpbar"] = statusbars("tp", $userrow["currenttp"], $userrow["maxtp"]); - - + + return parsetemplate(gettemplate("panels_bottom"),$row); - + } function panelmiddle() { - + global $userrow, $townrow, $worldrow; - - - + + + return gettemplate("panels_middle"); - + } function statusbars($stat, $current, $max) { - + $row = array(); - switch ($stat) { + switch ($stat) { case "hp": $row["bigname"] = "Hit Points"; $row["littlename"] = "HP"; @@ -232,16 +236,16 @@ function statusbars($stat, $current, $max) { $row["littlename"] = "Exp"; break; } - + $row["width"] = ceil(($current / $max) * 100); if ($row["width"] >= 66) { $row["color"] = "green"; } if ($row["width"] < 66 && $row["width"] >= 33) { $row["color"] = "yellow"; } if ($row["width"] < 33) { $row["color"] = "red"; } - + $row["current"] = $current; $row["max"] = $max; return parsetemplate(gettemplate("statusbars"),$row); - + } -?> \ No newline at end of file +?> diff --git a/users.php b/users.php index 627b215..2a8567d 100644 --- a/users.php +++ b/users.php @@ -358,6 +358,7 @@ function charnew() { $characternamequery = doquery("SELECT charname FROM <> WHERE charname='$charname' LIMIT 1"); if (mysql_num_rows($characternamequery) > 0) { $errors++; $errorlist .= "Character Name already taken - unique Character Name required.
"; } + // Upload new charpicture, if required. 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."); } $newcharpicture = $controlrow["avatarurl"] . $acctrow["username"] . $randomext . $type; - } + } else { + $newcharpicture = $controlrow["avatarurl"] . "nopicture.gif"; + } // Process everything else important. if (!is_numeric($charclass)) { $errors++; $errorlist .= "Invalid character class.
"; }