[Mapbender-commits] r9740 - in trunk/mapbender/http: classes plugins

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri May 12 04:19:42 PDT 2017


Author: armin11
Date: 2017-05-12 04:19:42 -0700 (Fri, 12 May 2017)
New Revision: 9740

Added:
   trunk/mapbender/http/classes/class_owsproxy_log.php
Modified:
   trunk/mapbender/http/plugins/mb_owsproxy_log_csv.js
   trunk/mapbender/http/plugins/mb_owsproxy_log_csv.php
Log:
Extent owsproxy log export to export also wfs logs

Added: trunk/mapbender/http/classes/class_owsproxy_log.php
===================================================================
--- trunk/mapbender/http/classes/class_owsproxy_log.php	                        (rev 0)
+++ trunk/mapbender/http/classes/class_owsproxy_log.php	2017-05-12 11:19:42 UTC (rev 9740)
@@ -0,0 +1,655 @@
+<?php
+# License:
+# Copyright (c) 2009, Open Source Geospatial Foundation
+# This program is dual licensed under the GNU General Public License 
+# and Simplified BSD license.  
+# http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt
+
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
+
+class OwsLogCsv {
+    private $mb_user_id;
+    private $function;
+    private $listType;
+    private $userId;
+    private $owsType;
+    private $owsId;
+    private $timeFrom;
+    private $timeTo;
+    private $withContactData;
+    
+    private $resultHeader;
+    private $resultHeaderDisplay;
+    private $resultData;
+    private $resultDataDisplay;
+    private $resultMessage;
+    
+    
+    private static $SEPARATOR_VALUE = "\t";
+    private static $SEPARATOR_ROW = "\n";
+    
+    private static $LIMIT_INT = OWS_LOG_EXPORT_LIMIT;
+    
+    private static $LIMIT_SQL = " ORDER BY m.log_id DESC LIMIT ";
+    
+    private function __construct() {
+    }
+    
+    public static function create($mb_user_id, $function, $userId, $owsId, $listType, $timeFrom, $timeTo, $withContactData, $owsType){
+        if($listType === null){
+            return "Der Parameter 'listType' wurde nicht uebergeben.";
+        } else if($listType != "service" && $listType != "user"){
+            return "Der 'listType' ".$listType." ist nicht unterstuetzt.";
+        }
+        if(($listType == "service" && $owsId === null)
+                || ($listType == "user" && $userId === null)){
+            return "Parameter 'userId' oder/und 'owsId' wurde/n nicht uebergeben.";
+        }
+        
+        if ($timeFrom === null || $timeTo === null){
+            return "Parameter 'timeFrom' oder/und 'timeTo' wurde/n nicht uebergeben.";
+        }
+
+        if($function == null
+                 || ($function != "getServiceLogs"
+                 && $function != "listServiceLogs"
+                 && $function != "getSum"
+                 && $function != "deleteServiceLogs")){
+            return "Der Parameter 'function' wurde nicht uebergeben bzw. ist nicth unterstützt";
+        }
+
+        $owslogcsv = new OwsLogCsv();
+        $owslogcsv->owsId = $owsId;
+        $owslogcsv->owsType = $owsType;
+        $owslogcsv->userId = $userId;
+        $owslogcsv->timeFrom = $timeFrom;
+        $owslogcsv->timeTo = $timeTo;
+        $owslogcsv->mb_user_id = $mb_user_id;
+        $owslogcsv->listType = $listType;
+        $owslogcsv->function = $function;
+        
+        if($withContactData != null && strlen($withContactData) > 0){
+            $owslogcsv->withContactData = $withContactData;
+        }
+        $owslogcsv->resultHeader = array();
+        $owslogcsv->resultHeaderDisplay = array();
+        $owslogcsv->resultData = array();
+        $owslogcsv->resultDataDisplay = array();
+        $owslogcsv->resultMessage = "";
+        return $owslogcsv;
+    }
+    
+    public function handle(){
+        if($this->function == "getServiceLogs"){
+            $this->getServiceLogs();
+        } else if($this->function == "listServiceLogs"){
+            $this->listServiceLogs();
+        } else if($this->function == "deleteServiceLogs"){
+            $this->deleteServiceLogs();
+        } else if($this->function == "getSum"){
+            $this->getSum();
+        }
+    }
+
+    private function getSum() {
+        $this->getServiceLogs();
+
+        if(!empty($this->resultData)) {
+            $rowCount = count($this->resultData[0]);
+            $maxRows = (count($this->resultData) -1);
+            $offset = array();
+            $data = array();
+
+            for($i=0;$i<$rowCount;$i++) {
+                if($this->resultHeader[$i] == 'price')
+                    $data[] = array('price', $this->resultData[$maxRows][$i]);
+                else if($this->resultHeader[$i] == 'pixel')
+                    $data[] = array('pixel', $this->resultData[$maxRows][$i]);
+            }
+
+            
+        }
+
+        $this->resultHeader = array();
+        $this->resultData = $data;
+    }
+
+    private function getServiceLogs(){
+#function=getServiceLogs&listType=service&serviceType=wms& owsId=xyz&timeFrom=2012-05-31T12:01&timeTo=2012-05-31T12:12&withContactData=1
+#function=getServiceLogs&listType=user&   serviceType=wms&userId=xyz&timeFrom=2012-05-31T12:01&timeTo=2012-05-31T12:12
+        if($this->listType == "service"){
+            $selectColumns = " m.*,u.mb_user_id,u.mb_user_name";
+		switch ($this->owsType) {
+			case "wms":
+           			$selectColumnsDisplay = " m.fkey_wms_id as wms_id,u.mb_user_id,u.mb_user_name, sum(m.pixel) as pixel,sum(m.price) as price";
+				$groupByForDisplay = " GROUP BY m.fkey_wms_id, u.mb_user_id,u.mb_user_name  ORDER BY m.fkey_wms_id DESC";
+				break;
+			case "wfs":
+           			$selectColumnsDisplay = " m.fkey_wfs_id as wfs_id,u.mb_user_id,u.mb_user_name, sum(m.features) as features,sum(m.price) as price";
+				$groupByForDisplay = " GROUP BY m.fkey_wfs_id, u.mb_user_id,u.mb_user_name  ORDER BY m.fkey_wfs_id DESC";
+				break;
+		}
+
+            $join = " INNER JOIN mb_user AS u ON (u.mb_user_id = m.fkey_mb_user_id)";
+//            $innerjoinContactData = "";
+            if($this->withContactData !== null && $this->withContactData == "1") {
+                	$selectColumns .= ",u.mb_user_firstname,mb_user_lastname"
+                        .",u.mb_user_department,u.mb_user_description"
+                        .",u.mb_user_email,u.mb_user_phone,u.mb_user_street"
+                        .",u.mb_user_housenumber,u.mb_user_postal_code"
+                        .",u.mb_user_city";
+			switch ($this->owsType) {
+				case "wms":
+           				$groupByForDisplay = " GROUP BY m.fkey_wms_id, u.mb_user_id,u.mb_user_name, u.mb_user_firstname,mb_user_lastname,u.mb_user_department,u.mb_user_description,u.mb_user_email,u.mb_user_phone,u.mb_user_street,u.mb_user_housenumber,u.mb_user_postal_code,u.mb_user_city ORDER BY m.fkey_wms_id DESC";
+					break;
+				case "wfs":
+           				$groupByForDisplay = " GROUP BY m.fkey_wfs_id, u.mb_user_id,u.mb_user_name, u.mb_user_firstname,mb_user_lastname,u.mb_user_department,u.mb_user_description,u.mb_user_email,u.mb_user_phone,u.mb_user_street,u.mb_user_housenumber,u.mb_user_postal_code,u.mb_user_city ORDER BY m.fkey_wfs_id DESC";
+					break;
+			}
+            }
+            $v = array($this->mb_user_id, $this->timeFrom, $this->timeTo);
+//            $v = array($this->owsId, $this->timeFrom, $this->timeTo, 9415);
+            $t = array('i', "t", "t");
+            $owsIdWhere = "";
+            if($this->owsId !== null && intval($this->owsId)> -1){
+                $v[] = $this->owsId;
+                $t[] = "i";
+		switch ($this->owsType) {
+			case "wms":
+           			$owsIdWhere = " AND m.fkey_wms_id = $".count($v);
+				break;
+			case "wfs":
+           			$owsIdWhere = " AND m.fkey_wfs_id = $".count($v);
+				break;
+		}
+            }
+      	switch ($this->owsType) {
+		case "wms":
+           		$sql  = "SELECT".$selectColumns
+                    	." FROM mb_proxy_log AS m INNER JOIN wms AS w ON"
+                    	." (m.fkey_wms_id = w.wms_id AND w.wms_owner=$1"
+                   	.$owsIdWhere." AND m.proxy_log_timestamp >= $2"
+                    	." AND m.proxy_log_timestamp <= $3)".$join;
+		                
+            		$sqlDisplay  = "SELECT".$selectColumnsDisplay
+           		." FROM mb_proxy_log AS m INNER JOIN wms AS w ON"
+            		." (m.fkey_wms_id = w.wms_id AND w.wms_owner=$1"
+            		.$owsIdWhere." AND m.proxy_log_timestamp >= $2"
+            		." AND m.proxy_log_timestamp <= $3)".$join
+            		." ". $groupByForDisplay;
+			break;
+		case "wfs":
+           		$sql  = "SELECT".$selectColumns
+                    	." FROM mb_proxy_log AS m INNER JOIN wfs AS w ON"
+                    	." (m.fkey_wfs_id = w.wfs_id AND w.wfs_owner=$1"
+                   	.$owsIdWhere." AND m.proxy_log_timestamp >= $2"
+                    	." AND m.proxy_log_timestamp <= $3)".$join;
+		                
+            		$sqlDisplay  = "SELECT".$selectColumnsDisplay
+           		." FROM mb_proxy_log AS m INNER JOIN wfs AS w ON"
+            		." (m.fkey_wfs_id = w.wfs_id AND w.wfs_owner=$1"
+            		.$owsIdWhere." AND m.proxy_log_timestamp >= $2"
+            		." AND m.proxy_log_timestamp <= $3)".$join
+            		." ". $groupByForDisplay;
+			break;
+	}    
+            $result = db_prep_query($sql,$v,$t);
+            $resultDisplay = db_prep_query($sqlDisplay,$v,$t);
+            $this->readResult($result);
+            $this->readResultDisplay($resultDisplay);
+        } else if($this->listType == "user"){
+		switch ($this->owsType) {
+			case "wms":
+           			$selectColumns = " m.*,w.wms_title,w.wms_version,w.wms_abstract";
+            			$selectColumnsDisplay = " m.fkey_wms_id as wms_id,w.wms_title,w.wms_version,w.wms_abstract, sum(m.pixel) as pixel,sum(m.price) as price";
+            			$groupByForDisplay = " GROUP BY m.fkey_wms_id,w.wms_title,w.wms_version,w.wms_abstract ORDER BY m.fkey_wms_id DESC";
+				break;
+			case "wfs":
+           			$selectColumns = " m.*,w.wfs_title,w.wfs_version,w.wfs_abstract";
+            			$selectColumnsDisplay = " m.fkey_wfs_id as wfs_id,w.wfs_title,w.wfs_version,w.wfs_abstract, sum(m.features) as features,sum(m.price) as price";
+            			$groupByForDisplay = " GROUP BY m.fkey_wfs_id,w.wfs_title,w.wfs_version,w.wfs_abstract ORDER BY m.fkey_wfs_id DESC";
+				break;
+		}
+            $join = "";
+//            $innerjoinContactData = "";
+            if($this->withContactData !== null && $this->withContactData == "1") {
+                $selectColumns .= ",u.mb_user_firstname,mb_user_lastname"
+                        .",u.mb_user_department,u.mb_user_description"
+                        .",u.mb_user_email,u.mb_user_phone,u.mb_user_street"
+                        .",u.mb_user_housenumber,u.mb_user_postal_code"
+                        .",u.mb_user_city";
+                $join .= " INNER JOIN mb_user AS u  ON (u.mb_user_id = m.fkey_mb_user_id)";
+		switch ($this->owsType) {
+			case "wms":
+           			$groupByForDisplay = " GROUP BY m.fkey_wms_id, 		w.wms_title,w.wms_version,w.wms_abstract,u.mb_user_firstname,mb_user_lastname,u.mb_user_department,u.mb_user_description,u.mb_user_email,u.mb_user_phone,u.mb_user_street,u.mb_user_housenumber,u.mb_user_postal_code,u.mb_user_city ORDER BY m.fkey_wms_id DESC";
+				break;
+			case "wfs":
+           			$groupByForDisplay = " GROUP BY m.fkey_wfs_id, 		w.wfs_title,w.wfs_version,w.wfs_abstract,u.mb_user_firstname,mb_user_lastname,u.mb_user_department,u.mb_user_description,u.mb_user_email,u.mb_user_phone,u.mb_user_street,u.mb_user_housenumber,u.mb_user_postal_code,u.mb_user_city ORDER BY m.fkey_wfs_id DESC";
+				break;
+		}
+            }            
+            
+            $v = array($this->timeFrom, $this->timeTo, $this->mb_user_id);
+            $t = array("t", "t", "i");
+            
+            /* GUI start*/
+            if(intval($this->userId) == -1){ // all users
+                $userWhere = "";
+            } else {
+                $v[] = $this->userId;
+                $t[] = "i";
+                $userWhere = " AND m.fkey_mb_user_id = $".count($v);
+            }
+            $owsIdWhere = "";
+            if($this->owsId !== null && strlen($this->owsId)> 0 && intval($this->owsId)> -1){
+                $v[] = $this->owsId;
+                $t[] = "i";
+		switch ($this->owsType) {
+			case "wms":
+           			$owsIdWhere = " AND m.fkey_wms_id=$".count($v);
+				break;
+			case "wfs":
+           			$owsIdWhere = " AND m.fkey_wfs_id=$".count($v);
+				break;
+		}
+            }
+            /* GUI end*/
+		switch ($this->owsType) {
+			case "wms":
+           			$sql  = "SELECT ".$selectColumns
+                    		." FROM mb_proxy_log AS m INNER JOIN wms AS w ON"
+                    		." (m.fkey_wms_id = w.wms_id AND w.wms_owner=$3"
+                    		.$userWhere." AND m.proxy_log_timestamp >= $1"
+                    		." AND m.proxy_log_timestamp <= $2".$owsIdWhere.")".$join;
+		    
+            			$sqlDisplay  = "SELECT".$selectColumnsDisplay
+				." FROM mb_proxy_log AS m INNER JOIN wms AS w ON"
+                    		." (m.fkey_wms_id = w.wms_id AND w.wms_owner=$3"
+                    		.$userWhere." AND m.proxy_log_timestamp >= $1"
+                    		." AND m.proxy_log_timestamp <= $2".$owsIdWhere.")".$join
+            			." ". $groupByForDisplay;
+				break;
+			case "wfs":
+           			$sql  = "SELECT ".$selectColumns
+                    		." FROM mb_proxy_log AS m INNER JOIN wfs AS w ON"
+                    		." (m.fkey_wfs_id = w.wfs_id AND w.wfs_owner=$3"
+                    		.$userWhere." AND m.proxy_log_timestamp >= $1"
+                    		." AND m.proxy_log_timestamp <= $2".$owsIdWhere.")".$join;
+		    
+            			$sqlDisplay  = "SELECT".$selectColumnsDisplay
+				." FROM mb_proxy_log AS m INNER JOIN wfs AS w ON"
+                    		." (m.fkey_wfs_id = w.wfs_id AND w.wfs_owner=$3"
+                    		.$userWhere." AND m.proxy_log_timestamp >= $1"
+                    		." AND m.proxy_log_timestamp <= $2".$owsIdWhere.")".$join
+            			." ". $groupByForDisplay;
+				break;
+		}
+            $result = db_prep_query($sql,$v,$t);
+            $resultDisplay = db_prep_query($sqlDisplay,$v,$t);
+            $this->readResult($result);
+            $this->readResultDisplay($resultDisplay);
+        }
+    }
+
+    private function listServiceLogs(){
+#function=listServiceLogs&listType=service&serviceType=wms& owsId=xyz&timeFrom=2012-05-31T12:01&timeTo=2012-05-31T12:12&withContactData=1
+#function=listServiceLogs&listType=user&   serviceType=wms&userId=xyz&timeFrom=2012-05-31T12:01&timeTo=2012-05-31T12:12
+#function=listServiceLogs&listType=user&   serviceType=wms&userId=xyz&timeFrom=2012-05-31T12:01&timeTo=2012-05-31T12:12&owsId=xyz
+        if($this->listType == "service"){
+            $selectColumns = " m.log_id,u.mb_user_id,u.mb_user_name,u.mb_user_department";
+            $join = " INNER JOIN mb_user AS u  ON (u.mb_user_id = m.fkey_mb_user_id)";
+            if($this->withContactData !== null && $this->withContactData == "1") {
+                $selectColumns .= ",u.mb_user_firstname,mb_user_lastname"
+                        .",u.mb_user_street,u.mb_user_housenumber"
+                        .",u.mb_user_postal_code,u.mb_user_city";
+            }
+            $v = array($this->owsId, $this->timeFrom, $this->timeTo, $this->mb_user_id);
+//            $v = array($this->owsId, $this->timeFrom, $this->timeTo, 9415);
+            $t = array('i', "t", "t", "i");
+		switch ($this->owsType) {
+			case "wms":
+           			$sql  = "SELECT".$selectColumns
+                    		." FROM mb_proxy_log AS m INNER JOIN wms AS w ON"
+                    		." (m.fkey_wms_id = w.wms_id AND w.wms_owner=$4"
+                    		." AND m.fkey_wms_id = $1 AND  m.proxy_log_timestamp >= $2"
+                    		." AND m.proxy_log_timestamp <= $3)".$join
+                    		." GROUP BY m.log_id, ".$selectColumns
+		    		. OwsLogCsv::$LIMIT_SQL . OwsLogCsv::$LIMIT_INT;
+				break;
+			case "wfs":
+           			$sql  = "SELECT".$selectColumns
+                    		." FROM mb_proxy_log AS m INNER JOIN wfs AS w ON"
+                    		." (m.fkey_wfs_id = w.wfs_id AND w.wfs_owner=$4"
+                    		." AND m.fkey_wfs_id = $1 AND  m.proxy_log_timestamp >= $2"
+                    		." AND m.proxy_log_timestamp <= $3)".$join
+                    		." GROUP BY m.log_id, ".$selectColumns
+		    		. OwsLogCsv::$LIMIT_SQL . OwsLogCsv::$LIMIT_INT;
+				break;
+		}
+            $result = db_prep_query($sql,$v,$t);
+            $this->readResult($result);
+        } else if($this->listType == "user"){
+		switch ($this->owsType) {
+			case "wms":
+           			$selectColumns = " m.log_id,w.wms_id,w.wms_title";
+				break;
+			case "wfs":
+           			$selectColumns = " m.log_id,w.wfs_id,w.wfs_title";
+				break;
+		}
+            $join = "";
+//            $innerjoinContactData = "";
+            if($this->withContactData !== null && $this->withContactData == "1") {
+                $selectColumns .= ",u.mb_user_firstname,mb_user_lastname"
+                        .",u.mb_user_department,u.mb_user_description"
+                        .",u.mb_user_email,u.mb_user_phone,u.mb_user_street"
+                        .",u.mb_user_housenumber,u.mb_user_postal_code"
+                        .",u.mb_user_city";
+                $join .= " INNER JOIN mb_user AS u  ON (u.mb_user_id = m.fkey_mb_user_id)";
+            }
+            $v = array($this->userId, $this->timeFrom, $this->timeTo, $this->mb_user_id);
+//            $v = array($this->userId, $this->timeFrom, $this->timeTo, 9415);
+            $t = array('i', "t", "t", "i");
+            $whereOws = "";
+		switch ($this->owsType) {
+			case "wms":
+           			$sql  = "SELECT ".$selectColumns
+                    		." FROM mb_proxy_log AS m INNER JOIN wms AS w ON"
+                    		." (m.fkey_wms_id = w.wms_id AND w.wms_owner=$4"
+                    		." AND m.fkey_mb_user_id = $1 AND m.proxy_log_timestamp >= $2"
+                    		." AND m.proxy_log_timestamp <= $3".$whereOws.")".$join
+                    		." GROUP BY m.log_id, ".$selectColumns
+		    		. OwsLogCsv::$LIMIT_SQL . OwsLogCsv::$LIMIT_INT;
+				break;
+			case "wfs":
+           			$sql  = "SELECT ".$selectColumns
+                    		." FROM mb_proxy_log AS m INNER JOIN wfs AS w ON"
+                    		." (m.fkey_wfs_id = w.wfs_id AND w.wfs_owner=$4"
+                    		." AND m.fkey_mb_user_id = $1 AND m.proxy_log_timestamp >= $2"
+                    		." AND m.proxy_log_timestamp <= $3".$whereOws.")".$join
+                    		." GROUP BY m.log_id, ".$selectColumns
+		    		. OwsLogCsv::$LIMIT_SQL . OwsLogCsv::$LIMIT_INT;
+				break;
+		}
+            $result = db_prep_query($sql,$v,$t);
+            $this->readResult($result);
+        }
+    }
+
+    private function deleteServiceLogs(){
+#function=deleteServiceLogs&listType=service&serviceType=wms& owsId=xyz&timeFrom=2012-05-31T12:01&timeTo=2012-05-31T12:12
+#function=deleteServiceLogs&listType=user&   serviceType=wms&userId=xyz&timeFrom=2012-05-31T12:01&timeTo=2012-05-31T12:12
+#function=deleteServiceLogs&listType=user&   serviceType=wms&userId=xyz&timeFrom=2012-05-31T12:01&timeTo=2012-05-31T12:12&owsId=xyz
+        if($this->listType == "service"){
+//            $v = array($owsId, $timeFrom, $timeTo);
+//            $t = array('i', "t", "t");
+//            $sql = "DELETE FROM mb_proxy_log WHERE fkey_wms_id = $1"
+//                    ." AND proxy_log_timestamp >= $2 AND proxy_log_timestamp <= $3";
+            $v = array($this->timeFrom, $this->timeTo, $this->mb_user_id);
+            $t = array("t", "t", "i");
+		switch ($this->owsType) {
+			case "wms":
+           			$sql = "DELETE FROM mb_proxy_log"
+                    		." WHERE log_id in("
+                        	." SELECT m.log_id"
+                        	." FROM mb_proxy_log AS m INNER JOIN wms AS w ON"
+                        	." (m.fkey_wms_id = w.wms_id AND w.wms_owner=$3";
+				break;
+			case "wfs":
+           			$sql = "DELETE FROM mb_proxy_log"
+                    		." WHERE log_id in("
+                        	." SELECT m.log_id"
+                        	." FROM mb_proxy_log AS m INNER JOIN wfs AS w ON"
+                        	." (m.fkey_wfs_id = w.wfs_id AND w.wfs_owner=$3";
+				break;
+		}
+            $inOffset = 4;
+    		foreach(explode(",",$this->owsId) as $ows) {
+    			$v[] = trim($ows);
+    			$t[] = "i";
+    			$inParams[] = "$".$inOffset;
+    			$inOffset++;
+    		}
+		switch ($this->owsType) {
+			case "wms":
+ 				$sql .= " AND m.fkey_wms_id IN (" .implode(",",$inParams) .")";
+				break;
+			case "wfs":
+ 				$sql .= " AND m.fkey_wfs_id IN (" .implode(",",$inParams) .")";
+				break;
+		}
+    		$sql .= " AND  m.proxy_log_timestamp >= $1"
+                   ." AND m.proxy_log_timestamp <= $2)"
+                    .")";
+            $result = db_prep_query($sql,$v,$t);
+            $resnum = pg_affected_rows($result);
+            if($resnum > 0){
+                $this->resultMessage = $resnum." Log-Datensaetze (DienstId :".$this->owsId.") wurden erfolgreich geloescht.";
+            } else {
+                $this->resultMessage = "Kein Log-Datensatz (DienstId: ".$this->owsId.") wurde geloescht.";
+            }
+        } else if($this->listType == "user"){
+//            $v = array($userId, $timeFrom, $timeTo);
+//            $t = array('i', "t", "t");
+//            $sql = "DELETE FROM mb_proxy_log WHERE fkey_mb_user_id = $1"
+//                    ." AND proxy_log_timestamp >= $2 AND proxy_log_timestamp <= $3";
+//            if($owsId !== null && $owsId != "") {
+//                $sql .= " AND fkey_wms_id = $4";
+//                $v[] = $owsId;
+//                $t[] = 'i';
+//            }
+            $v = array($this->userId, $this->timeFrom, $this->timeTo, $this->mb_user_id);
+            $t = array('i', "t", "t", "i");
+            $whereOws = "";
+            if($this->owsId !== null && $this->owsId != "") {
+		switch ($this->owsType) {
+			case "wms":
+ 				$whereOws = " AND m.fkey_wms_id IN (";
+				break;
+			case "wfs":
+ 				$whereOws = " AND m.fkey_wfs_id IN (";
+				break;
+		}
+                $inOffset = 5;
+    			foreach(explode(",",$this->owsId) as $ows) {
+    				$v[] = trim($ows);
+    				$t[] = "i";
+    				$inParams[] = "$".$inOffset;
+    				$inOffset++;
+    			}
+
+                $whereOws .= implode(",",$inParams); 
+    			
+                $whereOws .= ")";
+            }
+		switch ($this->owsType) {
+			case "wms":
+ 				$sql = "DELETE FROM mb_proxy_log"
+                    		." WHERE log_id in("
+                        	." SELECT m.log_id"
+                        	." FROM mb_proxy_log AS m INNER JOIN wms AS w ON"
+                        	." (m.fkey_wms_id = w.wms_id AND w.wms_owner=$4"
+                        	." AND m.fkey_mb_user_id = $1 AND  m.proxy_log_timestamp >= $2"
+                        	." AND m.proxy_log_timestamp <= $3".$whereOws.")"
+                    		.")";
+				break;
+			case "wfs":
+ 				$sql = "DELETE FROM mb_proxy_log"
+                    		." WHERE log_id in("
+                        	." SELECT m.log_id"
+                        	." FROM mb_proxy_log AS m INNER JOIN wfs AS w ON"
+                        	." (m.fkey_wfs_id = w.wfs_id AND w.wfs_owner=$4"
+                        	." AND m.fkey_mb_user_id = $1 AND  m.proxy_log_timestamp >= $2"
+                        	." AND m.proxy_log_timestamp <= $3".$whereOws.")"
+                    		.")";
+				break;
+		}
+            $result = db_prep_query($sql,$v,$t);
+            $resnum = pg_affected_rows($result);
+
+            if($resnum > 0){
+                if($this->owsId !== null && $this->owsId != ""){
+                    $this->resultMessage = $resnum." Log-Datensaetze (DienstId :".$this->owsId.", UserId: ".$this->userId.") wurden erfolgreich geloescht.";
+                } else {
+                    $this->resultMessage = $resnum." Log-Datensaetze (UserId: ".$this->userId.") wurden erfolgreich geloescht.";
+                }
+            } else {
+                if($this->owsId !== null && $this->owsId != ""){
+                    $this->resultMessage = "Kein Log-Datensatz (DienstId: ".$this->owsId.", UserId: ".$this->userId.") wurde geloescht.";
+                } else {
+                    $this->resultMessage = "Kein Log-Datensatz (UserId: ".$this->userId.") wurde geloescht.";
+                }
+            }
+        }
+    }
+    
+    private function readResult($result){
+    	$offsetPixel = null;
+    	$offsetPrice = null;
+    	$offsetFeatures = null;
+    	$sumPixel = 0;
+    	$sumPrice = 0;
+    	$sumFeatures = 0;
+    	if ($result != false) {
+    		$num_fields = pg_num_fields($result);
+    		for ( $i = 0; $i < $num_fields; $i++ ){
+    			$field_name = pg_field_name($result , $i);
+    			$this->resultHeader[] = $field_name;
+    			// keep offsets of prixel and price row
+    			if($field_name === "pixel")        $offsetPixel = $i;
+    			else if($field_name === "price")   $offsetPrice = $i;
+			else if($field_name === "features")   $offsetFeatures = $i;
+    		}
+    	}
+    	$i = 0;
+    	while($row = db_fetch_row($result)){
+    		foreach( $row as $key=>$value){
+    			$this->resultData[$i][] = $value;
+    			    
+    			if($key == $offsetPixel)        $sumPixel += $value;
+    			else if($key == $offsetPrice)   $sumPrice += $value;
+   			else if($key == $offsetFeatures)   $sumFeatures += $value;
+    		}
+    		$i++;
+    	}
+    
+    	if(!is_null($offsetPixel) || !is_null($offsetPrice) || !is_null($offsetFeatures)) {
+    		for($j=0;$j<$num_fields;$j++) {
+    			if($j == $offsetPixel && !is_null($offsetPixel)) {
+    				$this->resultData[$i][] = (string)$sumPixel;
+    			}
+    			else if($j == $offsetPrice && !is_null($offsetPrice)) {
+    				$this->resultData[$i][] = (string)$sumPrice;
+    			}
+    			else if($j == $offsetFeatures && !is_null($offsetFeatures)) {
+    				$this->resultData[$i][] = (string)$sumFeatures;
+    			}
+    			else {
+    				$this->resultData[$i][] = '---';
+    			}
+    		}
+    	}
+    }
+    
+    private function readResultDisplay($result){
+        $offsetPixel = null;
+        $offsetPrice = null;
+        $offsetFeatures = null;
+        $sumPixel = 0;
+        $sumPrice = 0;
+    	$sumFeatures = 0;
+        if ($result != false) {
+            $num_fields = pg_num_fields($result);
+            for ( $i = 0; $i < $num_fields; $i++ ){
+                $field_name = pg_field_name($result , $i);
+                $this->resultHeaderDisplay[] = $field_name;
+
+                // keep offsets of prixel and price row
+                if($field_name === "pixel")        $offsetPixel = $i;
+                else if($field_name === "price")   $offsetPrice = $i;
+                else if($field_name === "features")   $offsetFeatures = $i;
+            }
+        }
+        $i = 0;
+        while($row = db_fetch_row($result)){
+        foreach( $row as $key=>$value){
+    			$this->resultDataDisplay[$i][] = $value;
+    			    
+    			if($key == $offsetPixel)        $sumPixel += $value;
+    			else if($key == $offsetPrice)   $sumPrice += $value;
+    			else if($key == $offsetFeatures)   $sumFeatures += $value;
+    		}
+
+            $i++;
+        }
+        
+        if(!is_null($offsetPixel) || !is_null($offsetPrice)) {
+        	for($j=0;$j<$num_fields;$j++) {
+        		if($j == $offsetPixel && !is_null($offsetPixel)) {
+        			$this->resultDataDisplay[$i][] = (string)$sumPixel;
+        		}
+        		else if($j == $offsetPrice && !is_null($offsetPrice)) {
+        			$this->resultDataDisplay[$i][] = (string)$sumPrice;
+        		}
+        		else if($j == $offsetFeatures && !is_null($offsetFeatures)) {
+        			$this->resultDataDisplay[$i][] = (string)$sumFeatures;
+        		}
+        		else {
+        			$this->resultDataDisplay[$i][] = '---';
+        		}
+        	}
+        }
+    }
+    
+    public function getAsCsv(){
+        $header = "";
+        $data = "";
+        foreach($this->resultHeader as $colname){
+            $header .= '"'.$colname.'"'.OwsLogCsv::$SEPARATOR_VALUE;
+        }
+
+        foreach($this->resultData as $row){
+            $line = '';
+            foreach( $row as $value){
+                if ($value == null || $value == ""){
+                    $value = "".OwsLogCsv::$SEPARATOR_VALUE;
+                } else {
+//                    if(CHARSET == 'UTF-8'){
+//                        $value = utf8_encode($value);
+//                    }
+                    $value = str_replace('"', '""', $value);
+                    $value = '"'.$value.'"'.OwsLogCsv::$SEPARATOR_VALUE;
+                }
+                $line .= $value;
+            }
+            $data .= trim($line).OwsLogCsv::$SEPARATOR_ROW;
+        }
+        return $header.OwsLogCsv::$SEPARATOR_ROW.$data;
+    }
+    
+    public function getAsArray($function=null) {
+    	if($function == "getServiceLogs") {
+    		return array(
+    				"function"=> $this->function,
+    				"header"=> $this->resultHeader,
+    				"headerDisplay"=> $this->resultHeaderDisplay,
+    				//"data" => $this->resultData,
+    				"dataDisplay" => $this->resultDataDisplay,
+    				"message" => $this->resultMessage,
+    				"error" => "",
+    				"limit" => OwsLogCsv::$LIMIT_INT);
+    	}
+    	else {
+	        return array(
+	            "function"=> $this->function,
+	            "header"=> $this->resultHeader,
+	        	"headerDisplay"=> $this->resultHeaderDisplay,
+	            "data" => $this->resultData,
+	        	"dataDisplay" => $this->resultDataDisplay,
+	            "message" => $this->resultMessage,
+	            "error" => "",
+	            "limit" => OwsLogCsv::$LIMIT_INT);
+    	}
+    }
+}
+?>

