svn commit: r647 - trunk/mapbender/http/php

christoph at osgeo.org christoph at osgeo.org
Fri Jul 7 11:20:19 EDT 2006


Author: christoph
Date: 2006-07-07 15:20:19+0000
New Revision: 647

Modified:
   trunk/mapbender/http/php/mod_monitorCapabilities_main.php
   trunk/mapbender/http/php/mod_monitorCapabilities_read.php
   trunk/mapbender/http/php/mod_monitorCapabilities_write.php

Log:
bigger and better

Modified: trunk/mapbender/http/php/mod_monitorCapabilities_main.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/php/mod_monitorCapabilities_main.php?view=diff&rev=647&p1=trunk/mapbender/http/php/mod_monitorCapabilities_main.php&p2=trunk/mapbender/http/php/mod_monitorCapabilities_main.php&r1=646&r2=647
==============================================================================
--- trunk/mapbender/http/php/mod_monitorCapabilities_main.php	(original)
+++ trunk/mapbender/http/php/mod_monitorCapabilities_main.php	2006-07-07 15:20:19+0000
@@ -24,17 +24,57 @@
 $con = db_connect($DBSERVER,$OWNER,$PW);
 db_select_db(DB,$con);
 $admin = new administration();
+
+
+//
+//
+//
+// Falls nicht alle GUIs des Root-Benutzers gewünscht sind, folgende Zeile auskommentieren...
+//
 $ownguis = $admin->getGuisByOwner(1);
+
+//
+//
+//
+//... und in diesen Array die GUI IDs eintragen, z.B.:
+//
+#$ownguis = array("gui", "gui1");
+
+//
+//
+//
+// ... falls das monitoring von einem cronjob ausgelöst werden sollte, könnte die php-Datei 
+// um einen Parameter erweitert werden, der die GUI ID enthält, z.B. 
+//                 php mod_monitorCapabilities_main.php gui1
+//
+// dann wäre folgende Zeile einzukommentieren
+#$ownguis = array($_SERVER["argv"][1]);
+
+
+
 $wms_id_own = $admin->getWmsByOwnGuis($ownguis);
 
-set_time_limit(300);
 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>";
 $time = time();
 for ($k=0; $k<count($wms_id_own); $k++) {
-#	$exec = "php mod_monitorCapabilities_write.php ".$wms_id_own[$k]." ".$time." 0 1 > output_" . $wms_id_own[$k] . "_" . $time . ".txt &";
-	$exec = "php mod_monitorCapabilities_write.php ".$wms_id_own[$k]." ".$time." 0 1 > output.txt &";
+	$sql = "INSERT INTO mb_monitor (upload_id, fkey_wms_id, status, status_comment, mb_timestamp, upload_url, updated) ";
+	$sql .= "VALUES ($1, $2, $3, $4, $5, $6, $7)";
+	$v = array($time,$wms_id_own[$k],"-1","Monitoring is still in progress...", $time,"","0");
+	$t = array('s', 'i', 's', 's', 's', 's', 's');
+	$res = db_prep_query($sql,$v,$t);
+}
+sleep(2);
+for ($k=0; $k<count($wms_id_own); $k++) {
+#	$exec = "/usr/local/bin/php mod_monitorCapabilities_write.php ".$wms_id_own[$k]." ".$time." 0 > output_" . $wms_id_own[$k] . "_" . $time . ".txt &";
+
+	if (AUTO_UPDATE) {
+		$exec = PHP_PATH . "php mod_monitorCapabilities_write.php ".$wms_id_own[$k]." ".$time." 1 > output.txt &";
+	}
+	else {
+		$exec = PHP_PATH . "php mod_monitorCapabilities_write.php ".$wms_id_own[$k]." ".$time." 0 > output.txt &";
+	}
 	exec($exec);
 }
 echo "Monitoring Cycle completed (total: " . count($wms_id_own) . " wms).";

