";
}
display("Realms List", parsetemplate(gettemplate("realms_realms"), $pagerow));
} elseif ($action == "edit") {
if (!isset($_GET["id"]) || !is_numeric($_GET["id"])) { err("Invalid Realm ID number entered."); }
$id = $_GET["id"];
$therealm = dorow(doquery("SELECT * FROM {{table}} WHERE id='$id' LIMIT 1", "worlds"));
if ($therealm == false) { err("The Realm you entered does not exist."); }
if (isset($_POST["submit"])) {
// Check numbers.
$numerics = array("size");
foreach($numerics as $a => $b) { if (!is_numeric($_POST[$b])) { err("The $b field must be a number."); } }
// Other stuff.
if ($_POST["size"] < 0) { $_POST["size"] *= -1; }
// Update & finish.
extract($_POST);
$query = doquery("UPDATE {{table}} SET name='$name', size='$size' WHERE id='$id' LIMIT 1", "worlds");
display("Edit a Realm", "The Realm was edited successfully. Click here to return to the Realms List.");
}
display("Edit a Realm", parsetemplate(gettemplate("realms_realms_edit"), $therealm));
} elseif ($action == "new") {
if (isset($_POST["submit"])) {
// Check numbers.
$numerics = array("size");
foreach($numerics as $a => $b) { if (!is_numeric($_POST[$b])) { err("The $b field must be a number."); } }
// Other stuff.
if ($_POST["size"] < 0) { $_POST["size"] *= -1; }
// Update & finish.
extract($_POST);
$query = doquery("INSERT INTO {{table}} SET id='', name='$name', size='$size'", "worlds");
display("Add a Realm", "The Realm was created successfully. Click here to return to the Realms List.");
}
display("Add a Realm", parsetemplate(gettemplate("realms_realms_add"), $therealm));
} elseif ($action == "delete") {
if (!isset($_GET["id"]) || !is_numeric($_GET["id"])) { err("Invalid Realm ID number entered."); }
$id = $_GET["id"];
$therealm = dorow(doquery("SELECT * FROM {{table}} WHERE id='$id' LIMIT 1", "worlds"));
if ($therealm == false) { err("The Realm you entered does not exist."); }
if (isset($_POST["diediedie"])) {
$query = doquery("DELETE FROM {{table}} WHERE id='$id'", "worlds");
display("Delete a Realm", "The Realm was deleted successfully. Click here to return to the Realms List.");
} elseif (isset($_POST["abort"])) {
die(header("Location: index.php?do=realms&fn=realms"));
}
display("Delete a Realm", parsetemplate(gettemplate("realms_realms_delete"), $therealm));
}
}
function towns() {
if (isset($_GET["action"])) {
$action = $_GET["action"];
} else { $action = "list"; }
if ($action == "list") {
$towns = dorow(doquery("SELECT * FROM {{table}} ORDER BY id", "towns"), "id");
$realms = dorow(doquery("SELECT * FROM {{table}} ORDER BY id", "worlds"), "id");
$alt = false;
$pagerow["townslist"] = "";
foreach($towns as $a => $b) {
extract($b);
if ($alt) { $bg = "class=\"td_alt\""; $alt = false; } else { $bg = ""; $alt = true; }
$pagerow["townslist"] .= "
";
}
display("Towns List", parsetemplate(gettemplate("realms_towns"), $pagerow));
} elseif ($action == "edit") {
if (!isset($_GET["id"]) || !is_numeric($_GET["id"])) { err("Invalid Town ID number entered."); }
$id = $_GET["id"];
$thetown = dorow(doquery("SELECT * FROM {{table}} WHERE id='$id' LIMIT 1", "towns"));
if ($thetown == false) { err("The town you entered does not exist."); }
if (isset($_POST["submit"])) {
// Check numbers.
$numerics = array("world","latitude","longitude","innprice","mapprice","travelpoints","itemminlvl","itemmaxlvl");
foreach($numerics as $a => $b) { if (!is_numeric($_POST[$b])) { err("The $b field must be a number."); } }
// Update & finish.
extract($_POST);
$query = doquery("UPDATE {{table}} SET name='$name', world='$world', latitude='$latitude', longitude='$longitude', innprice='$innprice', mapprice='$mapprice', travelpoints='$travelpoints', itemminlvl='$itemminlvl', itemmaxlvl='$itemmaxlvl' WHERE id='$id' LIMIT 1", "towns");
display("Edit a Town", "The town was edited successfully. Click here to return to the Towns List.");
}
// Realms list.
$realms = dorow(doquery("SELECT * FROM {{table}} ORDER BY id", "worlds"), "id");
$thetown["realmselect"] = "";
foreach($realms as $a => $b) {
if ($thetown["world"] == $b["id"]) { $selected = "selected=\"selected\""; } else { $selected = ""; }
$thetown["realmselect"] .= "";
}
// Realm max size.
$thetown["realmsize"] = $realms[$thetown["world"]]["size"];
// Display.
display("Edit a Town", parsetemplate(gettemplate("realms_towns_edit"), $thetown));
} elseif ($action == "new") {
if (isset($_POST["submit"])) {
// Check numbers.
$numerics = array("world","latitude","longitude","innprice","mapprice","travelpoints","itemminlvl","itemmaxlvl");
foreach($numerics as $a => $b) { if (!is_numeric($_POST[$b])) { err("The $b field must be a number."); } }
// Update & finish.
extract($_POST);
$query = doquery("INSERT INTO {{table}} SET id='', name='$name', world='$world', latitude='$latitude', longitude='$longitude', innprice='$innprice', mapprice='$mapprice', travelpoints='$travelpoints', itemminlvl='$itemminlvl', itemmaxlvl='$itemmaxlvl'", "towns");
display("Add a Town", "The town was created successfully. Click here to return to the Towns List.");
}
// Realms list.
$realms = dorow(doquery("SELECT * FROM {{table}} ORDER BY id", "worlds"), "id");
$thetown["realmselect"] = "";
foreach($realms as $a => $b) {
$thetown["realmselect"] .= "";
}
// Realm max size.
$thetown["realmsize"] = $realms[$thetown["world"]]["size"];
// Display.
display("Add a Town", parsetemplate(gettemplate("realms_towns_add"), $thetown));
} elseif ($action == "delete") {
if (!isset($_GET["id"]) || !is_numeric($_GET["id"])) { err("Invalid town ID number entered."); }
$id = $_GET["id"];
$thetown = dorow(doquery("SELECT * FROM {{table}} WHERE id='$id' LIMIT 1", "towns"));
if ($thetown == false) { err("The town you entered does not exist."); }
if (isset($_POST["diediedie"])) {
$query = doquery("DELETE FROM {{table}} WHERE id='$id'", "towns");
display("Delete a Town", "The town was deleted successfully. Click here to return to the towns List.");
} elseif (isset($_POST["abort"])) {
die(header("Location: index.php?do=realms&fn=towns"));
}
display("Delete a Town", parsetemplate(gettemplate("realms_towns_delete"), $thetown));
}
}
function storyline() {
if (isset($_GET["action"])) {
$action = $_GET["action"];
} else { $action = "list"; }
if ($action == "list") {
$story = dorow(doquery("SELECT * FROM {{table}} ORDER BY id", "story"), "id");
$alt = false;
$pagerow["storylist"] = "";
foreach($story as $a => $b) {
extract($b);
if ($alt) { $bg = "class=\"td_alt\""; $alt = false; } else { $bg = ""; $alt = true; }
$pagerow["storylist"] .= "
";
}
display("Story List", parsetemplate(gettemplate("realms_story"), $pagerow));
} elseif ($action == "edit") {
if (!isset($_GET["id"]) || !is_numeric($_GET["id"])) { err("Invalid Town ID number entered."); }
$id = $_GET["id"];
$thetown = dorow(doquery("SELECT * FROM {{table}} WHERE id='$id' LIMIT 1", "towns"));
if ($thetown == false) { err("The town you entered does not exist."); }
if (isset($_POST["submit"])) {
// Check numbers.
$numerics = array("world","latitude","longitude","innprice","mapprice","travelpoints","itemminlvl","itemmaxlvl");
foreach($numerics as $a => $b) { if (!is_numeric($_POST[$b])) { err("The $b field must be a number."); } }
// Update & finish.
extract($_POST);
$query = doquery("UPDATE {{table}} SET name='$name', world='$world', latitude='$latitude', longitude='$longitude', innprice='$innprice', mapprice='$mapprice', travelpoints='$travelpoints', itemminlvl='$itemminlvl', itemmaxlvl='$itemmaxlvl' WHERE id='$id' LIMIT 1", "towns");
display("Edit a Town", "The town was edited successfully. Click here to return to the Towns List.");
}
// Realms list.
$realms = dorow(doquery("SELECT * FROM {{table}} ORDER BY id", "worlds"), "id");
$thetown["realmselect"] = "";
foreach($realms as $a => $b) {
if ($thetown["world"] == $b["id"]) { $selected = "selected=\"selected\""; } else { $selected = ""; }
$thetown["realmselect"] .= "";
}
// Realm max size.
$thetown["realmsize"] = $realms[$thetown["world"]]["size"];
// Display.
display("Edit a Town", parsetemplate(gettemplate("realms_towns_edit"), $thetown));
} elseif ($action == "new") {
if (isset($_POST["submit"])) {
// Check numbers.
$numerics = array("world","latitude","longitude","innprice","mapprice","travelpoints","itemminlvl","itemmaxlvl");
foreach($numerics as $a => $b) { if (!is_numeric($_POST[$b])) { err("The $b field must be a number."); } }
// Update & finish.
extract($_POST);
$query = doquery("INSERT INTO {{table}} SET id='', name='$name', world='$world', latitude='$latitude', longitude='$longitude', innprice='$innprice', mapprice='$mapprice', travelpoints='$travelpoints', itemminlvl='$itemminlvl', itemmaxlvl='$itemmaxlvl'", "towns");
display("Add a Town", "The town was created successfully. Click here to return to the Towns List.");
}
// Realms list.
$realms = dorow(doquery("SELECT * FROM {{table}} ORDER BY id", "worlds"), "id");
$thetown["realmselect"] = "";
foreach($realms as $a => $b) {
$thetown["realmselect"] .= "";
}
// Realm max size.
$thetown["realmsize"] = $realms[$thetown["world"]]["size"];
// Display.
display("Add a Town", parsetemplate(gettemplate("realms_towns_add"), $thetown));
} elseif ($action == "delete") {
if (!isset($_GET["id"]) || !is_numeric($_GET["id"])) { err("Invalid town ID number entered."); }
$id = $_GET["id"];
$thetown = dorow(doquery("SELECT * FROM {{table}} WHERE id='$id' LIMIT 1", "towns"));
if ($thetown == false) { err("The town you entered does not exist."); }
if (isset($_POST["diediedie"])) {
$query = doquery("DELETE FROM {{table}} WHERE id='$id'", "towns");
display("Delete a Town", "The town was deleted successfully. Click here to return to the towns List.");
} elseif (isset($_POST["abort"])) {
die(header("Location: index.php?do=realms&fn=towns"));
}
display("Delete a Town", parsetemplate(gettemplate("realms_towns_delete"), $thetown));
}
}
?>