Modified: trunk/mapbender/http/plugins/mb_owsproxy_log_csv.js
===================================================================
--- trunk/mapbender/http/plugins/mb_owsproxy_log_csv.js	2017-05-12 10:05:32 UTC (rev 9739)
+++ trunk/mapbender/http/plugins/mb_owsproxy_log_csv.js	2017-05-12 11:19:42 UTC (rev 9740)
@@ -24,12 +24,13 @@
 	var that = this;
     var lastRequestData = null;
     
-    this.loadForm = function() {
+    this.loadForm = function(serviceType) {
         $.ajax({
             url: "../plugins/mb_owsproxy_log_csv.php",
             type: "post",
+	    async: false,
             dataType: "json",
-            data: {action: "getForm",XDEBUG_SESSION_START:"netbeans-xdebug"},
+            data: {action: "getForm",XDEBUG_SESSION_START:"netbeans-xdebug", serviceType: serviceType},
             success: function(data){
                 if(data.error != "") {
                     alert(data.error);
@@ -40,14 +41,21 @@
                     $owsproxyCsv.find("input#button-csv-download").bind("click", that.loadCsvData);
                     $owsproxyCsv.find("input#button-logs-delete").bind("click", that.deleteData);
                     $owsproxyCsv.find("div.field select#listType").bind("change", that.initSelects);
+		    $owsproxyCsv.find("div.field select#serviceType").bind("change", that.reloadServicesAndUsers);
                     $owsproxyCsv.find("div.field select#function").bind("change", that.initSelects);
                     that.initForm();
+		    
                     if(data.message != ""){
                         $owsproxyCsv.find("input#button-logs-query").attr('disabled','disabled');
                         alert(data.message);
                     }
                 }
-            }
+            },
+	    complete: function (data) {
+      		//alert(serviceType);
+		//$("div.field select#servicetype").val(serviceType).prop('selected', true);
+		//$('#gate').val('Gateway 2').prop('selected', true);
+     	    }
         });
     };
     this.loadCsvData = function(e){
@@ -57,8 +65,14 @@
         }
     }
     