Modified: trunk/mapbender/http/php/mod_monitorCapabilities_read.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/php/mod_monitorCapabilities_read.php?view=diff&rev=647&p1=trunk/mapbender/http/php/mod_monitorCapabilities_read.php&p2=trunk/mapbender/http/php/mod_monitorCapabilities_read.php&r1=646&r2=647
==============================================================================
--- trunk/mapbender/http/php/mod_monitorCapabilities_read.php	(original)
+++ trunk/mapbender/http/php/mod_monitorCapabilities_read.php	2006-07-07 15:20:19+0000
@@ -39,11 +39,16 @@
 <?php
 
 for ($i=0; $i < $_POST['cbs']; $i++) {
-	$upd_wmsid = $_POST['cb'.$i]; 
+	$upd_wmsid = intval($_POST['cb'.$i]); 
 	if ($upd_wmsid) {
-		$exec = "php mod_monitorCapabilities_write.php ".$upd_wmsid." ".$_POST['max_id']." 1 0 > output.txt &";
+		
+		$sql = "UPDATE mb_monitor SET status = '-1', status_comment = 'Monitoring is still in progress...', mb_timestamp = $1 WHERE upload_id = $2 AND fkey_wms_id = $3";
+		$v = array($_POST['max_id'], $_POST['max_id'], $upd_wmsid);
+		$t = array('s', 's', 'i');
+		$res = db_prep_query($sql,$v,$t);
+		
+		$exec = PHP_PATH . "php mod_monitorCapabilities_write.php ".$upd_wmsid." ".$_POST['max_id']." 1 > output.txt &";
 		exec($exec);
-		echo "updating WMS " . $upd_wmsid . "...<br>";
 	}
 }
 
@@ -57,7 +62,7 @@
 	$max = db_result($res,$cnt,0);
 }
 
-$sql = "SELECT upload_id, fkey_wms_id, status, status_comment, mb_timestamp, upload_url, updated FROM mb_monitor WHERE upload_id = " . $max;
+$sql = "SELECT upload_id, fkey_wms_id, status, status_comment, mb_timestamp, upload_url, updated FROM mb_monitor WHERE upload_id = " . $max . " ORDER BY mb_timestamp, fkey_wms_id";
 $v = array();
 $t = array();
 $res = db_prep_query($sql,$v,$t);
@@ -73,8 +78,10 @@
 	$cnt++;
 }	
 
-$str = "<br><b>last monitoring cycle results</b> (" . date("F j, Y, g:i a", $upload_id[0]) . ", " . count($upload_id). " wms)<br><br>\n";
-$str .= "<form name = 'form1' method='post' target='".$PHP_SELF."?".SID."'>\n\t";
+$str = "<br><b>last monitoring cycle results</b> (" . date("F j, Y, G:i:s", $upload_id[0]) . ", " . count($upload_id). " wms)<br><br>\n";
+$str .= "<form name = 'form1' method='post' action='".$PHP_SELF."'>\n\t";
+$str .= "\n\t<input type=submit value='update selected WMS'>\n";
+$str .= "\n\t<input type=button onclick=\"self.location.href='".$PHP_SELF."'\" value='refresh'>\n<br/><br/>\n	";
 $str .= "<table cellpadding=5 border=1>";
 for ($k=0; $k<count($upload_id); $k++) {
 	$img = "stop.bmp";
@@ -88,10 +95,11 @@
 	$str .= "\n\t\t\t<td><b>" . $wms_id[$k] . "</b><br>" . $admin->getWmsTitleByWmsId($wms_id[$k]) . "</td>";
 	$str .= "\n\t\t\t<td><a href='".$upload_url[$k]."' target=_blank><img border=0 src = '../img/trafficlights/". $img. "'></a></td>";
 	$str .= "\n\t\t\t<td>" . $comment[$k] . "</td>";
+	$str .= "\n\t\t\t<td>" . date("F j, Y, G:i:s", $timestamp[$k]) . "</td>";
 #	$str .= "\n\t\t\t<td><a href='output_".$wms_id[$k]."_".$max.".txt' target=_blank>log</a></td>";
 	$str .= "\n\t\t</tr>";
 }
-$str .= "\n\t</table>\n\t<br/>\n\t<input type=submit value='update selected WMS'>\n<input type=hidden name=cbs value='".count($upload_id)."'>\n<input type=hidden name=max_id value='".$max."'></form>";
+$str .= "\n\t</table>\n\t<br/><input type=hidden name=cbs value='".count($upload_id)."'>\n<input type=hidden name=max_id value='".$max."'></form>";
 echo $str;
 ?>
 </body></html>
\ No newline at end of file

