Mercurial > hg > batmud > maputils
changeset 337:ca191c3a0ce1
Updates and lots of new ugly glue.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 11 Jul 2007 16:05:32 +0000 |
parents | 7e527c2825ba |
children | 5df69bb02c9e |
files | www/common.inc.php www/index.php www/info.php www/loc.php |
diffstat | 4 files changed, 388 insertions(+), 197 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/www/common.inc.php Wed Jul 11 16:05:32 2007 +0000 @@ -0,0 +1,152 @@ +<? +function printPageHeader($title) +{ +global $pageCSS, $pageCharset; +echo "<?xml version=\"1.0\" encoding=\"".$pageCharset."\"?>\n"; +?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=<? echo $pageCharset ?>" /> + <meta name="Author" content="Matti Hämäläinen aka Ggr Pupunen" /> + <title><? echo $title ?></title> + <link href="<? echo $pageCSS ?>" rel="stylesheet" type="text/css" /> +</head> +<body> +<!-- ============================================= --> +<? +} + + +function burl($name) +{ +// echo "<a href=\"http://www.bat.org/help/finger.php?str=".$name."\">".$name."</a>"; + echo "<b>".$name."</b>"; +} + + +function readLocations($filename, &$locTable, $showPCities = FALSE) +{ + $inFile = @fopen($filename.".loc", "r"); + if (!$inFile) { + return FALSE; + } + + while (!feof($inFile)) { + $inLine = rtrim(fgets($inFile)); + + if (strlen($inLine) == 0 || $inLine[0] == "#") { + } else + if (preg_match("/^([0-9]+)[ \t]*;[ \t]*([0-9]+)[ \t]*;[ \t]*([0-9][CcMGSP%\?\-]*)[ \t]*;[ \t]*([^;]+)(;(.+))?$/", $inLine, $m)) { + $addInfo = preg_split("/[ \t]*;[ \t]*/", $m[6]); + + if (strlen($addInfo[0]) > 0) { + $coders = preg_split("/[ \t]*,[ \t]*/", $addInfo[0]); + } else { + $coders = array(); + } + + if (!strstr($m[3], "-")) { + + if (strstr($m[3], "C")) + $isPCity = TRUE; + else + $isPCity = FALSE; + + if (($showPCities && $isPCity) || (!$showPCities && !$isPCity)) { + $s = ""; + if (strstr($m[3], "S")) $s = "SHRINE "; + else if (strstr($m[3], "G")) $s = "GUILD "; + else if (strstr($m[3], "P")) $s = "SS "; + else if (strstr($m[3], "M")) $s = "MONSTER "; + else if (strstr($m[3], "c")) $s = "CITY "; + $s .= $m[4]; + + if (isset($locTable[$s])) { + echo "Error: Location <b>".$s."</b> already defined (".$locTable[$s]["continent"]." <=> ".$filename.")\n"; + return FALSE; + } + + $locTable[$s] = array( + "name" => $s, + "continent" => $filename, + "x" => $m[1], + "y" => $m[2], + "flags" => $m[3], + "coders" => $coders, + "url" => $addInfo[1], + "freeform" => $addInfo[2] + ); + } + } + } else { + echo "Error: <b>$inLine</b><br>\n"; + //return FALSE; + } + } + + fclose($inFile); + return TRUE; +} + + +function submitWZ(&$wizTable, $field, $data) +{ + $s = trim($data); + if (strlen($s) > 0) $wizTable[$field] = $s; +} + + +function submitWizInfo(&$wizTable, $m) +{ + $s = trim($m[1]); + if (isset($wizTable[$s])) { + echo "Error: <b>".$s."</b> is already set!<br />\n"; + } else { + $tmp = array("name" => $s); + submitWZ($tmp, "homeURL", $m[2]); + submitWZ($tmp, "imageURL", $m[3]); + submitWZ($tmp, "desc", $m[4]); + + if (count($tmp) > 1) + $wizTable[$s] = $tmp; + } +} + + +function readWizInfo($filename, &$wizTable) +{ + $inFile = @fopen($filename, "r"); + if (!$inFile) { + return FALSE; + } + + $contMode = FALSE; + while (!feof($inFile)) { + $inLine = rtrim(fgets($inFile)); + + if ($contMode) { + if (substr($inLine, -1, 1) == "$") { + $m[4] .= " ".substr($inLine, 0, -1); + $contMode = FALSE; + submitWizInfo($wizTable, $m); + } else + $m[4] .= " ".$inLine; + } else + if (strlen($inLine) == 0 || $inLine[0] == "#") { + } else + if (preg_match("/^([A-Z][a-z]+);(http:\/\/[^;]+|bat)?;(http:\/\/[^;]+|bat:\/\/[^;]+|img\/[^;]+)?;([^\$]*)\\\$$/", $inLine, $m)) { + submitWizInfo($wizTable, $m); + } else + if (preg_match("/^([A-Z][a-z]+);(http:\/\/[^;]+|bat)?;(http:\/\/[^;]+|bat:\/\/[^;]+|img\/[^;]+)?;(.*)$/", $inLine, $m)) { + $contMode = TRUE; + } else { + echo "Error: <b>$inLine</b><br>\n"; + } + } + + fclose($inFile); + return TRUE; +} + +?> \ No newline at end of file
--- a/www/index.php Wed Jul 11 16:05:01 2007 +0000 +++ b/www/index.php Wed Jul 11 16:05:32 2007 +0000 @@ -1,11 +1,6 @@ <? require "config.inc.php"; - -function burl($name) -{ - echo "<a href=\"http://www.bat.org/help/finger.php?str=".$name."\">".$name."</a>"; -} - +require "common.inc.php"; function printFileTD($fileName, $mapName) { @@ -74,19 +69,12 @@ echo " </tr>\n"; } -echo "<?xml version=\"1.0\" encoding=\"".$pageCharset."\"?>\n"; +printPageHeader($pageTitle); ?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> -<head> - <meta http-equiv="Content-Type" content="text/html; charset=<? echo $pageCharset ?>" /> - <meta name="Author" content="Matti Hämäläinen aka Ggr Pupunen" /> - <title><? echo $pageTitle ?></title> - <link href="<? echo $pageCSS ?>" rel="stylesheet" type="text/css" /> -</head> -<body> -<!-- ============================================= --> <h1><? echo $pageTitle ?></h1> +<table> +<tr> +<td> <p> Maps of <a href="http://www.bat.org/">BatMUD realm</a>, including maps of the continents and maps of some areas and cities. @@ -96,23 +84,53 @@ <a href="http://www.zerobelow.net/maps/">maps available</a>. </p> -<div style="background: black; color: white; padding: 4px; border: 1px solid white;"> -<b>NEWSFLASH!</b> New JavaScript enhanced versions of the HTML maps are now available. -These maps have a floating location menu, which you can use to hop around the map.<br /> -<b>WARNING!</b> These JS-enhanced maps do NOT render properly in Internet Explorer currently. -I'll try to fix this as time permits. Safari, Firefox and Opera should work OK. -</div> +<h2>General Information</h2> +<ul> + <li><a href="loc.php?c">An incomplete listing of player cities</a>, includes player guild (secret society) info.</li> -<h2>Continents of BatMUD: Age of Exiles</h2> -<ul> + <li><a href="info.php">List of Wizards</a> - the incomplete "who is who" database of BatMUD immortals.</li> + <li><? printURL("world.jpg") ?>JPEG image of the whole BatWorld</a>, scenics and other locations marked with circles of varying colours.</li> - <li>List of <a href="loc.php">scenics/locations of the whole world</a>.</li> - - <li>A small list of <a href="loc.php?c">player cities</a> in the whole world.</li> + <li>List of <a href="loc.php">scenics/locations of the whole world</a>, with incomplete list of coder information</li> </ul> +</td> +<td> +<script type="text/javascript"><!-- +google_ad_client = "pub-0261199601131882"; +google_ad_width = 120; +google_ad_height = 240; +google_ad_format = "120x240_as"; +google_ad_type = "text"; +//2007-07-02: maps +google_ad_channel = "8186232915"; +google_color_border = "336699"; +google_color_bg = "FFFFFF"; +google_color_link = "0000FF"; +google_color_text = "000000"; +google_color_url = "008000"; +google_ui_features = "rc:0"; +//--> +</script> +<script type="text/javascript" + src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> +</script> +</td> +</tr></table> + + +<h2>Continents of BatMUD: Age of Exiles</h2> + +<p style="background: #555; color: white; padding: 4px; border: 1px solid #888; color: yellow;"> +<b>NEWS!</b> New JavaScript enhanced versions of the HTML maps are +now available. These maps have a floating location menu, which you can use +to hop around the map.<br /> +<b>WARNING!</b> The JavaScript-enhanced maps do NOT +render properly in Internet Explorer at the moment. I'll try to fix this as time +permits. Safari, Firefox and Opera9 should work OK. +</p> <table class="area" width="90%"> <tr> @@ -146,11 +164,12 @@ </tr> <? $n = 0; -printLine($n++, "votk", "Valley of the Kings", TRUE); -printLine($n++, "lanzia", "The Isle of Lanzia", TRUE); printLine($n++, "lorenchia", "City of Lorenchia", TRUE); printLine($n++, "rilynttar", "City of Rilynt'tar", TRUE); printLine($n++, "esiris", "E'siris, the Ethereal City", TRUE); +printLine($n++, "votk", "Valley of the Kings", TRUE); +printLine($n++, "lanzia", "The Isle of Lanzia", TRUE); +printLine($n++, "faerieforest", "Faerie Forest", TRUE); ?> </table> @@ -169,7 +188,6 @@ <b>-- <a href="http://www.bat.org/help/finger.php?str=ggr">Ggr Pupunen</a>, master of carrots.</b> </p> </div> - <? // Google Analytics require "../urchin.inc.php";
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/www/info.php Wed Jul 11 16:05:32 2007 +0000 @@ -0,0 +1,133 @@ +<? +require "config.inc.php"; +require "common.inc.php"; + +/* Page start + */ +printPageHeader($pageTitle." - Wizards of the Realm"); +//echo "<div><b>DEVELOPMENT VERSION</b></div>"; +?> +<h1>Wizards of the Realm</h1> + +<div class="wizinfo"> +<table><tr><td> +<b>Notice #1</b>: The area counts are not really accurate, as the database only +lists areas accessible from outworld. Thus the areas only accessible via some +other fashion are not listed.<br /> +<b>Notice #2</b>: Not everyone who has once been immortal is listed. +Some purged and/or remorted wizards without known contributions are unlisted. +<br /> +<b>Notice #3</b>: It is certainly possible, that some of this information is +incorrect. Sorry for that. Please report to <? burl("Ggr") ?>, if you have Knowledge(tm). + +</td><td> + +<script type="text/javascript"><!-- +google_ad_client = "pub-0261199601131882"; +google_ad_width = 180; +google_ad_height = 60; +google_ad_format = "180x60_as_rimg"; +google_cpa_choice = "CAAQ24Oy0QEaCH9Si1cjMAnSKMu293MwAA"; +google_ad_channel = "4482432148"; +//--> +</script> +<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> +</script> + +</td></tr></table> +</div> +<p>[<a href="index.php">Back to the main page</a>]</p> + +<? + +$locTable = array(); +$wizTable = array(); + +readWizInfo("wizards.txt", $wizTable); + +if (isset($_GET["a"])) { + $coderName = basename($_GET["a"]); + $coderName = strtoupper(substr($coderName, 0, 1)).strtolower(substr($coderName, 1)); +} + +reset($continentList); +while (list($iKey, $iValue) = each($continentList)) { + readLocations($iKey, $locTable, FALSE); +} + +/* Print table of wizards + */ +while (list($key, $value) = each($locTable)) { + while (list($ik, $iv) = each($value["coders"])) { + if (!isset($wizTable[$iv])) + $wizTable[$iv] = array("name" => $iv); + + if (!isset($wizTable[$iv]["areas"])) + $wizTable[$iv]["areas"] = 1; + else + $wizTable[$iv]["areas"]++; + } +} + +reset($wizTable); +if (count($wizTable) > 0) { + /* Make alphabetical table + */ + while (list($key, $value) = each($wizTable)) { + $alphaTable[$key[0]][] = $value; + } + + ksort($alphaTable, SORT_STRING); + + + /* Print wizards per first character + */ + $totalWiz = 0; + $maxRow = 6; + while (list($key, $value) = each($alphaTable)) { + if (count($value) > 0) { + asort($value); + echo "<h3><a name=\"".strtolower($key)."\"></a>".$key."</h3>\n"; + echo "<table class=\"loc\" width=\"95%\">\n"; + $n = 0; + while (list($ik, $iv) = each($value)) { + if ($n == 0) { + echo " <tr>\n"; + } + + $totalWiz++; + + printf(" <td width=\"%d%%\" style=\"background: %s;\"><a href=\"loc.php?a=%s\">%s</a> <span style=\"color: #f80;\">", + (100 / $maxRow), (count($iv) > 2 || isset($iv["desc"])) ? "#474" : "#744", $iv["name"], $iv["name"]); + + if (isset($iv["areas"])) + echo " (".$iv["areas"].")"; + + echo "</span></td>\n"; + + $n++; + if ($n >= $maxRow) { + echo " </tr>\n"; + $n = 0; + } + } + if ($n > 0) { + while ($n++ < $maxRow) + echo " <td></td>\n"; + + echo " </tr>\n"; + } + echo "</table>\n"; + } + } + + echo "<p><b>".$totalWiz."</b> wizards.</p>\n"; +} else { + echo "<p><b>No wizards known!</b></p>\n"; +} + +// Google Analytics +require "../urchin.inc.php"; +?> +</body> +</html>
--- a/www/loc.php Wed Jul 11 16:05:01 2007 +0000 +++ b/www/loc.php Wed Jul 11 16:05:32 2007 +0000 @@ -1,155 +1,6 @@ <? require "config.inc.php"; - - -function readLocations($filename, &$locTable, $showPCities = FALSE) -{ - $inFile = @fopen($filename.".loc", "r"); - if (!$inFile) { - return FALSE; - } - - while (!feof($inFile)) { - $inLine = rtrim(fgets($inFile)); - - if (strlen($inLine) == 0 || $inLine[0] == "#") { - } else - if (preg_match("/^([0-9]+)[ \t]*;[ \t]*([0-9]+)[ \t]*;[ \t]*([0-9][CcMGSP%\?\-]*)[ \t]*;[ \t]*([^;]+)(;(.+))?$/", $inLine, $m)) { - $addInfo = preg_split("/[ \t]*;[ \t]*/", $m[6]); - - if (strlen($addInfo[0]) > 0) { - $coders = preg_split("/[ \t]*,[ \t]*/", $addInfo[0]); - } else { - $coders = array(); - } - - if (!strstr($m[3], "-")) { - - if (strstr($m[3], "C")) - $isPCity = TRUE; - else - $isPCity = FALSE; - - if (($showPCities && $isPCity) || (!$showPCities && !$isPCity)) { - $s = ""; - if (strstr($m[3], "S")) $s = "SHRINE "; - else if (strstr($m[3], "G")) $s = "GUILD "; - else if (strstr($m[3], "P")) $s = "SS "; - else if (strstr($m[3], "M")) $s = "MONSTER "; - else if (strstr($m[3], "c")) $s = "CITY "; - - $s .= $m[4]; - - $locTable[$s] = array( - "name" => $s, - "continent" => $filename, - "x" => $m[1], - "y" => $m[2], - "flags" => $m[3], - "coders" => $coders, - "url" => $addInfo[1], - "freeform" => $addInfo[2] - ); - } - } - } else { - echo "Error: <b>$inLine</b><br>\n"; - //return FALSE; - } - } - - fclose($inFile); - return TRUE; -} - - -function submitWizInfo(&$wizTable, $m) -{ - $s = trim($m[1]); - $wizTable[$s] = array( - "name" => $s, - "homeURL" => trim($m[2]), - "imageURL" => trim($m[3]), - "desc" => trim($m[4]) - ); -} - -function readWizInfo($filename, &$wizTable) -{ - $inFile = @fopen($filename, "r"); - if (!$inFile) { - return FALSE; - } - - $contMode = FALSE; - while (!feof($inFile)) { - $inLine = rtrim(fgets($inFile)); - - if ($contMode) { - if (substr($inLine, -1, 1) == "$") { - $m[4] .= " ".substr($inLine, 0, -1); - $contMode = FALSE; - submitWizInfo($wizTable, $m); - } else - $m[4] .= " ".$inLine; - } else - if (strlen($inLine) == 0 || $inLine[0] == "#") { - } else - if (preg_match("/^([A-Z][a-z]+);(http:\/\/[^;]+|bat)?;(http:\/\/[^;]+|bat:\/\/[^;]+)?;([^\$]*)\\\$$/", $inLine, $m)) { - submitWizInfo($wizTable, $m); - } else - if (preg_match("/^([A-Z][a-z]+);(http:\/\/[^;]+|bat)?;(http:\/\/[^;]+|bat:\/\/[^;]+)?;(.*)$/", $inLine, $m)) { - $contMode = TRUE; - } else { - echo "Error: <b>$inLine</b><br>\n"; - //return FALSE; - } - } - - fclose($inFile); - return TRUE; -} - - -echo "<?xml version=\"1.0\" encoding=\"".$pageCharset."\"?>\n"; -?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> -<head> - <meta http-equiv="Content-Type" content="text/html; charset=<? echo $pageCharset ?>" /> - <meta name="Author" content="Matti Hämäläinen aka Ggr Pupunen" /> - <title><? echo $pageTitle ?></title> - <link href="<? echo $pageCSS ?>" rel="stylesheet" type="text/css" /> -</head> - -<body> -<? -$locTable = array(); -$wizTable = array(); - -$onlyPCities = isset($_GET["c"]); -$showCoders = !isset($_GET["s"]); - -if (isset($_GET["a"])) { - $coderName = basename($_GET["a"]); - $coderName = strtoupper(substr($coderName, 0, 1)).strtolower(substr($coderName, 1)); -} - -if (isset($_GET["n"])) { - $setName = strtolower(basename($_GET["n"])); - if (isset($continentList[$setName]) && file_exists($setName.".loc")) { - readLocations($setName, $locTable, $onlyPCities); - } else { - echo "<h1>No such continent ID!</h1>"; - unset($setName); - } -} else { - reset($continentList); - while (list($iKey, $iValue) = each($continentList)) { - readLocations($iKey, $locTable, $onlyPCities); - } -} - +require "common.inc.php"; function makeURL($pcities, $coders, $name, $desc, $class) { @@ -172,11 +23,44 @@ echo " <td>"; - echo "<a href=\"loc.php"; + echo "<a href=\"".$GLOBALS["SCRIPT_NAME"]; if (strlen($s) > 0) echo "?".$s; echo "\">".$desc."</a></td>\n"; } + +/* Page start + */ +printPageHeader($pageTitle." - Locations"); +//echo "<div><b>DEVELOPMENT VERSION</b></div>"; + +$locTable = array(); +$wizTable = array(); + +$onlyPCities = isset($_GET["c"]); +$showCoders = !isset($_GET["s"]); + +if (isset($_GET["a"])) { + $coderName = basename($_GET["a"]); + $coderName = strtoupper(substr($coderName, 0, 1)).strtolower(substr($coderName, 1)); + readWizInfo("wizards.txt", $wizTable); +} + +if (isset($_GET["n"])) { + $setName = strtolower(basename($_GET["n"])); + if (isset($continentList[$setName]) && file_exists($setName.".loc")) { + readLocations($setName, $locTable, $onlyPCities); + } else { + echo "<h1>No such continent ID!</h1>"; + unset($setName); + } +} else { + reset($continentList); + while (list($iKey, $iValue) = each($continentList)) { + readLocations($iKey, $locTable, $onlyPCities); + } +} + /* Header */ echo "<h1>"; @@ -218,36 +102,37 @@ makeURL($onlyPCities, $showCoders, $iKey, $iValue, $iKey); } ?> - <td>[<a href="index.php">Back to main page</a>]</td> </tr> </table> </div> <? -/* -if ($showCoders && isset($coderName) && isset($wizTable[$coderName])) { +if ($showCoders && isset($coderName) && isset($wizTable[$coderName]) && count($wizTable[$coderName]) > 1) { echo "<div class=\"wizinfo\">\n <table>\n <tr>\n"; $s = $wizTable[$coderName]["imageURL"]; - if (strlen($s) > 0) { + if (isset($s)) { if (substr($s, 0, 6) == "bat://") $s = "http://www.bat.org/albums/".substr($s, 6); - echo " <td class=\"img\"><img src=\"".$s."\" alt=\"".$coderName."\" /></td>\n"; - } + } else + $s = "img/unknown.png"; + + echo " <td class=\"img\"><img src=\"".$s."\" alt=\"".$coderName."\" /></td>\n"; + echo " <td class=\"info\">\n"; - echo " <h2><a href=\"http://www.bat.org/help/finger.php?str=".$coderName."\">".$coderName."</a></h2>\n"; $s = $wizTable[$coderName]["desc"]; - if (strlen($s) > 0) { + if (isset($s) > 0) { echo " <p>".$s."</p>\n"; } echo " [<a href=\"http://www.bat.org/help/finger.php?str=".$coderName."\">Finger</a>]\n"; + $s = $wizTable[$coderName]["homeURL"]; - if (strlen($s) > 0) { + if (isset($s)) { if ($s == "bat") $s = "http://wiz.bat.org/~".strtolower($coderName)."/"; @@ -256,7 +141,7 @@ echo " </td>\n </tr>\n </table>\n</div>\n"; } -*/ + /* Print list of locations */ @@ -264,12 +149,15 @@ /* Make alphabetical table of locations */ while (list($key, $value) = each($locTable)) { - if (isset($coderName)) { - if (array_search($coderName, $value["coders"]) !== FALSE) { + if (isset($_GET["nocoders"])) { + if (count($value["coders"]) == 0 && !preg_match("/[SPG]/", $value["flags"])) $alphaTable[$key[0]][] = $value; - } } else { - $alphaTable[$key[0]][] = $value; + if (isset($coderName)) { + if (array_search($coderName, $value["coders"]) !== FALSE) + $alphaTable[$key[0]][] = $value; + } else + $alphaTable[$key[0]][] = $value; } } @@ -293,7 +181,7 @@ $totalLoc++; - printf(" <td width=\"%d%%\"class=\"%s\">", + printf(" <td width=\"%d%%\" class=\"%s\">", (100 / $maxRow), $iv["continent"]); printURL($iv["continent"].".html#loc".$iv["x"]."_".$iv["y"]);