Mercurial > hg > batmud > maputils
changeset 1620:6d620441af7f
Rename various functions, and other cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 08 Mar 2016 16:55:23 +0200 |
parents | 6e736c036eae |
children | 471fa81c6c67 |
files | www/common.inc.php www/index.php www/info.php www/latest.php www/level.php www/loc.php www/query.php www/quests.php www/ss.php |
diffstat | 9 files changed, 92 insertions(+), 99 deletions(-) [+] |
line wrap: on
line diff
--- a/www/common.inc.php Tue Mar 08 16:41:28 2016 +0200 +++ b/www/common.inc.php Tue Mar 08 16:55:23 2016 +0200 @@ -27,7 +27,7 @@ -function printPageHeader($title, $extra = "") +function mpPrintPageHeader($title, $extra = "") { cmPrintPageHeader($title, " <meta name=\"keywords\" content=\"batmud,map,laenor,lucentium,rothikgen,desolathya,furnachia,mud,mush,mmorpg,mmo,massively,multiplayer,online,network,game,ggr,pupunen\"/>\n". @@ -36,7 +36,7 @@ } -function fingerURL($name) +function mpFingerURL($name) { return "http://www.bat.org/char/".$name; } @@ -44,12 +44,12 @@ function burl($name) { -// echo "<a href=\"".fingerURL($name)."\">".$name."</a>"; - echo "<b>".$name."</b>"; +// return "<a href=\"".mpFingerURL($name)."\">".$name."</a>"; + return "<b>".$name."</b>"; } -function stGetURLLink($url, $name, $extra = FALSE) +function mpGetURLLink($url, $name, $extra = FALSE) { global $pageMapURL; return @@ -58,12 +58,12 @@ } -function stGetMapURLLink($data, $link, $name) +function mpGetMapURLLink($data, $link, $name) { global $pageGMapURL, $continentList; if ($link) { - $str = stGetURLLink($data["continent"].".html#loc".$data["x"]."_".$data["y"], $name, "class=\"mapLink\""); + $str = mpGetURLLink($data["continent"].".html#loc".$data["x"]."_".$data["y"], $name, "class=\"mapLink\""); $c = $continentList[$data["continent"]]; if ($c[4] == TRUE && $c[7] == TRUE) // hasmap & read regular cont must be true { @@ -78,20 +78,20 @@ } -function stGetMapLink($data, $link) +function mpGetMapLink($data, $link) { - return stGetMapURLLink($data, $link, $data["name"]); + return mpGetMapURLLink($data, $link, $data["name"]); } -function chsetconv($str) +function mpChConv($str) { global $pageCharset; return iconv("ISO-8859-1", $pageCharset, $str); } -function stAddLocNames(&$list, $input) +function mpAddLocNames(&$list, $input) { $list = array(); foreach ($input as $name) @@ -115,7 +115,7 @@ } -function stGetGlobalCoords($continent, $xc, $yc, &$gx, &$gy) +function mpGetGlobalCoords($continent, $xc, $yc, &$gx, &$gy) { global $continentList, $worldMap; if (isset($continentList[$continent])) @@ -129,7 +129,7 @@ } -function stParseLocFile($filename, &$locations, $applyFilter, $filter) +function mpParseLocFile($filename, &$locations, $applyFilter, $filter) { global $locationTypes; @@ -137,7 +137,7 @@ if (!$file) return FALSE; while (!feof($file)) { - $inLine = chsetconv(trim(fgets($file))); + $inLine = mpChConv(trim(fgets($file))); // Ignore comments and empty lines if (strlen($inLine) == 0 || $inLine[0] == "#") @@ -150,7 +150,7 @@ // Split coder names if (strlen($addInfo[0]) > 0) - stAddLocNames($coders, preg_split("/\s*,\s*/", $addInfo[0])); + mpAddLocNames($coders, preg_split("/\s*,\s*/", $addInfo[0])); else $coders = array(); @@ -185,7 +185,7 @@ if (($applyFilter && $filterMatch) || (!$applyFilter && !$filterMatch)) { // Get location names - stAddLocNames($names, preg_split("/\s*\|\s*/", $record[4])); + mpAddLocNames($names, preg_split("/\s*\|\s*/", $record[4])); // Check for duplicate locations $id = $rawflags.$names[0]["name"]; @@ -213,7 +213,7 @@ $ffreeform .= "This location is closed."; } - stGetGlobalCoords($filename, $record[1], $record[2], $glx, $gly); + mpGetGlobalCoords($filename, $record[1], $record[2], $glx, $gly); // Add location to array of locations $locations[$id] = array( @@ -245,7 +245,7 @@ } -function stReadLocationFiles($applyFilter = FALSE, $filter = "CF") +function mpReadLocationFiles($applyFilter = FALSE, $filter = "CF") { global $continentList; $locations = array(); @@ -253,14 +253,14 @@ foreach ($continentList as $id => $data) { if ($data[7]) - stParseLocFile($id, $locations, $applyFilter, $filter); + mpParseLocFile($id, $locations, $applyFilter, $filter); } return $locations; } -function stSubmitWizField(&$table, $field, $data) +function mpStoreWizInfoField(&$table, $field, $data) { $s = trim($data); if (strlen($s) > 0) @@ -268,7 +268,7 @@ } -function stSubmitWizInfo(&$table, $record) +function mpStoreWizInfoRecordInfo(&$table, $record) { $s = trim($record[1]); if (isset($table[$s])) @@ -279,9 +279,9 @@ else { $tmp = array("name" => $s, "areas" => 0); - stSubmitWizField($tmp, "homeURL", $record[2]); - stSubmitWizField($tmp, "imageURL", $record[3]); - stSubmitWizField($tmp, "desc", $record[4]); + mpStoreWizInfoField($tmp, "homeURL", $record[2]); + mpStoreWizInfoField($tmp, "imageURL", $record[3]); + mpStoreWizInfoField($tmp, "desc", $record[4]); if (count($tmp) > 1) $table[$s] = $tmp; @@ -291,7 +291,7 @@ } -function stParseWizInfoFile($filename, &$table) +function mpParseWizInfoFile($filename, &$table) { if (($file = @fopen($filename, "r")) === false) return FALSE; @@ -299,7 +299,7 @@ $contMode = FALSE; while (!feof($file)) { - $line = chsetconv(trim(fgets($file))); + $line = mpChConv(trim(fgets($file))); if (strlen($line) == 0 || $line[0] == "#") continue; @@ -310,13 +310,13 @@ { $record[4] .= " ".substr($line, 0, -1); $contMode = FALSE; - stSubmitWizInfo($table, $record); + mpStoreWizInfoRecordInfo($table, $record); } else $record[4] .= " ".$line; } else if (preg_match("/^([A-Z][a-z]+);(http:\/\/[^;]+|bat)?;([^;]+)?;([^\$]*)\\\$$/", $line, $record)) - stSubmitWizInfo($table, $record); + mpStoreWizInfoRecordInfo($table, $record); else if (preg_match("/^([A-Z][a-z]+);(http:\/\/[^;]+|bat)?;([^;]+)?;(.*)$/", $line, $record)) $contMode = TRUE; @@ -329,20 +329,20 @@ } -function stReadWizInfoFiles() +function mpReadWizInfoFiles() { global $wizFileList; $wizInfo = array(); foreach ($wizFileList as $id) - stParseWizInfoFile($id, $wizInfo); + mpParseWizInfoFile($id, $wizInfo); return $wizInfo; } -function stPrintExtraBoxAlphaList($prefix, $table, $class = FALSE) +function mpPrintExtraBoxAlphaList($prefix, $table, $class = FALSE) { echo "<div id=\"extrabox\"".($class !== FALSE ? " class=\"".$class."\"" : "").">\n";
--- a/www/index.php Tue Mar 08 16:41:28 2016 +0200 +++ b/www/index.php Tue Mar 08 16:55:23 2016 +0200 @@ -4,7 +4,7 @@ require "common.inc.php"; -function printFileTD($filename, $mapName, $useTD = TRUE, $filename2 = FALSE) +function mpPrintFileTD($filename, $mapName, $useTD = TRUE, $filename2 = FALSE) { if ($useTD) echo " <td>"; if (file_exists($filename)) @@ -12,7 +12,7 @@ $fileStat = stat($filename); $q = $fileStat[7]; - echo stGetURLLink($filename, $mapName).", <b>"; + echo mpGetURLLink($filename, $mapName).", <b>"; if ($q < 1024) printf("%d</b> bytes", $q); @@ -26,16 +26,16 @@ } -function printTR($n) +function mpPrintTR($n) { echo " <tr class=\"line".(($n & 1) + 1)."\">\n"; } -function printLine($n, $filename, $mapName, $noExtra = FALSE) +function mpPrintLine($n, $filename, $mapName, $noExtra = FALSE) { global $lastMTime; - printTR($n); + mpPrintTR($n); $fname = $filename.".loc"; if (file_exists($fname) && ($mtime = filemtime($fname)) > $lastMTime) @@ -47,21 +47,21 @@ { if (($mtime = filemtime($fname)) > $lastMTime) $lastMTime = $mtime; - echo stGetURLLink($fname, $mapName); + echo mpGetURLLink($fname, $mapName); } else echo " <td>".$mapName."</td>\n"; if (file_exists($filename.".htm")) - echo " ".stGetURLLink($filename.".htm", "*"); + echo " ".mpGetURLLink($filename.".htm", "*"); echo "</td>\n"; if ($noExtra) - printFileTD($filename.".map", "ASCII"); + mpPrintFileTD($filename.".map", "ASCII"); if (!$noExtra) { - printFileTD($filename.".png", "PNG"); - printFileTD($filename.".ansi", "ANSI"); + mpPrintFileTD($filename.".png", "PNG"); + mpPrintFileTD($filename.".ansi", "ANSI"); if (file_exists($filename.".loc")) { echo " <td>"; @@ -75,7 +75,7 @@ echo " </tr>\n"; } -printPageHeader($pageTitle, +mpPrintPageHeader($pageTitle, " <link rel=\"search\" type=\"application/opensearchdescription+xml\" href=\"/maps/opensearch.xml\" title=\"PupuMaps\" />\n" //." <script type=\"text/javascript\" src=\"search.js\"></script>\n" ); @@ -121,7 +121,7 @@ foreach ($continentList as $continent => $data) { if (!$data[3]) - printLine($n++, $continent, $data[0]); + mpPrintLine($n++, $continent, $data[0]); } echo @@ -136,27 +136,27 @@ " </tr>\n"; $n = 0; -printLine($n++, "arelium", "City of Arelium", TRUE); -printLine($n++, "calythien", "City of Calythien", 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); -printLine($n++, "renardy", "Renardy", TRUE); -printLine($n++, "tyr_farwyn", "Tyr Farwyn", TRUE); -printLine($n++, "dortlewall", "Village of Dortlewall", TRUE); -//printLine($n++, "tormentas", "Islas de Tormentas", TRUE); +mpPrintLine($n++, "arelium", "City of Arelium", TRUE); +mpPrintLine($n++, "calythien", "City of Calythien", TRUE); +mpPrintLine($n++, "lorenchia", "City of Lorenchia", TRUE); +mpPrintLine($n++, "rilynttar", "City of Rilynt'tar", TRUE); +mpPrintLine($n++, "esiris", "E'siris, the Ethereal City", TRUE); +mpPrintLine($n++, "votk", "Valley of the Kings", TRUE); +mpPrintLine($n++, "lanzia", "The Isle of Lanzia", TRUE); +mpPrintLine($n++, "faerieforest", "Faerie Forest", TRUE); +mpPrintLine($n++, "renardy", "Renardy", TRUE); +mpPrintLine($n++, "tyr_farwyn", "Tyr Farwyn", TRUE); +mpPrintLine($n++, "dortlewall", "Village of Dortlewall", TRUE); +//mpPrintLine($n++, "tormentas", "Islas de Tormentas", TRUE); -printLine($n++, "batcity", "Old BatCity map", TRUE); -printTR($n++); +mpPrintLine($n++, "batcity", "Old BatCity map", TRUE); +mpPrintTR($n++); echo " <td>". - stGetURLLink("hcbat.html", "HCBat map"). + mpGetURLLink("hcbat.html", "HCBat map"). " ". - stGetURLLink("hcbat.htm", "*"). + mpGetURLLink("hcbat.htm", "*"). "</td>\n". " <td>[<a href=\"loc.php?n=hcbat\">Locations</a>] ". "[<a href=\"loc.php?n=hcbat&c\">PCities</a>] ". @@ -165,7 +165,7 @@ " </tr>\n". "</table>\n". "<div>\n". - "<b>-- <a href=\"".fingerURL("ggr")."\">Ggr Pupunen</a>, master of carrots.</b>\n". + "<b>-- <a href=\"".mpFingerURL("ggr")."\">Ggr Pupunen</a>, master of carrots.</b>\n". "</div>\n". "</div>\n"; // end of <div id="contents">
--- a/www/info.php Tue Mar 08 16:41:28 2016 +0200 +++ b/www/info.php Tue Mar 08 16:55:23 2016 +0200 @@ -5,7 +5,7 @@ /* Page start */ -printPageHeader($pageTitle." - Wizards of the Realm"); +mpPrintPageHeader($pageTitle." - Wizards of the Realm"); require "menu.inc.php"; ?> @@ -24,7 +24,7 @@ <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). + incorrect. Sorry for that. Please report to <? echo burl("Ggr") ?>, if you have Knowledge(tm). </div> <hr /> <div style="text-align: center;"> @@ -40,24 +40,17 @@ $locTable = apc_fetch("info_locTable"); if (empty($locTable)) { - $locTable = stReadLocationFiles(); + $locTable = mpReadLocationFiles(); apc_store("info_locTable", $locTable, 3600); } $wizTable = apc_fetch("wizTable"); if (empty($wizTable)) { - $wizTable = stReadWizInfoFiles(); + $wizTable = mpReadWizInfoFiles(); apc_store("wizTable", $wizTable, 3600); } -if (isset($_GET["a"])) -{ - $coderName = basename($_GET["a"]); - $coderName = strtoupper(substr($coderName, 0, 1)).strtolower(substr($coderName, 1)); -} - - function wizardSort($a, $b) { return strcmp($a["name"], $b["name"]); @@ -136,7 +129,7 @@ echo "<p><b>".$totalWiz."</b> wizards.</p>\n"; // Print out the alpha link index - stPrintExtraBoxAlphaList("ch", $alphaTable); + mpPrintExtraBoxAlphaList("ch", $alphaTable); } else {
--- a/www/latest.php Tue Mar 08 16:41:28 2016 +0200 +++ b/www/latest.php Tue Mar 08 16:55:23 2016 +0200 @@ -3,11 +3,11 @@ require "world.inc.php"; require "common.inc.php"; -$locTable = stReadLocationFiles(FALSE); +$locTable = mpReadLocationFiles(FALSE); /* Page start */ -printPageHeader($pageTitle." - Latest added locations"); +mpPrintPageHeader($pageTitle." - Latest added locations"); //echo "<div><b>DEVELOPMENT VERSION</b></div>"; require "menu.inc.php"; @@ -86,7 +86,7 @@ echo " <tr>\n". " <td>".strftime("%d %b %Y", $iv["added"])."</td>\n". - " <td class=\"".$iv["continent"]."\">".stGetMapLink($iv, TRUE)."</td>\n". + " <td class=\"".$iv["continent"]."\">".mpGetMapLink($iv, TRUE)."</td>\n". " <td>".$continentList[$iv["continent"]][0]."</td>\n". " <td>".implode(", ", $fs)."</td>\n". " <td>".(isset($iv["freeform"]) ? chentities($iv["freeform"]) : "")."</td>\n".
--- a/www/level.php Tue Mar 08 16:41:28 2016 +0200 +++ b/www/level.php Tue Mar 08 16:55:23 2016 +0200 @@ -3,17 +3,17 @@ require "world.inc.php"; require "common.inc.php"; -printPageHeader($pageTitle." - Level limited areas"); +mpPrintPageHeader($pageTitle." - Level limited areas"); if (isset($_GET["hcbat"])) { $locTable = array(); - stParseLocFile("hcbat", $locTable, FALSE, "C"); + mpParseLocFile("hcbat", $locTable, FALSE, "C"); $hcbat = TRUE; } else { - $locTable = stReadLocationFiles(FALSE); + $locTable = mpReadLocationFiles(FALSE); $hcbat = FALSE; } @@ -65,7 +65,7 @@ echo " <tr>\n". " <td>". - stGetMapLink($loc, !isset($continentList[$loc["continent"]]) || $continentList[$loc["continent"]][4]). + mpGetMapLink($loc, !isset($continentList[$loc["continent"]]) || $continentList[$loc["continent"]][4]). "</td>\n". " <td>".($data["limit"] > 0 ? $data["limit"] : "?")."</td>\n". ($hcbat ? "" : " <td class=\"".$loc["continent"]."\">".$continentList[$loc["continent"]][0]."</td>").
--- a/www/loc.php Tue Mar 08 16:41:28 2016 +0200 +++ b/www/loc.php Tue Mar 08 16:55:23 2016 +0200 @@ -86,15 +86,15 @@ if (($tmpName = stGetRequestItem("a", FALSE, TRUE)) !== false) { - if (preg_match("#^([a-z]{1,15})#i", $tmpName, $m)) + if (preg_match("#^([a-z]{1,15})#i", $tmpName, $matches)) { - $coderName = $m[1]; + $coderName = $matches[1]; $coderName = strtoupper(substr($coderName, 0, 1)).strtolower(substr($coderName, 1)); $wizTable = apc_fetch("wizTable"); if (empty($wizTable)) { - $wizTable = stReadWizInfoFiles(); + $wizTable = mpReadWizInfoFiles(); apc_store("wizTable", $wizTable, 3600); } } @@ -115,7 +115,7 @@ if (empty($locTable)) { $locTable = []; - stParseLocFile($setName, $locTable, $applyFilter, $filter); + mpParseLocFile($setName, $locTable, $applyFilter, $filter); apc_store("loc_".$setName, $locTable, 3600); } } @@ -130,7 +130,7 @@ $locTable = apc_fetch("loc_locTable"); if (empty($locTable)) { - $locTable = stReadLocationFiles($applyFilter, $filter); + $locTable = mpReadLocationFiles($applyFilter, $filter); apc_store("loc_locTable", $locTable, 3600); } } @@ -138,7 +138,7 @@ /* Start of the page */ -printPageHeader($pageTitle." - Locations", +mpPrintPageHeader($pageTitle." - Locations", "<script type=\"text/javascript\" src=\"tooltip.js\"></script>\n". "<meta name=\"robots\" content=\"nofollow\" />\n"); @@ -242,7 +242,7 @@ } // Links, etc. - echo " [<a href=\"".fingerURL($coderName)."\">Finger</a>]\n"; + echo " [<a href=\"".mpFingerURL($coderName)."\">Finger</a>]\n"; if (qcheck($wizTable[$coderName], "homeURL", $s)) { @@ -339,7 +339,7 @@ printf(" <td class=\"%s\" style=\"width: %d%%\">", $iv["continent"], (100 / $maxRow)); - echo stGetMapLink($iv, $continentList[$iv["continent"]][4]); + echo mpGetMapLink($iv, $continentList[$iv["continent"]][4]); // If either freeform desc or URL field are set, we add those if (isset($iv["url"]) || isset($iv["freeform"])) @@ -446,7 +446,7 @@ } // Print out the alpha link index div - stPrintExtraBoxAlphaList("ch", $alphaTable); + mpPrintExtraBoxAlphaList("ch", $alphaTable); } else {
--- a/www/query.php Tue Mar 08 16:41:28 2016 +0200 +++ b/www/query.php Tue Mar 08 16:55:23 2016 +0200 @@ -12,7 +12,7 @@ global $locWebPage; if ($locWebPage) { - printPageHeader("Search results"); + mpPrintPageHeader("Search results"); require "menu.inc.php"; echo "<div id=\"contents\">\n". @@ -31,7 +31,7 @@ } // Read in location data, etc. -$locTable = stReadLocationFiles(FALSE, "Q"); +$locTable = mpReadLocationFiles(FALSE, "Q"); // Check arguments
--- a/www/quests.php Tue Mar 08 16:41:28 2016 +0200 +++ b/www/quests.php Tue Mar 08 16:55:23 2016 +0200 @@ -3,17 +3,17 @@ require "world.inc.php"; require "common.inc.php"; -printPageHeader($pageTitle." - Quests"); +mpPrintPageHeader($pageTitle." - Quests"); if (isset($_GET["hcbat"])) { $locTable = array(); - stParseLocFile("hcbat", $locTable, FALSE, "C"); + mpParseLocFile("hcbat", $locTable, FALSE, "C"); $hcbat = TRUE; } else { - $locTable = stReadLocationFiles(FALSE); + $locTable = mpReadLocationFiles(FALSE); $hcbat = FALSE; } @@ -24,7 +24,7 @@ echo "<td><a href=\"".$batQuestURL.urlencode($name)."\">".chentities($name)."</a></td>". "<td class=\"".$area["continent"]."\">". - stGetMapLink($area, !isset($continentList[$area["continent"]]) || $continentList[$area["continent"]][4]). + mpGetMapLink($area, !isset($continentList[$area["continent"]]) || $continentList[$area["continent"]][4]). "</td>". ($hcbat ? "" : "<td>".$continentList[$area["continent"]][0]."</td>"); }
--- a/www/ss.php Tue Mar 08 16:41:28 2016 +0200 +++ b/www/ss.php Tue Mar 08 16:55:23 2016 +0200 @@ -6,13 +6,13 @@ $locTable = apc_fetch("ss_locTable"); if (empty($locTable)) { - $locTable = stReadLocationFiles(TRUE, "C", TRUE); - stParseLocFile("limbo", $locTable, TRUE, "C"); + $locTable = mpReadLocationFiles(TRUE, "C", TRUE); + mpParseLocFile("limbo", $locTable, TRUE, "C"); apc_store("ss_locTable", $locTable, 3600); } // Page start -printPageHeader($pageTitle." - Secret societies"); +mpPrintPageHeader($pageTitle." - Secret societies"); require "menu.inc.php"; @@ -55,8 +55,8 @@ $link = $continentList[$cont][4]; echo " <tr>\n". - " <td>".stGetMapURLLink($data, $link, $name)."</td>\n". - " <td class=\"".$cont."\">".stGetMapLink($data, $link)."</td>\n". + " <td>".mpGetMapURLLink($data, $link, $name)."</td>\n". + " <td class=\"".$cont."\">".mpGetMapLink($data, $link)."</td>\n". " <td>".chentities($continentList[$cont][0])."</td>\n". " </tr>\n"; }