svn commit: r121 - trunk/mapbender/http/php/mod_monitorCapabilities.php

christoph at osgeo.org christoph at osgeo.org
Fri Apr 21 11:44:39 EDT 2006


Author: christoph
Date: 2006-04-21 15:44:38+0000
New Revision: 121

Modified:
   trunk/mapbender/http/php/mod_monitorCapabilities.php

Log:
added traffic lights

Modified: trunk/mapbender/http/php/mod_monitorCapabilities.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/php/mod_monitorCapabilities.php?view=diff&rev=121&p1=trunk/mapbender/http/php/mod_monitorCapabilities.php&p2=trunk/mapbender/http/php/mod_monitorCapabilities.php&r1=120&r2=121
==============================================================================
--- trunk/mapbender/http/php/mod_monitorCapabilities.php	(original)
+++ trunk/mapbender/http/php/mod_monitorCapabilities.php	2006-04-21 15:44:38+0000
@@ -42,10 +42,60 @@
 $permguis = $admin->getGuisByPermission($_SESSION["mb_user_id"]);
 $wms_id_own = $admin->getWmsByOwnGuis($ownguis);
 
+//$someUrl = "http://www2.demis.nl/wms/wms.asp?wms=WorldMap&VERSION=1.1.1&REQUEST=GetMap&SERVICE=WMS&LAYERS=Bathymetry,Countries,Topogghraphy,Hillshading,Builtup%20areas,Coastlines,Waterbodies,Inundated,Rivers,Streams,Railroads,Highways,Roads,Trails,Borders,Cities,Settlements,Spot%20elevations,Airports,Ocean%20features&STYLES=,,,,,,,,,,,,,,,,,,,&SRS=EPSG:4326&BBOX=-106.8888888888889,-80,80.8888888888889,89&WIDTH=500&HEIGHT=450&FORMAT=image/png&BGCOLOR=0xffffff&TRANSPARENT=TRUE";
+set_time_limit(0);
+//$remoteXml = fetchUrlWithoutHanging($someUrl);
+//$remoteXml = implode("", file($someUrl));
+//echo $remoteXml;
+
+
+function fetchUrlWithoutHanging($url)
+   {
+   // Set maximum number of seconds (can have floating-point) to wait for feed before displaying page without feed
+   $numberOfSeconds=4;   
+
+   // Suppress error reporting so Web site visitors are unaware if the feed fails
+   error_reporting(0);
+
+   // Extract resource path and domain from URL ready for fsockopen
+
+   $url = str_replace("http://","",$url);
+   $urlComponents = explode("/",$url);
+   $domain = $urlComponents[0];
+   $resourcePath = str_replace($domain,"",$url);
+
+   // Establish a connection
+   $socketConnection = fsockopen($domain, 80, $errno, $errstr, $numberOfSeconds);
+
+   if (!$socketConnection)
+       {
+       // You may wish to remove the following debugging line on a live Web site
+       print("<!-- Network error: $errstr ($errno) -->");
+       }    // end if
+   else    {
+       $xml = '';
+       fputs($socketConnection, "GET /$resourcePath HTTP/1.0\r\nHost: $domain\r\n\r\n");
+  
+       // Loop until end of file
+       while (!feof($socketConnection))
+           {
+           $xml .= fgets($socketConnection, 128);
+           }    // end while
+
+       fclose ($socketConnection);
+
+       }    // end else
+
+   return($xml);
+
+   }    // end function
+
+//for ($k=0; $k<count($wms_id_own) && 0 == 1; $k++) {
+echo "<table cellspacing=10 cellpadding = 8 border = 1>";
 for ($k=0; $k<count($wms_id_own); $k++) {
 	$wmsId = $wms_id_own[$k];
 
-	echo "<br><b>Processing WMS Id </b>" . $wmsId . " : ";
+	echo "<tr><td><b>Processing WMS Id </b>" . $wmsId . "<br>";
 	// get the wms version, capabilities, capabilities_doc
 	$sql = "SELECT wms_version, wms_getcapabilities, wms_getcapabilities_doc FROM wms WHERE wms_id = '" . $wmsId . "'";
 	$res = db_query($sql);
@@ -62,12 +112,13 @@
 		$myURL = $capabilities . "REQUEST=capabilities&WMTVER=1.0.0";	
 	}
 	else {
-		echo "Unknown wms version '" . $version . "'! No update possible.<br><br>";
+		echo "Unknown wms version '" . $version . "'! No update possible.</td><td><img src ='../img/trafficlights/stop.bmp'></td></tr>";
 
 	}
-	if ($myURL) {
+	if (($version == "1.1.1" || $version == "1.1.0" ||$version == "1.0.0") && $myURL) {
 		// compare the capabilities XML documents
 		$localXml = $capabilities_doc;
+		set_time_limit(30);
 		$remoteXml = implode("", file($myURL));
  		
 		$localXmlArray = explode("\n", $localXml);
@@ -85,7 +136,8 @@
 	//print_r($remoteXmlArray);			
 		if (!$remoteXml) {
 			$result = -1;
-			echo "Can't connect to " . $myURL . "<br><br>";
+//			echo "Can't connect to " . $myURL . "</td><td><img src ='../img/trafficlights/stop.bmp'></td></tr>";
+			echo "Connection failed.</td><td><img src ='../img/trafficlights/stop.bmp'></td></tr>";
 		}
 		elseif (!$localXml) {
 			$result = 0;
@@ -93,7 +145,7 @@
 		else {
 			if ($localXml == $remoteXml) {
 				$result = 1;
-				echo "No update necessary.<br><br>";
+				echo "No update necessary.</td><td><img src ='../img/trafficlights/go.bmp'></td></tr>";
 			}
 			else {
 				$result = 0;
@@ -102,18 +154,18 @@
 
 				
 		if ($result == 0) {
-			echo "Updating WMS " . $wmsId . "...<br><br>";
-			$mywms = new wms();
-			$mywms->createObjFromXML($myURL);    
-			$mywms->optimizeWMS();
-			$mywms->updateObjInDB($wmsId);
+			echo "Updating WMS " . $wmsId . "...</td><td><img src ='../img/trafficlights/wait.bmp'></td></tr>";
+#			$mywms = new wms();
+#			$mywms->createObjFromXML($myURL);    
+#			$mywms->optimizeWMS();
+#			$mywms->updateObjInDB($wmsId);
 		}
 
 	}
 	
 }
-
-echo "done!";
+echo "</table>";
+echo "<br><br>done!";
 
 ?>
 </body>




More information about the Mapbender_commits mailing list