[Mapbender-commits] r8762 - in trunk/mapbender: conf http/geoportal

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon Jan 27 23:09:12 PST 2014


Author: armin11
Date: 2014-01-27 23:09:12 -0800 (Mon, 27 Jan 2014)
New Revision: 8762

Modified:
   trunk/mapbender/conf/mapbender.conf-dist
   trunk/mapbender/http/geoportal/mod_readCSWResults.php
Log:
Bugfix and new mapbender.conf for memcached configuration

Modified: trunk/mapbender/conf/mapbender.conf-dist
===================================================================
--- trunk/mapbender/conf/mapbender.conf-dist	2014-01-27 22:24:41 UTC (rev 8761)
+++ trunk/mapbender/conf/mapbender.conf-dist	2014-01-28 07:09:12 UTC (rev 8762)
@@ -252,6 +252,12 @@
 #define("MAPBENDER_VARIABLE_CACHE", false);
 #define("MAPBENDER_CACHE_TYPE", "apc");
 
+# define memcached server connections, if memcached ist used for session storing
+# lib/class_Mapbender_session.php
+#
+#define("MEMCACHED_IP", "localhost");
+#define("MEMCACHED_PORT", "11211");
+
 #---------------------------------------------
 # HOSTNAME WHITELIST
 # The whitelist is used for some modules who generate urls from a given hostName GET parameter. In such a case it is usefull to give a whitelist for security reasons! If no hostName is given, the parameter $_SERVER['HTTP_HOST'] is used for the urls!

Modified: trunk/mapbender/http/geoportal/mod_readCSWResults.php
===================================================================
--- trunk/mapbender/http/geoportal/mod_readCSWResults.php	2014-01-27 22:24:41 UTC (rev 8761)
+++ trunk/mapbender/http/geoportal/mod_readCSWResults.php	2014-01-28 07:09:12 UTC (rev 8762)
@@ -1,3 +1,4 @@
+
 <?php
 //
 require_once(dirname(__FILE__)."/../../core/globalSettings.php");
@@ -6,6 +7,8 @@
 //Script to read Results from CSW 2.0.2 Interfaces from mapbender geoportal
 //example requests:
 //GetRecords with textfilter
+
+
 /*gp_csw
 
 CREATE TABLE gp_csw (
@@ -24,8 +27,8 @@
 select param_value from cat_op_conf where fk_cat_id=2 and param_type='getrecords';
 
 select param_value from cat_op_conf where fk_cat_id=2 and param_type='getrecordsbyid';*/
-$resdir = TMPDIR;
-//$resdir = "/data/mapbender/http/tmp/";
+//$resdir = TMPDIR;
+$resdir = "/data/mapbender/http/tmp/";
 $con = db_connect(DBSERVER,OWNER,PW);
 db_select_db(DB,$con);
 
@@ -43,39 +46,36 @@
 #if it came from cli, use output to tmp folder - > typo3 would find it and will show it in template, there should be an identifier from the gaz.php script which controls the different search moduls
 #if it came as http request it should generate its own html window
 #Maybe problematic: if requested from command-line, how would mapbender get the content? Should be tested.
-#check if requested as cli
-if(isset($_REQUEST["type"]) && $_REQUEST["type"]=="rss") {
-	$outputRss = true;
-} else {
-	$outputRss = false;
-}
 
+
+#check if requested as cli
 if (isset($argv[0])&isset($argv[1])){
-	if (!$outputRss) echo "\nthe script was invoked from commandline\n";
+	echo "\nthe script was invoked from commandline\n";
 	$from_cli=true;
 	#do something with the searchstring if needed
 	#from cli no pagenumber will be given. Therefor everytime page number 1 will be requested
 	$request_p = 1;
 	$_REQUEST["q"] = $argv[2];//.$argv[3];//$searchPortaluFilter = $argv[3];
 	$cli_id = $argv[1];
-	if (!$outputRss) echo "\nID: ".$argv[1]."\n";
-	if (!$outputRss) echo "\nSearchstring: ".$argv[2]."\n";
-} else {	
-		if (!$outputRss) echo "<html><body>";
-		if (!$outputRss) echo "\n<br>no commandline args set!\n<br>";
+	echo "\nID: ".$argv[1]."\n";
+	echo "\nSearchstring: ".$argv[2]."\n";
+	}
+	else
+	{
+		echo "<html><body>";
+		echo "\n<br>no commandline args set!\n<br>";
 		$from_cli=false;
-}
+	}
 #When script was not invoked from cli it should have been invoked per http - check the params
 if (!$from_cli){
 	#***Validation of GET Parameters
-
 	#handle errors
 	//make html frame
 	
 	if(!isset($_REQUEST["q"]) ) {
-		if (!$outputRss) echo "No search string found! Please send a query!<br>";
+		echo "No search string found! Please send a query!<br>";
 		die();
-	}
+		}
 	if(!isset($_REQUEST["p"]) ) {
 		$request_p = 1;
 		}