Modified: trunk/mapbender/http/php/mod_monitorCapabilities_write.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/php/mod_monitorCapabilities_write.php?view=diff&rev=647&p1=trunk/mapbender/http/php/mod_monitorCapabilities_write.php&p2=trunk/mapbender/http/php/mod_monitorCapabilities_write.php&r1=646&r2=647
==============================================================================
--- trunk/mapbender/http/php/mod_monitorCapabilities_write.php	(original)
+++ trunk/mapbender/http/php/mod_monitorCapabilities_write.php	2006-07-07 15:20:19+0000
@@ -26,7 +26,7 @@
 $con = db_connect($DBSERVER,$OWNER,$PW);
 db_select_db(DB,$con);
 
-if ($_SERVER["argc"] != 5) {
+if ($_SERVER["argc"] != 4) {
 	echo "Insufficient arguments! Monitoring aborted.";
 	die();
 }
@@ -34,7 +34,6 @@
 $wmsId = $_SERVER["argv"][1];
 $upload_id = $_SERVER["argv"][2];
 $auto_update = intval($_SERVER["argv"][3]);
-$db_entry = intval($_SERVER["argv"][4]);
 
 
 // get the wms version, capabilities, capabilities_doc
@@ -61,7 +60,6 @@
 $comment = "";
 $updated = "0";
 $result = -1;
-$now = time();
 
 set_time_limit(30);
 
@@ -71,11 +69,9 @@
 
 		// compare the capabilities XML documents
 		$localXml = $capabilities_doc;
-
 		$x = new connector($myURL);
 		$z = new wms();
-		$remoteXml = $x->file;
-#		$remoteXml = $z->char_encode($x->file);
+		$remoteXml = $z->char_encode($x->file);
 
 		if (!$remoteXml) {
 			$result = -1;
@@ -96,9 +92,8 @@
 		}
 		if ($result == 0) {
 			$mywms = new wms();
-			$ok = $mywms->createObjFromXML($myURL);
 			
-			if ($ok) {
+			if ($mywms->createObjFromXML($myURL)) {
 				if ($auto_update) {
 					$mywms->updateObjInDB($wmsId);
 					$updated = "1";
@@ -124,10 +119,11 @@
 	$comment = "Invalid WMS version (" .$version . ").";
 }
 
+$now = time();
 echo "wmsid: " . $wmsId . "\nupload_id: " . $upload_id . "\n";
-echo "autoupdate: " . $auto_update . "\ndb_entry: " . $db_entry . "\n";
+echo "autoupdate: " . $auto_update . "\n";
 echo "result: " . $result . "\ncomment: " . $comment . "\n";
-echo "timestamp: " . $now . " (".date("F j, Y, g:i a",$now).")\n";
+echo "timestamp: " . $now . " (".date("F j, Y, G:i:s",$now).")\n";
 echo "getCapabilities URL: " . $myURL . "\nupdated: " . $updated . "\n\n";
 echo "-------------------------------------------------------------------\n";
 echo "remote XML:\n\n" . $remoteXml . "\n\n";
@@ -135,20 +131,9 @@
 echo "local XML:\n\n" . $localXml . "\n\n";
 echo "-------------------------------------------------------------------\n";
 
-if ($db_entry) {
-	$sql = "INSERT INTO mb_monitor (upload_id, fkey_wms_id, status, status_comment, mb_timestamp, upload_url, updated) ";
-	$sql .= "VALUES ($1, $2, $3, $4, $5, $6, $7)";
-	$v = array($upload_id,$wmsId,$result,$comment, $now,$myURL,$updated);
-	$t = array('s', 'i', 's', 's', 's', 's', 's');
-	$res = db_prep_query($sql,$v,$t);
-}
-else {
-	if ($auto_update && $updated == 1) {
-		$sql = "UPDATE mb_monitor SET updated = 1, status_comment = $1 WHERE upload_id = $2 AND fkey_wms_id = $3";
-		$v = array($comment, $upload_id,$wmsId);
-		$t = array('s', 's', 'i');
-		$res = db_prep_query($sql,$v,$t);
-	}
-}
 
+$sql = "UPDATE mb_monitor SET updated = $1, status = $2, status_comment = $3, upload_url = $4, mb_timestamp = $5 WHERE upload_id = $6 AND fkey_wms_id = $7";
+$v = array($updated, $result, $comment, $myURL, $now, $upload_id, $wmsId);
+$t = array('s', 's', 's', 's', 's', 's', 'i');
+$res = db_prep_query($sql,$v,$t);
 ?>
\ No newline at end of file




More information about the Mapbender_commits mailing list