'; ?> Monitor WMS Capabilities getGuisByOwner($_SESSION["mb_user_id"],true); $permguis = $admin->getGuisByPermission($_SESSION["mb_user_id"],true); $wms_id_own = $admin->getWmsByOwnGuis($ownguis); $sql = "SELECT fkey_wms_id, wms_getmap FROM wms_monitor"; $res = db_query($sql); $wmsList = array(); $i=0; while($row = db_fetch_array($res)){ $wmsList[$i] = array(); $wmsList[$i]["id"] = $row['fkey_wms_id']; $wmsList[$i]["getmap"] = $row['wms_getmap']; $i++; } //$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"; //$remoteXml = fetchUrlWithoutHanging($someUrl); //$remoteXml = implode("", file($someUrl)); //echo $remoteXml; function microtime_float() { list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); } function fetchUrlWithoutHanging($url){ // Set maximum number of seconds to wait for feed before displaying page without feed $numberOfSeconds=20; // 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); $resourcePath = str_replace(" ", "%20", $resourcePath); // 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(""); return false; } // 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
"; echo "WMS services are requested for availabiltiy. "; echo "Capabilities documents are requested and all changes synchronized with the database cache.

"; echo ""; for ($k=0; $k"; } else { if (strpos($remoteXml, "Content-Type: image")) { echo "Connection established, getmap query successful.".$duration_str.""; } else { echo "Connection established, getmap query failed.".$duration_str.""; } } #echo $remoteXml; //print_r($localXmlArray); //print_r($remoteXmlArray); # if (!$remoteXml) { # $result = -1; // echo "Can't connect to " . $myURL . ""; # echo "Connection failed."; # } # elseif (!$localXml) { # $result = 0; # } # else { # if ($localXml == $remoteXml) { # $result = 1; # echo "WMS is stable."; # } # else { # $result = 0; # } # } # if ($result == 0) { # echo "Updating WMS " . $wmsId . "..."; # $mywms = new wms(); # $mywms->createObjFromXML($myURL); # $mywms->optimizeWMS(); # $mywms->updateObjInDB($wmsId); # } # } } echo "
Processing WMS (ID = " . $wmsId . ")
"; $sql = "SELECT wms_title FROM wms WHERE wms_id = '" . $wmsId . "'"; $res = db_query($sql); $someArray = db_fetch_row($res); $wms_title = $someArray[0]; echo "WMS Title: " . $wms_title . "
"; echo "getmap

"; set_time_limit(30); $wmsGetmap = eregi_replace("EXCEPTIONS=[^&]*","EXCEPTIONS=application/vnd.ogc.se_xml",$wmsGetmap); $request_start = microtime_float(); $remoteXml = fetchUrlWithoutHanging($wmsGetmap); $request_end = microtime_float(); $duration = $request_end - $request_start; $duration_str = "
query time: " . round($duration,3) . " s"; if ($remoteXml == false) { echo "Connection failed." . $duration_str. "
"; echo "
Monitoring Cycle completed."; ?>