[Mapbender-commits] r7037 - trunk/mapbender/lib

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon Oct 11 01:49:15 EDT 2010


Author: armin11
Date: 2010-10-10 22:49:15 -0700 (Sun, 10 Oct 2010)
New Revision: 7037

Modified:
   trunk/mapbender/lib/class_Monitor.php
Log:
Add possibility to monitor secured web map services too.

Modified: trunk/mapbender/lib/class_Monitor.php
===================================================================
--- trunk/mapbender/lib/class_Monitor.php	2010-10-11 05:17:08 UTC (rev 7036)
+++ trunk/mapbender/lib/class_Monitor.php	2010-10-11 05:49:15 UTC (rev 7037)
@@ -21,6 +21,7 @@
 require_once(dirname(__FILE__)."/../http/classes/class_connector.php");
 require_once(dirname(__FILE__)."/../http/classes/class_mb_exception.php");
 require_once(dirname(__FILE__)."/../http/extensions/DifferenceEngine.php");
+require_once(dirname(__FILE__) . "/../http/classes/class_administration.php");
 
 class Monitor {
 	/**
@@ -71,7 +72,12 @@
 		set_time_limit(TIME_LIMIT);
 		
 		$this->timestamp = microtime(TRUE);
-		
+		//get authentication info for service
+		$admin = new administration();
+		$auth = $admin->getAuthInfoOfWMS($this->wmsId);
+		if ($auth['auth_type']==''){
+			unset($auth);
+		}
 		if ($this->capabilitiesURL) {
 		
 			//$remoteWms = new wms(); #exchange by other handling
@@ -82,9 +88,13 @@
 
 			//$remoteWms->createObjFromXML($this->capabilitiesURL);#exchange by other handling
 			
-			
+
 			//$this->remoteXML = $remoteWms->wms_getcapabilities_doc;
-			$capObject = new connector($this->capabilitiesURL);
+			if isset($auth) {
+				$capObject = new connector($this->capabilitiesURL,$auth);
+			} else {
+				$capObject = new connector($this->capabilitiesURL);
+			}
 			//decode and encode to have the same behavior as loading caps to database
 			$this->remoteXML = $capObject->file;
 
@@ -142,6 +152,15 @@
 				
 				$this->mapURL = urldecode($this->getTagOutOfXML($this->reportFile,'getmapurl'));
 				//$e=new mb_exception("mapurl:".$this->mapURL);
+			if isset($auth) {
+				if ($this->isImage($this->mapURL,$auth)) {
+					$this->returnsImage = 1;
+				}
+				else {
+					$this->returnsImage = -1;
+				}
+				
+			} else {
 				if ($this->isImage($this->mapURL)) {
 					$this->returnsImage = 1;
 					//$e=new mb_exception("Returns image");
@@ -150,11 +169,10 @@
 					$this->returnsImage = -1;
 					//$e=new mb_exception("Returns no image!");
 				}
-				
+			}
 
 
 
-
 				//Check for valid XML - validate it again wms 1.1.1 -some problems occur?
 				#$dtd = "../schemas/capabilities_1_1_1.dtd";
 				#$dom = new domDocument;
@@ -249,23 +267,23 @@
 	 */
 	function updateInXMLReport() {
 		//create text for diff
-		$difftext = "<html>\n";
-		$difftext .= "<head>\n";
-		$difftext .= "<title>Mapbender - monitor diff results</title>\n";
-		$difftext .= "<meta http-equiv=\"cache-control\" content=\"no-cache\">\n";
-		$difftext .= "<meta http-equiv=\"pragma\" content=\"no-cache\">\n";
-		$difftext .= "<meta http-equiv=\"expires\" content=\"0\">\n";
-		$difftext .= "<meta http-equiv=\"Content-Type\" content=\"text/html; charset='.CHARSET.'\">";	
-		$difftext .= "<style type=\"text/css\">\n";
-		$difftext .= "* {font-family: Arial, \"Courier New\", monospace; font-size: small;}\n";
-		$difftext .= ".diff-context {background: #eee;}\n";
-		$difftext .= ".diff-deletedline {background: #eaa;}\n";
-		$difftext .= ".diff-addedline {background: #aea;}\n";
-		$difftext .= ".diff-blockheader {background: #ccc;}\n";
-		$difftext .= "</style>\n";
-		$difftext .= "</head>\n";
+		$difftext = "<html>\n";
+		$difftext .= "<head>\n";
+		$difftext .= "<title>Mapbender - monitor diff results</title>\n";
+		$difftext .= "<meta http-equiv=\"cache-control\" content=\"no-cache\">\n";
+		$difftext .= "<meta http-equiv=\"pragma\" content=\"no-cache\">\n";
+		$difftext .= "<meta http-equiv=\"expires\" content=\"0\">\n";
+		$difftext .= "<meta http-equiv=\"Content-Type\" content=\"text/html; charset='.CHARSET.'\">";	
+		$difftext .= "<style type=\"text/css\">\n";
+		$difftext .= "* {font-family: Arial, \"Courier New\", monospace; font-size: small;}\n";
+		$difftext .= ".diff-context {background: #eee;}\n";
+		$difftext .= ".diff-deletedline {background: #eaa;}\n";
+		$difftext .= ".diff-addedline {background: #aea;}\n";
+		$difftext .= ".diff-blockheader {background: #ccc;}\n";
+		$difftext .= "</style>\n";
+		$difftext .= "</head>\n";
 		$difftext .= "<body>\n";
-		$difftext .= "<table cellpadding=3 cellspacing=0 border=0>\n";
+		$difftext .= "<table cellpadding=3 cellspacing=0 border=0>\n";
 		$difftext .= "<tr><td align='center' colspan='2'>Local</td><td align='center' colspan='2'>Remote</td></tr>\n";		
 		$difftext .= $this->capabilitiesDiff;
 		$difftext .= "\n\t</table>\n\t";
@@ -292,7 +310,15 @@
 		#if (preg_match("/xml/", $headers["Content-Type"])) {
 		#	return false;
 		#}
-		$imgObject = new connector($url);
+
+
+		if (func_num_args() == 2) { //new for HTTP Authentication
+        	    	$auth = func_get_arg(1);
+			$imgObject = new connector($url, $auth);
+		}
+		else {
+			$imgObject = new connector($url);
+		}
 		$image = $imgObject->file;
 		//write images to tmp folder
 		$imageName=$this->tmpDir."/"."monitor_getmap_image_".md5(uniqid()).".png";
@@ -347,7 +373,18 @@
 		|\xF4[\x80-\x8F][\x80-\xBF]{2}    # plane 16
 		)+%xs', $string);
 	}
-	
+//function to get documents with authentication
+	function getDocumentContent($url){
+		if (func_num_args() == 2) { //new for HTTP Authentication
+        	    	$auth = func_get_arg(1);
+			$d = new connector($url, $auth);
+		}
+		else {
+			$d = new connector($url);
+		}
+		return $d->file;
+	}
+
 	function is_utf8_xml($xml) {
 		return preg_match('/<\?xml[^>]+encoding="utf-8"[^>]*\?>/is', $xml);
 	}



More information about the Mapbender_commits mailing list