]> git.openstreetmap.org Git - nominatim.git/commitdiff
Change access control to implement more of CORS. Change so OPTIONS requests don...
authorBrian Quinion <openstreetmap@brian.quinion.co.uk>
Mon, 17 Dec 2012 00:24:58 +0000 (00:24 +0000)
committerBrian Quinion <openstreetmap@brian.quinion.co.uk>
Mon, 17 Dec 2012 00:25:06 +0000 (00:25 +0000)
lib/init-website.php
lib/template/address-xml.php
lib/template/search-json.php
lib/template/search-xml.php
osm2pgsql
settings/settings.php
website/reverse.php

index 8603e309f426f888bb8bd1834ee8a6b86be75736..94dba6f4a15599675da89c7e484a334692035b39 100644 (file)
@@ -1,6 +1,14 @@
 <?php
        require_once('init.php');
 
+       if (CONST_NoAccessControl)
+       {
+               header("Access-Control-Allow-Origin: *");
+               header("Access-Control-Allow-Methods: OPTIONS,GET");
+               header("Access-Control-Allow-Headers: ".$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']);
+       }
+       if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') exit;
+
        if (CONST_ClosedForIndexing && strpos(CONST_ClosedForIndexingExceptionIPs, ','.$_SERVER["REMOTE_ADDR"].',') === false)
        {
                echo "Closed for re-indexing...";
index fcd90b85e63cc6b9ea55c2accde01763244bebfa..9989bb31aa0a515ffe508f3aef4a68be5563ee59 100644 (file)
@@ -1,6 +1,5 @@
 <?php
        header("content-type: text/xml; charset=UTF-8");
-       header("Access-Control-Allow-Origin: *");
 
        echo "<";
        echo "?xml version=\"1.0\" encoding=\"UTF-8\" ?";
@@ -29,7 +28,7 @@
                if (isset($aPlace['lon'])) echo ' lon="'.htmlspecialchars($aPlace['lon']).'"';
                echo ">".htmlspecialchars($aPlace['langaddress'])."</result>";
 
-        if ($bShowAddressDetails) {
+               if ($bShowAddressDetails) {
                        echo "<addressparts>";
                        foreach($aAddress as $sKey => $sValue)
                        {
@@ -39,7 +38,7 @@
                                echo "</$sKey>";
                        }
                        echo "</addressparts>";
-        }
+               }
        }
-       
+
        echo "</reversegeocode>";
index 45272d3540dc822511148b3bd1b5bcfb6ef80075..4b3b279d77362c2b9dec8d4ff4a6d411587f82bc 100644 (file)
@@ -1,4 +1,6 @@
 <?php
+       header("content-type: application/json; charset=UTF-8");
+
        $aFilteredPlaces = array();
        foreach($aSearchResults as $iResNum => $aPointDetails)
        {
index fa6b14a37af693515b52473f071822fdb8172d78..aa029d2bb142bcd9fc4b16660e512c4f63063c85 100644 (file)
@@ -1,6 +1,5 @@
 <?php
        header("content-type: text/xml; charset=UTF-8");
-       header("Access-Control-Allow-Origin: *");
 
        echo "<";
        echo "?xml version=\"1.0\" encoding=\"UTF-8\" ?";
index efe87e2740349bdda46dfc44f7806b9f6bc40a3d..3586caa0936e052ec14a7172769df4b3b4da2d08 160000 (submodule)
--- a/osm2pgsql
+++ b/osm2pgsql
@@ -1 +1 @@
-Subproject commit efe87e2740349bdda46dfc44f7806b9f6bc40a3d
+Subproject commit 3586caa0936e052ec14a7172769df4b3b4da2d08
index 58463a516c2a28cbe147a92e7f92e56a186f1abd..cd97b4a76fd7c9feda9ba19278df5c7880b394d6 100644 (file)
@@ -37,6 +37,7 @@
        }
 
        // Website settings
+       @define('CONST_NoAccessControl', true);
        @define('CONST_ClosedForIndexing', false);
        @define('CONST_ClosedForIndexingExceptionIPs', '');
        @define('CONST_BlockedIPs', '');
index d5a36998efd4143a7513dc6f5f8a30797f9e4aab..1cdbf46754f1f6bdcbea1367b195fcde94ef78dd 100755 (executable)
                $sSQL .= " get_name_by_language(name, ARRAY['ref']) as ref,";
                $sSQL .= " st_y(st_centroid(geometry)) as lat, st_x(st_centroid(geometry)) as lon";
                $sSQL .= " from placex where place_id = $iPlaceID ";
-//var_dump($sSQL);
+
                $aPlace = $oDB->getRow($sSQL);
+//var_dump($sSQL, $aPlace); exit;
 
                if ($bShowAddressDetails)
                {