changeset 300:edac314ac9bb

Added in the ugly PHP-glue used in http://tnsp.org/maps/
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 19 Jun 2007 14:49:15 +0000
parents ed5dfa77511f
children bee9674c9faf
files www/Makefile www/config.inc.php www/index.php www/loc.php
diffstat 4 files changed, 475 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/www/Makefile	Tue Jun 19 14:49:15 2007 +0000
@@ -0,0 +1,12 @@
+include ../Makefile.inc
+
+#
+# Special targets
+#
+upload: *.php
+	scp $? $(UPURL2)
+	touch $@
+
+clean:
+	$(RM) *~
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/www/config.inc.php	Tue Jun 19 14:49:15 2007 +0000
@@ -0,0 +1,26 @@
+<?
+$pageCharset = "iso-8859-1";
+$pageTitle = "BatMUD Maps";
+$pageCSS = "http://tnsp.org/docs.css";
+$useTNSP = TRUE;
+
+$continentList = array(
+  "laenor" => "Laenor",
+  "roth" => "Rothikgen",
+  "luc" => "Lucentium",
+  "furn" => "Furnachia",
+  "deso" => "Desolathya"
+);
+
+function printURL($url)
+{
+  global $useTNSP;
+  if ($useTNSP)
+    $urlPrefix = "http://students.oamk.fi/~mhamalai/bat/maps/";
+  else
+    $urlPrefix = "";
+  
+  echo "<a href=\"".$urlPrefix.$url."\">";
+}
+
+?>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/www/index.php	Tue Jun 19 14:49:15 2007 +0000
@@ -0,0 +1,164 @@
+<?
+require "config.inc.php";
+
+function burl($name)
+{
+  echo "<a href=\"http://www.bat.org/help/finger.php?str=".$name."\">".$name."</a>";
+}
+
+
+function printFileTD($fileName, $mapName)
+{
+  if (file_exists($fileName)) {
+    $fileStat = stat($fileName);
+    $q = $fileStat[7];
+    
+    echo "  <td>";
+    printURL($fileName);
+    echo $mapName."</a> (<b>";
+
+    if ($q < 1024)
+      printf("%d</b> bytes", $q);
+    else if ($q < (1024*1024))
+      printf("%d</b>kB", $q/1024);
+    else printf("%1.2f</b>MB", $q/(1024.0*1024.0));
+    
+    echo ")</td>\n";
+  } else {
+    echo "  <td></td>\n";
+  }
+}
+
+
+function printLine($n, $fileName, $mapName, $noExtra = FALSE)
+{
+  echo " <tr class=\"";
+  if ($n & 1)
+    echo "cffile";
+  else
+    echo "cfdir";
+  
+  echo "\">\n";
+	
+  if (file_exists($fileName.".html")) {
+    echo "  <td>";
+    printURL($fileName.".html");
+    echo $mapName."</a>\n";
+  } else {
+    echo "  <td>".$mapName."</td>\n";
+  }
+
+  printFileTD($fileName.".html", "HTML");
+	
+  if ($noExtra) {
+    printFileTD($fileName.".map", "ASCII");
+  }
+	
+  if (!$noExtra) {
+    printFileTD($fileName.".ansi", "ANSI");
+    printFileTD($fileName.".png", "PNG");
+    
+    if (file_exists($fileName.".loc")) {
+      echo "  <td>";
+      echo "[<a href=\"loc.php?n=".$fileName."\">Locations</a>] ";
+      echo "[<a href=\"loc.php?c&amp;n=".$fileName."\">PCities</a>] ";
+      echo "</td>\n";
+    } else
+      echo "  <td>-</td>\n";
+    }
+  
+  echo " </tr>\n";
+}
+
+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>
+<!-- ============================================= -->
+<h1><? echo $pageTitle ?></h1>
+<p>
+Maps of <a href="http://www.bat.org/">BatMUD realm</a>, including
+maps of the continents and maps of some areas and cities.
+As an alternative, <? burl("Jeskko") ?> has created an interesting
+<a href="http://jeskko.pupunen.net/map/">Google Maps-style implementation</a>
+of the continent maps. Also, <? burl("Ooga") ?> has his
+<a href="http://www.zerobelow.net/maps/">maps available</a>.
+</p>
+
+<h2>Continents of BatMUD: Age of Exiles</h2>
+<ul>
+ <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>
+</ul>
+
+
+<table width="90%">
+ <tr>
+  <th>Continent
+  <th>HTML+CSS</th>
+  <th>Raw ANSI</th>
+  <th>Image files</th>
+  <th>Info</th>
+ </tr>
+<?
+$n = 0;
+while (list($iKey, $iValue) = each($continentList)) {
+  printLine($n++, $iKey, $iValue);
+}
+?>
+</table>
+
+<p>
+The ANSI files are maps rendered as ASCII text with ANSI colour codes, UNIX users can apply
+the familiar less(1) utility to view them, assuming their less supports raw output - 
+GNU less works: <b>less -S -R laenor.ansi</b>.
+</p>
+
+<h2>Area maps</h2>
+<table width="90%">
+ <tr>
+  <th>Area</th>
+  <th>HTML+CSS</th>
+  <th>Plain ASCII</th>
+ </tr>
+<?
+$n = 0;
+printLine($n++, "votk", "Valley of the Kings", TRUE);
+printLine($n++, "lanzia", "The Isle of Lanzia", TRUE);
+printLine($n++, "rilynttar", "City of Rilynt'tar", TRUE);
+printLine($n++, "esiris", "E'siris, the Ethereal City", TRUE);
+?>
+</table>
+
+<br /><hr />
+
+<p><b>Special thanks fly out to:</b></p>
+<ul>
+ <li><? burl("Ooga") ?> - Raw mapdata for Desolathya, Furnachia and Rothikgen. Ideas, and some locations.</li>
+ <li><? burl("Jeskko") ?> - Help with Laenor re-mapping, some locations, Pupunen.net hosting.</li>
+ <li><? burl("Malacoda") ?> - Loaned her ship for re-mapping of Lucentium and Laenor.</li>
+ <li><? burl("Moonlord") ?> and <? burl("Nuane") ?> - Area coder information.</li>
+ <li>Few unnamed BatMUD wizards for bits and pieces of information about area names.</li>
+</ul>
+
+<p>
+ <b>-- <a href="http://www.bat.org/help/finger.php?str=ggr">Ggr Pupunen</a>, master of carrots.</b>
+</p>
+
+<?
+// Google Analytics
+require "../urchin.inc.php";
+?>
+</body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/www/loc.php	Tue Jun 19 14:49:15 2007 +0000
@@ -0,0 +1,273 @@
+<?
+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;
+}
+
+
+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();
+
+$onlyPCities = isset($_GET["c"]);
+$showCoders = !isset($_GET["s"]);
+
+if (isset($_GET["a"])) {
+  $coderName = basename($_GET["a"]);
+}
+
+if (isset($_GET["n"])) {
+  $setName = 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);
+  }
+}
+
+
+function makeURL($pcities, $coders, $name, $desc, $class)
+{
+  $s = "";
+  if ($pcities) $s = "c";
+
+  if (!$coders) {
+    if ($s != "") $s .= "&amp;";
+    $s .= "s";
+  }
+
+  if (isset($name)) {
+    if ($s != "") $s .= "&amp;";
+    $s .= "n=".$name;
+  }
+  
+  if (isset($class))
+    echo "  <td class=\"".$class."\">";
+  else
+    echo "  <td>";
+    
+  echo "<a href=\"loc.php?".$s."\">".$desc."</a></td>\n";
+}
+
+/* Header
+ */
+echo "<h1>";
+if ($onlyPCities)
+  echo "Player cities";
+else
+  echo "Locations";
+echo " of ";
+if (isset($continentList[$setName]))
+  echo $continentList[$setName]." continent in ";
+echo "BatMUD";
+if (isset($coderName))
+  echo " by ".$coderName;
+echo "</h1>\n";
+
+echo "<table>\n <tr>\n";
+
+echo "  <td><a href=\"loc.php\">EVERYTHING</a></td>\n";
+
+if (!$onlyPCities) {
+  makeURL(TRUE, $showCoders, $setName, "PCities");
+  
+  if (!$showCoders)
+    makeURL($onlyPCities, TRUE, $setName, "Show Coders");
+  else
+    makeURL($onlyPCities, FALSE, $setName, "Hide Coders");
+} else {
+  makeURL(FALSE, $showCoders, $setName, "Locations");
+
+  if (!$showCoders)
+    makeURL($onlyPCities, TRUE, $setName, "Show SS");
+  else
+    makeURL($onlyPCities, FALSE, $setName, "Hide SS");
+}
+
+
+echo "  <td></td>\n";
+
+reset($continentList);
+while (list($iKey, $iValue) = each($continentList)) {
+  makeURL($onlyPCities, $showCoders, $iKey, $iValue, $iKey);
+}
+?>
+ </tr>
+</table>
+<p>
+[<a href="index.php">Back to main map page</a>]
+</p>
+<?
+/*
+if (isset($coderName)) {
+  echo "<a href=\"http://www.bat.org/help/finger.php?str=".$coderName."\">
+}
+
+if (isset($coderName)) {
+  $coderList = array(
+    "Kyo" => "http://www.bat.org/albums/album47/aav.jpg",
+    "" => "","
+  );
+  if (isset($coderList[$coderName])) {
+    echo "<img src=\"".$coderList[$coderName]."\" /><br />\n";
+  }
+}
+*/
+
+/* Print list of locations
+ */
+if (count($locTable) > 0) {
+
+  /* Make alphabetical table of locations
+   */
+  while (list($key, $value) = each($locTable)) {
+    if (isset($coderName)) {
+      if (array_search($coderName, $value["coders"]) !== FALSE) {
+        $alphaTable[$key[0]][] = $value;
+      }
+    } else {
+      $alphaTable[$key[0]][] = $value;
+    }
+  }
+
+  ksort($alphaTable, SORT_STRING);
+
+
+  /* Print locations per first character
+   */
+  $totalLoc = 0;
+  $maxRow = 6;
+  while (list($key, $value) = each($alphaTable)) {
+    if (count($value) > 0) {
+      asort($value);
+      echo "<a name=\"".strtolower($key)."\"></a><h3>".$key."</h3>\n";
+      echo "<table width=\"95%\">\n";
+      $n = 0;
+      while (list($ik, $iv) = each($value)) {
+        if ($n == 0) {
+          echo " <tr>\n";
+        }
+        
+        $totalLoc++;
+
+        printf("  <td width=\"%d%%\" class=\"%s\">",
+          (100 / $maxRow), $iv["continent"]);
+      
+        printURL($iv["continent"].".html#loc".$iv["x"]."_".$iv["y"]);
+      
+        echo $iv["name"]."</a>";
+        
+        if (count($iv["coders"]) > 0 && $showCoders) {
+          $fs = "";
+          while (list($fKey, $fVal) = each($iv["coders"])) {
+            if ($fs != "") $fs .= ", ";
+            if (!$onlyPCities)
+              $fs .= "<a href=\"loc.php?a=".$fVal."\">".$fVal."</a>";
+            else
+              $fs .= $fVal;
+          }
+          echo "<br />[".$fs."]";
+        }
+        
+        echo "</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>".$totalLoc."</b> locations.</p>\n";
+} else {
+  echo "<p><b>No locations known!</b></p>\n";
+}
+
+// Google Analytics
+require "../urchin.inc.php";
+?>
+</body>
+</html>