svn commit: r371 - trunk/mapbender/http: classes php

christoph at osgeo.org christoph at osgeo.org
Wed May 31 08:45:24 EDT 2006


Author: christoph
Date: 2006-05-31 12:45:24+0000
New Revision: 371

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

Log:
bugfix: if a wms has no name, it will not be updated any longer

Modified: trunk/mapbender/http/classes/class_wms.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/classes/class_wms.php?view=diff&rev=371&p1=trunk/mapbender/http/classes/class_wms.php&p2=trunk/mapbender/http/classes/class_wms.php&r1=370&r2=371
==============================================================================
--- trunk/mapbender/http/classes/class_wms.php	(original)
+++ trunk/mapbender/http/classes/class_wms.php	2006-05-31 12:45:24+0000
@@ -390,11 +390,14 @@
 	}
 	if(!$this->wms_title || $this->wms_title == ""){
 		$this->wms_status = false;
+		$this->optimizeWMS();
+		return false;
 	}
 	else{
 		$this->wms_status = true;
+		$this->optimizeWMS();
+		return true;
 	}
-	$this->optimizeWMS();
 }
 function optimizeWMS(){
 	/*define defaults for wms-version 1.0.0*/
@@ -807,7 +810,6 @@
 	$sql .= "wms_upload_url = $9 ";
 	$sql .= " WHERE wms_id = $10";
 	
-	
 	$v = array($this->wms_version,$this->wms_title,$this->wms_abstract,$this->wms_getcapabilities,
 		$this->wms_getmap,$this->wms_getfeatureinfo,$this->wms_getlegendurl,
 		$this->wms_getcapabilities_doc,$this->wms_upload_url,$myWMS);
@@ -1029,7 +1031,7 @@
 	 	echo "<br /> UPDATE ERROR -> KILL PROCESS AND ROLLBACK....................no update<br><br>";
 		}
 }
-  /**
+/**
 * creatObjfromDB
 *
 */ 

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=371&p1=trunk/mapbender/http/php/mod_monitorCapabilities.php&p2=trunk/mapbender/http/php/mod_monitorCapabilities.php&r1=370&r2=371
==============================================================================
--- trunk/mapbender/http/php/mod_monitorCapabilities.php	(original)
+++ trunk/mapbender/http/php/mod_monitorCapabilities.php	2006-05-31 12:45:24+0000
@@ -16,9 +16,9 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
 require_once("../php/mb_validateSession.php");
 require_once("../../conf/mapbender.conf");
+session_start();
 import_request_variables("PG");
 ?>
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
@@ -34,50 +34,15 @@
 <?php
 require_once("../classes/class_wms.php");
 require_once("../classes/class_administration.php");
-
 $con = db_connect($DBSERVER,$OWNER,$PW);
 db_select_db(DB,$con);
-
 $admin = new administration();
 $ownguis = $admin->getGuisByOwner($_SESSION["mb_user_id"]);
 $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 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 "Starting monitoring cycle...<br><br>";
 echo "WMS services are requested for availabiltiy. "; 
 echo "Capabilities documents are requested and all changes synchronized with the database cache.<br><br>";
@@ -106,33 +71,37 @@
 	}
 	else {
 		echo "Version '" . $version . "' cannot be handled! Update process terminated.</td><td><img src ='../img/trafficlights/stop.bmp'></td></tr>";
-
 	}
 	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);
+		set_time_limit(300);
 		echo "<a href='" . $myURL . "'>Get Capabilities Link</a><br>";
-		$remoteXml = implode("", file($myURL));
-		$localXmlArray = explode("\n", $localXml);
-		$remoteXmlArray = explode("\n", $remoteXml);
-		for ($i=0; $i<count($localXmlArray); $i++) {
-			$localXmlArray[$i] = trim(htmlentities($localXmlArray[$i]));
-		}
-		for ($i=0; $i<count($remoteXmlArray); $i++) {
-			$remoteXmlArray[$i] = trim(htmlentities($remoteXmlArray[$i]));
-		}
-		//print_r($localXmlArray);
-		//print_r($remoteXmlArray);			
+		$x = new connector($myURL);
+		$z = new wms();
+		$remoteXml = $z->char_encode($x->file);
+
+//		$remoteXml = implode("", file($myURL));
+//		$localXmlArray = explode("\n", $localXml);
+//		$remoteXmlArray = explode("\n", $remoteXml);
+//		$remoteXmlArray = explode("\n", $remoteXml);
+//		for ($i=0; $i<count($localXmlArray); $i++) {
+//			$localXmlArray[$i] = trim(htmlentities($localXmlArray[$i]));
+//		}
+//		for ($i=0; $i<count($remoteXmlArray); $i++) {
+//			$remoteXmlArray[$i] = trim(htmlentities($remoteXmlArray[$i]));
+//		}
+//		print_r($localXmlArray);
+//		print_r($remoteXmlArray);			
 		if (!$remoteXml) {
 			$result = -1;
-//			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;
 		}
 		else {
+			
 			if ($localXml == $remoteXml) {
 				$result = 1;
 				echo "WMS is stable.</td><td><img src ='../img/trafficlights/go.bmp'></td></tr>";
@@ -142,11 +111,17 @@
 			}
 		}
 		if ($result == 0) {
-			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);
+			$result = $mywms->createObjFromXML($myURL);
+			
+			if ($result == true) {
+				$mywms->updateObjInDB($wmsId);
+				echo "Updating WMS " . $wmsId . "...</td><td><img src ='../img/trafficlights/wait.bmp'></td></tr>";
+			}
+			else {
+				$result = -1;
+				echo "Invalid getCapabilities request.</td><td><img src ='../img/trafficlights/stop.bmp'></td></tr>";
+			}    
 		}
 	}
 }




More information about the Mapbender_commits mailing list