diff --git a/game/misc.php b/game/misc.php
new file mode 100644
index 0000000..3dd079e
--- /dev/null
+++ b/game/misc.php
@@ -0,0 +1,230 @@
+
Latest News |
\n";
+ $townrow["news"] .= "[".prettydate($newsrow["postdate"])."] ".nl2br($newsrow["content"]);
+ $townrow["news"] .= " |
\n";
+ } else { $townrow["news"] = ""; }
+
+ // Who's Online. Currently just members. Guests maybe later.
+ if ($controlrow["showonline"] == 1) {
+ $onlinequery = doquery("SELECT * FROM {{table}} WHERE UNIX_TIMESTAMP(onlinetime) >= '".(time()-600)."' ORDER BY charname", "users");
+ $townrow["whosonline"] = "Who's Online |
\n";
+ $townrow["whosonline"] .= "There are " . mysqli_num_rows($onlinequery) . " user(s) online within the last 10 minutes: ";
+ while ($onlinerow = mysqli_fetch_array($onlinequery)) { $townrow["whosonline"] .= "".$onlinerow["charname"]."" . ", "; }
+ $townrow["whosonline"] = rtrim($townrow["whosonline"], ", ");
+ $townrow["whosonline"] .= " |
\n";
+ } else { $townrow["whosonline"] = ""; }
+
+ if ($controlrow["showbabble"] == 1) {
+ $townrow["babblebox"] = "Babble Box |
\n";
+ $townrow["babblebox"] .= "";
+ $townrow["babblebox"] .= " |
\n";
+ } else { $townrow["babblebox"] = ""; }
+
+ $page = gettemplate("towns");
+ $page = parsetemplate($page, $townrow);
+
+ return $page;
+
+}
+
+function doexplore() { // Just spit out a blank exploring page.
+
+ // Exploring without a GET string is normally when they first log in, or when they've just finished fighting.
+
+$page = <<
+ |
+
+You are exploring the map, and nothing has happened. Continue exploring using the direction buttons or the Travel To menus.
+ |
+
+END;
+
+ return $page;
+
+}
+
+function dofight() { // Redirect to fighting.
+
+ header("Location: index.php?do=fight");
+
+}
+
+function showchar() {
+
+ global $userrow, $controlrow;
+
+ // Format various userrow stuffs.
+ $userrow["experience"] = number_format($userrow["experience"]);
+ $userrow["gold"] = number_format($userrow["gold"]);
+ if ($userrow["expbonus"] > 0) {
+ $userrow["plusexp"] = "(+".$userrow["expbonus"]."%)";
+ } elseif ($userrow["expbonus"] < 0) {
+ $userrow["plusexp"] = "(".$userrow["expbonus"]."%)";
+ } else { $userrow["plusexp"] = ""; }
+ if ($userrow["goldbonus"] > 0) {
+ $userrow["plusgold"] = "(+".$userrow["goldbonus"]."%)";
+ } elseif ($userrow["goldbonus"] < 0) {
+ $userrow["plusgold"] = "(".$userrow["goldbonus"]."%)";
+ } else { $userrow["plusgold"] = ""; }
+
+ $levelquery = doquery("SELECT ". $userrow["charclass"]."_exp FROM {{table}} WHERE id='".($userrow["level"]+1)."' LIMIT 1", "levels");
+ $levelrow = mysqli_fetch_array($levelquery);
+ if ($userrow["level"] < 99) { $userrow["nextlevel"] = number_format($levelrow[$userrow["charclass"]."_exp"]); } else { $userrow["nextlevel"] = "None"; }
+
+ if ($userrow["charclass"] == 1) { $userrow["charclass"] = $controlrow["class1name"]; }
+ elseif ($userrow["charclass"] == 2) { $userrow["charclass"] = $controlrow["class2name"]; }
+ elseif ($userrow["charclass"] == 3) { $userrow["charclass"] = $controlrow["class3name"]; }
+
+ if ($userrow["difficulty"] == 1) { $userrow["difficulty"] = $controlrow["diff1name"]; }
+ elseif ($userrow["difficulty"] == 2) { $userrow["difficulty"] = $controlrow["diff2name"]; }
+ elseif ($userrow["difficulty"] == 3) { $userrow["difficulty"] = $controlrow["diff3name"]; }
+
+ $spellquery = doquery("SELECT id,name FROM {{table}}","spells");
+ $userspells = explode(",",$userrow["spells"]);
+ $userrow["magiclist"] = "";
+ while ($spellrow = mysqli_fetch_array($spellquery)) {
+ $spell = false;
+ foreach($userspells as $a => $b) {
+ if ($b == $spellrow["id"]) { $spell = true; }
+ }
+ if ($spell == true) {
+ $userrow["magiclist"] .= $spellrow["name"]."
";
+ }
+ }
+ if ($userrow["magiclist"] == "") { $userrow["magiclist"] = "None"; }
+
+ // Make page tags for XHTML validation.
+ $xml = "\n"
+ . "\n"
+ . "\n";
+
+ $charsheet = gettemplate("showchar");
+ $page = $xml . gettemplate("minimal");
+ $array = array("content"=>parsetemplate($charsheet, $userrow), "title"=>"Character Information");
+ echo parsetemplate($page, $array);
+ die();
+
+}
+
+function onlinechar($id) {
+
+ global $controlrow;
+ $userquery = doquery("SELECT * FROM {{table}} WHERE id='$id' LIMIT 1", "users");
+ if (mysqli_num_rows($userquery) == 1) { $userrow = mysqli_fetch_array($userquery); } else { display("No such user.", "Error"); }
+
+ // Format various userrow stuffs.
+ $userrow["experience"] = number_format($userrow["experience"]);
+ $userrow["gold"] = number_format($userrow["gold"]);
+ if ($userrow["expbonus"] > 0) {
+ $userrow["plusexp"] = "(+".$userrow["expbonus"]."%)";
+ } elseif ($userrow["expbonus"] < 0) {
+ $userrow["plusexp"] = "(".$userrow["expbonus"]."%)";
+ } else { $userrow["plusexp"] = ""; }
+ if ($userrow["goldbonus"] > 0) {
+ $userrow["plusgold"] = "(+".$userrow["goldbonus"]."%)";
+ } elseif ($userrow["goldbonus"] < 0) {
+ $userrow["plusgold"] = "(".$userrow["goldbonus"]."%)";
+ } else { $userrow["plusgold"] = ""; }
+
+ $levelquery = doquery("SELECT ". $userrow["charclass"]."_exp FROM {{table}} WHERE id='".($userrow["level"]+1)."' LIMIT 1", "levels");
+ $levelrow = mysqli_fetch_array($levelquery);
+ $userrow["nextlevel"] = number_format($levelrow[$userrow["charclass"]."_exp"]);
+
+ if ($userrow["charclass"] == 1) { $userrow["charclass"] = $controlrow["class1name"]; }
+ elseif ($userrow["charclass"] == 2) { $userrow["charclass"] = $controlrow["class2name"]; }
+ elseif ($userrow["charclass"] == 3) { $userrow["charclass"] = $controlrow["class3name"]; }
+
+ if ($userrow["difficulty"] == 1) { $userrow["difficulty"] = $controlrow["diff1name"]; }
+ elseif ($userrow["difficulty"] == 2) { $userrow["difficulty"] = $controlrow["diff2name"]; }
+ elseif ($userrow["difficulty"] == 3) { $userrow["difficulty"] = $controlrow["diff3name"]; }
+
+ $charsheet = gettemplate("onlinechar");
+ $page = parsetemplate($charsheet, $userrow);
+ display($page, "Character Information");
+
+}
+
+function showmap() {
+
+ global $userrow;
+
+ // Make page tags for XHTML validation.
+ $xml = "\n"
+ . "\n"
+ . "\n";
+
+ $page = $xml . gettemplate("minimal");
+ $array = array("content"=>"
", "title"=>"Map");
+ echo parsetemplate($page, $array);
+ die();
+
+}
+
+function babblebox() {
+
+ global $userrow;
+
+ if (isset($_POST["babble"])) {
+ $safecontent = makesafe($_POST["babble"]);
+ if ($safecontent == "" || $safecontent == " ") { //blank post. do nothing.
+ } else { $insert = doquery("INSERT INTO {{table}} SET id='',posttime=NOW(),author='".$userrow["charname"]."',babble='$safecontent'", "babble"); }
+ header("Location: index.php?do=babblebox");
+ die();
+ }
+
+ $babblebox = array("content"=>"");
+ $bg = 1;
+ $babblequery = doquery("SELECT * FROM {{table}} ORDER BY id DESC LIMIT 20", "babble");
+ while ($babblerow = mysqli_fetch_array($babblequery)) {
+ if ($bg == 1) { $new = "[".$babblerow["author"]."] ".$babblerow["babble"]."
\n"; $bg = 2; }
+ else { $new = "[".$babblerow["author"]."] ".stripslashes($babblerow["babble"])."
\n"; $bg = 1; }
+ $babblebox["content"] = $new . $babblebox["content"];
+ }
+ $babblebox["content"] .= "";
+
+ // Make page tags for XHTML validation.
+ $xml = "\n"
+ . "\n"
+ . "\n";
+ $page = $xml . gettemplate("babblebox");
+ echo parsetemplate($page, $babblebox);
+ die();
+
+}
+
+function ninja() {
+ header("Location: http://www.se7enet.com/img/shirtninja.jpg");
+}
\ No newline at end of file
diff --git a/index.php b/index.php
index 53cb7d1..73f7436 100644
--- a/index.php
+++ b/index.php
@@ -48,242 +48,13 @@ if (isset($_GET["do"])) {
// Misc functions.
elseif ($do[0] == "verify") { header("Location: users.php?do=verify"); die(); }
elseif ($do[0] == "spell") { include('game/heal.php'); healspells($do[1]); }
- elseif ($do[0] == "showchar") { showchar(); }
- elseif ($do[0] == "onlinechar") { onlinechar($do[1]); }
- elseif ($do[0] == "showmap") { showmap(); }
- elseif ($do[0] == "babblebox") { babblebox(); }
- elseif ($do[0] == "ninja") { ninja(); }
+ elseif ($do[0] == "showchar") { include('game/misc.php'); showchar(); }
+ elseif ($do[0] == "onlinechar") { include('game/misc.php'); onlinechar($do[1]); }
+ elseif ($do[0] == "showmap") { include('game/misc.php'); showmap(); }
+ elseif ($do[0] == "babblebox") { include('game/misc.php'); babblebox(); }
+ elseif ($do[0] == "ninja") { include('game/misc.php'); ninja(); }
elseif ($do[0] == "die") { header('Location: index.php?do=buy'); die(); }
-} else { donothing(); }
-
-function donothing() {
-
- global $userrow;
-
- if ($userrow["currentaction"] == "In Town") {
- $page = dotown();
- $title = "In Town";
- } elseif ($userrow["currentaction"] == "Exploring") {
- $page = doexplore();
- $title = "Exploring";
- } elseif ($userrow["currentaction"] == "Fighting") {
- $page = dofight();
- $title = "Fighting";
- }
-
- display($page, $title);
-
-}
-
-function dotown() { // Spit out the main town page.
-
- global $userrow, $controlrow, $numqueries;
-
- $townquery = doquery("SELECT * FROM {{table}} WHERE latitude='".$userrow["latitude"]."' AND longitude='".$userrow["longitude"]."' LIMIT 1", "towns");
- if (mysqli_num_rows($townquery) == 0) { display("There is an error with your user account, or with the town data. Please try again.","Error"); }
- $townrow = mysqli_fetch_array($townquery);
-
- // News box. Grab latest news entry and display it. Something a little more graceful coming soon maybe.
- if ($controlrow["shownews"] == 1) {
- $newsquery = doquery("SELECT * FROM {{table}} ORDER BY id DESC LIMIT 1", "news");
- $newsrow = mysqli_fetch_array($newsquery);
- $townrow["news"] = "Latest News |
\n";
- $townrow["news"] .= "[".prettydate($newsrow["postdate"])."] ".nl2br($newsrow["content"]);
- $townrow["news"] .= " |
\n";
- } else { $townrow["news"] = ""; }
-
- // Who's Online. Currently just members. Guests maybe later.
- if ($controlrow["showonline"] == 1) {
- $onlinequery = doquery("SELECT * FROM {{table}} WHERE UNIX_TIMESTAMP(onlinetime) >= '".(time()-600)."' ORDER BY charname", "users");
- $townrow["whosonline"] = "Who's Online |
\n";
- $townrow["whosonline"] .= "There are " . mysqli_num_rows($onlinequery) . " user(s) online within the last 10 minutes: ";
- while ($onlinerow = mysqli_fetch_array($onlinequery)) { $townrow["whosonline"] .= "".$onlinerow["charname"]."" . ", "; }
- $townrow["whosonline"] = rtrim($townrow["whosonline"], ", ");
- $townrow["whosonline"] .= " |
\n";
- } else { $townrow["whosonline"] = ""; }
-
- if ($controlrow["showbabble"] == 1) {
- $townrow["babblebox"] = "Babble Box |
\n";
- $townrow["babblebox"] .= "";
- $townrow["babblebox"] .= " |
\n";
- } else { $townrow["babblebox"] = ""; }
-
- $page = gettemplate("towns");
- $page = parsetemplate($page, $townrow);
-
- return $page;
-
-}
-
-function doexplore() { // Just spit out a blank exploring page.
-
- // Exploring without a GET string is normally when they first log in, or when they've just finished fighting.
-
-$page = <<
- |
-
-You are exploring the map, and nothing has happened. Continue exploring using the direction buttons or the Travel To menus.
- |
-
-END;
-
- return $page;
-
-}
-
-function dofight() { // Redirect to fighting.
-
- header("Location: index.php?do=fight");
-
-}
-
-function showchar() {
-
- global $userrow, $controlrow;
-
- // Format various userrow stuffs.
- $userrow["experience"] = number_format($userrow["experience"]);
- $userrow["gold"] = number_format($userrow["gold"]);
- if ($userrow["expbonus"] > 0) {
- $userrow["plusexp"] = "(+".$userrow["expbonus"]."%)";
- } elseif ($userrow["expbonus"] < 0) {
- $userrow["plusexp"] = "(".$userrow["expbonus"]."%)";
- } else { $userrow["plusexp"] = ""; }
- if ($userrow["goldbonus"] > 0) {
- $userrow["plusgold"] = "(+".$userrow["goldbonus"]."%)";
- } elseif ($userrow["goldbonus"] < 0) {
- $userrow["plusgold"] = "(".$userrow["goldbonus"]."%)";
- } else { $userrow["plusgold"] = ""; }
-
- $levelquery = doquery("SELECT ". $userrow["charclass"]."_exp FROM {{table}} WHERE id='".($userrow["level"]+1)."' LIMIT 1", "levels");
- $levelrow = mysqli_fetch_array($levelquery);
- if ($userrow["level"] < 99) { $userrow["nextlevel"] = number_format($levelrow[$userrow["charclass"]."_exp"]); } else { $userrow["nextlevel"] = "None"; }
-
- if ($userrow["charclass"] == 1) { $userrow["charclass"] = $controlrow["class1name"]; }
- elseif ($userrow["charclass"] == 2) { $userrow["charclass"] = $controlrow["class2name"]; }
- elseif ($userrow["charclass"] == 3) { $userrow["charclass"] = $controlrow["class3name"]; }
-
- if ($userrow["difficulty"] == 1) { $userrow["difficulty"] = $controlrow["diff1name"]; }
- elseif ($userrow["difficulty"] == 2) { $userrow["difficulty"] = $controlrow["diff2name"]; }
- elseif ($userrow["difficulty"] == 3) { $userrow["difficulty"] = $controlrow["diff3name"]; }
-
- $spellquery = doquery("SELECT id,name FROM {{table}}","spells");
- $userspells = explode(",",$userrow["spells"]);
- $userrow["magiclist"] = "";
- while ($spellrow = mysqli_fetch_array($spellquery)) {
- $spell = false;
- foreach($userspells as $a => $b) {
- if ($b == $spellrow["id"]) { $spell = true; }
- }
- if ($spell == true) {
- $userrow["magiclist"] .= $spellrow["name"]."
";
- }
- }
- if ($userrow["magiclist"] == "") { $userrow["magiclist"] = "None"; }
-
- // Make page tags for XHTML validation.
- $xml = "\n"
- . "\n"
- . "\n";
-
- $charsheet = gettemplate("showchar");
- $page = $xml . gettemplate("minimal");
- $array = array("content"=>parsetemplate($charsheet, $userrow), "title"=>"Character Information");
- echo parsetemplate($page, $array);
- die();
-
-}
-
-function onlinechar($id) {
-
- global $controlrow;
- $userquery = doquery("SELECT * FROM {{table}} WHERE id='$id' LIMIT 1", "users");
- if (mysqli_num_rows($userquery) == 1) { $userrow = mysqli_fetch_array($userquery); } else { display("No such user.", "Error"); }
-
- // Format various userrow stuffs.
- $userrow["experience"] = number_format($userrow["experience"]);
- $userrow["gold"] = number_format($userrow["gold"]);
- if ($userrow["expbonus"] > 0) {
- $userrow["plusexp"] = "(+".$userrow["expbonus"]."%)";
- } elseif ($userrow["expbonus"] < 0) {
- $userrow["plusexp"] = "(".$userrow["expbonus"]."%)";
- } else { $userrow["plusexp"] = ""; }
- if ($userrow["goldbonus"] > 0) {
- $userrow["plusgold"] = "(+".$userrow["goldbonus"]."%)";
- } elseif ($userrow["goldbonus"] < 0) {
- $userrow["plusgold"] = "(".$userrow["goldbonus"]."%)";
- } else { $userrow["plusgold"] = ""; }
-
- $levelquery = doquery("SELECT ". $userrow["charclass"]."_exp FROM {{table}} WHERE id='".($userrow["level"]+1)."' LIMIT 1", "levels");
- $levelrow = mysqli_fetch_array($levelquery);
- $userrow["nextlevel"] = number_format($levelrow[$userrow["charclass"]."_exp"]);
-
- if ($userrow["charclass"] == 1) { $userrow["charclass"] = $controlrow["class1name"]; }
- elseif ($userrow["charclass"] == 2) { $userrow["charclass"] = $controlrow["class2name"]; }
- elseif ($userrow["charclass"] == 3) { $userrow["charclass"] = $controlrow["class3name"]; }
-
- if ($userrow["difficulty"] == 1) { $userrow["difficulty"] = $controlrow["diff1name"]; }
- elseif ($userrow["difficulty"] == 2) { $userrow["difficulty"] = $controlrow["diff2name"]; }
- elseif ($userrow["difficulty"] == 3) { $userrow["difficulty"] = $controlrow["diff3name"]; }
-
- $charsheet = gettemplate("onlinechar");
- $page = parsetemplate($charsheet, $userrow);
- display($page, "Character Information");
-
-}
-
-function showmap() {
-
- global $userrow;
-
- // Make page tags for XHTML validation.
- $xml = "\n"
- . "\n"
- . "\n";
-
- $page = $xml . gettemplate("minimal");
- $array = array("content"=>"
", "title"=>"Map");
- echo parsetemplate($page, $array);
- die();
-
-}
-
-function babblebox() {
-
- global $userrow;
-
- if (isset($_POST["babble"])) {
- $safecontent = makesafe($_POST["babble"]);
- if ($safecontent == "" || $safecontent == " ") { //blank post. do nothing.
- } else { $insert = doquery("INSERT INTO {{table}} SET id='',posttime=NOW(),author='".$userrow["charname"]."',babble='$safecontent'", "babble"); }
- header("Location: index.php?do=babblebox");
- die();
- }
-
- $babblebox = array("content"=>"");
- $bg = 1;
- $babblequery = doquery("SELECT * FROM {{table}} ORDER BY id DESC LIMIT 20", "babble");
- while ($babblerow = mysqli_fetch_array($babblequery)) {
- if ($bg == 1) { $new = "[".$babblerow["author"]."] ".$babblerow["babble"]."
\n"; $bg = 2; }
- else { $new = "[".$babblerow["author"]."] ".stripslashes($babblerow["babble"])."
\n"; $bg = 1; }
- $babblebox["content"] = $new . $babblebox["content"];
- }
- $babblebox["content"] .= "";
-
- // Make page tags for XHTML validation.
- $xml = "\n"
- . "\n"
- . "\n";
- $page = $xml . gettemplate("babblebox");
- echo parsetemplate($page, $babblebox);
- die();
-
-}
-
-function ninja() {
- header("Location: http://www.se7enet.com/img/shirtninja.jpg");
-}
+} else { include('game/misc.php'); donothing(); }
?>
\ No newline at end of file