[Mapbender-commits] r9118 - trunk/mapbender/http/php

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Oct 29 05:50:02 PDT 2014


Author: armin11
Date: 2014-10-29 05:50:02 -0700 (Wed, 29 Oct 2014)
New Revision: 9118

Modified:
   trunk/mapbender/http/php/mod_inspireDownloadFeed.php
Log:
Bugfix for GDI-DE Testsuite - don't use URLs with /../ pathes any longer

Modified: trunk/mapbender/http/php/mod_inspireDownloadFeed.php
===================================================================
--- trunk/mapbender/http/php/mod_inspireDownloadFeed.php	2014-10-29 12:15:20 UTC (rev 9117)
+++ trunk/mapbender/http/php/mod_inspireDownloadFeed.php	2014-10-29 12:50:02 UTC (rev 9118)
@@ -37,6 +37,8 @@
 
 $admin = new administration();
 $mapbenderPath = MAPBENDER_PATH."/";
+$mapbenderPathArray = parse_url($mapbenderPath);
+$mapbenderServerUrl = $mapbenderPathArray['scheme']."://".$mapbenderPathArray['host'];
 
 $imageResolution = 300;
 
@@ -306,9 +308,9 @@
 
 
 function answerOpenSearchRequest () {
-	global $admin, $type, $mapbenderMetadata, $indexMapbenderMetadata, $layerId, $wfsId, $mapbenderPath, $epsgId, $alterAxisOrder, $departmentMetadata, $userMetadata, $hasPermission, $m, $crs, $crsUpper, $countRessource, $furtherLink, $osDatasetIdentifier, $osQuery, $osDatasetNamespace, $osCrs, $osLanguage, $osRequest;
+	global $admin, $type, $mapbenderMetadata, $indexMapbenderMetadata, $layerId, $wfsId, $mapbenderPath, $mapbenderServerUrl, $epsgId, $alterAxisOrder, $departmentMetadata, $userMetadata, $hasPermission, $m, $crs, $crsUpper, $countRessource, $furtherLink, $osDatasetIdentifier, $osQuery, $osDatasetNamespace, $osCrs, $osLanguage, $osRequest;
 	//service feed url
-	$serviceFeed = delTotalFromQuery("getopensearch",$mapbenderPath."..".$_SERVER['REQUEST_URI']);//delete GETOPENSEARCH
+	$serviceFeed = delTotalFromQuery("getopensearch",$mapbenderServerUrl.$_SERVER['REQUEST_URI']);//delete GETOPENSEARCH
 	$serviceFeed = delTotalFromQuery("OPENSEARCH",$serviceFeed);
 	//echo $serviceFeed;
 	//die();
@@ -438,7 +440,7 @@
 
 
 function generateOpenSearchDescription($feedDoc, $recordId, $generateFrom) {
-	global $admin, $type, $mapbenderMetadata, $indexMapbenderMetadata, $layerId, $wfsId, $mapbenderPath, $epsgId, $alterAxisOrder, $departmentMetadata, $userMetadata, $hasPermission, $m, $crs, $crsUpper, $countRessource, $numberOfTiles;
+	global $admin, $type, $mapbenderMetadata, $indexMapbenderMetadata, $layerId, $wfsId, $mapbenderPath, $mapbenderServerUrl, $epsgId, $alterAxisOrder, $departmentMetadata, $userMetadata, $hasPermission, $m, $crs, $crsUpper, $countRessource, $numberOfTiles;
 	switch ($generateFrom) {
 				case "dataurl":
 					$mimetype = $formatsMimetype[$mapbenderMetadata[$m]->format];
@@ -474,33 +476,33 @@
 	$urlSelf = $feedDoc->createElement("Url");
 	$urlSelf->setAttribute("type", "application/opensearchdescription+xml");
 	$urlSelf->setAttribute("rel", "self");
-	$urlSelf->setAttribute("template", $mapbenderPath."..".$_SERVER['REQUEST_URI']);
+	$urlSelf->setAttribute("template", $mapbenderServerUrl.$_SERVER['REQUEST_URI']);
 	$feed->appendChild($urlSelf);
 	//Url - results Atom
 	$urlSelf = $feedDoc->createElement("Url");
 	$urlSelf->setAttribute("type", "application/atom+xml");
 	$urlSelf->setAttribute("rel", "results");
-	$urlSelf->setAttribute("template", str_replace("=SERVICE&","=DATASET&",$mapbenderPath."..".$_SERVER['REQUEST_URI'])."&OPENSEARCH=true&q={searchTerms}");
+	$urlSelf->setAttribute("template", str_replace("=SERVICE&","=DATASET&",$mapbenderServerUrl.$_SERVER['REQUEST_URI'])."&OPENSEARCH=true&q={searchTerms}");
 	$feed->appendChild($urlSelf);
 	//Url - describedby
 	$urlDescribedby = $feedDoc->createElement("Url");
 	$urlDescribedby->setAttribute("type", "application/atom+xml");
 	$urlDescribedby->setAttribute("rel", "describedby");
 	//see documentation
-	$urlDescribedby->setAttribute("template", str_replace("=SERVICE&","=DATASET&",$mapbenderPath."..".$_SERVER['REQUEST_URI'])."&OPENSEARCH=true&request=DescribeSpatialDataset&spatial_dataset_identifier_code={inspire_dls:spatial_dataset_identifier_code?}&spatial_dataset_identifier_namespace={inspire_dls:spatial_dataset_identifier_namespace?}&crs={inspire_dls:crs?}&language={language?}&q={searchTerms?}");
-	//$urlDescribedby->setAttribute("template", str_replace("=SERVICE&","=DATASET&",$mapbenderPath."..".$_SERVER['REQUEST_URI']));
+	$urlDescribedby->setAttribute("template", str_replace("=SERVICE&","=DATASET&",$mapbenderServerUrl.$_SERVER['REQUEST_URI'])."&OPENSEARCH=true&request=DescribeSpatialDataset&spatial_dataset_identifier_code={inspire_dls:spatial_dataset_identifier_code?}&spatial_dataset_identifier_namespace={inspire_dls:spatial_dataset_identifier_namespace?}&crs={inspire_dls:crs?}&language={language?}&q={searchTerms?}");
+	//$urlDescribedby->setAttribute("template", str_replace("=SERVICE&","=DATASET&",$mapbenderServerUrl.$_SERVER['REQUEST_URI']));
 	$feed->appendChild($urlDescribedby);
 	//Url - results single part (e.g. zipfile)
 	$urlResults = $feedDoc->createElement("Url");
 	$urlResults->setAttribute("type", $mimetype);//TODO give reasonable format!! - mimetypes??? geotiff/gml/other - see format of metadata
 	$urlResults->setAttribute("rel", "results");
-	$urlResults->setAttribute("template", str_replace("=SERVICE&","=DATASET&",$mapbenderPath."..".$_SERVER['REQUEST_URI'])."&OPENSEARCH=true&request=GetSpatialDataset&spatial_dataset_identifier_code={inspire_dls:spatial_dataset_identifier_code?}&spatial_dataset_identifier_namespace={inspire_dls:spatial_dataset_identifier_namespace?}&crs={inspire_dls:crs?}&language={language?}&q={searchTerms?}");
+	$urlResults->setAttribute("template", str_replace("=SERVICE&","=DATASET&",$mapbenderServerUrl.$_SERVER['REQUEST_URI'])."&OPENSEARCH=true&request=GetSpatialDataset&spatial_dataset_identifier_code={inspire_dls:spatial_dataset_identifier_code?}&spatial_dataset_identifier_namespace={inspire_dls:spatial_dataset_identifier_namespace?}&crs={inspire_dls:crs?}&language={language?}&q={searchTerms?}");
 	$feed->appendChild($urlResults);
 	//for firefox?
 	$urlResults = $feedDoc->createElement("Url");
 	$urlResults->setAttribute("type", "text/html");//TODO give reasonable format!! - mimetypes??? geotiff/gml/other - see format of metadata - see https://developer.mozilla.org/de/docs/OpenSearch_Plugin_f%C3%BCr_Firefox_erstellen
 	$urlResults->setAttribute("rel", "results");
-	$urlResults->setAttribute("template", str_replace("=SERVICE&","=DATASET&",$mapbenderPath."..".$_SERVER['REQUEST_URI'])."&OPENSEARCH=true&request=GetSpatialDataset&spatial_dataset_identifier_code={inspire_dls:spatial_dataset_identifier_code?}&spatial_dataset_identifier_namespace={inspire_dls:spatial_dataset_identifier_namespace?}&crs={inspire_dls:crs?}&language={language?}&q={searchTerms?}");
+	$urlResults->setAttribute("template", str_replace("=SERVICE&","=DATASET&",$mapbenderServerUrl.$_SERVER['REQUEST_URI'])."&OPENSEARCH=true&request=GetSpatialDataset&spatial_dataset_identifier_code={inspire_dls:spatial_dataset_identifier_code?}&spatial_dataset_identifier_namespace={inspire_dls:spatial_dataset_identifier_namespace?}&crs={inspire_dls:crs?}&language={language?}&q={searchTerms?}");
 	$feed->appendChild($urlResults);
 
 	//Url -results multi part
@@ -508,7 +510,7 @@
 	$urlResults = $feedDoc->createElement("Url");
 	$urlResults->setAttribute("type", "application/atom");
 	$urlResults->setAttribute("rel", "results");
-	$urlResults->setAttribute("template", $mapbenderPath."..".$_SERVER['SCRIPT_NAME']."?spatial_dataset_identifier_code={inspire_dls:spatial_dataset_identifier_code?}&spatial_dataset_identifier_namespace={inspire_dls:spatial_dataset_identifier_namespace?}&crs={inspire_dls:crs?}&language={language?}&q={searchTerms?}");
+	$urlResults->setAttribute("template", $mapbenderServerUrl.$_SERVER['SCRIPT_NAME']."?spatial_dataset_identifier_code={inspire_dls:spatial_dataset_identifier_code?}&spatial_dataset_identifier_namespace={inspire_dls:spatial_dataset_identifier_namespace?}&crs={inspire_dls:crs?}&language={language?}&q={searchTerms?}");
 	$feed->appendChild($urlResults);
 	*/
 	//Metadata for OpenSearch
@@ -564,7 +566,7 @@
 
 
 function readInfoFromDatabase($recordId, $generateFrom){
-	global $admin, $type, $mapbenderMetadata, $indexMapbenderMetadata, $layerId, $wfsId, $mapbenderPath, $epsgId, $alterAxisOrder, $departmentMetadata, $userMetadata, $hasPermission, $m, $crs, $crsUpper, $countRessource;
+	global $admin, $type, $mapbenderMetadata, $indexMapbenderMetadata, $layerId, $wfsId, $mapbenderPath, $mapbenderServerUrl, $epsgId, $alterAxisOrder, $departmentMetadata, $userMetadata, $hasPermission, $m, $crs, $crsUpper, $countRessource;
 	
 	switch ($generateFrom) {
 		case "dataurl":
@@ -791,7 +793,7 @@
 // - 
 
 function generateFeed($feedDoc, $recordId, $generateFrom) {
-	global $admin, $type, $imageResolution, $maxImageSize, $maxFeatureCount, $mapbenderMetadata, $indexMapbenderMetadata, $layerId, $wfsId, $mapbenderPath, $epsgId, $alterAxisOrder, $departmentMetadata, $userMetadata, $hasPermission, $m, $crs, $crsUpper,$countRessource, $numberOfTiles, $furtherLink;
+	global $admin, $type, $imageResolution, $maxImageSize, $maxFeatureCount, $mapbenderMetadata, $indexMapbenderMetadata, $layerId, $wfsId, $mapbenderPath, $mapbenderServerUrl, $epsgId, $alterAxisOrder, $departmentMetadata, $userMetadata, $hasPermission, $m, $crs, $crsUpper,$countRessource, $numberOfTiles, $furtherLink;
 	//caching feeds in apc cache
 	//check age of information to allow caching of atom feeds
 	/*$e = new mb_exception("mod_inspireDownloadFeed.php: wms_timestamp: ".date("Y-m-d H:i:s",$mapbenderMetadata[$m]->wms_timestamp));
@@ -923,7 +925,7 @@
 
 	//self reference - 5.1.4 / 5.2
 	if ($type == 'SERVICE') {
-		$selfReference = $mapbenderPath."..".$_SERVER['SCRIPT_NAME']."?ID=".$recordId."&type=SERVICE&generatefrom=".$generateFrom;
+		$selfReference = $mapbenderServerUrl.$_SERVER['SCRIPT_NAME']."?ID=".$recordId."&type=SERVICE&generatefrom=".$generateFrom;
 		switch($generateFrom) {
 			case "wmslayer":
 				$selfReference .= "&layerid=".$mapbenderMetadata[$m]->layer_id;
@@ -933,7 +935,7 @@
 			break;
 		}
 	} else { //DATASET
-		$selfReference = $mapbenderPath."..".$_SERVER['SCRIPT_NAME']."?ID=".$recordId."&type=DATASET&generatefrom=".$generateFrom;
+		$selfReference = $mapbenderServerUrl.$_SERVER['SCRIPT_NAME']."?ID=".$recordId."&type=DATASET&generatefrom=".$generateFrom;
 		switch($generateFrom) {
 			case "wmslayer":
 				$selfReference .= "&layerid=".$mapbenderMetadata[$m]->layer_id;
@@ -956,7 +958,7 @@
 	//opensearch descriptionlink 5.1.5
 	if ($type == 'SERVICE') {
 		$feedLink = $feedDoc->createElement("link");
-		$feedLink->setAttribute("href", $mapbenderPath."..".$_SERVER['SCRIPT_NAME']."?id=".$recordId."&type=".$type."&generateFrom=".$generateFrom."&wfsid=".$wfsId."&layerid=".$layerId."&getopensearch=true");
+		$feedLink->setAttribute("href", $mapbenderServerUrl.$_SERVER['SCRIPT_NAME']."?id=".$recordId."&type=".$type."&generateFrom=".$generateFrom."&wfsid=".$wfsId."&layerid=".$layerId."&getopensearch=true");
 		$feedLink->setAttribute("rel", "search");
 		$feedLink->setAttribute("type", "application/opensearchdescription+xml");
 		//$feedLink->setAttribute("hreflang", "de");
@@ -1395,7 +1397,7 @@
 		//or link to dataset 5.2.3
 		//<link rel="alternate" href="http://xyz.org/data/abc/waternetwork_WGS84.shp" type="application/x-shp" hreflang="en" title="Water Network encoded as a ShapeFile in WGS84geographic coordinates (http://www.opengis.net/def/crs/OGC/1.3/CRS84)"/>
 			
-		$datasetFeedLink = $mapbenderPath."..".$_SERVER['SCRIPT_NAME']."?id=".$recordId."&type=DATASET&generatefrom=".$mapbenderMetadata[$i]->origin;
+		$datasetFeedLink = $mapbenderServerUrl.$_SERVER['SCRIPT_NAME']."?id=".$recordId."&type=DATASET&generatefrom=".$mapbenderMetadata[$i]->origin;
 		switch($mapbenderMetadata[$i]->origin) {
 			case "wmslayer":
 				$datasetFeedLink .= "&layerid=".$mapbenderMetadata[$i]->layer_id;



More information about the Mapbender_commits mailing list