[Mapbender-commits] r9374 - trunk/mapbender/http/classes

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Jan 19 03:05:15 PST 2016


Author: armin11
Date: 2016-01-19 03:05:15 -0800 (Tue, 19 Jan 2016)
New Revision: 9374

Modified:
   trunk/mapbender/http/classes/class_administration.php
   trunk/mapbender/http/classes/class_mb_exception.php
Log:
New functions for wfs owsproxy getfeature logging

Modified: trunk/mapbender/http/classes/class_administration.php
===================================================================
--- trunk/mapbender/http/classes/class_administration.php	2016-01-19 11:04:36 UTC (rev 9373)
+++ trunk/mapbender/http/classes/class_administration.php	2016-01-19 11:05:15 UTC (rev 9374)
@@ -494,6 +494,23 @@
 	}
 
     /**
+     * returns an array of WMS where the owner is the user with the passed user_id
+     * @param integer	the user id
+     * @return array 	wms ids for the user
+     */
+	function getWfsByWfsOwner($user_id){
+		$sql = "SELECT wfs_id FROM wfs WHERE wfs_owner = $1 ORDER BY wfs_id";
+		$v = array($user_id);
+		$t = array('i');
+		$res = db_prep_query($sql,$v,$t);
+		$r = array();
+		while($row = db_fetch_array($res)){
+			array_push($r,$row["wfs_id"]);
+		}
+		return $r;
+	}
+
+    /**
      * returns an array of user which are associated with a wms
      *
      * @param integer	the wms id
@@ -562,6 +579,23 @@
 	}
 
     /**
+     * selects the WFS-title for a given wfs id.
+     *
+     * @param integer 			the wfs id
+     * @return string|boolean 	either the title of the wfs as string or false when none exists
+     */
+	function getWfsTitleByWfsId($id){
+		$sql = "SELECT wfs_title FROM wfs WHERE wfs_id = $1 GROUP BY wfs_title";
+		$v = array($id);
+		$t = array('i');
+		$res = db_prep_query($sql,$v,$t);
+		$row = db_fetch_array($res);
+		if ($row) return $row["wfs_title"]; else return false;
+	}
+
+
+
+    /**
      * selects the Layer-title for a given layer id.
      *
      * @param integer			the wms id
@@ -1025,6 +1059,32 @@
    		$res = db_prep_query($sql,$v,$t);
    	}
 
+	function getWFSOWSstring($wfs_id){
+   		$sql = "SELECT wfs_owsproxy FROM wfs WHERE wfs_id = $1 ";
+   		$v = array($wfs_id);
+   		$t = array("i");
+   		$res = db_prep_query($sql,$v,$t);
+   		if($row = db_fetch_array($res)){
+   			return $row["wfs_owsproxy"];
+   		}
+   		else{
+   			return false;
+   		}
+   	}
+
+   	function setWFSOWSstring($wfs_id, $status){
+   		$sql = "UPDATE wfs SET wfs_owsproxy = $1 WHERE wfs_id = $2 ";
+   		$t = array("s","i");
+   		if($status == 1){
+   			$time = md5(uniqid());
+			$v = array($time,$wfs_id);
+   		}
+   		else{
+   			$v = array("",$wfs_id);
+   		}
+   		$res = db_prep_query($sql,$v,$t);
+   	}
+
 	/*
 	 * set the log tag of the wms
 	 * 
@@ -1092,6 +1152,73 @@
    		}
    	}		
     
+	/*
+	 * set the log tag of the wfs
+	 * 
+	 * @param integer the wfs-id 
+	 * 
+	 */
+
+   	function setWfsLogTag($wfs_id,$value){
+   		$sql = "UPDATE wfs set wfs_proxylog=$2 WHERE  wfs_id = $1 ";
+   		$t = array("i","i");
+		$v = array($wfs_id,$value);
+   		$res = db_prep_query($sql,$v,$t);
+   	}	
+
+	/*
+	 * get the log tag of the wfs
+	 * 
+	 * @param integer the wfs-id 
+	 * @return 1 for active log and 0 or null for deactivated log
+	 */
+
+   	function getWfsLogTag($wfs_id){
+   		$sql = "SELECT wfs_proxylog from wfs WHERE  wfs_id = $1 ";
+   		$t = array("i");
+		$v = array($wfs_id);
+   		$res = db_prep_query($sql,$v,$t);
+		if($row = db_fetch_array($res)){
+   			return $row["wfs_proxylog"];
+   		}
+   		else{
+   			return false;
+   		}
+   	}	
+	/*
+	 * set the pricevolume of the wfs
+	 * 
+	 * @param integer the wfs-id 
+	 * @param integer the price for one feature of wfs data
+	 */
+
+   	function setWfsPrice($price,$wfs_id){
+   		$sql = "UPDATE wfs set wfs_pricevolume=$1 WHERE  wfs_id = $2 ";
+   		$t = array("i","i");
+		$v = array($price,$wfs_id);
+   		$res = db_prep_query($sql,$v,$t);
+   	}	
+
+	/*
+	 * get the price for one feature of wfs data
+	 * 
+	 * @param integer the wfs-id 
+	 * @return integer for price in cents for one feature of wfs data
+	 */
+
+   	function getWfsPrice($wfs_id){
+   		$sql = "SELECT wfs_pricevolume from wfs WHERE  wfs_id = $1 ";
+   		$t = array("i");
+		$v = array($wfs_id);
+   		$res = db_prep_query($sql,$v,$t);
+		if($row = db_fetch_array($res)){
+   			return $row["wfs_pricevolume"];
+   		}
+   		else{
+   			return false;
+   		}
+   	}		
+    
     /*
 	 * set the pricevolume of the wms feature info
 	 * 
@@ -1216,8 +1343,37 @@
    			#return false;
    		#}
    	}
-    
-    function logFullWmsProxyRequest($wms_id,$user_id,$getmap,$price,$got_result,$set0Pixels=false){
+
+    	/*
+	 * log wfs getfeature proxy urls to db
+	 * 
+	 * @param 
+	 * @return
+	 */
+
+   	function logWfsProxyRequest($wfs_id, $user_id, $getfeature, $price, $numberOfFeatures, $featuretype){
+   		$sql = "INSERT INTO mb_proxy_log (fkey_wms_id, fkey_mb_user_id, request, price, got_result, features, fkey_wfs_id, layer_featuretype_list)"
+            ." VALUES ($1, $2, $3, $4, $5, $6, $7, $8)";
+   		$t = array("i","i","s","i","r", "i", "i", "s");
+		$priceFeatures=$price;
+		$v = array(0,intval($user_id),$getfeature,$priceFeatures, 0, $numberOfFeatures, intval($wfs_id), $featuretype);
+		$res = db_prep_query($sql,$v,$t) or die(db_error());
+		if(!$res){
+			include_once(dirname(__FILE__)."/class_mb_exception.php");
+			$e = new mb_exception("class_log: Writing table mb_proxy_log failed.");
+			return false;
+		}
+		$res_id = db_query("select currval('mb_proxy_log_log_id_seq') as log_id");
+                if(pg_num_rows($res_id)){
+            		$row = db_fetch_array($res_id);
+            		$id = $row["log_id"];
+            		return intval($id);
+        	} else {
+            		return false;
+        	}
+	}
+
+    	function logFullWmsProxyRequest($wms_id,$user_id,$getmap,$price,$got_result,$set0Pixels=false){
    		$sql = "INSERT INTO mb_proxy_log "
             ."(fkey_wms_id,fkey_mb_user_id, request, pixel, price, layer_featuretype_list, request_type, got_result) "
             ."VALUES ($1, $2, $3, $4, $5, $6, 'getMap', $7)";
@@ -1259,7 +1415,8 @@
         } else {
             return false;
         }