@@ -85,21 +85,16 @@
 		}
 
 	if(!isset($_REQUEST["request_id"]) or $_REQUEST["request_id"]=='') {
-
-		if (!$outputRss) echo "<br> request_id is not set <br>";
-
+		echo "<br> request_id is not set <br>";
 		$requeststring="&request_id=from_http";
 		$cli_id="from_http";
 		}
 	else
 		{
-
-		if (!$outputRss) echo "<br>request_id is set<br>";
-
+		echo "<br>request_id is set<br>";
 		$cli_id=$_REQUEST["request_id"];
 		}
-	if (!$outputRss) echo "<br>Search string: <b>".$_REQUEST["q"]."</b> will be send<br>";
-
+	echo "<br>Search string: <b>".$_REQUEST["q"]."</b> will be send<br>";
 }
 
 //convert the the opensearch filter to ogc filter encoding
@@ -215,7 +210,7 @@
 while($row_csw = db_fetch_array($res_csw)){
 	$csw_list[$cnt_csw]['id'] = $row_csw["csw_id"];
 	$csw_list[$cnt_csw]['name'] = $row_csw["csw_name"];
-	if (!$outputRss) echo "csw_name=".$row_csw["csw_name"];
+	echo "csw_name=".$row_csw["csw_name"];
 	$csw_list[$cnt_csw]['hierachylevel'] = $row_csw["hierachylevel"];
 	$csw_list[$cnt_csw]['fkey_cat_id'] = $row_csw["fkey_cat_id"];
 	//echo "<br>CAT ID from DB: ".$row_csw["fkey_cat_id"]."<br>";
@@ -269,7 +264,7 @@
 
 //debug output
 if (!$from_cli) {
-	if (!$outputRss) echo "<br>Count of registrated OpenSearch Interfaces: ".count($csw_list)."<br>";
+	echo "<br>Count of registrated OpenSearch Interfaces: ".count($csw_list)."<br>";
 }
 
 #get command_line args
@@ -298,8 +293,8 @@
 #if ($from_cli) {
 	#write out xml 'is really no xml!' with opensearch-catalogs
 if ($from_cli) {
-if (!$outputRss) echo "\nFolder to write to: ".$resdir."\n";
-if (!$outputRss) echo "\nFile to open: ".$resdir."/".$cli_id."_os.xml\n";
+echo "\nFolder to write to: ".$resdir."\n";
+echo "\nFile to open: ".$resdir."/".$cli_id."_os.xml\n";
 }
 	if($os_catalogs_file_handle = fopen($resdir."/".$cli_id."_os.xml","w")){
 		fwrite($os_catalogs_file_handle,"<interfaces>\n");
@@ -315,7 +310,7 @@
 	else
 	{
 		if ($from_cli) {
-			if (!$outputRss) echo "\nCouldn't open file!\n";
+			echo "\nCouldn't open file!\n";
 		}
 	}
 #}
@@ -324,19 +319,12 @@
 #***loop for things to do for each registrated search interface - only if the search should be done in all interfaces!
 #use only one catalogue if a further page is requested
 $start_cat=0;
-
 $end_cat=count($csw_list);
-
-$e = new mb_exception($end_cat);
-	
-$cat = $_REQUEST["cat"];
-$e = new mb_exception($cat);
-
+$cat=$_REQUEST["cat"];
 if (isset($cat)){
-	$start_cat=(int)$cat;
-	$end_cat=(int)$cat+1;
+$start_cat=(int)$cat;
+$end_cat=(int)$cat+1;
 }
-
 for ($i_si = $start_cat; $i_si < $end_cat ; $i_si++) {
 	//$i_si = 0;
 	//echo "<br>".$csw_list[$i_si]['getrecordsurl']."<br>";
@@ -445,9 +433,9 @@
 	$getRecords .= '          </csw:Query>';
 	$getRecords .= '</csw:GetRecords>';
 
-	//echo "<br>REQUEST for results<br>".htmlentities($getRecords)."<br>";
-	$e = new mb_notice($getRecords);
-	//for CSW define POST REQUEST for getrecords
+//echo "<br>REQUEST for results<br>".htmlentities($getRecords)."<br>";
+$e = new mb_notice($getRecords);
+//for CSW define POST REQUEST for getrecords
 	$cswInterfaceObject = new connector();
 	$cswInterfaceObject->set('httpType','POST');
 	$postData = $getRecords;
@@ -459,7 +447,8 @@
 	$cswInterfaceObject->set('httpContentType','text/xml');
 	//extent url when needed
 	$openSearchUrlSearch[$i_si] = $openSearchUrl[$i_si];
-	if (!$outputRss) echo "<br><br>".$openSearchUrlSearch[$i_si]."<br>";
+	echo "<br><br>".$openSearchUrlSearch[$i_si]."<br>";
+
 	//echo $openSearchUrl[$i_si]."<br>";
 	$cswInterfaceObject->load($openSearchUrl[$i_si]);
 	#echo "<br>Results: ".htmlentities($cswInterfaceObject->file)."<br><br>";
@@ -470,7 +459,7 @@
 	//$url=$openSearchUrlSearch[$i_si]."q=".$queryText.$csw_list[$i_si] ['standardfilter']."&h=".$csw_list[$i_si] ['h']."&p=".$request_p;
 	$url = $openSearchUrl[$i_si];
 	if (!$from_cli) {	
-	if (!$outputRss) echo "<br> url: ".$url."<br>";
+	echo "<br> url: ".$url."<br>";
 	}
 	else
 	{
@@ -483,7 +472,7 @@
 	//	$e = new mb_exception('external xml : '.$openSearchResult);
 	//}
 
-	$e = new mb_exception('external xml : '.$openSearchResult);
+	$e = new mb_notice('external xml : '.$openSearchResult);
 	#parse result to simplexml 
 	$openSearchXml =  new SimpleXMLElement($openSearchResult);	
 	//$openSearchXml = ($openSearchResult);
@@ -512,19 +501,19 @@
 
 #do a html output for showing results of the different opensearch catalogues
 //if (!$from_cli) {
-	if (!$outputRss) echo "<b>".$n_results."</b> Ergebnisse in Katalog <b>".$csw_list[$i_si] ['name']."</b><br><br>";
+	echo "<b>".$n_results."</b> Ergebnisse in Katalog <b>".$csw_list[$i_si] ['name']."</b><br><br>";
 	#show Pagenumbers
 	if ((int)$request_p>1) {
-	if (!$outputRss) echo "<a href=\"mod_readCSWResults.php?q=".$_REQUEST['q']."&p=".(string)((int)$request_p-1)."&cat=".$i_si.$requeststring."\"> Vorige Seite </a> ";
+	echo "<a href=\"mod_readCSWResults.php?q=".$_REQUEST['q']."&p=".(string)((int)$request_p-1)."&cat=".$i_si.$requeststring."\"> Vorige Seite </a> ";
 	}
 
-	if (!$outputRss) echo "Seite: <b>".$request_p."</b> von <b>".$number_of_pages."</b>";
+	echo "Seite: <b>".$request_p."</b> von <b>".$number_of_pages."</b>";
 	
 	if ((int)$request_p < (int)$number_of_pages) {
-	if (!$outputRss) echo " <a href=\"mod_readCSWResults.php?q=".$_REQUEST['q']."&p=".(string)((int)$request_p+1)."&cat=".$i_si.$requeststring."\"> Nächste Seite </a>";
+	echo " <a href=\"mod_readCSWResults.php?q=".$_REQUEST['q']."&p=".(string)((int)$request_p+1)."&cat=".$i_si.$requeststring."\"> Nächste Seite </a>";
 	}
 	
-	if (!$outputRss) echo "<br><br>";
+	echo "<br><br>";
 //}
 //else
 //{
@@ -532,70 +521,6 @@
 //}
 	
 $from_cli=true; //- do this everytime
-
-if ($_REQUEST['type'] == "rss") {
-	//initialize new rss document
-	$rssDoc = new DOMDocument('1.0');
-	$rssDoc->encoding = 'UTF-8';
-	$rssDoc->preserveWhiteSpace = false;
-	$rssDoc->formatOutput = true;
-	/*<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">
-  		<channel>
-    			<title>WMS servers</title>
-    			<link>http://www.geopole.org/wms/search?search=wald&type=rss</link>
-    			<description>Geopole WMS search results for "wald"</description>
-   			<opensearch:totalResults>25</opensearch:totalResults>
-    			<opensearch:Query role="request" searchTerms="wald" />
-  		</channel>*/
-	
-	$rssElement = $rssDoc->createElement("rss");
-	$rssElement->setAttribute("version", "2.0");
-	$rssElement->setAttribute("xmlns:dc", "http://purl.org/dc/elements/1.1/");
-	$rssElement->setAttribute("xmlns:opensearch", "http://a9.com/-/spec/opensearch/1.1/");
-	$channel = $rssDoc->createElement("channel");
-
-	$title = $rssDoc->createElement("title");
-	$titleText = $rssDoc->createTextNode("Service Search in CSW Catalogue: ".$csw_list[$i_si] ['name']);
-	$title->appendChild($titleText);
-	$channel->appendChild($title);
-
-	$link = $rssDoc->createElement("link");
-	$linkText = $rssDoc->createTextNode("http://www.geoportal.rlp.de");
-	$link->appendChild($linkText);
-	$channel->appendChild($link);
-
-	$description = $rssDoc->createElement("description");
-	$descriptionText = $rssDoc->createTextNode("Extract service metadata from CSW. Show only first ".$csw_list[$i_si] ['h']." from total ".$n_results." results! Please refine your search.");
-	$description->appendChild($descriptionText);
-	$channel->appendChild($description);
-
-
-	$openSearchTotalResults = $rssDoc->createElement("opensearch:totalResults");
-	$openSearchTotalResultsText = $rssDoc->createTextNode($n_results);
-	$openSearchTotalResults->appendChild($openSearchTotalResultsText);
-	$channel->appendChild($openSearchTotalResults);
-
-	/*$openSearchQuery = $rssDoc->createElement("opensearch:Query");
-	$openSearchQueryText = $rssDoc->createTextNode($query);
-	$openSearchQuery->appendChild($openSearchQueryText);
-	$channel->appendChild($openSearchQuery);*/
-
-	$openSearchQuery = $rssDoc->createElement("opensearch:Query");
-	$openSearchQuery->setAttribute("role", "request");
-	$openSearchQuery->setAttribute("searchTerms", $q);
-	$channel->appendChild($openSearchQuery);
-
-	$rssElement->appendChild($channel);
-	
-	//header("Content-type: text/xml; charset=UTF-8");
-	//$xml = $rssDoc->saveXML();
-	//$xml = trim($xml,"\n");
-	//remove newline from xml
-	//echo $xml;
-	//die();
-	
-	
-}
 if ($from_cli) { #do these things if the request was done from the commandline - it is done by the central search function
 	#generate the output for each page! Like: xyz_os1_1_10.xml = this means: searchid_os#catalogid_#page_#totalpages.xml
 	#open the specific file for writing
@@ -665,7 +590,7 @@
 			$abstract = $openSearchXml->xpath('/csw:GetRecordsResponse/csw:SearchResults/gmd:MD_Metadata['.$index.']/gmd:identificationInfo/*/gmd:abstract/gco:CharacterString');
 			$accessUrl = $openSearchXml->xpath('/csw:GetRecordsResponse/csw:SearchResults/gmd:MD_Metadata['.$index.']/gmd:distributionInfo/gmd:MD_Distribution/gmd:transferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine/gmd:CI_OnlineResource/gmd:linkage/gmd:URL');
 			
-			if (!$outputRss) echo "<br>General first accessUrl: ".$accessUrl[0]."<br>";
+			echo "<br>General first accessUrl: ".$accessUrl[0]."<br>";
 
 
 
@@ -739,9 +664,9 @@
 			$isViewService = false;	
 			$accessUrl = $accessUrl[0];
 			$typeOfServiceUpper = strtoupper($typeOfService);
-			if (!$outputRss) echo "<br>accessUrl: ".$accessUrl."<br>";
-			if (!$outputRss) echo "<br>typeOfService:*".$typeOfServiceUpper."*<br>";
-			if (!$outputRss) echo "<br>typeOfRecord:*".$typeOfRecord."*<br>";
+			echo "<br>accessUrl: ".$accessUrl."<br>";
+			echo "<br>typeOfService:*".$typeOfServiceUpper."*<br>";
+			echo "<br>typeOfRecord:*".$typeOfRecord."*<br>";
 
 			$title = $title[0];
 			$graphicURL = $graphicURL[0];
@@ -755,7 +680,7 @@
 			//check for view service type
 			if ($typeOfServiceUpper == 'WMS' || $typeOfServiceUpper == 'VIEW'  || strpos($typeOfServiceUpper,'WMS') !== false) {
 				$isViewService = true;	
-				if (!$outputRss) echo "view service identified<br>";
+				echo "view service identified<br>";
 			}
 			//check if service is view or wms and correct it for wms 1.1.1 caabilities request
 			if ($typeOfRecord == 'service' && $isViewService) {
@@ -765,7 +690,7 @@
 					$accessUrl = '';
 				}
 			} else {
-				if (!$outputRss) echo "<b>no</b> view service identified<br>";
+				echo "<b>no</b> view service identified<br>";
 				$isViewService = false;
 			}
 			//give dummy if orgaName not given
@@ -780,46 +705,24 @@
 			}
                         $abstractShort = substr($abstract,0,250)."...";
 			//echo "<br>Resultlist:<br>";
-			if (!$outputRss) echo "<br><span>";
+			echo "<br><span>";
 			if (isset($graphicURL) && $graphicURL != '') {
-				if (!$outputRss) echo "<img src='".$graphicURL."' width='100' height='100'/>";
+				echo "<img src='".$graphicURL."' width='100' height='100'/>";
 			}
-			if (!$outputRss) echo "<a href = '".$openSearchWrapperDetail."?cat_id=".$csw_list[$i_si] ['id']."&uuid=".$uuid."&mdtype=html'>".$title."</a><br>";
-			if (!$outputRss) echo $dateStamp." - ".$orgaName."<br>";
+			echo "<a href = '".$openSearchWrapperDetail."?cat_id=".$csw_list[$i_si] ['id']."&uuid=".$uuid."&mdtype=html'>".$title."</a><br>";
+			echo $dateStamp." - ".$orgaName."<br>";
 			if (isset($bbox) && $bbox != '') {
-				if (!$outputRss) echo $bbox."<br>";
+				echo $bbox."<br>";
 			}
-			if (!$outputRss) echo $abstractShort."</span>";
+			echo $abstractShort."</span>";
 			//check for isViewService to allow integration into Viewer by link TODO
 			if (isset($accessUrl) && $accessUrl != '') {
 				if ($isViewService) {
-					if (!$outputRss) echo "<br><span><a href ='".$accessUrl."'>Capabilities</a><br><br></span>";
+					echo "<br><span><a href ='".$accessUrl."'>Capabilities</a><br><br></span>";
 				} else {
-					if (!$outputRss) echo "<br><span><a href ='".$accessUrl."'>Link</a><br><br></span>";
+					echo "<br><span><a href ='".$accessUrl."'>Link</a><br><br></span>";
 				}
 			}
-			//write xml tags for rss feed
-			if ($outputRss) {
-					$e = new mb_exception("fill item: ".$title);
-					$item = $rssDoc->createElement("item");
-
-					$titleItem = $rssDoc->createElement("title");
-					$titleItemText = $rssDoc->createTextNode($title);
-					$titleItem->appendChild($titleItemText);
-					$item->appendChild($titleItem);
-
-					$link = $rssDoc->createElement("link");
-					$linkText = $rssDoc->createTextNode($accessUrl);
-					$link->appendChild($linkText);
-					$item->appendChild($link);
-
-					$description = $rssDoc->createElement("description");
-					$descriptionText = $rssDoc->createTextNode($abstract);
-					$description->appendChild($descriptionText);
-					$item->appendChild($description);
-					
-					$rssElement->appendChild($item);
-			}
 			//output to file in tmp folder:
 			if (isset($uuid) && $uuid != ''){
 				#Do result XML output to file
@@ -891,17 +794,10 @@
 	}	
 	fwrite($os_catalogs_file_handle,"</resultlist>\n");
 	fclose($os_catalogs_file_handle);
-	if($outputRss) {
-		$rssDoc->appendChild($rssElement);
-		header("Content-type: text/xml; charset=UTF-8");
-		$xml = $rssDoc->saveXML();
-		echo $xml;
-		die();
-	}
 }	
 }
 }
-	if (!$outputRss) echo "</body></html>";
+	echo "</body></html>";
 
 function correctWmsUrl($wms_url) {
 	//check if last sign is ? or & or none of them



More information about the Mapbender_commits mailing list