Mercurial > hg > batmud > maputils
changeset 1911:1e65d3dd91c8
Get rid of the OpenSearch stuff.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 06 Nov 2017 20:41:59 +0200 |
parents | 597cfb985659 |
children | fd642a09c8db |
files | www/index.php www/opensearch.xml www/query.php |
diffstat | 3 files changed, 1 insertions(+), 187 deletions(-) [+] |
line wrap: on
line diff
--- a/www/index.php Mon Nov 06 15:48:02 2017 +0200 +++ b/www/index.php Mon Nov 06 20:41:59 2017 +0200 @@ -98,10 +98,7 @@ echo " </tr>\n"; } -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" -); +mpPrintPageHeader($pageTitle); echo "<h1>".$pageTitle."</h1>\n". @@ -116,8 +113,6 @@ "including maps of the continents, some areas and cities. As an alternative\n". "for the continent maps, ".burl("Jeskko")." has an interesting\n". "<a href=\"".$pageGMapURL."\">Google Maps-style world map</a>.\n". - "You can also add <a href=\"#\" onclick=\"window.external.AddSearchProvider('/maps/opensearch.xml');\">PupuMaps Search Engine</a>\n". - "to your browser.\n". "<p>\n". "The ANSI files are maps rendered as ASCII text with ANSI colour codes, UNIX users\n". "can apply the familiar less(1) utility to view them, assuming their less supports\n".
--- a/www/opensearch.xml Mon Nov 06 15:48:02 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/"> - <ShortName>PupuMaps</ShortName> - <Description>PupuMaps BatMUD map location search</Description> - <Contact>ccr@tnsp.org</Contact> - <Image height="16" width="16" type="image/x-icon">http://tnsp.org/maps/favicon.ico</Image> - <Url type="text/html" method="get" template="http://www.tnsp.org/maps/query.php?q={searchTerms}" /> - <Url type="application/x-suggestions+json" method="get" template="http://www.tnsp.org/maps/query.php?os&q={searchTerms}" /> - <Developer>PupuMaps and TNSP</Developer> - <SyndicationRight>open</SyndicationRight> - <AdultContent>false</AdultContent> - <Language>en-us</Language> - <OutputEncoding>UTF-8</OutputEncoding> - <InputEncoding>UTF-8</InputEncoding> -</OpenSearchDescription> \ No newline at end of file
--- a/www/query.php Mon Nov 06 15:48:02 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,166 +0,0 @@ -<?php -// -// PupuMaps OpenSearch database query code. -// This is a rather ugly blob of glue, but it works. -// -require "config.inc.php"; -require "world.inc.php"; -require "common.inc.php"; - -function myerr() -{ - global $locWebPage; - if ($locWebPage) - { - mpPrintPageHeader("Search results"); - echo - "<h1>Search results</h1>\n". - "<p>Location not found.</p>\n". - "</div>\n". - "</body>\n". - "</html>\n"; - } - else - { - header("Status: 404 Not Found"); - echo "Location not found."; - } - exit; -} - -// Read in location data, etc. -$locTable = mpReadLocationFiles(FALSE, "Q"); - - -// Check arguments -$locDebug = isset($_GET["debug"]); -$locWebPage = isset($_GET["web"]); -$locExactMatch = isset($_GET["exact"]); -$locJSMap = isset($_GET["js"]); -$locOpenSearch = isset($_GET["os"]); - -if (isset($argv[0])) - $locName = stripslashes($argv[0]); -else -if (isset($_GET["q"])) - $locName = stripslashes($_GET["q"]); - -if (!isset($locName)) - myerr(); - -$locRegEx = "/".preg_quote($locName, "/")."/i"; -$locFound = FALSE; - - -// -// OpenSearch mode? -// -if ($locOpenSearch) -{ - header("Content-Type: application/json; charset=".$pageCharset); - $locResult = array(); - - // Get all names into associative array - foreach ($locTable as $data) - { - $match = FALSE; - foreach ($data["names"] as $n) - { - if (preg_match($locRegEx, $n["name"])) - $locResult[$n["name"]] = 1; - } - - if (preg_match($locRegEx, $data["name"])) - $locResult[$data["name"]] = 2; - } - - // Format output - $str = array_map(function($value) { return "\"".addslashes($value)."\""; }, array_keys($locResult)); - echo "[\"".$locName."\",[".implode(",", $str)."]]"; -} -else -// -// Match location exactly (non-case sensitive tho) -// -{ - foreach ($locTable as $id => $data) - { - if (!strcasecmp($locName, $data["name"])) - { - $locFound = TRUE; - } - else - { - foreach ($data["names"] as $n) - { - if (!strcasecmp($locName, $n["name"])) - { - $locFound = TRUE; - break; - } - } - } - - if ($locFound) - { - $locData = $data; - break; - } - } - - if ($locDebug && $locFound) - { - echo "Exact match: '".$locName."' -> ".var_export($locData, TRUE)."\n"; - } - - - // If not exact matching mode specified, try non-exact also - if (!$locExactMatch && !$locFound) - { - foreach ($locTable as $id => $data) - { - if (preg_match($locRegEx, $data["name"])) - $locFound = TRUE; - else - { - foreach ($data["names"] as $n) - if (preg_match($locRegEx, $n["name"])) - { - $locFound = TRUE; - break; - } - } - if ($locFound) - { - $locData = $data; - break; - } - } - - if ($locDebug && $locFound) - { - echo "Non-Exact match: '".$locName."' -> ".var_export($locData, TRUE)."\n"; - } - } - - // Set result - if ($locFound) - { - header("Location: ".$pageMapURL.$locData["continent"].".". - ($locJSMap ? "htm" : "html"). - "#loc".$locData["x"]."_".$locData["y"]); - - if ($locDebug) - { - echo("Location: ".$pageMapURL.$locData["continent"].".". - ($locJSMap ? "htm" : "html"). - "#loc".$locData["x"]."_".$locData["y"]); - } - } - else - myerr(); -} - -if ($locDebug) - echo "\n\n"; -?> \ No newline at end of file