+    this.reloadServicesAndUsers = function(e){
+	//alert($("div.field select#serviceType").val());
+	that.loadForm($("div.field select#serviceType").val());
+	//$("div.field select#servicetype").val($("div.field select#serviceType").val()).prop('selected', true);
+    }
+
     this.deleteData = function(e){
-    	if(lastRequestData.wmsId == -1) {
+    	if(lastRequestData.serviceId == -1) {
     		var delMsg = "Die Logeinträge ALLER vorhandenen Dienste aus der Liste werden gelöscht. Soll diese Aktion ausgeführt werden?";
     	}
     	else {
@@ -70,14 +84,14 @@
         if (lastRequestData != null){
             var parameter = lastRequestData;
             parameter['function'] = "deleteServiceLogs";
-        		if(lastRequestData.wmsId == -1) {
+        		if(lastRequestData.serviceId == -1) {
         			var allServices = new Array();
-        			$('#wmsId option').each(function(){
+        			$('#serviceId option').each(function(){
         				if(this.value != "" && this.value != -1) {
         					allServices.push(this.value);
         				}
         			});
-        			parameter['wmsId'] = allServices.join(',');		 	
+        			parameter['serviceId'] = allServices.join(',');		 	
         		}	
             that.loadJson(parameter);
             } 
@@ -97,18 +111,18 @@
             return;
         }
         var parameter = {
-                serviceType: $("div.form input#serviceType").val(),
+                serviceType: $("div.form select#serviceType").val(), //?
                 "function": $("div.field select#function").val(),
                 listType: $("div.field select#listType").val(),
                 timeFrom: $("div.field input#timeFrom").val(),
                 timeTo: $("div.field input#timeTo").val()
             };
         if($("div.field select#listType").val() == "service"){
-            if($("div.field select#wmsId").val() == ""){
-                alert("Bitte wählen Sie "+$('div.field label[for="wmsId"]').text()+" aus.");
+            if($("div.field select#serviceId").val() == ""){
+                alert("Bitte wählen Sie "+$('div.field label[for="serviceId"]').text()+" aus.");
                 return;
             }
-            parameter["wmsId"] = $("div.field select#wmsId").val();
+            parameter["serviceId"] = $("div.field select#serviceId").val();
         } else if($("div.field select#listType").val() == "user"){
             if($("div.field select#userId").val() == ""){
                 alert("Bitte wählen Sie "+$('div.field label[for="userId"]').text()+" aus.");
@@ -126,7 +140,7 @@
                 }
             }
             if($("div.field select#listType").val() == "user"){
-                parameter["wmsId"] = $("div.field select#wmsId").val();
+                parameter["serviceId"] = $("div.field select#serviceId").val();
                 if($("div.field input#withContactData").attr('checked')){
                     parameter['withContactData'] = 1;
                 }
@@ -137,13 +151,13 @@
                     parameter['withContactData'] = 1;
                 }
             } else if($("div.field select#listType").val() == "user"
-                    && $("div.field select#wmsId").val() != ""){
-                parameter["wmsId"] = $("div.field select#wmsId").val();
+                    && $("div.field select#serviceId").val() != ""){
+                parameter["serviceId"] = $("div.field select#serviceId").val();
             }
         } else if($("div.field select#function").val() == "deleteServiceLogs"){   
             if($("div.field select#listType").val() == "user"
-                    && $("div.field select#wmsId").val() != ""){
-                parameter["wmsId"] = $("div.field select#wmsId").val();
+                    && $("div.field select#serviceId").val() != ""){
+                parameter["serviceId"] = $("div.field select#serviceId").val();
             }
         }
         
@@ -274,49 +288,50 @@
     };
 	
 	this.initSelects = function () {
-        $('div.field select#wmsId option[value=""]').attr('selected','selected');
+		serviceType = $("div.field select#serviceType").val();
+        $('div.field select#serviceId option[value=""]').attr('selected','selected');
         $('div.field select#userId option[value=""]').attr('selected','selected');
         $("div.field input#withContactData").removeAttr('checked');
         
         if($("div.field select#listType").val() == "user"){
-            $("div.field select#wmsId").attr('disabled', "disabled");
-//                $("div.field select#wmsId ").parent().addClass('field-disabled');
+            $("div.field select#serviceId").attr('disabled', "disabled");
+//                $("div.field select#serviceId ").parent().addClass('field-disabled');
 //                $("div.field select#userId ").parent().removeClass('field-disabled');
             $("div.field select#userId").removeAttr('disabled');
-            $("div.field select#wmsId ").parent().css("display", "none");
+            $("div.field select#serviceId ").parent().css("display", "none");
             $("div.field select#userId ").parent().css("display", "block");
         } else if($("div.field select#listType").val() == "service"){
-            $("div.field select#wmsId").removeAttr('disabled');
+            $("div.field select#serviceId").removeAttr('disabled');
             $("div.field select#userId").attr('disabled', "disabled");
-//                $("div.field select#wmsId ").parent().removeClass('field-disabled');
+//                $("div.field select#serviceId ").parent().removeClass('field-disabled');
 //                $("div.field select#userId ").parent().addClass('field-disabled');
-            $("div.field select#wmsId ").parent().css("display", "block");
+            $("div.field select#serviceId ").parent().css("display", "block");
             $("div.field select#userId ").parent().css("display", "none");
         }
         
-        $('div.field select#wmsId option[value="-1"]').attr("disabled","disabled");
+        $('div.field select#serviceId option[value="-1"]').attr("disabled","disabled");
         $('div.field select#userId option[value="-1"]').attr("disabled","disabled");
 
         
         if($("div.field select#listType").val() == "user"
                 && $("div.field select#function").val() == "deleteServiceLogs"){
-            $("div.field select#wmsId").removeAttr('disabled');
-//            $("div.field select#wmsId ").parent().removeClass('field-disabled');
-            $("div.field select#wmsId ").parent().css("display", "block");
+            $("div.field select#serviceId").removeAttr('disabled');
+//            $("div.field select#serviceId ").parent().removeClass('field-disabled');
+            $("div.field select#serviceId ").parent().css("display", "block");
         } else if($("div.field select#listType").val() == "user"
                 && $("div.field select#function").val() == "listServiceLogs"){
-            $("div.field select#wmsId").removeAttr('disabled');
-//            $("div.field select#wmsId ").parent().removeClass('field-disabled');
-            $("div.field select#wmsId ").parent().css("display", "none");
+            $("div.field select#serviceId").removeAttr('disabled');
+//            $("div.field select#serviceId ").parent().removeClass('field-disabled');
+            $("div.field select#serviceId ").parent().css("display", "none");
         } else if($("div.field select#listType").val() == "user"
                 && ($("div.field select#function").val() == "getServiceLogs" ||
                     $("div.field select#function").val() == "getSum"
                 )
         ){
-            $("div.field select#wmsId").removeAttr('disabled');
-//            $("div.field select#wmsId ").parent().removeClass('field-disabled');
-            $("div.field select#wmsId ").parent().css("display", "block");
-            $('div.field select#wmsId option[value="-1"]').removeAttr("disabled");
+            $("div.field select#serviceId").removeAttr('disabled');
+//            $("div.field select#serviceId ").parent().removeClass('field-disabled');
+            $("div.field select#serviceId ").parent().css("display", "block");
+            $('div.field select#serviceId option[value="-1"]').removeAttr("disabled");
             $('div.field select#userId option[value="-1"]').removeAttr("disabled");
         }
         
@@ -327,7 +342,7 @@
         ){
 //            $("div.field input#withContactData").parent().removeClass('field-disabled');
             $("div.field input#withContactData").parent().css("display", "block");
-            $('div.field select#wmsId option[value="-1"]').removeAttr("disabled");
+            $('div.field select#serviceId option[value="-1"]').removeAttr("disabled");
             $('div.field select#userId option[value="-1"]').removeAttr("disabled");
         } else if($("div.field select#listType").val() == "service"
                 && ($("div.field select#function").val() == "getServiceLogs" ||
@@ -347,7 +362,7 @@
 //            $("div.field input#withContactData").parent().addClass('field-disabled');
             $("div.field input#withContactData").parent().css("display", "none");
         }
-        
+        return serviceType;
 	};
     
     
@@ -356,8 +371,9 @@
         $("div.field input#timeFrom").attr("readonly", "readonly");
         $("div.field input#timeTo").attr("readonly", "readonly");
         
-        this.initSelects();
-        
+        var serviceType = this.initSelects();
+        // that.loadForm(serviceType);
+	//$("div.field select#serviceType").bind("select",alert($("div.field select#serviceType").val()));//that.loadForm($("div.field select#serviceType").val())
         $(function() {
             $("div.field input#timeFrom").datetimepicker({
                 dayNamesMin: ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"],
@@ -422,7 +438,7 @@
     };
     
 	Mapbender.events.init.register(function () {
-        that.loadForm();
+        that.loadForm('wms');
 	});
 };
 $owsproxyCsv.mapbender(new OwsProxyCsv(options));

Modified: trunk/mapbender/http/plugins/mb_owsproxy_log_csv.php
===================================================================
--- trunk/mapbender/http/plugins/mb_owsproxy_log_csv.php	2017-05-12 10:05:32 UTC (rev 9739)
+++ trunk/mapbender/http/plugins/mb_owsproxy_log_csv.php	2017-05-12 11:19:42 UTC (rev 9740)
@@ -26,28 +26,69 @@
 }
 
 if($_REQUEST['action'] == "getForm"){
+    //$e = new mb_exception($_REQUEST['serviceType']);
+    switch ($_REQUEST['serviceType']) {
+	case "wms":
+   	    $sql = "SELECT DISTINCT u.mb_user_id, w.wms_id,w.wms_title,u.mb_user_name"
+   			." FROM mb_proxy_log AS m INNER JOIN wms AS w ON"
+   			." (m.fkey_wms_id = w.wms_id AND w.wms_owner=$1)"
+   					." INNER JOIN mb_user u ON(m.fkey_mb_user_id = u.mb_user_id)"
+   							." ORDER BY u.mb_user_name ASC, u.mb_user_id ";
+	    break;
+	case "wfs":
+   	    $sql = "SELECT DISTINCT u.mb_user_id, w.wfs_id,w.wfs_title,u.mb_user_name"
+   			." FROM mb_proxy_log AS m INNER JOIN wfs AS w ON"
+   			." (m.fkey_wfs_id = w.wfs_id AND w.wfs_owner=$1)"
+   					." INNER JOIN mb_user u ON(m.fkey_mb_user_id = u.mb_user_id)"
+   							." ORDER BY u.mb_user_name ASC, u.mb_user_id ";
+            break;	
+    }
     $mb_user_id = $_SESSION['mb_user_id'];
    	$v = array($mb_user_id);
    	$t = array('i');
    	$users = array();
-   	$wmses = array();
-   	$sql = "SELECT DISTINCT u.mb_user_id, w.wms_id,w.wms_title,u.mb_user_name"
+   	$services = array();
+   	/*$sql = "SELECT DISTINCT u.mb_user_id, w.wms_id,w.wms_title,u.mb_user_name"
    			." FROM mb_proxy_log AS m INNER JOIN wms AS w ON"
    			." (m.fkey_wms_id = w.wms_id AND w.wms_owner=$1)"
    					." INNER JOIN mb_user u ON(m.fkey_mb_user_id = u.mb_user_id)"
-   							." ORDER BY u.mb_user_name ASC, u.mb_user_id ";
+   							." ORDER BY u.mb_user_name ASC, u.mb_user_id ";*/
    	$result = db_prep_query($sql,$v,$t);
    	while($row = db_fetch_assoc($result)){
    		$users[$row['mb_user_id']] = $row['mb_user_name'];
-   		$wmses[$row['wms_id']] = $row['wms_title'];
+		switch ($_REQUEST['serviceType']) {
+			case "wms":
+				$services[$row['wms_id']] = $row['wms_title'];
+				break;
+			case "wfs":
+				$services[$row['wfs_id']] = $row['wfs_title'];
+				break;
+		}
    	}
     
+
+
     $form = '<div class="form">
-    <input name="serviceType" id="serviceType" value="wms" type="hidden" />
+    <!--<input name="serviceType" id="serviceType" value="wms" type="hidden" />-->
     <input name="format" id="format" value="json" type="hidden" />
     <fieldset id="owsproxy-log-query" style="float:left;">
         <legend>OwsProxy Logs Abfrage</legend>
             <div class="field">
+                <label for="serviceType">Service Typ:</label>
+                <select name="serviceType" id="serviceType">';
+		switch ($_REQUEST['serviceType']) {
+			case "wms":
+				$form .= '<option value="wms">WMS</option>
+					  <option value="wfs">WFS</option>';
+				break;
+			case "wfs":
+				$form .= '<option value="wfs">WFS</option>
+					  <option value="wms">WMS</option>';
+				break;
+		}
+    $form .=           '</select>
+            </div>
+            <div class="field">
                 <label for="function">Abfrageart:</label>
                 <select name="function" id="function">
                     <option value="getServiceLogs">getServiceLogs</option>
@@ -79,11 +120,11 @@
             $form .= '</select>
             </div>
             <div class="field">
-                <label for="wmsId">Dienst:</label>
-                <select name="wmsId" id="wmsId">
+                <label for="serviceId">Dienst:</label>
+                <select name="serviceId" id="serviceId">
                     <option value=""></option>
                     <option value="-1">alle</option>';
-                    foreach ($wmses as $key => $value) {
+                    foreach ($services as $key => $value) {
                         $form .= '<option value="'.$key.'">'.$value.'</option>';
                     }
             $form .= '</select>
@@ -134,33 +175,81 @@
     </fieldset>';
             
     $jsonOutput = array("form"=>$form,"error"=>"","message"=>"");
-    if(count($users) == 0 || count($wmses) == 0){
+    if(count($users) == 0 || count($services) == 0){
         $jsonOutput["message"] = "In der OwsProxy-Tabelle ist kein Datensatz vorhanden. Keine Abfrage ist möglich.";
     }
     header("ContentType: application/json");
     die(json_encode($jsonOutput));
 } else {
-    require_once dirname(__FILE__) . "/../classes/class_wms_owsproxy_log.php";
+    require_once dirname(__FILE__) . "/../classes/class_owsproxy_log.php";
     $function = isset($_REQUEST['function']) ? $_REQUEST['function'] : null;#getServiceLogs,deleteServiceLogs,listServiceLogs
     $listType = isset($_REQUEST['listType']) ? $_REQUEST['listType'] : null;#service,user
 
-    $serviceType = isset($_REQUEST['serviceType']) ? $_REQUEST['serviceType'] : null;#wms
+    $serviceType = isset($_REQUEST['serviceType']) ? $_REQUEST['serviceType'] : null;#wms, wfs
 
     $userId = isset($_REQUEST['userId']) ? $_REQUEST['userId'] : null;#XXX
-    $wmsId = isset($_REQUEST['wmsId']) ? $_REQUEST['wmsId'] : null;# XXX
+    $serviceId = isset($_REQUEST['serviceId']) ? $_REQUEST['serviceId'] : null;# XXX
     $timeFrom = isset($_REQUEST['timeFrom']) ? $_REQUEST['timeFrom'] : null;#
     $timeTo = isset($_REQUEST['timeTo']) ? $_REQUEST['timeTo'] : null;#
     $withContactData = isset($_REQUEST['withContactData']) ? $_REQUEST['withContactData'] : null;# 1,
 
-    if($serviceType === null){
+    if ($serviceType === null) {
+	$e = new mb_exception("Parameter serviceType is missing!");
         die ("Der Parameter 'serviceType' wurde nicht uebergeben.");
     }
-    
-    if($serviceType == "wms"){
+    //begin serviceType handling**********
+    $mb_user_id = $_SESSION['mb_user_id'];
+    $export = "export dummy";
+    switch ($serviceType) {
+        case "wms":
+	    $serviceLog = OwsLogCsv::create($mb_user_id, $function, $userId, $serviceId,
+                $listType, $timeFrom, $timeTo, $withContactData, $serviceType);
+	    $serviceLog->handle();
+            switch ($_REQUEST['action']) {
+                case "getCsv":            
+		    header("Content-Type: text/csv; charset=".CHARSET);
+            	    header("Content-Disposition: attachment; filename=csv_export.csv");
+            	    header("Pragma: no-cache");
+            	    header("Expires: 0");
+		    $export = $serviceLog->getAsCsv();
+                    break;
+                case "getJson":
+		    $export = json_encode($serviceLog->getAsArray($function));
+                    break;
+            }
+            break;
+        case "wfs":
+	    $serviceLog = OwsLogCsv::create($mb_user_id, $function, $userId, $serviceId,
+                $listType, $timeFrom, $timeTo, $withContactData, $serviceType);
+	    $serviceLog->handle();
+            switch ($_REQUEST['action']) {
+                case "getCsv":            
+		    header("Content-Type: text/csv; charset=".CHARSET);
+            	    header("Content-Disposition: attachment; filename=csv_export.csv");
+            	    header("Pragma: no-cache");
+            	    header("Expires: 0");
+		    $export = $serviceLog->getAsCsv();
+                    break;
+                case "getJson":
+		    $export = json_encode($serviceLog->getAsArray($function));
+                    break;
+            }
+            break;
+        default:
+	    die ("Der 'serviceType' ".$serviceType." ist nicht unterstuetzt.");
+            break;
+    }
+    print $export;
+    die();
+    //end serviceType handling**********
+
+//$e = new mb_exception("servicetype not supported");
+   /* if($serviceType == "wms"){
+
         $mb_user_id = $_SESSION['mb_user_id'];
         if($_REQUEST['action'] == "getCsv"){
-            $wmslog = WmsOwsLogCsv::create($mb_user_id, $function, $userId, $wmsId,
-                $listType, $timeFrom, $timeTo, $withContactData);
+            $wmslog = OwsLogCsv::create($mb_user_id, $function, $userId, $serviceId,
+                $listType, $timeFrom, $timeTo, $withContactData, $serviceType);
             $wmslog->handle();
             header("Content-Type: text/csv; charset=".CHARSET);
             header("Content-Disposition: attachment; filename=csv_export.csv");
@@ -170,14 +259,16 @@
             print $csv;
             die();
         } else if($_REQUEST['action'] == "getJson"){
-            $wmslog = WmsOwsLogCsv::create($mb_user_id, $function, $userId, $wmsId,
-                $listType, $timeFrom, $timeTo, $withContactData);
+            $wmslog = OwsLogCsv::create($mb_user_id, $function, $userId, $serviceId,
+                $listType, $timeFrom, $timeTo, $withContactData, $serviceType);
             $wmslog->handle();
             print json_encode($wmslog->getAsArray($function));
             die();
         }
     } else {
+	$e = new mb_exception("servicetype not supported");
         die ("Der 'serviceType'".$serviceType." ist nicht unterstuetzt.");
-    }
+    }*/
+    //end serviceType handling**********
 }
 ?>



More information about the Mapbender_commits mailing list