-   	}	
+   }
+	
     function updateWmsLog($got_result, $error_message, $error_mime_type, $log_id){
         $sql = "UPDATE mb_proxy_log SET got_result=$1,error_message=$2,error_mime_type=$3"
             . ($got_result === -1 ? ',pixel=0' : '') ." WHERE log_id=$4";
@@ -1274,6 +1431,26 @@
 		}
         return true;
     }	
+
+    function updateWfsLog($got_result, $error_message, $error_mime_type, $features, $log_id){
+        $sql = "UPDATE mb_proxy_log SET got_result=$1,error_message=$2,error_mime_type=$3"
+            . ($got_result === -1 ? ',features=0' : ',features=$5') ." WHERE log_id=$4";
+        $t = array("i","s","s","i","i");
+        $v = array($got_result, $error_message, $error_mime_type, $log_id, $features);
+        $res = db_prep_query($sql,$v,$t) or die(db_error());
+	if(!$res){
+		include_once(dirname(__FILE__)."/class_mb_exception.php");
+		$e = new mb_exception("class_log: Updating table mb_proxy_log failed.");
+		return false;
+	}
+        //calculate total price
+	$sql = "UPDATE mb_proxy_log SET price = price * features WHERE log_id = $1";
+	$t = array("i");
+	$v = array($log_id);
+	$res = db_prep_query($sql,$v,$t);
+        return true;
+    }	
+
     function logWmsGFIProxyRequest($wms_id,$user_id,$getmap,$price){
    		$sql = "INSERT INTO mb_proxy_log "
             ."(fkey_wms_id,fkey_mb_user_id, request, price, layer_featuretype_list, request_type) "

Modified: trunk/mapbender/http/classes/class_mb_exception.php
===================================================================
--- trunk/mapbender/http/classes/class_mb_exception.php	2016-01-19 11:04:36 UTC (rev 9373)
+++ trunk/mapbender/http/classes/class_mb_exception.php	2016-01-19 11:05:15 UTC (rev 9374)
@@ -31,7 +31,7 @@
 	 * @param	string $message		message that is being logged
 	 */
 	public function __construct ($message) {
-		if ($message == Exception) {
+		if ($message == 'Exception') {
 			return $this->mb_log("ERROR: " . $e->getMessage(), $this->level);
 		}
 		return $this->mb_log("ERROR: " . $message, $this->level);



More information about the Mapbender_commits mailing list