changeset 813:28825de98943

Sync.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 29 Aug 2009 13:48:12 +0000
parents 020e1d79aa0d
children 43c8ca88c740
files www/common.inc.php www/config.inc.php www/faq.xml www/index.php www/loc.php www/quests.php
diffstat 6 files changed, 54 insertions(+), 57 deletions(-) [+]
line wrap: on
line diff
--- a/www/common.inc.php	Sat Aug 29 12:39:05 2009 +0000
+++ b/www/common.inc.php	Sat Aug 29 13:48:12 2009 +0000
@@ -51,10 +51,9 @@
 {
   global $locationTypes;
   
-  $inFile = @fopen($filename.".loc", "r");
-  if (!$inFile) {
+  $inFile = @fopen(basename($filename.".loc"), "r");
+  if (!$inFile)
     return FALSE;
-  }
   
   while (!feof($inFile)) {
     $inLine = trim(fgets($inFile));
--- a/www/config.inc.php	Sat Aug 29 12:39:05 2009 +0000
+++ b/www/config.inc.php	Sat Aug 29 13:48:12 2009 +0000
@@ -6,6 +6,7 @@
 #$pageMapURL = "http://pet8032.tnsp.org/maps/";
 $pageMapURL = "http://tnsp.org/maps/";
 $jeskkoURL = "http://jeskko.pupunen.net/map/";
+$batQuestURL = "http://www.bat.org/help/quests?str=";
 $pageIndex = "index.php";
 
 $continentList = array(
--- a/www/faq.xml	Sat Aug 29 12:39:05 2009 +0000
+++ b/www/faq.xml	Sat Aug 29 13:48:12 2009 +0000
@@ -237,9 +237,9 @@
 
 <p>
 Currently this data is available through the Subversion repository of
-Ggr's MapUtils: <b>http://svn.pupunen.net/public/maputils/trunk/maps/</b>
+Ggr's MapUtils: <b>http://dev.pupunen.net/public/maputils/trunk/maps/</b>
 You may also be interested in the utilities themselves
-<b>http://svn.pupunen.net/public/maputils/trunk/</b> and especially the file
+<b>http://dev.pupunen.net/public/maputils/trunk/</b> and especially the file
 "README.loc", which contains some documentation on the format of
 *.loc-files.
 </p>
--- a/www/index.php	Sat Aug 29 12:39:05 2009 +0000
+++ b/www/index.php	Sat Aug 29 13:48:12 2009 +0000
@@ -24,13 +24,7 @@
 
 function printTR($n, $fileName, $mapName)
 {
-  echo " <tr class=\"";
-  if ($n & 1)
-    echo "line1";
-  else
-    echo "line2";
-  
-  echo "\">\n";
+  echo " <tr class=\"line".(($n & 1) + 1)."\">\n";
 
   if (file_exists($fileName.".html")) {
     echo "  <td>";
@@ -183,8 +177,7 @@
 printTR($n++, "hcbat", "HCBat map");
 echo "  <td>";
 printFileTD("hcbat.htm", "XHTML+JS", FALSE);
-echo "</td>\n";
-printFileTD("hcbat.ansi", "ANSI");
+echo "</td><td>[<a href=\"loc.php?n=hcbat\">Locations</a>] [<a href=\"loc.php?n=hcbat&amp;c\">PCities</a>]</td>\n";
 echo " </tr>\n";
 ?>
 </table>
--- a/www/loc.php	Sat Aug 29 12:39:05 2009 +0000
+++ b/www/loc.php	Sat Aug 29 13:48:12 2009 +0000
@@ -39,7 +39,13 @@
 } else {
   if (isset($_GET["f"]) && $_GET["f"] != "") {
     $filter = $_GET["f"];
-    $applyFilter = TRUE;
+    if (!preg_match("/^[A-Za-z]+\$/", $filter)) {
+      echo "<h1>Invalid filter rule '".htmlentities($filter)."'</h1>\n";
+      $filter = "C";
+      $applyFilter = FALSE;
+    } else {
+      $applyFilter = TRUE;
+    }
   } else {
     $filter = "CF";
     $applyFilter = FALSE;
@@ -60,7 +66,7 @@
   if (file_exists($setName.".loc")) {
     parseLocFile($setName, $locTable, $applyFilter, $filter);
   } else {
-    echo "<h1>No such continent ID!</h1>";
+    echo "<h1>No such continent ID!</h1>\n";
     unset($setName);
   }
 } else {
@@ -178,6 +184,7 @@
 if (count($locTable) > 0) {
   /* Make alphabetical table of locations
    */
+  $alphaTable = array();
   while (list($key, $value) = each($locTable)) {
     if (isset($_GET["nocoders"])) {
       if (count($value["coders"]) == 0 && !preg_match("/[SPG]/", $value["flags"]))
@@ -202,8 +209,8 @@
     if (count($value) > 0) {
       asort($value);
       
-      echo "<h3><a name=\"".strtolower($key)."\"></a>".$key."</h3>\n";
-      echo "<table class=\"loc\" width=\"95%\">\n";
+      echo "<h3><a name=\"".strtolower($key)."\"></a>".$key."</h3>\n".
+      "<table class=\"loc\" width=\"95%\">\n";
       $n = 0;
       while (list($ik, $iv) = each($value)) {
         if ($n == 0)
--- a/www/quests.php	Sat Aug 29 12:39:05 2009 +0000
+++ b/www/quests.php	Sat Aug 29 13:48:12 2009 +0000
@@ -2,16 +2,9 @@
 require "config.inc.php";
 require "common.inc.php";
 
-/* Page start
- */
 printPageHeader($pageTitle." - Quests");
-//echo "<div><b>DEVELOPMENT VERSION</b></div>";
-
 $locTable = readLocationFiles(FALSE);
 
-
-/* Header
- */
 ?>
 <h1>BatMUD Quests</h1>
 
@@ -30,6 +23,9 @@
 <br />
 </div>
 <?
+//========================================================================
+// Create quest data tables
+
 if (count($locTable) > 0) {
   $lqTable = array();
   $aqTable = array();
@@ -37,17 +33,12 @@
   reset($locTable);
   while (list($key, $value) = each($locTable)) {
     if (preg_match_all("/LQ([0-9]+) *\"([^\"]+)\"/", $value["freeform"], $matches, PREG_SET_ORDER)) {
-      
-      while (list($k, $v) = each($matches)) {
-        $level = intval($v[1]);
-        $lqTable[$level] = $value;
-        $lqTable[$level]["lqname"] = $v[2];
-      }
+      while (list($k, $v) = each($matches))
+        $lqTable[intval($v[1])][$v[2]] = $value;
     }
     if (preg_match_all("/AQ *\"([^\"]+)\"/", $value["freeform"], $matches, PREG_SET_ORDER)) {
-      while (list($k, $v) = each($matches)) {
+      while (list($k, $v) = each($matches))
         $aqTable[$v[1]] = $value;
-      }
     }
   }
   
@@ -55,6 +46,25 @@
   ksort($aqTable, SORT_STRING);
 }
 
+//========================================================================
+
+function printQuestData($name, &$area)
+{
+  global $batQuestURL, $specialList, $continentList;
+  echo
+  "<td><a href=\"".$batQuestURL.urlencode($name)."\">".htmlentities($name)."</a></td>".
+  "<td class=\"".$area["continent"]."\">";
+  if (isset($specialList[$area["continent"]]) && !$specialList[$area["continent"]][1]) {
+    echo "<b>".htmlentities($area["name"])."</b>";
+  } else {
+    printURL($area["continent"].".html#loc".$area["x"]."_".$area["y"]);
+    echo htmlentities($area["name"])."</a>";
+  }
+  echo "</td><td>".$continentList[$area["continent"]][0]."</td>";
+}
+
+//========================================================================
+
 echo
 "<table><tr><td valign=\"top\">\n".
 "<h2>Level Quests</h2>\n";
@@ -70,19 +80,13 @@
   "  <th>Continent</th>\n".
   " </tr>\n";
   
-  while (list($ik, $iv) = each($lqTable)) {
-    $totalLQ++;
-    echo
-    " <tr><td>".$ik."</td>".
-    "<td><a href=\"http://www.bat.org/help/quests?str=".urlencode($iv["lqname"])."\">".$iv["lqname"]."</a></td>".
-    "<td class=\"".$iv["continent"]."\">";
-    if (isset($specialList[$iv["continent"]]) && !$specialList[$iv["continent"]][1]) {
-      echo "<b>".htmlentities($iv["name"])."</b>";
-    } else {
-      printURL($iv["continent"].".html#loc".$iv["x"]."_".$iv["y"]);
-      echo htmlentities($iv["name"])."</a>";
+  while (list($level, $quests) = each($lqTable)) {
+    while (list($name, $area) = each($quests)) {
+      $totalLQ++;
+      echo " <tr><td>".$level."</td>";
+      printQuestData($name, $area);
+      echo "</tr>\n";
     }
-    echo "</td><td>".$continentList[$iv["continent"]][0]."</td></tr>\n";
   }
   echo "</table>\n".
   "<p><b>".$totalLQ."</b> level quests.</p>\n";
@@ -90,11 +94,11 @@
   echo "<p><b>No level quests known!</b></p>\n";
 }
 
+//========================================================================
 
 echo "</td><td valign=\"top\">\n".
 "<h2>Area Quests</h2>\n";
 
-
 if (count($aqTable) > 0) {
   $totalAQ = 0;
   echo
@@ -105,18 +109,11 @@
   "  <th>Continent</th>\n".
   " </tr>\n";
   
-  while (list($ik, $iv) = each($aqTable)) {
+  while (list($name, $area) = each($aqTable)) {
     $totalAQ++;
-    echo
-    " <tr><td><a href=\"http://www.bat.org/help/quests?str=".urlencode($ik)."\">".$ik."</a></td>".
-    "<td class=\"".$iv["continent"]."\">";
-    if (isset($specialList[$iv["continent"]]) && !$specialList[$iv["continent"]][1]) {
-      echo "<b>".htmlentities($iv["name"])."</b>";
-    } else {
-      printURL($iv["continent"].".html#loc".$iv["x"]."_".$iv["y"]);
-      echo htmlentities($iv["name"])."</a>";
-    }
-    echo "</td><td>".$continentList[$iv["continent"]][0]."</td></tr>\n";
+    echo "  <tr>";
+    printQuestData($name, $area);
+    echo "</tr>\n";
   }
   echo "</table>\n".
   "<p><b>".$totalAQ."</b> area quests.</p>\n";