[Mapbender-commits] r8786 - in trunk/mapbender: . http/classes http/css http/extensions/jquery-ui-1.8.16.custom/development-bundle/ui http/extensions/jquery-ui-1.8.16.custom/development-bundle/ui/localization http/php http/plugins http_auth/http owsproxy/http owsproxy_api owsproxy_api/http resources/db/pgsql/UTF-8/update
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Fri Feb 28 04:57:18 PST 2014
Author: verenadiewald
Date: 2014-02-28 04:57:18 -0800 (Fri, 28 Feb 2014)
New Revision: 8786
Added:
trunk/mapbender/http/classes/class_wms_owsproxy_log.php
trunk/mapbender/http/css/owsproxy_logs.css
trunk/mapbender/http/extensions/jquery-ui-1.8.16.custom/development-bundle/ui/jquery.ui.timepicker.js
trunk/mapbender/http/extensions/jquery-ui-1.8.16.custom/development-bundle/ui/localization/
trunk/mapbender/http/extensions/jquery-ui-1.8.16.custom/development-bundle/ui/localization/jquery-ui-timepicker-de.js.js
trunk/mapbender/http/plugins/mb_owsproxy_log_csv.js
trunk/mapbender/http/plugins/mb_owsproxy_log_csv.php
trunk/mapbender/owsproxy_api/
trunk/mapbender/owsproxy_api/http/
trunk/mapbender/owsproxy_api/http/index.php
Modified:
trunk/mapbender/http/classes/class_administration.php
trunk/mapbender/http/php/mod_owsproxy_conf.php
trunk/mapbender/http_auth/http/index.php
trunk/mapbender/owsproxy/http/index.php
trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7.4_to_2.8_pgsql_UTF-8.sql
Log:
added owsproxy calculation functionality
Modified: trunk/mapbender/http/classes/class_administration.php
===================================================================
--- trunk/mapbender/http/classes/class_administration.php 2014-02-28 11:51:21 UTC (rev 8785)
+++ trunk/mapbender/http/classes/class_administration.php 2014-02-28 12:57:18 UTC (rev 8786)
@@ -1090,9 +1090,77 @@
else{
return false;
}
+ }
+
+ /*
+ * set the pricevolume of the wms feature info
+ *
+ * @param integer the wms-id
+ * @param integer the price for one kilobyte of wms data
+ */
+
+ function setWmsfiPrice($price,$wms_id){
+ $sql = "UPDATE wms set wms_price_fi=$1 WHERE wms_id = $2 ";
+ $t = array("i","i");
+ $v = array($price,$wms_id);
+ $res = db_prep_query($sql,$v,$t);
}
/*
+ * get the price for one request of wms feature info
+ *
+ * @param integer the wms-id
+ * @return integer for price in cents for one kb of wms data
+ */
+
+ function getWmsfiPrice($wms_id){
+ $sql = "SELECT wms_price_fi from wms WHERE wms_id = $1 ";
+ $t = array("i");
+ $v = array($wms_id);
+ $res = db_prep_query($sql,$v,$t);
+ if($row = db_fetch_array($res)){
+ return $row["wms_price_fi"];
+ }
+ else{
+ return false;
+ }
+ }
+
+ /*
+ * set the log tag of the wms
+ *
+ * @param integer the wms-id
+ *
+ */
+
+ function setWmsfiLogTag($wms_id,$value){
+ $sql = "UPDATE wms set wms_proxy_log_fi=$2 WHERE wms_id = $1 ";
+ $t = array("i","i");
+ $v = array($wms_id,$value);
+ $res = db_prep_query($sql,$v,$t);
+ }
+
+ /*
+ * get the log tag of the wms feature info
+ *
+ * @param integer the wms-id
+ * @return 1 for active log and 0 or null for deactivated log
+ */
+
+ function getWmsfiLogTag($wms_id){
+ $sql = "SELECT wms_proxy_log_fi from wms WHERE wms_id = $1 ";
+ $t = array("i");
+ $v = array($wms_id);
+ $res = db_prep_query($sql,$v,$t);
+ if($row = db_fetch_array($res)){
+ return $row["wms_proxy_log_fi"];
+ }
+ else{
+ return false;
+ }
+ }
+
+ /*
* unset the proxy definitions and logging/pricing for the owned wms proxy list
*
* @param string the wms-list
@@ -1100,7 +1168,7 @@
*/
function unsetWmsProxy($wms_list){
- $sql = "UPDATE wms set wms_owsproxy='', wms_pricevolume=0,wms_proxylog=0 WHERE wms_id IN ($1)";
+ $sql = "UPDATE wms set wms_owsproxy='', wms_pricevolume=0,wms_proxylog=0,wms_proxy_log_fi=0,wms_price_fi=0 WHERE wms_id IN ($1)";
$t = array("s");
$v = array($wms_list);
$res = db_prep_query($sql,$v,$t);
@@ -1146,7 +1214,119 @@
#else{
#return false;
#}
+ }
+
+ function logFullWmsProxyRequest($wms_id,$user_id,$getmap,$price){
+ $sql = "INSERT INTO mb_proxy_log "
+ ."(fkey_wms_id,fkey_mb_user_id, request, pixel, price, layer_featuretype_list, request_type) "
+ ."VALUES ($1, $2, $3, $4, $5, $6, 'getMap')";
+ $t = array("i","i","s","i","r","s");
+ #extract height and width
+ #use regexpr
+ $pattern_height = '~HEIGHT=(\d+)&~i';
+ $pattern_width = '~WIDTH=(\d+)&~i';
+ $pattern_layers = '~LAYERS=([^&.])+~i';
+ preg_match($pattern_width, $getmap,$sub_width);
+ preg_match($pattern_height, $getmap,$sub_height);
+ preg_match($pattern_layers, $getmap,$sub_layers);
+ $layers = explode("=", $sub_layers[0]);
+ $width=intval($sub_width[1]);
+ $height=intval($sub_height[1]);
+ $pixel=intval($width*$height);
+ $price=$pixel*$price/1000000;
+ $v = array(intval($wms_id),intval($user_id),$getmap,$pixel,$price,isset($layers[1]) ? urldecode($layers[1]) : '');
+ #echo print_r($v,true)."<br>";
+ #var_dump($v);
+ #echo $sql."<br>";
+ #echo "test<br>";
+ $res = db_prep_query($sql,$v,$t) or die(db_error());
+ #echo "test<br>";
+ if(!$res){
+ include_once(dirname(__FILE__)."/class_mb_exception.php");
+ $e = new mb_exception("class_log: Writing table mb_proxy_log failed.");
+ return false;
+ }
+ #$myid = pg_last_oid($res);
+
+ #$res_id = db_prep_query("SELECT log_id from mb_proxy_log where oid=$1",
+ # array(intval(pg_last_oid($res))),array("i")) or die(db_error());
+ $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 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 WHERE log_id=$4";
+ $t = array("i","s","s","i");
+ $v = array($got_result, $error_message, $error_mime_type, $log_id);
+ $res = db_prep_query($sql,$v,$t) or die(db_error());
+ #echo "test<br>";
+ if(!$res){
+ include_once(dirname(__FILE__)."/class_mb_exception.php");
+ $e = new mb_exception("class_log: Updating table mb_proxy_log failed.");
+ return false;
+ }
+ 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) "
+ ."VALUES ($1, $2, $3, $4, $5, 'getFeatureInfo')";
+ $t = array("i","i","s","r","s");
+ #extract height and width
+ #use regexpr
+ $pattern_layers = '~LAYERS=([^&.])+~i';
+ preg_match($pattern_layers, $getmap,$sub_layers);
+ $layers = explode("=", $sub_layers[0]);
+ $v = array(intval($wms_id), intval($user_id), $getmap, $price, isset($layers[1]) ? urldecode($layers[1]) : '');
+ #echo print_r($v,true)."<br>";
+ #var_dump($v);
+ #echo $sql."<br>";
+ #echo "test<br>";
+ $res = db_prep_query($sql,$v,$t) or die(db_error());
+ #echo "test<br>";
+ if(!$res){
+ include_once(dirname(__FILE__)."/class_mb_exception.php");
+ $e = new mb_exception("class_log: Writing table mb_proxy_log failed.");
+ return false;
+ }
+ $myid = pg_last_oid($res);
+ $res_id = db_prep_query("SELECT log_id from mb_proxy_log where oid=$1",
+ array(intval(pg_last_oid($res))),array("i")) or die(db_error());
+ if(pg_num_rows($res_id)){
+ $row = db_fetch_array($res_id);
+ $id = $row["log_id"];
+ return intval($id);
+ } else {
+ return false;
+ }
+ }
+ function updateWmsFiLog($error_message, $error_mime_type, $log_id){
+ if($error_message != null) {
+ $sql = "UPDATE mb_proxy_log SET price=0"
+ .",error_message=$1,error_mime_type=$2 WHERE log_id=$3";
+ $t = array("s","s","i");
+ $v = array($error_message, $error_mime_type, $log_id);
+ } else {
+ $sql = "UPDATE mb_proxy_log SET error_message=$1,error_mime_type=$2 WHERE log_id=$3";
+ $t = array("s","s","i");
+ $v = array($error_message, $error_mime_type, $log_id);
+ }
+
+ $res = db_prep_query($sql,$v,$t) or die(db_error());
+ #echo "test<br>";
+ if(!$res){
+ include_once(dirname(__FILE__)."/class_mb_exception.php");
+ $e = new mb_exception("class_log: Updating table mb_proxy_log failed.");
+ return false;
+ }
+ return true;
+ }
/*
* get the owsproxy-string of the current wfs
*
Added: trunk/mapbender/http/classes/class_wms_owsproxy_log.php
===================================================================
--- trunk/mapbender/http/classes/class_wms_owsproxy_log.php (rev 0)
+++ trunk/mapbender/http/classes/class_wms_owsproxy_log.php 2014-02-28 12:57:18 UTC (rev 8786)
@@ -0,0 +1,386 @@
+<?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 WmsOwsLogCsv {
+ private $mb_user_id;
+ private $function;
+ private $listType;
+ private $userId;
+ private $wmsId;
+ private $timeFrom;
+ private $timeTo;
+ private $withContactData;
+
+ private $resultHeader;
+ private $resultData;
+ private $resultMessage;
+
+
+ private static $SEPARATOR_VALUE = "\t";
+ private static $SEPARATOR_ROW = "\n";
+
+ private static $LIMIT_INT = 1000;
+
+ private static $LIMIT_SQL = " ORDER BY m.log_id DESC LIMIT ";
+
+ private function __construct() {
+ }
+
+ public static function create($mb_user_id, $function, $userId, $wmsId, $listType, $timeFrom, $timeTo, $withContactData){
+ 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" && $wmsId === null)
+ || ($listType == "user" && $userId === null)){
+ return "Parameter 'userId' oder/und 'wmsId' 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";
+ }
+
+ $wmslogcsv = new WmsOwsLogCsv();
+ $wmslogcsv->wmsId = $wmsId;
+ $wmslogcsv->userId = $userId;
+ $wmslogcsv->timeFrom = $timeFrom;
+ $wmslogcsv->timeTo = $timeTo;
+ $wmslogcsv->mb_user_id = $mb_user_id;
+ $wmslogcsv->listType = $listType;
+ $wmslogcsv->function = $function;
+
+ if($withContactData != null && strlen($withContactData) > 0){
+ $wmslogcsv->withContactData = $withContactData;
+ }
+ $wmslogcsv->resultHeader = array();
+ $wmslogcsv->resultData = array();
+ $wmslogcsv->resultMessage = "";
+ return $wmslogcsv;
+ }
+
+ 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& wmsId=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";
+ $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";
+ }
+ $v = array($this->mb_user_id, $this->timeFrom, $this->timeTo);
+// $v = array($this->wmsId, $this->timeFrom, $this->timeTo, 9415);
+ $t = array('i', "t", "t");
+ $wmsIdWhere = "";
+ if($this->wmsId !== null && intval($this->wmsId)> -1){
+ $v[] = $this->wmsId;
+ $t[] = "i";
+ $wmsIdWhere = " AND m.fkey_wms_id = $".count($v);
+ }
+
+ $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"
+ .$wmsIdWhere." AND m.proxy_log_timestamp >= $2"
+ ." AND m.proxy_log_timestamp <= $3)".$join
+ . WmsOwsLogCsv::$LIMIT_SQL . WmsOwsLogCsv::$LIMIT_INT;
+
+ $result = db_prep_query($sql,$v,$t);
+ $this->readResult($result);
+ } else if($this->listType == "user"){
+ $selectColumns = " m.*,w.wms_title,w.wms_version,w.wms_abstract";
+ $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->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);
+ }
+ $wmsIdWhere = "";
+ if($this->wmsId !== null && strlen($this->wmsId)> 0 && intval($this->wmsId)> -1){
+ $v[] = $this->wmsId;
+ $t[] = "i";
+ $wmsIdWhere = " AND m.fkey_wms_id=$".count($v);
+ }
+ /* GUI end*/
+ $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".$wmsIdWhere.")".$join
+ . WmsOwsLogCsv::$LIMIT_SQL . WmsOwsLogCsv::$LIMIT_INT;
+ $result = db_prep_query($sql,$v,$t);
+ $this->readResult($result);
+ }
+ }
+
+ private function listServiceLogs(){
+#function=listServiceLogs&listType=service&serviceType=wms& wmsId=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&wmsId=xyz
+ if($this->listType == "service"){
+ $selectColumns = " 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->wmsId, $this->timeFrom, $this->timeTo, $this->mb_user_id);
+// $v = array($this->wmsId, $this->timeFrom, $this->timeTo, 9415);
+ $t = array('i', "t", "t", "i");
+ $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 ".$selectColumns
+ . WmsOwsLogCsv::$LIMIT_SQL . WmsOwsLogCsv::$LIMIT_INT;
+
+ $result = db_prep_query($sql,$v,$t);
+ $this->readResult($result);
+ } else if($this->listType == "user"){
+ $selectColumns = " w.wms_id,w.wms_title";
+ $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");
+ $whereWms = "";
+ $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".$whereWms.")".$join
+ ." GROUP BY ".$selectColumns
+ . WmsOwsLogCsv::$LIMIT_SQL . WmsOwsLogCsv::$LIMIT_INT;
+ $result = db_prep_query($sql,$v,$t);
+ $this->readResult($result);
+ }
+ }
+
+ private function deleteServiceLogs(){
+#function=deleteServiceLogs&listType=service&serviceType=wms& wmsId=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&wmsId=xyz
+ if($this->listType == "service"){
+// $v = array($wmsId, $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->wmsId, $this->timeFrom, $this->timeTo, $this->mb_user_id);
+ $t = array('i', "t", "t", "i");
+ $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_wms_id = $1 AND m.proxy_log_timestamp >= $2"
+ ." AND m.proxy_log_timestamp <= $3)"
+ .")";
+ $result = db_prep_query($sql,$v,$t);
+ $resnum = pg_affected_rows($result);
+ if($resnum > 0){
+ $this->resultMessage = $resnum." Log-Datensaetze (DienstId :".$this->wmsId.") wurden erfolgreich geloescht.";
+ } else {
+ $this->resultMessage = "Kein Log-Datensatz (DienstId: ".$this->wmsId.") 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($wmsId !== null && $wmsId != "") {
+// $sql .= " AND fkey_wms_id = $4";
+// $v[] = $wmsId;
+// $t[] = 'i';
+// }
+ $v = array($this->userId, $this->timeFrom, $this->timeTo, $this->mb_user_id);
+ $t = array('i', "t", "t", "i");
+ $whereWms = "";
+ if($this->wmsId !== null && $this->wmsId != "") {
+ $whereWms = " AND m.fkey_wms_id = $5";
+ $v[] = $this->wmsId;
+ $t[] = 'i';
+ }
+ $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".$whereWms.")"
+ .")";
+ $result = db_prep_query($sql,$v,$t);
+ $resnum = pg_affected_rows($result);
+ if($resnum > 0){
+ if($this->wmsId !== null && $this->wmsId != ""){
+ $this->resultMessage = $resnum." Log-Datensaetze (DienstId :".$this->wmsId.", UserId: ".$this->userId.") wurden erfolgreich geloescht.";
+ } else {
+ $this->resultMessage = $resnum." Log-Datensaetze (UserId: ".$this->userId.") wurden erfolgreich geloescht.";
+ }
+ } else {
+ if($this->wmsId !== null && $this->wmsId != ""){
+ $this->resultMessage = "Kein Log-Datensatz (DienstId: ".$this->wmsId.", UserId: ".$this->userId.") wurde geloescht.";
+ } else {
+ $this->resultMessage = "Kein Log-Datensatz (UserId: ".$this->userId.") wurde geloescht.";
+ }
+ }
+ }
+ }
+
+ private function readResult($result){
+ $offsetPixel = null;
+ $offsetPrice = null;
+ $sumPixel = 0;
+ $sumPrice = 0;
+
+ $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;
+ }
+
+ $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;
+ }
+
+ $i++;
+ }
+
+ if(!is_null($offsetPixel) || !is_null($offsetPrice)) {
+ 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
+ $this->resultData[$i][] = '---';
+ }
+ }
+ }
+
+ public function getAsCsv(){
+ $header = "";
+ $data = "";
+ foreach($this->resultHeader as $colname){
+ $header .= '"'.$colname.'"'.WmsOwsLogCsv::$SEPARATOR_VALUE;
+ }
+
+ foreach($this->resultData as $row){
+ $line = '';
+ foreach( $row as $value){
+ if ($value == null || $value == ""){
+ $value = "".WmsOwsLogCsv::$SEPARATOR_VALUE;
+ } else {
+// if(CHARSET == 'UTF-8'){
+// $value = utf8_encode($value);
+// }
+ $value = str_replace('"', '""', $value);
+ $value = '"'.$value.'"'.WmsOwsLogCsv::$SEPARATOR_VALUE;
+ }
+ $line .= $value;
+ }
+ $data .= trim($line).WmsOwsLogCsv::$SEPARATOR_ROW;
+ }
+ return $header.WmsOwsLogCsv::$SEPARATOR_ROW.$data;
+ }
+
+ public function getAsArray(){
+ return array(
+ "function"=> $this->function,
+ "header"=> $this->resultHeader,
+ "data" => $this->resultData,
+ "message" => $this->resultMessage,
+ "error" => "",
+ "limit" => WmsOwsLogCsv::$LIMIT_INT);
+ }
+}
+?>
Added: trunk/mapbender/http/css/owsproxy_logs.css
===================================================================
--- trunk/mapbender/http/css/owsproxy_logs.css (rev 0)
+++ trunk/mapbender/http/css/owsproxy_logs.css 2014-02-28 12:57:18 UTC (rev 8786)
@@ -0,0 +1,32 @@
+fieldset#owsproxy-log-query {
+ width: 400px;
+}
+div.field label {
+ display: block;
+ float: left;
+ width: 100px;
+ vertical-align: middle;
+}
+div.field input {
+ width: auto;
+ vertical-align: middle;
+}
+
+fieldset#owsproxy-log-result table,td {
+ border-width: 1px;
+ border-color: black;
+ border-style: solid;
+}
+
+div#result {
+ padding-top: 20px;
+}
+
+tr.result-header {
+ font-weight: bold;
+ background-color: #DDD;
+}
+
+div#result-operation {
+ padding-top: 10px;
+}
\ No newline at end of file
Added: trunk/mapbender/http/extensions/jquery-ui-1.8.16.custom/development-bundle/ui/jquery.ui.timepicker.js
===================================================================
--- trunk/mapbender/http/extensions/jquery-ui-1.8.16.custom/development-bundle/ui/jquery.ui.timepicker.js (rev 0)
+++ trunk/mapbender/http/extensions/jquery-ui-1.8.16.custom/development-bundle/ui/jquery.ui.timepicker.js 2014-02-28 12:57:18 UTC (rev 8786)
@@ -0,0 +1,1326 @@
+/*
+* jQuery timepicker addon
+* By: Trent Richardson [http://trentrichardson.com]
+* Version 0.9.9
+* Last Modified: 02/05/2012
+*
+* Copyright 2012 Trent Richardson
+* Dual licensed under the MIT and GPL licenses.
+* http://trentrichardson.com/Impromptu/GPL-LICENSE.txt
+* http://trentrichardson.com/Impromptu/MIT-LICENSE.txt
+*
+* HERES THE CSS:
+* .ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }
+* .ui-timepicker-div dl { text-align: left; }
+* .ui-timepicker-div dl dt { height: 25px; margin-bottom: -25px; }
+* .ui-timepicker-div dl dd { margin: 0 10px 10px 65px; }
+* .ui-timepicker-div td { font-size: 90%; }
+* .ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; }
+*/
+
+(function($) {
+
+$.extend($.ui, { timepicker: { version: "0.9.9" } });
+
+/* Time picker manager.
+ Use the singleton instance of this class, $.timepicker, to interact with the time picker.
+ Settings for (groups of) time pickers are maintained in an instance object,
+ allowing multiple different settings on the same page. */
+
+function Timepicker() {
+ this.regional = []; // Available regional settings, indexed by language code
+ this.regional[''] = { // Default regional settings
+ currentText: 'Now',
+ closeText: 'Done',
+ ampm: false,
+ amNames: ['AM', 'A'],
+ pmNames: ['PM', 'P'],
+ timeFormat: 'hh:mm tt',
+ timeSuffix: '',
+ timeOnlyTitle: 'Choose Time',
+ timeText: 'Time',
+ hourText: 'Hour',
+ minuteText: 'Minute',
+ secondText: 'Second',
+ millisecText: 'Millisecond',
+ timezoneText: 'Time Zone'
+ };
+ this._defaults = { // Global defaults for all the datetime picker instances
+ showButtonPanel: true,
+ timeOnly: false,
+ showHour: true,
+ showMinute: true,
+ showSecond: false,
+ showMillisec: false,
+ showTimezone: false,
+ showTime: true,
+ stepHour: 1,
+ stepMinute: 1,
+ stepSecond: 1,
+ stepMillisec: 1,
+ hour: 0,
+ minute: 0,
+ second: 0,
+ millisec: 0,
+ timezone: '+0000',
+ hourMin: 0,
+ minuteMin: 0,
+ secondMin: 0,
+ millisecMin: 0,
+ hourMax: 23,
+ minuteMax: 59,
+ secondMax: 59,
+ millisecMax: 999,
+ minDateTime: null,
+ maxDateTime: null,
+ onSelect: null,
+ hourGrid: 0,
+ minuteGrid: 0,
+ secondGrid: 0,
+ millisecGrid: 0,
+ alwaysSetTime: true,
+ separator: ' ',
+ altFieldTimeOnly: true,
+ showTimepicker: true,
+ timezoneIso8609: false,
+ timezoneList: null,
+ addSliderAccess: false,
+ sliderAccessArgs: null
+ };
+ $.extend(this._defaults, this.regional['']);
+};
+
+$.extend(Timepicker.prototype, {
+ $input: null,
+ $altInput: null,
+ $timeObj: null,
+ inst: null,
+ hour_slider: null,
+ minute_slider: null,
+ second_slider: null,
+ millisec_slider: null,
+ timezone_select: null,
+ hour: 0,
+ minute: 0,
+ second: 0,
+ millisec: 0,
+ timezone: '+0000',
+ hourMinOriginal: null,
+ minuteMinOriginal: null,
+ secondMinOriginal: null,
+ millisecMinOriginal: null,
+ hourMaxOriginal: null,
+ minuteMaxOriginal: null,
+ secondMaxOriginal: null,
+ millisecMaxOriginal: null,
+ ampm: '',
+ formattedDate: '',
+ formattedTime: '',
+ formattedDateTime: '',
+ timezoneList: null,
+
+ /* Override the default settings for all instances of the time picker.
+ @param settings object - the new settings to use as defaults (anonymous object)
+ @return the manager object */
+ setDefaults: function(settings) {
+ extendRemove(this._defaults, settings || {});
+ return this;
+ },
+
+ //########################################################################
+ // Create a new Timepicker instance
+ //########################################################################
+ _newInst: function($input, o) {
+ var tp_inst = new Timepicker(),
+ inlineSettings = {};
+
+ for (var attrName in this._defaults) {
+ var attrValue = $input.attr('time:' + attrName);
+ if (attrValue) {
+ try {
+ inlineSettings[attrName] = eval(attrValue);
+ } catch (err) {
+ inlineSettings[attrName] = attrValue;
+ }
+ }
+ }
+ tp_inst._defaults = $.extend({}, this._defaults, inlineSettings, o, {
+ beforeShow: function(input, dp_inst) {
+ if ($.isFunction(o.beforeShow))
+ return o.beforeShow(input, dp_inst, tp_inst);
+ },
+ onChangeMonthYear: function(year, month, dp_inst) {
+ // Update the time as well : this prevents the time from disappearing from the $input field.
+ tp_inst._updateDateTime(dp_inst);
+ if ($.isFunction(o.onChangeMonthYear))
+ o.onChangeMonthYear.call($input[0], year, month, dp_inst, tp_inst);
+ },
+ onClose: function(dateText, dp_inst) {
+ if (tp_inst.timeDefined === true && $input.val() != '')
+ tp_inst._updateDateTime(dp_inst);
+ if ($.isFunction(o.onClose))
+ o.onClose.call($input[0], dateText, dp_inst, tp_inst);
+ },
+ timepicker: tp_inst // add timepicker as a property of datepicker: $.datepicker._get(dp_inst, 'timepicker');
+ });
+ tp_inst.amNames = $.map(tp_inst._defaults.amNames, function(val) { return val.toUpperCase() });
+ tp_inst.pmNames = $.map(tp_inst._defaults.pmNames, function(val) { return val.toUpperCase() });
+
+ if (tp_inst._defaults.timezoneList === null) {
+ var timezoneList = [];
+ for (var i = -11; i <= 12; i++)
+ timezoneList.push((i >= 0 ? '+' : '-') + ('0' + Math.abs(i).toString()).slice(-2) + '00');
+ if (tp_inst._defaults.timezoneIso8609)
+ timezoneList = $.map(timezoneList, function(val) {
+ return val == '+0000' ? 'Z' : (val.substring(0, 3) + ':' + val.substring(3));
+ });
+ tp_inst._defaults.timezoneList = timezoneList;
+ }
+
+ tp_inst.hour = tp_inst._defaults.hour;
+ tp_inst.minute = tp_inst._defaults.minute;
+ tp_inst.second = tp_inst._defaults.second;
+ tp_inst.millisec = tp_inst._defaults.millisec;
+ tp_inst.ampm = '';
+ tp_inst.$input = $input;
+
+ if (o.altField)
+ tp_inst.$altInput = $(o.altField)
+ .css({ cursor: 'pointer' })
+ .focus(function(){ $input.trigger("focus"); });
+
+ if(tp_inst._defaults.minDate==0 || tp_inst._defaults.minDateTime==0)
+ {
+ tp_inst._defaults.minDate=new Date();
+ }
+ if(tp_inst._defaults.maxDate==0 || tp_inst._defaults.maxDateTime==0)
+ {
+ tp_inst._defaults.maxDate=new Date();
+ }
+
+ // datepicker needs minDate/maxDate, timepicker needs minDateTime/maxDateTime..
+ if(tp_inst._defaults.minDate !== undefined && tp_inst._defaults.minDate instanceof Date)
+ tp_inst._defaults.minDateTime = new Date(tp_inst._defaults.minDate.getTime());
+ if(tp_inst._defaults.minDateTime !== undefined && tp_inst._defaults.minDateTime instanceof Date)
+ tp_inst._defaults.minDate = new Date(tp_inst._defaults.minDateTime.getTime());
+ if(tp_inst._defaults.maxDate !== undefined && tp_inst._defaults.maxDate instanceof Date)
+ tp_inst._defaults.maxDateTime = new Date(tp_inst._defaults.maxDate.getTime());
+ if(tp_inst._defaults.maxDateTime !== undefined && tp_inst._defaults.maxDateTime instanceof Date)
+ tp_inst._defaults.maxDate = new Date(tp_inst._defaults.maxDateTime.getTime());
+ return tp_inst;
+ },
+
+ //########################################################################
+ // add our sliders to the calendar
+ //########################################################################
+ _addTimePicker: function(dp_inst) {
+ var currDT = (this.$altInput && this._defaults.altFieldTimeOnly) ?
+ this.$input.val() + ' ' + this.$altInput.val() :
+ this.$input.val();
+
+ this.timeDefined = this._parseTime(currDT);
+ this._limitMinMaxDateTime(dp_inst, false);
+ this._injectTimePicker();
+ },
+
+ //########################################################################
+ // parse the time string from input value or _setTime
+ //########################################################################
+ _parseTime: function(timeString, withDate) {
+ var regstr = this._defaults.timeFormat.toString()
+ .replace(/h{1,2}/ig, '(\\d?\\d)')
+ .replace(/m{1,2}/ig, '(\\d?\\d)')
+ .replace(/s{1,2}/ig, '(\\d?\\d)')
+ .replace(/l{1}/ig, '(\\d?\\d?\\d)')
+ .replace(/t{1,2}/ig, this._getPatternAmpm())
+ .replace(/z{1}/ig, '(z|[-+]\\d\\d:?\\d\\d)?')
+ .replace(/\s/g, '\\s?') + this._defaults.timeSuffix + '$',
+ order = this._getFormatPositions(),
+ ampm = '',
+ treg;
+
+ if (!this.inst) this.inst = $.datepicker._getInst(this.$input[0]);
+
+ if (withDate || !this._defaults.timeOnly) {
+ // the time should come after x number of characters and a space.
+ // x = at least the length of text specified by the date format
+ var dp_dateFormat = $.datepicker._get(this.inst, 'dateFormat');
+ // escape special regex characters in the seperator
+ var specials = new RegExp("[.*+?|()\\[\\]{}\\\\]", "g");
+ regstr = '^.{' + dp_dateFormat.length + ',}?' + this._defaults.separator.replace(specials, "\\$&") + regstr;
+ }
+
+ treg = timeString.match(new RegExp(regstr, 'i'));
+
+ if (treg) {
+ if (order.t !== -1) {
+ if (treg[order.t] === undefined || treg[order.t].length === 0) {
+ ampm = '';
+ this.ampm = '';
+ } else {
+ ampm = $.inArray(treg[order.t].toUpperCase(), this.amNames) !== -1 ? 'AM' : 'PM';
+ this.ampm = this._defaults[ampm == 'AM' ? 'amNames' : 'pmNames'][0];
+ }
+ }
+
+ if (order.h !== -1) {
+ if (ampm == 'AM' && treg[order.h] == '12')
+ this.hour = 0; // 12am = 0 hour
+ else if (ampm == 'PM' && treg[order.h] != '12')
+ this.hour = (parseFloat(treg[order.h]) + 12).toFixed(0); // 12pm = 12 hour, any other pm = hour + 12
+ else this.hour = Number(treg[order.h]);
+ }
+
+ if (order.m !== -1) this.minute = Number(treg[order.m]);
+ if (order.s !== -1) this.second = Number(treg[order.s]);
+ if (order.l !== -1) this.millisec = Number(treg[order.l]);
+ if (order.z !== -1 && treg[order.z] !== undefined) {
+ var tz = treg[order.z].toUpperCase();
+ switch (tz.length) {
+ case 1: // Z
+ tz = this._defaults.timezoneIso8609 ? 'Z' : '+0000';
+ break;
+ case 5: // +hhmm
+ if (this._defaults.timezoneIso8609)
+ tz = tz.substring(1) == '0000'
+ ? 'Z'
+ : tz.substring(0, 3) + ':' + tz.substring(3);
+ break;
+ case 6: // +hh:mm
+ if (!this._defaults.timezoneIso8609)
+ tz = tz == 'Z' || tz.substring(1) == '00:00'
+ ? '+0000'
+ : tz.replace(/:/, '');
+ else if (tz.substring(1) == '00:00')
+ tz = 'Z';
+ break;
+ }
+ this.timezone = tz;
+ }
+
+ return true;
+
+ }
+ return false;
+ },
+
+ //########################################################################
+ // pattern for standard and localized AM/PM markers
+ //########################################################################
+ _getPatternAmpm: function() {
+ var markers = [];
+ o = this._defaults;
+ if (o.amNames)
+ $.merge(markers, o.amNames);
+ if (o.pmNames)
+ $.merge(markers, o.pmNames);
+ markers = $.map(markers, function(val) { return val.replace(/[.*+?|()\[\]{}\\]/g, '\\$&') });
+ return '(' + markers.join('|') + ')?';
+ },
+
+ //########################################################################
+ // figure out position of time elements.. cause js cant do named captures
+ //########################################################################
+ _getFormatPositions: function() {
+ var finds = this._defaults.timeFormat.toLowerCase().match(/(h{1,2}|m{1,2}|s{1,2}|l{1}|t{1,2}|z)/g),
+ orders = { h: -1, m: -1, s: -1, l: -1, t: -1, z: -1 };
+
+ if (finds)
+ for (var i = 0; i < finds.length; i++)
+ if (orders[finds[i].toString().charAt(0)] == -1)
+ orders[finds[i].toString().charAt(0)] = i + 1;
+
+ return orders;
+ },
+
+ //########################################################################
+ // generate and inject html for timepicker into ui datepicker
+ //########################################################################
+ _injectTimePicker: function() {
+ var $dp = this.inst.dpDiv,
+ o = this._defaults,
+ tp_inst = this,
+ // Added by Peter Medeiros:
+ // - Figure out what the hour/minute/second max should be based on the step values.
+ // - Example: if stepMinute is 15, then minMax is 45.
+ hourMax = parseInt((o.hourMax - ((o.hourMax - o.hourMin) % o.stepHour)) ,10),
+ minMax = parseInt((o.minuteMax - ((o.minuteMax - o.minuteMin) % o.stepMinute)) ,10),
+ secMax = parseInt((o.secondMax - ((o.secondMax - o.secondMin) % o.stepSecond)) ,10),
+ millisecMax = parseInt((o.millisecMax - ((o.millisecMax - o.millisecMin) % o.stepMillisec)) ,10),
+ dp_id = this.inst.id.toString().replace(/([^A-Za-z0-9_])/g, '');
+
+ // Prevent displaying twice
+ //if ($dp.find("div#ui-timepicker-div-"+ dp_id).length === 0) {
+ if ($dp.find("div#ui-timepicker-div-"+ dp_id).length === 0 && o.showTimepicker) {
+ var noDisplay = ' style="display:none;"',
+ html = '<div class="ui-timepicker-div" id="ui-timepicker-div-' + dp_id + '"><dl>' +
+ '<dt class="ui_tpicker_time_label" id="ui_tpicker_time_label_' + dp_id + '"' +
+ ((o.showTime) ? '' : noDisplay) + '>' + o.timeText + '</dt>' +
+ '<dd class="ui_tpicker_time" id="ui_tpicker_time_' + dp_id + '"' +
+ ((o.showTime) ? '' : noDisplay) + '></dd>' +
+ '<dt class="ui_tpicker_hour_label" id="ui_tpicker_hour_label_' + dp_id + '"' +
+ ((o.showHour) ? '' : noDisplay) + '>' + o.hourText + '</dt>',
+ hourGridSize = 0,
+ minuteGridSize = 0,
+ secondGridSize = 0,
+ millisecGridSize = 0,
+ size;
+
+ // Hours
+ html += '<dd class="ui_tpicker_hour"><div id="ui_tpicker_hour_' + dp_id + '"' +
+ ((o.showHour) ? '' : noDisplay) + '></div>';
+ if (o.showHour && o.hourGrid > 0) {
+ html += '<div style="padding-left: 1px"><table class="ui-tpicker-grid-label"><tr>';
+
+ for (var h = o.hourMin; h <= hourMax; h += parseInt(o.hourGrid,10)) {
+ hourGridSize++;
+ var tmph = (o.ampm && h > 12) ? h-12 : h;
+ if (tmph < 10) tmph = '0' + tmph;
+ if (o.ampm) {
+ if (h == 0) tmph = 12 +'a';
+ else if (h < 12) tmph += 'a';
+ else tmph += 'p';
+ }
+ html += '<td>' + tmph + '</td>';
+ }
+
+ html += '</tr></table></div>';
+ }
+ html += '</dd>';
+
+ // Minutes
+ html += '<dt class="ui_tpicker_minute_label" id="ui_tpicker_minute_label_' + dp_id + '"' +
+ ((o.showMinute) ? '' : noDisplay) + '>' + o.minuteText + '</dt>'+
+ '<dd class="ui_tpicker_minute"><div id="ui_tpicker_minute_' + dp_id + '"' +
+ ((o.showMinute) ? '' : noDisplay) + '></div>';
+
+ if (o.showMinute && o.minuteGrid > 0) {
+ html += '<div style="padding-left: 1px"><table class="ui-tpicker-grid-label"><tr>';
+
+ for (var m = o.minuteMin; m <= minMax; m += parseInt(o.minuteGrid,10)) {
+ minuteGridSize++;
+ html += '<td>' + ((m < 10) ? '0' : '') + m + '</td>';
+ }
+
+ html += '</tr></table></div>';
+ }
+ html += '</dd>';
+
+ // Seconds
+ html += '<dt class="ui_tpicker_second_label" id="ui_tpicker_second_label_' + dp_id + '"' +
+ ((o.showSecond) ? '' : noDisplay) + '>' + o.secondText + '</dt>'+
+ '<dd class="ui_tpicker_second"><div id="ui_tpicker_second_' + dp_id + '"'+
+ ((o.showSecond) ? '' : noDisplay) + '></div>';
+
+ if (o.showSecond && o.secondGrid > 0) {
+ html += '<div style="padding-left: 1px"><table><tr>';
+
+ for (var s = o.secondMin; s <= secMax; s += parseInt(o.secondGrid,10)) {
+ secondGridSize++;
+ html += '<td>' + ((s < 10) ? '0' : '') + s + '</td>';
+ }
+
+ html += '</tr></table></div>';
+ }
+ html += '</dd>';
+
+ // Milliseconds
+ html += '<dt class="ui_tpicker_millisec_label" id="ui_tpicker_millisec_label_' + dp_id + '"' +
+ ((o.showMillisec) ? '' : noDisplay) + '>' + o.millisecText + '</dt>'+
+ '<dd class="ui_tpicker_millisec"><div id="ui_tpicker_millisec_' + dp_id + '"'+
+ ((o.showMillisec) ? '' : noDisplay) + '></div>';
+
+ if (o.showMillisec && o.millisecGrid > 0) {
+ html += '<div style="padding-left: 1px"><table><tr>';
+
+ for (var l = o.millisecMin; l <= millisecMax; l += parseInt(o.millisecGrid,10)) {
+ millisecGridSize++;
+ html += '<td>' + ((l < 10) ? '0' : '') + l + '</td>';
+ }
+
+ html += '</tr></table></div>';
+ }
+ html += '</dd>';
+
+ // Timezone
+ html += '<dt class="ui_tpicker_timezone_label" id="ui_tpicker_timezone_label_' + dp_id + '"' +
+ ((o.showTimezone) ? '' : noDisplay) + '>' + o.timezoneText + '</dt>';
+ html += '<dd class="ui_tpicker_timezone" id="ui_tpicker_timezone_' + dp_id + '"' +
+ ((o.showTimezone) ? '' : noDisplay) + '></dd>';
+
+ html += '</dl></div>';
+ $tp = $(html);
+
+ // if we only want time picker...
+ if (o.timeOnly === true) {
+ $tp.prepend(
+ '<div class="ui-widget-header ui-helper-clearfix ui-corner-all">' +
+ '<div class="ui-datepicker-title">' + o.timeOnlyTitle + '</div>' +
+ '</div>');
+ $dp.find('.ui-datepicker-header, .ui-datepicker-calendar').hide();
+ }
+
+ this.hour_slider = $tp.find('#ui_tpicker_hour_'+ dp_id).slider({
+ orientation: "horizontal",
+ value: this.hour,
+ min: o.hourMin,
+ max: hourMax,
+ step: o.stepHour,
+ slide: function(event, ui) {
+ tp_inst.hour_slider.slider( "option", "value", ui.value);
+ tp_inst._onTimeChange();
+ }
+ });
+
+
+ // Updated by Peter Medeiros:
+ // - Pass in Event and UI instance into slide function
+ this.minute_slider = $tp.find('#ui_tpicker_minute_'+ dp_id).slider({
+ orientation: "horizontal",
+ value: this.minute,
+ min: o.minuteMin,
+ max: minMax,
+ step: o.stepMinute,
+ slide: function(event, ui) {
+ tp_inst.minute_slider.slider( "option", "value", ui.value);
+ tp_inst._onTimeChange();
+ }
+ });
+
+ this.second_slider = $tp.find('#ui_tpicker_second_'+ dp_id).slider({
+ orientation: "horizontal",
+ value: this.second,
+ min: o.secondMin,
+ max: secMax,
+ step: o.stepSecond,
+ slide: function(event, ui) {
+ tp_inst.second_slider.slider( "option", "value", ui.value);
+ tp_inst._onTimeChange();
+ }
+ });
+
+ this.millisec_slider = $tp.find('#ui_tpicker_millisec_'+ dp_id).slider({
+ orientation: "horizontal",
+ value: this.millisec,
+ min: o.millisecMin,
+ max: millisecMax,
+ step: o.stepMillisec,
+ slide: function(event, ui) {
+ tp_inst.millisec_slider.slider( "option", "value", ui.value);
+ tp_inst._onTimeChange();
+ }
+ });
+
+ this.timezone_select = $tp.find('#ui_tpicker_timezone_'+ dp_id).append('<select></select>').find("select");
+ $.fn.append.apply(this.timezone_select,
+ $.map(o.timezoneList, function(val, idx) {
+ return $("<option />")
+ .val(typeof val == "object" ? val.value : val)
+ .text(typeof val == "object" ? val.label : val);
+ })
+ );
+ this.timezone_select.val((typeof this.timezone != "undefined" && this.timezone != null && this.timezone != "") ? this.timezone : o.timezone);
+ this.timezone_select.change(function() {
+ tp_inst._onTimeChange();
+ });
+
+ // Add grid functionality
+ if (o.showHour && o.hourGrid > 0) {
+ size = 100 * hourGridSize * o.hourGrid / (hourMax - o.hourMin);
+
+ $tp.find(".ui_tpicker_hour table").css({
+ width: size + "%",
+ marginLeft: (size / (-2 * hourGridSize)) + "%",
+ borderCollapse: 'collapse'
+ }).find("td").each( function(index) {
+ $(this).click(function() {
+ var h = $(this).html();
+ if(o.ampm) {
+ var ap = h.substring(2).toLowerCase(),
+ aph = parseInt(h.substring(0,2), 10);
+ if (ap == 'a') {
+ if (aph == 12) h = 0;
+ else h = aph;
+ } else if (aph == 12) h = 12;
+ else h = aph + 12;
+ }
+ tp_inst.hour_slider.slider("option", "value", h);
+ tp_inst._onTimeChange();
+ tp_inst._onSelectHandler();
+ }).css({
+ cursor: 'pointer',
+ width: (100 / hourGridSize) + '%',
+ textAlign: 'center',
+ overflow: 'hidden'
+ });
+ });
+ }
+
+ if (o.showMinute && o.minuteGrid > 0) {
+ size = 100 * minuteGridSize * o.minuteGrid / (minMax - o.minuteMin);
+ $tp.find(".ui_tpicker_minute table").css({
+ width: size + "%",
+ marginLeft: (size / (-2 * minuteGridSize)) + "%",
+ borderCollapse: 'collapse'
+ }).find("td").each(function(index) {
+ $(this).click(function() {
+ tp_inst.minute_slider.slider("option", "value", $(this).html());
+ tp_inst._onTimeChange();
+ tp_inst._onSelectHandler();
+ }).css({
+ cursor: 'pointer',
+ width: (100 / minuteGridSize) + '%',
+ textAlign: 'center',
+ overflow: 'hidden'
+ });
+ });
+ }
+
+ if (o.showSecond && o.secondGrid > 0) {
+ $tp.find(".ui_tpicker_second table").css({
+ width: size + "%",
+ marginLeft: (size / (-2 * secondGridSize)) + "%",
+ borderCollapse: 'collapse'
+ }).find("td").each(function(index) {
+ $(this).click(function() {
+ tp_inst.second_slider.slider("option", "value", $(this).html());
+ tp_inst._onTimeChange();
+ tp_inst._onSelectHandler();
+ }).css({
+ cursor: 'pointer',
+ width: (100 / secondGridSize) + '%',
+ textAlign: 'center',
+ overflow: 'hidden'
+ });
+ });
+ }
+
+ if (o.showMillisec && o.millisecGrid > 0) {
+ $tp.find(".ui_tpicker_millisec table").css({
+ width: size + "%",
+ marginLeft: (size / (-2 * millisecGridSize)) + "%",
+ borderCollapse: 'collapse'
+ }).find("td").each(function(index) {
+ $(this).click(function() {
+ tp_inst.millisec_slider.slider("option", "value", $(this).html());
+ tp_inst._onTimeChange();
+ tp_inst._onSelectHandler();
+ }).css({
+ cursor: 'pointer',
+ width: (100 / millisecGridSize) + '%',
+ textAlign: 'center',
+ overflow: 'hidden'
+ });
+ });
+ }
+
+ var $buttonPanel = $dp.find('.ui-datepicker-buttonpane');
+ if ($buttonPanel.length) $buttonPanel.before($tp);
+ else $dp.append($tp);
+
+ this.$timeObj = $tp.find('#ui_tpicker_time_'+ dp_id);
+
+ if (this.inst !== null) {
+ var timeDefined = this.timeDefined;
+ this._onTimeChange();
+ this.timeDefined = timeDefined;
+ }
+
+ //Emulate datepicker onSelect behavior. Call on slidestop.
+ var onSelectDelegate = function() {
+ tp_inst._onSelectHandler();
+ };
+ this.hour_slider.bind('slidestop',onSelectDelegate);
+ this.minute_slider.bind('slidestop',onSelectDelegate);
+ this.second_slider.bind('slidestop',onSelectDelegate);
+ this.millisec_slider.bind('slidestop',onSelectDelegate);
+
+ // slideAccess integration: http://trentrichardson.com/2011/11/11/jquery-ui-sliders-and-touch-accessibility/
+ if (this._defaults.addSliderAccess){
+ var sliderAccessArgs = this._defaults.sliderAccessArgs;
+ setTimeout(function(){ // fix for inline mode
+ if($tp.find('.ui-slider-access').length == 0){
+ $tp.find('.ui-slider:visible').sliderAccess(sliderAccessArgs);
+
+ // fix any grids since sliders are shorter
+ var sliderAccessWidth = $tp.find('.ui-slider-access:eq(0)').outerWidth(true);
+ if(sliderAccessWidth){
+ $tp.find('table:visible').each(function(){
+ var $g = $(this),
+ oldWidth = $g.outerWidth(),
+ oldMarginLeft = $g.css('marginLeft').toString().replace('%',''),
+ newWidth = oldWidth - sliderAccessWidth,
+ newMarginLeft = ((oldMarginLeft * newWidth)/oldWidth) + '%';
+
+ $g.css({ width: newWidth, marginLeft: newMarginLeft });
+ });
+ }
+ }
+ },0);
+ }
+ // end slideAccess integration
+
+ }
+ },
+
+ //########################################################################
+ // This function tries to limit the ability to go outside the
+ // min/max date range
+ //########################################################################
+ _limitMinMaxDateTime: function(dp_inst, adjustSliders){
+ var o = this._defaults,
+ dp_date = new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay);
+
+ if(!this._defaults.showTimepicker) return; // No time so nothing to check here
+
+ if($.datepicker._get(dp_inst, 'minDateTime') !== null && $.datepicker._get(dp_inst, 'minDateTime') !== undefined && dp_date){
+ var minDateTime = $.datepicker._get(dp_inst, 'minDateTime'),
+ minDateTimeDate = new Date(minDateTime.getFullYear(), minDateTime.getMonth(), minDateTime.getDate(), 0, 0, 0, 0);
+
+ if(this.hourMinOriginal === null || this.minuteMinOriginal === null || this.secondMinOriginal === null || this.millisecMinOriginal === null){
+ this.hourMinOriginal = o.hourMin;
+ this.minuteMinOriginal = o.minuteMin;
+ this.secondMinOriginal = o.secondMin;
+ this.millisecMinOriginal = o.millisecMin;
+ }
+
+ if(dp_inst.settings.timeOnly || minDateTimeDate.getTime() == dp_date.getTime()) {
+ this._defaults.hourMin = minDateTime.getHours();
+ if (this.hour <= this._defaults.hourMin) {
+ this.hour = this._defaults.hourMin;
+ this._defaults.minuteMin = minDateTime.getMinutes();
+ if (this.minute <= this._defaults.minuteMin) {
+ this.minute = this._defaults.minuteMin;
+ this._defaults.secondMin = minDateTime.getSeconds();
+ } else if (this.second <= this._defaults.secondMin){
+ this.second = this._defaults.secondMin;
+ this._defaults.millisecMin = minDateTime.getMilliseconds();
+ } else {
+ if(this.millisec < this._defaults.millisecMin)
+ this.millisec = this._defaults.millisecMin;
+ this._defaults.millisecMin = this.millisecMinOriginal;
+ }
+ } else {
+ this._defaults.minuteMin = this.minuteMinOriginal;
+ this._defaults.secondMin = this.secondMinOriginal;
+ this._defaults.millisecMin = this.millisecMinOriginal;
+ }
+ }else{
+ this._defaults.hourMin = this.hourMinOriginal;
+ this._defaults.minuteMin = this.minuteMinOriginal;
+ this._defaults.secondMin = this.secondMinOriginal;
+ this._defaults.millisecMin = this.millisecMinOriginal;
+ }
+ }
+
+ if($.datepicker._get(dp_inst, 'maxDateTime') !== null && $.datepicker._get(dp_inst, 'maxDateTime') !== undefined && dp_date){
+ var maxDateTime = $.datepicker._get(dp_inst, 'maxDateTime'),
+ maxDateTimeDate = new Date(maxDateTime.getFullYear(), maxDateTime.getMonth(), maxDateTime.getDate(), 0, 0, 0, 0);
+
+ if(this.hourMaxOriginal === null || this.minuteMaxOriginal === null || this.secondMaxOriginal === null){
+ this.hourMaxOriginal = o.hourMax;
+ this.minuteMaxOriginal = o.minuteMax;
+ this.secondMaxOriginal = o.secondMax;
+ this.millisecMaxOriginal = o.millisecMax;
+ }
+
+ if(dp_inst.settings.timeOnly || maxDateTimeDate.getTime() == dp_date.getTime()){
+ this._defaults.hourMax = maxDateTime.getHours();
+ if (this.hour >= this._defaults.hourMax) {
+ this.hour = this._defaults.hourMax;
+ this._defaults.minuteMax = maxDateTime.getMinutes();
+ if (this.minute >= this._defaults.minuteMax) {
+ this.minute = this._defaults.minuteMax;
+ this._defaults.secondMax = maxDateTime.getSeconds();
+ } else if (this.second >= this._defaults.secondMax) {
+ this.second = this._defaults.secondMax;
+ this._defaults.millisecMax = maxDateTime.getMilliseconds();
+ } else {
+ if(this.millisec > this._defaults.millisecMax) this.millisec = this._defaults.millisecMax;
+ this._defaults.millisecMax = this.millisecMaxOriginal;
+ }
+ } else {
+ this._defaults.minuteMax = this.minuteMaxOriginal;
+ this._defaults.secondMax = this.secondMaxOriginal;
+ this._defaults.millisecMax = this.millisecMaxOriginal;
+ }
+ }else{
+ this._defaults.hourMax = this.hourMaxOriginal;
+ this._defaults.minuteMax = this.minuteMaxOriginal;
+ this._defaults.secondMax = this.secondMaxOriginal;
+ this._defaults.millisecMax = this.millisecMaxOriginal;
+ }
+ }
+
+ if(adjustSliders !== undefined && adjustSliders === true){
+ var hourMax = parseInt((this._defaults.hourMax - ((this._defaults.hourMax - this._defaults.hourMin) % this._defaults.stepHour)) ,10),
+ minMax = parseInt((this._defaults.minuteMax - ((this._defaults.minuteMax - this._defaults.minuteMin) % this._defaults.stepMinute)) ,10),
+ secMax = parseInt((this._defaults.secondMax - ((this._defaults.secondMax - this._defaults.secondMin) % this._defaults.stepSecond)) ,10),
+ millisecMax = parseInt((this._defaults.millisecMax - ((this._defaults.millisecMax - this._defaults.millisecMin) % this._defaults.stepMillisec)) ,10);
+
+ if(this.hour_slider)
+ this.hour_slider.slider("option", { min: this._defaults.hourMin, max: hourMax }).slider('value', this.hour);
+ if(this.minute_slider)
+ this.minute_slider.slider("option", { min: this._defaults.minuteMin, max: minMax }).slider('value', this.minute);
+ if(this.second_slider)
+ this.second_slider.slider("option", { min: this._defaults.secondMin, max: secMax }).slider('value', this.second);
+ if(this.millisec_slider)
+ this.millisec_slider.slider("option", { min: this._defaults.millisecMin, max: millisecMax }).slider('value', this.millisec);
+ }
+
+ },
+
+
+ //########################################################################
+ // when a slider moves, set the internal time...
+ // on time change is also called when the time is updated in the text field
+ //########################################################################
+ _onTimeChange: function() {
+ var hour = (this.hour_slider) ? this.hour_slider.slider('value') : false,
+ minute = (this.minute_slider) ? this.minute_slider.slider('value') : false,
+ second = (this.second_slider) ? this.second_slider.slider('value') : false,
+ millisec = (this.millisec_slider) ? this.millisec_slider.slider('value') : false,
+ timezone = (this.timezone_select) ? this.timezone_select.val() : false,
+ o = this._defaults;
+
+ if (typeof(hour) == 'object') hour = false;
+ if (typeof(minute) == 'object') minute = false;
+ if (typeof(second) == 'object') second = false;
+ if (typeof(millisec) == 'object') millisec = false;
+ if (typeof(timezone) == 'object') timezone = false;
+
+ if (hour !== false) hour = parseInt(hour,10);
+ if (minute !== false) minute = parseInt(minute,10);
+ if (second !== false) second = parseInt(second,10);
+ if (millisec !== false) millisec = parseInt(millisec,10);
+
+ var ampm = o[hour < 12 ? 'amNames' : 'pmNames'][0];
+
+ // If the update was done in the input field, the input field should not be updated.
+ // If the update was done using the sliders, update the input field.
+ var hasChanged = (hour != this.hour || minute != this.minute
+ || second != this.second || millisec != this.millisec
+ || (this.ampm.length > 0
+ && (hour < 12) != ($.inArray(this.ampm.toUpperCase(), this.amNames) !== -1))
+ || timezone != this.timezone);
+
+ if (hasChanged) {
+
+ if (hour !== false)this.hour = hour;
+ if (minute !== false) this.minute = minute;
+ if (second !== false) this.second = second;
+ if (millisec !== false) this.millisec = millisec;
+ if (timezone !== false) this.timezone = timezone;
+
+ if (!this.inst) this.inst = $.datepicker._getInst(this.$input[0]);
+
+ this._limitMinMaxDateTime(this.inst, true);
+ }
+ if (o.ampm) this.ampm = ampm;
+
+ //this._formatTime();
+ this.formattedTime = $.datepicker.formatTime(this._defaults.timeFormat, this, this._defaults);
+ if (this.$timeObj) this.$timeObj.text(this.formattedTime + o.timeSuffix);
+ this.timeDefined = true;
+ if (hasChanged) this._updateDateTime();
+ },
+
+ //########################################################################
+ // call custom onSelect.
+ // bind to sliders slidestop, and grid click.
+ //########################################################################
+ _onSelectHandler: function() {
+ var onSelect = this._defaults.onSelect;
+ var inputEl = this.$input ? this.$input[0] : null;
+ if (onSelect && inputEl) {
+ onSelect.apply(inputEl, [this.formattedDateTime, this]);
+ }
+ },
+
+ //########################################################################
+ // left for any backwards compatibility
+ //########################################################################
+ _formatTime: function(time, format) {
+ time = time || { hour: this.hour, minute: this.minute, second: this.second, millisec: this.millisec, ampm: this.ampm, timezone: this.timezone };
+ var tmptime = (format || this._defaults.timeFormat).toString();
+
+ tmptime = $.datepicker.formatTime(tmptime, time, this._defaults);
+
+ if (arguments.length) return tmptime;
+ else this.formattedTime = tmptime;
+ },
+
+ //########################################################################
+ // update our input with the new date time..
+ //########################################################################
+ _updateDateTime: function(dp_inst) {
+ dp_inst = this.inst || dp_inst;
+ var dt = $.datepicker._daylightSavingAdjust(new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay)),
+ dateFmt = $.datepicker._get(dp_inst, 'dateFormat'),
+ formatCfg = $.datepicker._getFormatConfig(dp_inst),
+ timeAvailable = dt !== null && this.timeDefined;
+ this.formattedDate = $.datepicker.formatDate(dateFmt, (dt === null ? new Date() : dt), formatCfg);
+ var formattedDateTime = this.formattedDate;
+ if (dp_inst.lastVal !== undefined && (dp_inst.lastVal.length > 0 && this.$input.val().length === 0))
+ return;
+
+ if (this._defaults.timeOnly === true) {
+ formattedDateTime = this.formattedTime;
+ } else if (this._defaults.timeOnly !== true && (this._defaults.alwaysSetTime || timeAvailable)) {
+ formattedDateTime += this._defaults.separator + this.formattedTime + this._defaults.timeSuffix;
+ }
+
+ this.formattedDateTime = formattedDateTime;
+
+ if(!this._defaults.showTimepicker) {
+ this.$input.val(this.formattedDate);
+ } else if (this.$altInput && this._defaults.altFieldTimeOnly === true) {
+ this.$altInput.val(this.formattedTime);
+ this.$input.val(this.formattedDate);
+ } else if(this.$altInput) {
+ this.$altInput.val(formattedDateTime);
+ this.$input.val(formattedDateTime);
+ } else {
+ this.$input.val(formattedDateTime);
+ }
+
+ this.$input.trigger("change");
+ }
+
+});
+
+$.fn.extend({
+ //########################################################################
+ // shorthand just to use timepicker..
+ //########################################################################
+ timepicker: function(o) {
+ o = o || {};
+ var tmp_args = arguments;
+
+ if (typeof o == 'object') tmp_args[0] = $.extend(o, { timeOnly: true });
+
+ return $(this).each(function() {
+ $.fn.datetimepicker.apply($(this), tmp_args);
+ });
+ },
+
+ //########################################################################
+ // extend timepicker to datepicker
+ //########################################################################
+ datetimepicker: function(o) {
+ o = o || {};
+ var $input = this,
+ tmp_args = arguments;
+
+ if (typeof(o) == 'string'){
+ if(o == 'getDate')
+ return $.fn.datepicker.apply($(this[0]), tmp_args);
+ else
+ return this.each(function() {
+ var $t = $(this);
+ $t.datepicker.apply($t, tmp_args);
+ });
+ }
+ else
+ return this.each(function() {
+ var $t = $(this);
+ $t.datepicker($.timepicker._newInst($t, o)._defaults);
+ });
+ }
+});
+
+//########################################################################
+// format the time all pretty...
+// format = string format of the time
+// time = a {}, not a Date() for timezones
+// options = essentially the regional[].. amNames, pmNames, ampm
+//########################################################################
+$.datepicker.formatTime = function(format, time, options) {
+ options = options || {};
+ options = $.extend($.timepicker._defaults, options);
+ time = $.extend({hour:0, minute:0, second:0, millisec:0, timezone:'+0000'}, time);
+
+ var tmptime = format;
+ var ampmName = options['amNames'][0];
+
+ var hour = parseInt(time.hour, 10);
+ if (options.ampm) {
+ if (hour > 11){
+ ampmName = options['pmNames'][0];
+ if(hour > 12)
+ hour = hour % 12;
+ }
+ if (hour === 0)
+ hour = 12;
+ }
+ tmptime = tmptime.replace(/(?:hh?|mm?|ss?|[tT]{1,2}|[lz])/g, function(match) {
+ switch (match.toLowerCase()) {
+ case 'hh': return ('0' + hour).slice(-2);
+ case 'h': return hour;
+ case 'mm': return ('0' + time.minute).slice(-2);
+ case 'm': return time.minute;
+ case 'ss': return ('0' + time.second).slice(-2);
+ case 's': return time.second;
+ case 'l': return ('00' + time.millisec).slice(-3);
+ case 'z': return time.timezone;
+ case 't': case 'tt':
+ if (options.ampm) {
+ if (match.length == 1)
+ ampmName = ampmName.charAt(0);
+ return match.charAt(0) == 'T' ? ampmName.toUpperCase() : ampmName.toLowerCase();
+ }
+ return '';
+ }
+ });
+
+ tmptime = $.trim(tmptime);
+ return tmptime;
+}
+
+//########################################################################
+// the bad hack :/ override datepicker so it doesnt close on select
+// inspired: http://stackoverflow.com/questions/1252512/jquery-datepicker-prevent-closing-picker-when-clicking-a-date/1762378#1762378
+//########################################################################
+$.datepicker._base_selectDate = $.datepicker._selectDate;
+$.datepicker._selectDate = function (id, dateStr) {
+ var inst = this._getInst($(id)[0]),
+ tp_inst = this._get(inst, 'timepicker');
+
+ if (tp_inst) {
+ tp_inst._limitMinMaxDateTime(inst, true);
+ inst.inline = inst.stay_open = true;
+ //This way the onSelect handler called from calendarpicker get the full dateTime
+ this._base_selectDate(id, dateStr);
+ inst.inline = inst.stay_open = false;
+ this._notifyChange(inst);
+ this._updateDatepicker(inst);
+ }
+ else this._base_selectDate(id, dateStr);
+};
+
+//#############################################################################################
+// second bad hack :/ override datepicker so it triggers an event when changing the input field
+// and does not redraw the datepicker on every selectDate event
+//#############################################################################################
+$.datepicker._base_updateDatepicker = $.datepicker._updateDatepicker;
+$.datepicker._updateDatepicker = function(inst) {
+
+ // don't popup the datepicker if there is another instance already opened
+ var input = inst.input[0];
+ if($.datepicker._curInst &&
+ $.datepicker._curInst != inst &&
+ $.datepicker._datepickerShowing &&
+ $.datepicker._lastInput != input) {
+ return;
+ }
+
+ if (typeof(inst.stay_open) !== 'boolean' || inst.stay_open === false) {
+
+ this._base_updateDatepicker(inst);
+
+ // Reload the time control when changing something in the input text field.
+ var tp_inst = this._get(inst, 'timepicker');
+ if(tp_inst) tp_inst._addTimePicker(inst);
+ }
+};
+
+//#######################################################################################
+// third bad hack :/ override datepicker so it allows spaces and colon in the input field
+//#######################################################################################
+$.datepicker._base_doKeyPress = $.datepicker._doKeyPress;
+$.datepicker._doKeyPress = function(event) {
+ var inst = $.datepicker._getInst(event.target),
+ tp_inst = $.datepicker._get(inst, 'timepicker');
+
+ if (tp_inst) {
+ if ($.datepicker._get(inst, 'constrainInput')) {
+ var ampm = tp_inst._defaults.ampm,
+ dateChars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat')),
+ datetimeChars = tp_inst._defaults.timeFormat.toString()
+ .replace(/[hms]/g, '')
+ .replace(/TT/g, ampm ? 'APM' : '')
+ .replace(/Tt/g, ampm ? 'AaPpMm' : '')
+ .replace(/tT/g, ampm ? 'AaPpMm' : '')
+ .replace(/T/g, ampm ? 'AP' : '')
+ .replace(/tt/g, ampm ? 'apm' : '')
+ .replace(/t/g, ampm ? 'ap' : '') +
+ " " +
+ tp_inst._defaults.separator +
+ tp_inst._defaults.timeSuffix +
+ (tp_inst._defaults.showTimezone ? tp_inst._defaults.timezoneList.join('') : '') +
+ (tp_inst._defaults.amNames.join('')) +
+ (tp_inst._defaults.pmNames.join('')) +
+ dateChars,
+ chr = String.fromCharCode(event.charCode === undefined ? event.keyCode : event.charCode);
+ return event.ctrlKey || (chr < ' ' || !dateChars || datetimeChars.indexOf(chr) > -1);
+ }
+ }
+
+ return $.datepicker._base_doKeyPress(event);
+};
+
+//#######################################################################################
+// Override key up event to sync manual input changes.
+//#######################################################################################
+$.datepicker._base_doKeyUp = $.datepicker._doKeyUp;
+$.datepicker._doKeyUp = function (event) {
+ var inst = $.datepicker._getInst(event.target),
+ tp_inst = $.datepicker._get(inst, 'timepicker');
+
+ if (tp_inst) {
+ if (tp_inst._defaults.timeOnly && (inst.input.val() != inst.lastVal)) {
+ try {
+ $.datepicker._updateDatepicker(inst);
+ }
+ catch (err) {
+ $.datepicker.log(err);
+ }
+ }
+ }
+
+ return $.datepicker._base_doKeyUp(event);
+};
+
+//#######################################################################################
+// override "Today" button to also grab the time.
+//#######################################################################################
+$.datepicker._base_gotoToday = $.datepicker._gotoToday;
+$.datepicker._gotoToday = function(id) {
+ var inst = this._getInst($(id)[0]),
+ $dp = inst.dpDiv;
+ this._base_gotoToday(id);
+ var now = new Date();
+ var tp_inst = this._get(inst, 'timepicker');
+ if (tp_inst && tp_inst._defaults.showTimezone && tp_inst.timezone_select) {
+ var tzoffset = now.getTimezoneOffset(); // If +0100, returns -60
+ var tzsign = tzoffset > 0 ? '-' : '+';
+ tzoffset = Math.abs(tzoffset);
+ var tzmin = tzoffset % 60;
+ tzoffset = tzsign + ('0' + (tzoffset - tzmin) / 60).slice(-2) + ('0' + tzmin).slice(-2);
+ if (tp_inst._defaults.timezoneIso8609)
+ tzoffset = tzoffset.substring(0, 3) + ':' + tzoffset.substring(3);
+ tp_inst.timezone_select.val(tzoffset);
+ }
+ this._setTime(inst, now);
+ $( '.ui-datepicker-today', $dp).click();
+};
+
+//#######################################################################################
+// Disable & enable the Time in the datetimepicker
+//#######################################################################################
+$.datepicker._disableTimepickerDatepicker = function(target, date, withDate) {
+ var inst = this._getInst(target),
+ tp_inst = this._get(inst, 'timepicker');
+ $(target).datepicker('getDate'); // Init selected[Year|Month|Day]
+ if (tp_inst) {
+ tp_inst._defaults.showTimepicker = false;
+ tp_inst._updateDateTime(inst);
+ }
+};
+
+$.datepicker._enableTimepickerDatepicker = function(target, date, withDate) {
+ var inst = this._getInst(target),
+ tp_inst = this._get(inst, 'timepicker');
+ $(target).datepicker('getDate'); // Init selected[Year|Month|Day]
+ if (tp_inst) {
+ tp_inst._defaults.showTimepicker = true;
+ tp_inst._addTimePicker(inst); // Could be disabled on page load
+ tp_inst._updateDateTime(inst);
+ }
+};
+
+//#######################################################################################
+// Create our own set time function
+//#######################################################################################
+$.datepicker._setTime = function(inst, date) {
+ var tp_inst = this._get(inst, 'timepicker');
+ if (tp_inst) {
+ var defaults = tp_inst._defaults,
+ // calling _setTime with no date sets time to defaults
+ hour = date ? date.getHours() : defaults.hour,
+ minute = date ? date.getMinutes() : defaults.minute,
+ second = date ? date.getSeconds() : defaults.second,
+ millisec = date ? date.getMilliseconds() : defaults.millisec;
+
+ //check if within min/max times..
+ if ((hour < defaults.hourMin || hour > defaults.hourMax) || (minute < defaults.minuteMin || minute > defaults.minuteMax) || (second < defaults.secondMin || second > defaults.secondMax) || (millisec < defaults.millisecMin || millisec > defaults.millisecMax)) {
+ hour = defaults.hourMin;
+ minute = defaults.minuteMin;
+ second = defaults.secondMin;
+ millisec = defaults.millisecMin;
+ }
+
+ tp_inst.hour = hour;
+ tp_inst.minute = minute;
+ tp_inst.second = second;
+ tp_inst.millisec = millisec;
+
+ if (tp_inst.hour_slider) tp_inst.hour_slider.slider('value', hour);
+ if (tp_inst.minute_slider) tp_inst.minute_slider.slider('value', minute);
+ if (tp_inst.second_slider) tp_inst.second_slider.slider('value', second);
+ if (tp_inst.millisec_slider) tp_inst.millisec_slider.slider('value', millisec);
+
+ tp_inst._onTimeChange();
+ tp_inst._updateDateTime(inst);
+ }
+};
+
+//#######################################################################################
+// Create new public method to set only time, callable as $().datepicker('setTime', date)
+//#######################################################################################
+$.datepicker._setTimeDatepicker = function(target, date, withDate) {
+ var inst = this._getInst(target),
+ tp_inst = this._get(inst, 'timepicker');
+
+ if (tp_inst) {
+ this._setDateFromField(inst);
+ var tp_date;
+ if (date) {
+ if (typeof date == "string") {
+ tp_inst._parseTime(date, withDate);
+ tp_date = new Date();
+ tp_date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second, tp_inst.millisec);
+ }
+ else tp_date = new Date(date.getTime());
+ if (tp_date.toString() == 'Invalid Date') tp_date = undefined;
+ this._setTime(inst, tp_date);
+ }
+ }
+
+};
+
+//#######################################################################################
+// override setDate() to allow setting time too within Date object
+//#######################################################################################
+$.datepicker._base_setDateDatepicker = $.datepicker._setDateDatepicker;
+$.datepicker._setDateDatepicker = function(target, date) {
+ var inst = this._getInst(target),
+ tp_date = (date instanceof Date) ? new Date(date.getTime()) : date;
+
+ this._updateDatepicker(inst);
+ this._base_setDateDatepicker.apply(this, arguments);
+ this._setTimeDatepicker(target, tp_date, true);
+};
+
+//#######################################################################################
+// override getDate() to allow getting time too within Date object
+//#######################################################################################
+$.datepicker._base_getDateDatepicker = $.datepicker._getDateDatepicker;
+$.datepicker._getDateDatepicker = function(target, noDefault) {
+ var inst = this._getInst(target),
+ tp_inst = this._get(inst, 'timepicker');
+
+ if (tp_inst) {
+ this._setDateFromField(inst, noDefault);
+ var date = this._getDate(inst);
+ if (date && tp_inst._parseTime($(target).val(), tp_inst.timeOnly)) date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second, tp_inst.millisec);
+ return date;
+ }
+ return this._base_getDateDatepicker(target, noDefault);
+};
+
+//#######################################################################################
+// override parseDate() because UI 1.8.14 throws an error about "Extra characters"
+// An option in datapicker to ignore extra format characters would be nicer.
+//#######################################################################################
+$.datepicker._base_parseDate = $.datepicker.parseDate;
+$.datepicker.parseDate = function(format, value, settings) {
+ var date;
+ try {
+ date = this._base_parseDate(format, value, settings);
+ } catch (err) {
+ if (err.indexOf(":") >= 0) {
+ // Hack! The error message ends with a colon, a space, and
+ // the "extra" characters. We rely on that instead of
+ // attempting to perfectly reproduce the parsing algorithm.
+ date = this._base_parseDate(format, value.substring(0,value.length-(err.length-err.indexOf(':')-2)), settings);
+ } else {
+ // The underlying error was not related to the time
+ throw err;
+ }
+ }
+ return date;
+};
+
+//#######################################################################################
+// override formatDate to set date with time to the input
+//#######################################################################################
+$.datepicker._base_formatDate=$.datepicker._formatDate;
+$.datepicker._formatDate = function(inst, day, month, year){
+ var tp_inst = this._get(inst, 'timepicker');
+ if(tp_inst)
+ {
+ if(day)
+ var b = this._base_formatDate(inst, day, month, year);
+ tp_inst._updateDateTime(inst);
+ return tp_inst.$input.val();
+ }
+ return this._base_formatDate(inst);
+};
+
+//#######################################################################################
+// override options setter to add time to maxDate(Time) and minDate(Time). MaxDate
+//#######################################################################################
+$.datepicker._base_optionDatepicker = $.datepicker._optionDatepicker;
+$.datepicker._optionDatepicker = function(target, name, value) {
+ var inst = this._getInst(target),
+ tp_inst = this._get(inst, 'timepicker');
+ if (tp_inst) {
+ var min,max,onselect;
+ if (typeof name == 'string') { // if min/max was set with the string
+ if (name==='minDate' || name==='minDateTime' )
+ min = value;
+ else if (name==='maxDate' || name==='maxDateTime')
+ max = value;
+ else if (name==='onSelect')
+ onselect=value;
+ } else if (typeof name == 'object') { //if min/max was set with the JSON
+ if(name.minDate)
+ min = name.minDate;
+ else if (name.minDateTime)
+ min = name.minDateTime;
+ else if (name.maxDate)
+ max = name.maxDate;
+ else if (name.maxDateTime)
+ max = name.maxDateTime;
+ }
+ if(min){ //if min was set
+ if(min==0)
+ min=new Date();
+ else
+ min= new Date(min);
+
+ tp_inst._defaults.minDate = min;
+ tp_inst._defaults.minDateTime = min;
+ } else if (max){ //if max was set
+ if(max==0)
+ max=new Date();
+ else
+ max= new Date(max);
+ tp_inst._defaults.maxDate = max;
+ tp_inst._defaults.maxDateTime = max;
+ }
+ else if (onselect)
+ tp_inst._defaults.onSelect=onselect;
+ }
+ if (value === undefined)
+ return this._base_optionDatepicker(target, name);
+ return this._base_optionDatepicker(target, name, value);
+};
+
+//#######################################################################################
+// jQuery extend now ignores nulls!
+//#######################################################################################
+function extendRemove(target, props) {
+ $.extend(target, props);
+ for (var name in props)
+ if (props[name] === null || props[name] === undefined)
+ target[name] = props[name];
+ return target;
+};
+
+$.timepicker = new Timepicker(); // singleton instance
+$.timepicker.version = "0.9.9";
+
+})(jQuery);
+
Added: trunk/mapbender/http/extensions/jquery-ui-1.8.16.custom/development-bundle/ui/localization/jquery-ui-timepicker-de.js.js
===================================================================
--- trunk/mapbender/http/extensions/jquery-ui-1.8.16.custom/development-bundle/ui/localization/jquery-ui-timepicker-de.js.js (rev 0)
+++ trunk/mapbender/http/extensions/jquery-ui-1.8.16.custom/development-bundle/ui/localization/jquery-ui-timepicker-de.js.js 2014-02-28 12:57:18 UTC (rev 8786)
@@ -0,0 +1,23 @@
+/* German translation for the jQuery Timepicker Addon */
+/* Written by Marvin */
+(function($) {
+$.timepicker.regional['de'] = {
+dayNamesMin: ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"],
+monthNames: ["Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"],
+timeOnlyTitle: 'Zeit wählen',
+timeText: 'Zeit',
+hourText: 'Stunde',
+minuteText: 'Minute',
+secondText: 'Sekunde',
+millisecText: 'Millisekunde',
+timezoneText: 'Zeitzone',
+currentText: 'Jetzt',
+closeText: 'Fertig',
+timeFormat: 'hh:mm tt',
+dateFormat: 'yy-mm-dd',
+amNames: ['vorm.', 'AM', 'A'],
+pmNames: ['nachm.', 'PM', 'P'],
+ampm: false
+};
+$.timepicker.setDefaults($.timepicker.regional['de']);
+})(jQuery);
\ No newline at end of file
Modified: trunk/mapbender/http/php/mod_owsproxy_conf.php
===================================================================
--- trunk/mapbender/http/php/mod_owsproxy_conf.php 2014-02-28 11:51:21 UTC (rev 8785)
+++ trunk/mapbender/http/php/mod_owsproxy_conf.php 2014-02-28 12:57:18 UTC (rev 8786)
@@ -73,6 +73,12 @@
#serialize ownwms - to list and do sql
#for the definitions in the form set the params
#sequentialy read out the post variables
+
+if(isset($_POST["save"])) {
+
+}
+
+
foreach ($_POST as $var => $value) {
#select those which are relevant (hidden fields for proxy and log)
#identify them
@@ -80,17 +86,28 @@
#echo "All vars: <br>";
#echo $var." = ".$value."<br>";
$value=validateint($value);
- if ($parts[0]!='status' && $parts[2]=='price'){ #for the pricing in the textfield
-
- $admin->setWmsPrice(intval($value),intval($parts[1]));
+ if ($parts[0]!= 'status' && $parts[2]=='price'){ #for the pricing in the textfield
+ if($parts[0] == "wms") {
+ $admin->setWmsPrice(intval($value),intval($parts[1]));
+ } else if($parts[0] == "wmsfi"){
+ $admin->setWmsfiPrice(intval($value),intval($parts[1]));
+ }
}
#check the hidden fields if some log should be set
- if ($parts[2]=='log' && $parts[0]=='status'){
+ if (($parts[2]=='log' || $parts[2]=='logfi') && $parts[0]=='status'){
#set the log value to 1 or 0
- $admin->setWmsLogTag(intval($parts[1]),$value);
+ if($parts[2]=='log'){
+ $admin->setWmsLogTag(intval($parts[1]),$value);
+ } else if($parts[2]=='logfi'){
+ $admin->setWmsfiLogTag(intval($parts[1]),$value);
+ }
#if value is 0 then set the price to 0 to. there would be is no sense to have a price set - maybe change this behavior
if ($value==0) {
- $admin->setWmsPrice(intval($value),intval($parts[1]));
+ if($parts[2]=='log'){
+ $admin->setWmsPrice(intval($value),intval($parts[1]));
+ } else if($parts[2]=='logfi'){
+ $admin->setWmsfiPrice(intval($value),intval($parts[1]));
+ }
}
#echo "log: $var = $value<br>";
}
@@ -143,34 +160,30 @@
#$ownwmsconf['log']=array();
#$ownwmsconf['price']=array();
#TODO Get root layer id for showing metadata! - function should be in admin class
-echo "<form method=\"post\" action=\"".$_SERVER["SCRIPT_NAME"]."\">";
-echo "<i>Warning: Toggle proxy changes the url of the secured services!</i><br>";
-echo "<table border='1'>";
-echo "<tr valign = bottom>";
-echo "<td>";
-echo "WMS ID";
-echo "</td>";
-echo "<td>";
-echo "WMS Title";
-echo "</td>";
-echo "<td>";
-echo "Proxy";
-echo "</td>";
-echo "<td>";
-echo "Log";
-echo "</td>";
-echo "<td>";
-echo "Price(cent/Mpixel)";
-echo "</td>";
-echo "<td>";
-echo "Show detailed Usage";
-echo "</td>";
-echo "</tr>";
+
+
+echo "<form method=\"post\" action=\"".$_SERVER["SCRIPT_NAME"]."\">
+ <i>Warning: Toggle proxy changes the url of the secured services!</i><br>
+ <table border='1'>
+ <tr valign = bottom>
+ <td>WMS ID</td>
+ <td>WMS Title</td>
+ <td>Proxy</td>
+ <td>GetMap Log</td>
+ <td>GetMap Price(cent/Mpixel)</td>
+ <td>GetFeatureInfo Log</td>
+ <td>GetFeatureInfo Price(cent/Aufruf)</td>
+ <td>Show detailed Usage</td>
+ </tr>";
+
for($i=0; $i<count($ownwms); $i++){
#read out current values in db
if($admin->getWMSOWSstring($ownwms[$i]) == false){ $status_proxy = 0 ;} else {$status_proxy = 1;};
if($admin->getWmsLogTag($ownwms[$i]) == 1){$status_log=1;} else {$status_log=0;};
if ($admin->getWmsPrice($ownwms[$i]) != 0 ){$status_price=$admin->getWmsPrice($ownwms[$i]);} else {$status_price=0;};
+ if($admin->getWmsfiLogTag($ownwms[$i]) == 1){$status_logfi=1;} else {$status_logfi=0;};
+ if ($admin->getWmsfiPrice($ownwms[$i]) != 0 ){$status_price_fi=$admin->getWmsfiPrice($ownwms[$i]);} else {$status_price_fi=0;};
+
$auth=$admin->getAuthInfoOfWMS($ownwms[$i]);
if($auth['auth_type'] == ''){$status_auth = 0;} else {$status_auth = 1;};
echo "<tr>";
@@ -180,7 +193,26 @@
echo ">".$admin->getWmsTitleByWmsId($ownwms[$i]);
echo "<td>";
#for owsproxy
- echo "<input type='checkbox' id='wms_".$ownwms[$i]."_proxy' name='wms_".$ownwms[$i]."_proxy' onclick='if(this.checked){document.getElementById(\"wms_\"+".$ownwms[$i]."+\"_log\").disabled=false;document.getElementById(\"wms_\"+".$ownwms[$i]."+\"_price\").disabled=true;document.getElementById(\"status_\"+".$ownwms[$i]."+\"_proxy\").value=\"1\"}else{document.getElementById(\"wms_\"+".$ownwms[$i]."+\"_log\").checked=false;document.getElementById(\"wms_\"+".$ownwms[$i]."+\"_log\").disabled=true;document.getElementById(\"wms_\"+".$ownwms[$i]."+\"_price\").disabled=true;document.getElementById(\"wms_\"+".$ownwms[$i]."+\"_price\").value=\"0\";document.getElementById(\"status_\"+".$ownwms[$i]."+\"_proxy\").value=\"0\";document.getElementById(\"status_\"+".$ownwms[$i]."+\"_log\").value=\"0\"}'";
+ echo "<input type='checkbox' id='wms_".$ownwms[$i]."_proxy' name='wms_".$ownwms[$i]."_proxy'
+ onclick='if(this.checked){
+ document.getElementById(\"wms_\"+".$ownwms[$i]."+\"_log\").disabled=false;
+ document.getElementById(\"wms_\"+".$ownwms[$i]."+\"_logfi\").disabled=false;
+ document.getElementById(\"wms_\"+".$ownwms[$i]."+\"_price\").disabled=true;
+ document.getElementById(\"wmsfi_\"+".$ownwms[$i]."+\"_price\").disabled=true;
+ document.getElementById(\"status_\"+".$ownwms[$i]."+\"_proxy\").value=\"1\";
+ }else{
+ document.getElementById(\"wms_\"+".$ownwms[$i]."+\"_log\").checked=false;
+ document.getElementById(\"wms_\"+".$ownwms[$i]."+\"_log\").disabled=true;
+ document.getElementById(\"wms_\"+".$ownwms[$i]."+\"_logfi\").checked=false;
+ document.getElementById(\"wms_\"+".$ownwms[$i]."+\"_logfi\").disabled=true;
+ document.getElementById(\"wms_\"+".$ownwms[$i]."+\"_price\").disabled=true;
+ document.getElementById(\"wms_\"+".$ownwms[$i]."+\"_price\").value=\"0\";
+ document.getElementById(\"wmsfi_\"+".$ownwms[$i]."+\"_price\").disabled=true;
+ document.getElementById(\"wmsfi_\"+".$ownwms[$i]."+\"_price\").value=\"0\";
+ document.getElementById(\"status_\"+".$ownwms[$i]."+\"_proxy\").value=\"0\";
+ document.getElementById(\"status_\"+".$ownwms[$i]."+\"_log\").value=\"0\";
+ document.getElementById(\"status_\"+".$ownwms[$i]."+\"_logfi\").value=\"0\";
+ }'";
#default
@@ -219,7 +251,42 @@
echo "</td>";
-if($status_log == 1){
+
+
+
+ #for wmsfi logging
+ echo "<td><input type='checkbox' id='wms_".$ownwms[$i]."_logfi' name='wms_".$ownwms[$i]."_logfi' onclick='if(this.checked){document.getElementById(\"wmsfi_\"+".$ownwms[$i]."+\"_price\").disabled=false;document.getElementById(\"status_\"+".$ownwms[$i]."+\"_logfi\").value=\"1\"}else{document.getElementById(\"wmsfi_\"+".$ownwms[$i]."+\"_price\").disabled=true;document.getElementById(\"wmsfi_\"+".$ownwms[$i]."+\"_price\").value=\"0\";document.getElementById(\"status_\"+".$ownwms[$i]."+\"_logfi\").value=\"0\";document.getElementById(\"status_\"+".$ownwms[$i]."+\"_price\").value=\"0\"}'";
+
+
+ #default
+ if($status_proxy==0){ echo "disabled "; };
+ if($status_logfi == 1){ echo " checked"; };//if a log tag is set -> to activate
+ echo ">";
+ #initialize hidden field for status log:
+
+ echo "<input type=\"hidden\" name=\"status_".$ownwms[$i]."_logfi\" id=\"status_".$ownwms[$i]."_logfi\" value=".$status_logfi.">";
+
+ echo "</td>";
+ #for pricing
+ echo "<td><input id='wmsfi_".$ownwms[$i]."_price' name='wmsfi_".$ownwms[$i]."_price' type='text' size='5' value='";
+ echo $status_price_fi;
+ echo "' ";
+ #default
+ if($status_logfi != 1){ echo "disabled"; } else { echo "enabled"; };
+ //if($admin->getWmsPrice($ownwms[$i]) != 0){ echo "disabled"; }
+ echo ">";
+ #initialize hidden field for status price:
+
+ echo "<input type=\"hidden\" name=\"status_".$ownwms[$i]."_price\" id=\"status_".$ownwms[$i]."_price\" value=".$status_price_fi.">";
+
+
+ echo "</td>";
+
+
+
+
+
+if($status_log == 1 || $status_logfi == 1){
echo "<td><input type=button value='Show Usage' onclick=\"var newWindow = window.open('../php/mod_UsageShow.php?wmsid=".$ownwms[$i]."','wms','width=800,height=700,scrollbars');newWindow.href.location='Usage of Service: ".$wms_id."'\"></td>";
}
echo "</tr>";
Added: trunk/mapbender/http/plugins/mb_owsproxy_log_csv.js
===================================================================
--- trunk/mapbender/http/plugins/mb_owsproxy_log_csv.js (rev 0)
+++ trunk/mapbender/http/plugins/mb_owsproxy_log_csv.js 2014-02-28 12:57:18 UTC (rev 8786)
@@ -0,0 +1,393 @@
+/**
+ * Package: mb_owsproxy_csv
+ *
+ * Description:
+ *
+ * Files:
+ *
+ * SQL:
+ *
+ * Help:
+ *
+ * Maintainer:
+ *
+ * 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
+ */
+
+var $owsproxyCsv = $(this);
+
+var OwsProxyCsv = function (options) {
+ var that = this;
+ var lastRequestData = null;
+
+ this.loadForm = function() {
+ $.ajax({
+ url: "../plugins/mb_owsproxy_log_csv.php",
+ type: "post",
+ dataType: "json",
+ data: {action: "getForm",XDEBUG_SESSION_START:"netbeans-xdebug"},
+ success: function(data){
+ if(data.error != "") {
+ alert(data.error);
+ } else {
+ $owsproxyCsv.html(data.form);
+ $owsproxyCsv.find("fieldset#owsproxy-log-result").css("display", "none");
+ $owsproxyCsv.find("input#button-logs-query").bind("click", that.loadData);
+ $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#function").bind("change", that.initSelects);
+ that.initForm();
+ if(data.message != ""){
+ $owsproxyCsv.find("input#button-logs-query").attr('disabled','disabled');
+ alert(data.message);
+ }
+ }
+ }
+ });
+ };
+ this.loadCsvData = function(e){
+ var a = 0;
+ if (lastRequestData != null){
+ that.loadCsv(lastRequestData);
+ }
+ }
+
+ this.deleteData = function(e){
+ var a = 0;
+ if (lastRequestData != null){
+ var parameter = lastRequestData;
+ parameter['function'] = "deleteServiceLogs";
+ that.loadJson(parameter);
+ }
+ }
+
+ this.loadData = function(e){
+ if($("div.field input#timeFrom").val() == ""){
+ alert("Bitte wählen Sie \""+$('div.field label[for="timeFrom"]').text()+"\" aus.");
+ $('div.field label[for="timeFrom"]').focus();
+ return;
+ }
+
+ if($("div.field input#timeTo").val() == ""){
+ alert("Bitte wählen Sie "+$('div.field label[for="timeTo"]').text()+" aus.");
+ $('div.field label[for="timeTo"]').focus();
+ return;
+ }
+ var parameter = {
+ serviceType: $("div.form input#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.");
+ return;
+ }
+ parameter["wmsId"] = $("div.field select#wmsId").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.");
+ return;
+ }
+ parameter["userId"] = $("div.field select#userId").val();
+ }
+
+ if($("div.field select#function").val() == "getServiceLogs" ||
+ $("div.field select#function").val() == "getSum"
+ ){
+ if($("div.field select#listType").val() == "service"){
+ if($("div.field input#withContactData").attr('checked')){
+ parameter['withContactData'] = 1;
+ }
+ }
+ if($("div.field select#listType").val() == "user"){
+ parameter["wmsId"] = $("div.field select#wmsId").val();
+ if($("div.field input#withContactData").attr('checked')){
+ parameter['withContactData'] = 1;
+ }
+ }
+ } else if($("div.field select#function").val() == "listServiceLogs"){
+ if($("div.field select#listType").val() == "service"){
+ if($("div.field input#withContactData").attr('checked')){
+ parameter['withContactData'] = 1;
+ }
+ } else if($("div.field select#listType").val() == "user"
+ && $("div.field select#wmsId").val() != ""){
+ parameter["wmsId"] = $("div.field select#wmsId").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();
+ }
+ }
+
+
+// parameter["serviceType"] = $("div.form input#serviceType").val();
+// if($('div.field input[name="format"]:checked').val() == "csv"){
+// that.loadCsv(parameter);
+// } else if($('div.field input[name="format"]:checked').val() == "json"){
+//
+// console.log(parameter);
+ that.loadJson(parameter);
+// }
+
+ };
+
+ this.loadJson = function(parameter){
+ parameter['action'] = "getJson";
+ parameter['XDEBUG_SESSION_START'] = "netbeans-xdebug"; // to delete
+ $.ajax({
+ url: "../plugins/mb_owsproxy_log_csv.php",
+ type: "post",
+ dataType: "json",
+ data: parameter,
+ success: function(data){
+ lastRequestData = null;
+ if(data.error != "") {
+ alert(data.error);
+ } else {
+// alert(data.header);
+ if(data.message != ""){
+ $owsproxyCsv.find("fieldset#owsproxy-log-result").css("display", "none");
+ alert(data.message);
+ self.location.reload();
+ } else {
+ var fs = $owsproxyCsv.find("#queryResult");
+ fs.text(fs.attr('data-title')+" "+(data.data.length >= data.limit ? fs.attr('data-limit').replace("XXX", data.limit) : fs.attr('data-count').replace("XXX", data.data.length)));
+ lastRequestData = parameter;
+ var result = '<table class="result"><tr class="result-header">';
+ var col_layer_num = -1;
+ for(var i = 0; i < data.header.length; i++){
+ if(data.header[i] == "layer_featuretype_list"){
+ col_layer_num = i;
+ }
+ result += '<td>' + data.header[i] + '</td>'
+ }
+ result += '</tr>';
+
+ // Summe hier berechnen!
+
+ for(i = 0; i < data.data.length; i++){
+ result += '<tr>';
+ for(var j = 0; j < data.data[i].length; j++){
+ if(col_layer_num != -1 && col_layer_num == j && data.data[i][j] != null){
+ result += '<td>' + (data.data[i][j].replace(/,/g, ", ")) + '</td>';
+ } else {
+ result += '<td>' + data.data[i][j] + '</td>';
+ }
+ }
+ result += '</tr>';
+ }
+ result += '</table>';
+ $('div#result').html(result);
+ $owsproxyCsv.find("fieldset#owsproxy-log-result").css("display", "block");
+ }
+
+ }
+ }
+ });
+ };
+
+ this.loadCsv = function(parameter){
+ parameter['action'] = "getCsv";
+ parameter['XDEBUG_SESSION_START'] = "netbeans-xdebug"; // to delete
+ var get = "";
+ for(var name in parameter){
+ get += "&" + name + "=" + parameter[name];
+ }
+ $('iframe#csv-download').attr("src", "../plugins/mb_owsproxy_log_csv.php?"+get.substring(1));
+// $.download("../plugins/mb_owsproxy_log_csv.php", parameter, "post");
+// $('csv-download').src();
+// parameter['XDEBUG_SESSION_START'] = "netbeans-xdebug"; // to delete
+// $.ajax({
+// url: "../plugins/mb_owsproxy_log_csv.php",
+// type: "post",
+// dataType: "json",
+// data: parameter,
+// success: function(data){
+//// if(data.error != "") {
+//// alert(data.error);
+//// } else {
+//// alert(data.elements);
+//// }
+// }
+// });
+ };
+
+ this.initSelects = function () {
+ $('div.field select#wmsId 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#userId ").parent().removeClass('field-disabled');
+ $("div.field select#userId").removeAttr('disabled');
+ $("div.field select#wmsId ").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#userId").attr('disabled', "disabled");
+// $("div.field select#wmsId ").parent().removeClass('field-disabled');
+// $("div.field select#userId ").parent().addClass('field-disabled');
+ $("div.field select#wmsId ").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#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");
+ } 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");
+ } 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#userId option[value="-1"]').removeAttr("disabled");
+ }
+
+ if($("div.field select#listType").val() == "service"
+ && ($("div.field select#function").val() == "getServiceLogs" ||
+ $("div.field select#function").val() == "getSum"
+ )
+ ){
+// $("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#userId option[value="-1"]').removeAttr("disabled");
+ } else if($("div.field select#listType").val() == "service"
+ && ($("div.field select#function").val() == "getServiceLogs" ||
+ $("div.field select#function").val() == "getSum"
+ )
+ ){
+// $("div.field input#withContactData").parent().removeClass('field-disabled');
+ $("div.field input#withContactData").parent().css("display", "block");
+ } else if($("div.field select#listType").val() == "user"
+ && ($("div.field select#function").val() == "getServiceLogs" ||
+ $("div.field select#function").val() == "getSum"
+ )
+ ){
+// $("div.field input#withContactData").parent().removeClass('field-disabled');
+ $("div.field input#withContactData").parent().css("display", "block");
+ } else {
+// $("div.field input#withContactData").parent().addClass('field-disabled');
+ $("div.field input#withContactData").parent().css("display", "none");
+ }
+
+ };
+
+
+ this.initForm = function(e){
+
+ $("div.field input#timeFrom").attr("readonly", "readonly");
+ $("div.field input#timeTo").attr("readonly", "readonly");
+
+ this.initSelects();
+
+ $(function() {
+ $("div.field input#timeFrom").datetimepicker({
+ dayNamesMin: ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"],
+ monthNames: ["Januar","Ferbruar","Marz","April","Maj","Juni","Juli","August","September","Oktober","November","Dezember"],
+ timeOnlyTitle: 'Zeit Wählen',
+ timeText: 'Zeit',
+ hourText: 'Stunde',
+ minuteText: 'Minute',
+ currentText: 'Jetzt',
+ closeText: 'Fertig',
+ timeFormat: 'hh:mm tt',
+ dateFormat: 'yy-mm-dd',
+ ampm: false,
+ onClose: function(dateText, inst) {
+ var endDateTextBox = $("div.field input#timeTo");
+ if (endDateTextBox.val() != '') {
+ var testStartDate = new Date(dateText);
+ var testEndDate = new Date(endDateTextBox.val());
+ if (testStartDate > testEndDate)
+ endDateTextBox.val(dateText);
+ }
+ else {
+ endDateTextBox.val(dateText);
+ }
+ },
+ onSelect: function (selectedDateTime){
+ var start = $(this).datetimepicker('getDate');
+ $("div.field input#timeTo").datetimepicker('option', 'minDate', new Date(start.getTime()));
+ }
+ });
+ $("div.field input#timeTo").datetimepicker({
+ dayNamesMin: ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"],
+ monthNames: ["Januar","Ferbruar","Marz","April","Maj","Juni","Juli","August","September","Oktober","November","Dezember"],
+ timeOnlyTitle: 'Zeit Wählen',
+ timeText: 'Zeit',
+ hourText: 'Stunde',
+ minuteText: 'Minute',
+ currentText: 'Jetzt',
+ closeText: 'Fertig',
+ timeFormat: 'hh:mm tt',
+ dateFormat: 'yy-mm-dd',
+ ampm: false,
+ onClose: function(dateText, inst) {
+ var startDateTextBox = $("div.field input#timeFrom");
+ if (startDateTextBox.val() != '') {
+ var testStartDate = new Date(startDateTextBox.val());
+ var testEndDate = new Date(dateText);
+ if (testStartDate > testEndDate)
+ startDateTextBox.val(dateText);
+ }
+ else {
+ startDateTextBox.val(dateText);
+ }
+ },
+ onSelect: function (selectedDateTime){
+ var end = $(this).datetimepicker('getDate');
+ $("div.field input#timeFrom").datetimepicker('option', 'maxDate', new Date(end.getTime()) );
+ }
+ });
+ });
+ $("#ui-datepicker-div").css("display","none");
+ };
+
+ Mapbender.events.init.register(function () {
+ that.loadForm();
+ });
+};
+$owsproxyCsv.mapbender(new OwsProxyCsv(options));
+
+
+$(document).ready(function() {
+ $('#user_gui').live('change', function() {
+ $.ajax({
+ url: "../plugins/mb_owsproxy_log_csv.php",
+ type: "post",
+ dataType: "html",
+ data: {'userGuiId': $(this).val()},
+ success: function(data) {
+ $('#user_gui_result').html(data);
+ }
+ });
+
+ });
+});
\ No newline at end of file
Added: trunk/mapbender/http/plugins/mb_owsproxy_log_csv.php
===================================================================
--- trunk/mapbender/http/plugins/mb_owsproxy_log_csv.php (rev 0)
+++ trunk/mapbender/http/plugins/mb_owsproxy_log_csv.php 2014-02-28 12:57:18 UTC (rev 8786)
@@ -0,0 +1,184 @@
+<?php
+
+require_once dirname(__FILE__) . "/../../core/globalSettings.php";
+
+
+if(isset($_REQUEST['userGuiId'])) {
+ $id = (integer)$_REQUEST['userGuiId'];
+
+ if($id === -1) {
+ $html .= '<b>Bitte einen Benutzer auswählen</b>';
+ } else {
+ $result = db_prep_query(
+ "SELECT fkey_gui_id FROM gui_mb_user WHERE fkey_mb_user_id = $1",
+ $id,
+ array('i'));
+ }
+
+ $html .= "<table>";
+ while($row = db_fetch_assoc($result)) {
+ $html .= "<tr><td>" . $row['fkey_gui_id'] . "</td></tr>";
+ }
+ $html .= "</table>";
+
+ die($html);
+}
+
+if($_REQUEST['action'] == "getForm"){
+ $mb_user_id = $_SESSION['mb_user_id'];
+
+ $v = array($mb_user_id);
+ $t = array('i');
+ $users = array();
+ $wmses = array();
+ $sql = "SELECT w.wms_id,w.wms_title,u.mb_user_id,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 m.log_id DESC LIMIT 1000";
+
+ $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'];
+ }
+
+ $form = '<div class="form">
+ <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="function">Abfrageart:</label>
+ <select name="function" id="function">
+ <option value="getServiceLogs">getServiceLogs</option>
+ <option value="listServiceLogs">listServiceLogs</option>
+ <option value="getSum">getSum</option>
+ <!--option value="deleteServiceLogs">deleteServiceLogs</option-->
+ </select>
+ </div>
+ <div class="field">
+ <label for="listType">Listtyp:</label>
+ <select name="listType" id="listType">
+ <option value="user">Benutzer</option>
+ <option value="service">Dienst</option>
+ </select>
+ </div>
+ <div class="field">
+ <label for="withContactData">mit Kontaktdaten:</label>
+ <input name="withContactData" id="withContactData" type="checkbox"/>
+ </div>
+ <div class="field">
+ <label for="userId">Benutzername:</label>
+ <select name="userId" id="userId">
+ <option value=""></option>
+ <!--option value="-1">alle</option-->';
+ foreach ($users as $key => $value) {
+ $form .= '<option value="'.$key.'">'.$value.'</option>';
+ }
+
+ $form .= '</select>
+ </div>
+ <div class="field">
+ <label for="wmsId">Dienst:</label>
+ <select name="wmsId" id="wmsId">
+ <option value=""></option>
+ <option value="-1">alle</option>';
+ foreach ($wmses as $key => $value) {
+ $form .= '<option value="'.$key.'">'.$value.'</option>';
+ }
+ $form .= '</select>
+ </div>
+ <div class="field">
+ <label for="timeFrom">Zeit von:</label>
+ <input type="text" name="timeFrom" id="timeFrom"/>
+ </div>
+ <div class="field">
+ <label for="timeTo">Zeit bis zu:</label>
+ <input type="text" name="timeTo" id="timeTo"/>
+ </div>
+ <!--div class="field">
+ <label for="csv">CSV</label>:
+ <input type="radio" name="format" value="csv" id="csv" />
+ <label for="json">JSON</label>:
+ <input type="radio" name="format" value="json" id="json" checked="checked" />
+ </div-->
+ <div class="field">
+ <input type="button" value="Abfrage ausführen" id="button-logs-query"/>
+ </div>
+ <iframe id="csv-download" width="0" height="0" style="display:none"></iframe>
+ </div>
+ </fieldset>
+
+ <fieldset style="margin-left: 200px;width: 300px;">
+ <legend>User / GUI</legend>
+ <div class="field">
+ <label for="userId">Benutzername:</label>
+ <select id="user_gui">
+ <option value=""></option>
+ <!--option value="-1">alle</option-->';
+
+ foreach ($users as $key => $value) {
+ $form .= '<option value="'.$key.'">'.$value.'</option>';
+ }
+
+ $form .= '</select>
+ </div>
+ <div id="user_gui_result"></div>
+ </fieldset><br/>
+
+ <fieldset id="owsproxy-log-result" style="clear:both;">
+ <legend id="queryResult" data-title="OwsProxy Logs Abfrageergebnis:" data-count="XXX Treffer" data-limit="die Ausgabe ist auf XXX Treffer begrenzt.">OwsProxy Logs Abfrageergebnis</legend>
+ <div id="result-area">
+ <div id="result-operation"><input type="button" value="Ergebnis als CSV laden" id="button-csv-download"/> <input type="button" value="Ergebnisdaten löschen" id="button-logs-delete"/></div>
+ <div id="result"></div></div>
+ </fieldset>';
+
+ $jsonOutput = array("form"=>$form,"error"=>"","message"=>"");
+ if(count($users) == 0 || count($wmses) == 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";
+ $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
+
+ $userId = isset($_REQUEST['userId']) ? $_REQUEST['userId'] : null;#XXX
+ $wmsId = isset($_REQUEST['wmsId']) ? $_REQUEST['wmsId'] : 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){
+ die ("Der Parameter 'serviceType' wurde nicht uebergeben.");
+ }
+
+ 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->handle();
+ header("Content-Type: text/csv; charset=".CHARSET);
+ header("Content-Disposition: attachment; filename=csv_export.csv");
+ header("Pragma: no-cache");
+ header("Expires: 0");
+ $csv = $wmslog->getAsCsv();
+ print $csv;
+ die();
+ } else if($_REQUEST['action'] == "getJson"){
+ $wmslog = WmsOwsLogCsv::create($mb_user_id, $function, $userId, $wmsId,
+ $listType, $timeFrom, $timeTo, $withContactData);
+ $wmslog->handle();
+ print json_encode($wmslog->getAsArray());
+ die();
+ }
+ } else {
+ die ("Der 'serviceType'".$serviceType." ist nicht unterstuetzt.");
+ }
+}
+?>
\ No newline at end of file
Modified: trunk/mapbender/http_auth/http/index.php
===================================================================
--- trunk/mapbender/http_auth/http/index.php 2014-02-28 11:51:21 UTC (rev 8785)
+++ trunk/mapbender/http_auth/http/index.php 2014-02-28 12:57:18 UTC (rev 8786)
@@ -1,4 +1,5 @@
<?php
+
require(dirname(__FILE__) . "/../../conf/mapbender.conf");
require(dirname(__FILE__) . "/../../http/classes/class_administration.php");
require(dirname(__FILE__) . "/../../http/classes/class_connector.php");
@@ -6,16 +7,16 @@
require(dirname(__FILE__) . "/../../owsproxy/http/classes/class_QueryHandler.php");
//database connection
-$db = db_connect($DBSERVER,$OWNER,$PW);
-db_select_db(DB,$db);
+$db = db_connect($DBSERVER, $OWNER, $PW);
+db_select_db(DB, $db);
-$imageformats = array("image/png","image/gif","image/jpeg", "image/jpg");
+$imageformats = array("image/png", "image/gif", "image/jpeg", "image/jpg");
//control if digest auth is set, if not set, generate the challenge with getNonce()
if (empty($_SERVER['PHP_AUTH_DIGEST'])) {
header('HTTP/1.1 401 Unauthorized');
- header('WWW-Authenticate: Digest realm="'.REALM.
- '",qop="auth",nonce="'.getNonce().'",opaque="'.md5(REALM).'"');
+ header('WWW-Authenticate: Digest realm="' . REALM .
+ '",qop="auth",nonce="' . getNonce() . '",opaque="' . md5(REALM) . '"');
die('Text to send if user hits Cancel button');
}
@@ -24,47 +25,47 @@
//error if header could not be read
if (!($requestHeaderArray)) {
- echo 'Following Header information cannot be validated - check your clientsoftware!<br>';
- echo $_SERVER['PHP_AUTH_DIGEST'].'<br>';
- die();
+ echo 'Following Header information cannot be validated - check your clientsoftware!<br>';
+ echo $_SERVER['PHP_AUTH_DIGEST'] . '<br>';
+ die();
}
//get mb_username and email out of http_auth username string
-$userIdentification = explode(';',$requestHeaderArray['username']);
+$userIdentification = explode(';', $requestHeaderArray['username']);
$mbUsername = $userIdentification[0];
$mbEmail = $userIdentification[1];
-$userInformation = getUserInfo($mbUsername,$mbEmail);
+$userInformation = getUserInfo($mbUsername, $mbEmail);
if ($userInformation[0] == '-1') {
- die('User with name: '.$mbUsername.' and email: '.$mbEmail.' not known to security proxy!');
+ die('User with name: ' . $mbUsername . ' and email: ' . $mbEmail . ' not known to security proxy!');
}
-if ($userInformation[1]=='') { //check if digest exists in db - if no digest exists it should be a null string!
- die('User with name: '.$mbUsername.' and email: '.$mbEmail.' has no digest - please set a new password and try again!');
+if ($userInformation[1] == '') { //check if digest exists in db - if no digest exists it should be a null string!
+ die('User with name: ' . $mbUsername . ' and email: ' . $mbEmail . ' has no digest - please set a new password and try again!');
}
//first check the stale!
-if($requestHeaderArray['nonce'] == getNonce()) {
- // Up-to-date nonce received
- $stale = false;
- } else {
- // Stale nonce received (probably more than x seconds old)
- $stale = true;
- //give another chance to authenticate
- header('HTTP/1.1 401 Unauthorized');
- header('WWW-Authenticate: Digest realm="'.REALM.'",qop="auth",nonce="'.getNonce().'",opaque="'.md5(REALM).'" ,stale=true');
- }
+if ($requestHeaderArray['nonce'] == getNonce()) {
+ // Up-to-date nonce received
+ $stale = false;
+} else {
+ // Stale nonce received (probably more than x seconds old)
+ $stale = true;
+ //give another chance to authenticate
+ header('HTTP/1.1 401 Unauthorized');
+ header('WWW-Authenticate: Digest realm="' . REALM . '",qop="auth",nonce="' . getNonce() . '",opaque="' . md5(REALM) . '" ,stale=true');
+}
// generate the valid response to check the request of the client
$A1 = $userInformation[1];
-$A2 = md5($_SERVER['REQUEST_METHOD'].':'.$requestHeaderArray['uri']);
-$valid_response = $A1.':'.getNonce().':'.$requestHeaderArray['nc'];
-$valid_response .= ':'.$requestHeaderArray['cnonce'].':'.$requestHeaderArray['qop'].':'.$A2;
+$A2 = md5($_SERVER['REQUEST_METHOD'] . ':' . $requestHeaderArray['uri']);
+$valid_response = $A1 . ':' . getNonce() . ':' . $requestHeaderArray['nc'];
+$valid_response .= ':' . $requestHeaderArray['cnonce'] . ':' . $requestHeaderArray['qop'] . ':' . $A2;
-$valid_response=md5($valid_response);
+$valid_response = md5($valid_response);
if ($requestHeaderArray['response'] != $valid_response) {//the user have to authenticate new - cause something in the authentication went wrong
- die('Authentication failed - sorry, you have to authenticate once more!');
+ die('Authentication failed - sorry, you have to authenticate once more!');
}
//if we are here - authentication has been done well!
//let's do the proxy things (came from owsproxy.php):
@@ -73,7 +74,7 @@
//new option for nested layers
$withChilds = false;
if (isset($_REQUEST["withChilds"]) && $_REQUEST["withChilds"] === "1") {
- $withChilds = true;
+ $withChilds = true;
}
$query = new QueryHandler();
@@ -87,109 +88,104 @@
$owsproxyString = $n->getWMSOWSstring($wmsId);
if (!$owsproxyString) {
- die('The requested resource does not exists or the routing through mapbenders owsproxy is not activated!');
+ die('The requested resource does not exists or the routing through mapbenders owsproxy is not activated!');
}
//get authentication infos if they are available in wms table! if not $auth = false
$auth = $n->getAuthInfoOfWMS($wmsId);
-if ($auth['auth_type']==''){
- unset($auth);
+if ($auth['auth_type'] == '') {
+ unset($auth);
}
-$e = new mb_notice("REQUEST to HTTP_AUTH: ".strtolower($reqParams['request']));
+$e = new mb_notice("REQUEST to HTTP_AUTH: " . strtolower($reqParams['request']));
//what the proxy does
switch (strtolower($reqParams['request'])) {
- case 'getcapabilities':
- $arrayOnlineresources = checkWmsPermission($wmsId,$userInformation[0]);
- $query->setOnlineResource($arrayOnlineresources['wms_getcapabilities']);
- //$request = preg_replace("/(.*)frames\/login.php/", "$1php/wms.php?layer_id=".$layerId, LOGIN);
- if (isset($_SERVER["HTTPS"])){
- $urlPrefix = "https://";
- } else {
- $urlPrefix = "http://";
- }
- if (defined("MAPBENDER_PATH") && MAPBENDER_PATH != '') {
- $request = MAPBENDER_PATH."/php/wms.php?layer_id=".$layerId;
- } else {
- $request = $urlPrefix.$_SERVER['HTTP_HOST']."/mapbender/php/wms.php?layer_id=".$layerId;
-
- }
- if ($withChilds) {
- $requestFull .= $request.'&withChilds=1&REQUEST=GetCapabilities&VERSION=1.1.1&SERVICE=WMS';
- } else {
- $requestFull .= $request.'&REQUEST=GetCapabilities&VERSION=1.1.1&SERVICE=WMS';
- }
- if(isset($auth)){
- getCapabilities($request,$requestFull,$auth);
- }
- else {
- getCapabilities($request,$requestFull);
- }
- break;
- case 'getfeatureinfo':
- $arrayOnlineresources = checkWmsPermission($wmsId,$userInformation[0]);
- $query->setOnlineResource($arrayOnlineresources['wms_getfeatureinfo']);
- $layers = checkLayerPermission($wmsId,$reqParams['layers'],$userInformation[0]);
- if ($layers == '' ) {
- throwE("GetFeatureInfo permission denied on layer with id".$layerId);
- die();
- }
- $request = $query->getRequest();
- if(isset($auth)){
- getFeatureInfo($request,$auth);
- }
- else {
- getFeatureInfo($request);
- }
- break;
- case 'getmap':
- $arrayOnlineresources = checkWmsPermission($wmsId,$userInformation[0]);
- $query->setOnlineResource($arrayOnlineresources['wms_getmap']);
- $layers = checkLayerPermission($wmsId,$reqParams['layers'],$userInformation[0]);
- if ($layers == '' ) {
- throwE("GetMap permission denied on layer with id ".$layerId);
- die();
- }
- $query->setParam("layers",urldecode($layers));
- $request = $query->getRequest();
- //log proxy requests
- if($n->getWmsLogTag($wmsId)==1) {
- #do log to db
- #TODO read out size of bbox and calculate price
- #get price out of db
- $price=intval($n->getWmsPrice($wmsId));
- $n->logWmsProxyRequest($wmsId,$userInformation[0],$request,$price);
- }
- if(isset($auth)){
- getImage($request,$auth);
- }
- else {
- getImage($request);
- }
- break;
- case 'getlegendgraphic':
- $url = getLegendUrl($wmsId);
- $e = new mb_exception("URL for getlegendgraphic: ");
- if(isset($auth)){
- getImage($url,$auth);
- }
- else {
- getImage($url);
- }
- break;
- default:
-echo 'Your are logged in as: <b>' .$requestHeaderArray['username'].'</b> and requested the layer with id=<b>'.$layerId.'</b> but your request is not a valid OWS request';
+ case 'getcapabilities':
+ $arrayOnlineresources = checkWmsPermission($wmsId, $userInformation[0]);
+ $query->setOnlineResource($arrayOnlineresources['wms_getcapabilities']);
+ //$request = preg_replace("/(.*)frames\/login.php/", "$1php/wms.php?layer_id=".$layerId, LOGIN);
+ if (isset($_SERVER["HTTPS"])) {
+ $urlPrefix = "https://";
+ } else {
+ $urlPrefix = "http://";
+ }
+ if (defined("MAPBENDER_PATH") && MAPBENDER_PATH != '') {
+ $request = MAPBENDER_PATH . "/php/wms.php?layer_id=" . $layerId;
+ } else {
+ $request = $urlPrefix . $_SERVER['HTTP_HOST'] . "/mapbender/php/wms.php?layer_id=" . $layerId;
+ }
+ if ($withChilds) {
+ $requestFull .= $request . '&withChilds=1&REQUEST=GetCapabilities&VERSION=1.1.1&SERVICE=WMS';
+ } else {
+ $requestFull .= $request . '&REQUEST=GetCapabilities&VERSION=1.1.1&SERVICE=WMS';
+ }
+ if (isset($auth)) {
+ getCapabilities($request, $requestFull, $auth);
+ } else {
+ getCapabilities($request, $requestFull);
+ }
+ break;
+ case 'getfeatureinfo':
+ $arrayOnlineresources = checkWmsPermission($wmsId, $userInformation[0]);
+ $query->setOnlineResource($arrayOnlineresources['wms_getfeatureinfo']);
+ $request = $query->getRequest();
+ $layers = checkLayerPermission($wmsId, $reqParams['layers'], $userInformation[0]);
+ if ($layers == '') {
+ throwE("GetFeatureInfo permission denied on layer with id" . $layerId);
+ die();
+ }
+ if (isset($auth)) {
+ getFeatureInfo($request, $auth);
+ } else {
+ getFeatureInfo($request);
+ }
+ break;
+ case 'getmap':
+ $arrayOnlineresources = checkWmsPermission($wmsId, $userInformation[0]);
+ $query->setOnlineResource($arrayOnlineresources['wms_getmap']);
+ $layers = checkLayerPermission($wmsId, $reqParams['layers'], $userInformation[0]);
+ if ($layers == '') {
+ throwE("GetMap permission denied on layer with id " . $layerId);
+ die();
+ }
+ $query->setParam("layers", urldecode($layers));
+ $request = $query->getRequest();
+ #log proxy requests
+ if ($n->getWmsLogTag($wmsId) == 1) {
+ #do log to db
+ #TODO read out size of bbox and calculate price
+ #get price out of db
+ $price = intval($n->getWmsPrice($wmsId));
+ $n->logWmsProxyRequest($wmsId, $userInformation[0], $request, $price);
+ }
+ if (isset($auth)) {
+ getImage($request, $auth);
+ } else {
+ getImage($request);
+ }
+ break;
+ case 'getlegendgraphic':
+ $url = getLegendUrl($wmsId);
+ $e = new mb_exception("URL for getlegendgraphic: ");
+ if (isset($auth)) {
+ getImage($url, $auth);
+ } else {
+ getImage($url);
+ }
+ break;
+ default:
+ echo 'Your are logged in as: <b>' . $requestHeaderArray['username'] . '</b> and requested the layer with id=<b>' . $layerId . '</b> but your request is not a valid OWS request';
}
+
//functions for http_auth
//**********************************************************************************************
-
// function to parse the http auth header
function http_digest_parse($txt)
{
// protect against missing data
- $needed_parts = array('nonce'=>1, 'nc'=>1, 'cnonce'=>1, 'qop'=>1, 'username'=>1, 'uri'=>1, 'response'=>1);
+ $needed_parts = array('nonce' => 1, 'nc' => 1, 'cnonce' => 1, 'qop' => 1, 'username' => 1, 'uri' => 1, 'response' => 1);
$data = array();
$keys = implode('|', array_keys($needed_parts));
preg_match_all('@(' . $keys . ')=(?:([\'"])([^\2]+?)\2|([^\s,]+))@', $txt, $matches, PREG_SET_ORDER);
@@ -199,80 +195,103 @@
}
return $needed_parts ? false : $data;
}
+
// function to get relevant user information from mb db
-function getUserInfo($mbUsername,$mbEmail) {
- $result = array();
- $sql = "SELECT mb_user_id, mb_user_digest FROM mb_user where mb_user_name = $1 AND mb_user_email= $2";
- $v = array($mbUsername, $mbEmail);
- $t = array("s","s");
- $res = db_prep_query($sql, $v, $t);
- if(!($row = db_fetch_array($res))){
- $result[0] = "-1";
- }
- else {
- $result[0] = $row['mb_user_id'];
- $result[1] = $row['mb_user_digest'];
- }
- return $result;
+function getUserInfo($mbUsername, $mbEmail)
+{
+ $result = array();
+ $sql = "SELECT mb_user_id, mb_user_digest FROM mb_user where mb_user_name = $1 AND mb_user_email= $2";
+ $v = array($mbUsername, $mbEmail);
+ $t = array("s", "s");
+ $res = db_prep_query($sql, $v, $t);
+ if (!($row = db_fetch_array($res))) {
+ $result[0] = "-1";
+ } else {
+ $result[0] = $row['mb_user_id'];
+ $result[1] = $row['mb_user_digest'];
+ }
+ return $result;
}
-function getNonce() {
- global $nonceLife;
- $time = ceil(time() / $nonceLife) * $nonceLife;
- return md5(date('Y-m-d H:i', $time).':'.$_SERVER['REMOTE_ADDR'].':'.NONCEKEY);
+function getNonce()
+{
+ global $nonceLife;
+ $time = ceil(time() / $nonceLife) * $nonceLife;
+ return md5(date('Y-m-d H:i', $time) . ':' . $_SERVER['REMOTE_ADDR'] . ':' . NONCEKEY);
}
//**********************************************************************************************
//functions of owsproxy/http/index.php
//**********************************************************************************************
-function throwE($e){
- global $reqParams, $imageformats;
-
- if(in_array($reqParams['format'],$imageformats)){
- throwImage($e);
- }
- else{
- throwText($e);
- }
+function throwE($e)
+{
+ global $reqParams, $imageformats;
+
+ if (in_array($reqParams['format'], $imageformats)) {
+ throwImage($e);
+ } else {
+ throwText($e);
+ }
}
-function throwImage($e){
- global $reqParams;
- if (!$reqParams['width'] || !$reqParams['height']) { //width or height are not set by ows request - maybe for legendgraphics
- $width = 300;
- $height = 20;
- }
- $image = imagecreate($width,$height);
- $transparent = ImageColorAllocate($image,155,155,155);
- ImageFilledRectangle($image,0,0,$width,$height,$transparent);
- imagecolortransparent($image, $transparent);
- $text_color = ImageColorAllocate ($image, 233, 14, 91);
- for($i=0; $i<count($e); $i++){
- ImageString ($image, 3, 5, $i*20, $e[$i], $text_color);
- }
- responseImage($image);
+function throwImage($e)
+{
+ global $reqParams;
+ if (!$reqParams['width'] || !$reqParams['height']) { //width or height are not set by ows request - maybe for legendgraphics
+ $width = 300;
+ $height = 20;
+ }
+ $image = imagecreate($width, $height);
+ $transparent = ImageColorAllocate($image, 155, 155, 155);
+ ImageFilledRectangle($image, 0, 0, $width, $height, $transparent);
+ imagecolortransparent($image, $transparent);
+ $text_color = ImageColorAllocate($image, 233, 14, 91);
+ for ($i = 0; $i < count($e); $i++) {
+ ImageString($image, 3, 5, $i * 20, $e[$i], $text_color);
+ }
+ responseImage($image);
}
-function throwText($e){
- echo join(" ", $e);
+
+function throwText($e)
+{
+ echo join(" ", $e);
}
-function responseImage($im){
- global $reqParams;
- $format = $reqParams['format'];
- if($format == 'image/png'){header("Content-Type: image/png");}
- if($format == 'image/jpeg' || $format == 'image/jpg'){header("Content-Type: image/jpeg");}
- if($format == 'image/gif'){header("Content-Type: image/gif");}
- if($format == 'image/png'){imagepng($im);}
- if($format == 'image/jpeg' || $format == 'image/jpg'){imagejpeg($im);}
- if($format == 'image/gif'){imagegif($im);}
+
+function responseImage($im)
+{
+ global $reqParams;
+ $format = $reqParams['format'];
+ if ($format == 'image/png') {
+ header("Content-Type: image/png");
+ }
+ if ($format == 'image/jpeg' || $format == 'image/jpg') {
+ header("Content-Type: image/jpeg");
+ }
+ if ($format == 'image/gif') {
+ header("Content-Type: image/gif");
+ }
+ if ($format == 'image/png') {
+ imagepng($im);
+ }
+ if ($format == 'image/jpeg' || $format == 'image/jpg') {
+ imagejpeg($im);
+ }
+ if ($format == 'image/gif') {
+ imagegif($im);
+ }
}
-function completeURL($url){
- global $reqParams;
- $mykeys = array_keys($reqParams);
- for($i=0; $i<count($mykeys);$i++){
- if($i > 0){ $url .= "&"; }
- $url .= $mykeys[$i]."=".urlencode($reqParams[$mykeys[$i]]);
- }
- return $url;
+
+function completeURL($url)
+{
+ global $reqParams;
+ $mykeys = array_keys($reqParams);
+ for ($i = 0; $i < count($mykeys); $i++) {
+ if ($i > 0) {
+ $url .= "&";
+ }
+ $url .= $mykeys[$i] . "=" . urlencode($reqParams[$mykeys[$i]]);
+ }
+ return $url;
}
/**
@@ -280,18 +299,16 @@
*
* @param string the original url of the image to send
*/
-
-function getImage($or){
- global $reqParams;
- header("Content-Type: ".$reqParams['format']);
- if (func_num_args() == 2) { //new for HTTP Authentication
- $auth = func_get_arg(1);
- echo getDocumentContent($or,$auth);
- }
- else
- {
- echo getDocumentContent($or);
- }
+function getImage($or)
+{
+ global $reqParams;
+ header("Content-Type: " . $reqParams['format']);
+ if (func_num_args() == 2) { //new for HTTP Authentication
+ $auth = func_get_arg(1);
+ echo getDocumentContent($or, $auth);
+ } else {
+ echo getDocumentContent($or);
+ }
}
/**
@@ -300,188 +317,192 @@
* @param string the url of the FeatureInfoRequest
* @return string the content of the FeatureInfo document
*/
-function getFeatureInfo($url){
- global $reqParams;
- $e = new mb_notice("owsproxy: Try to fetch FeatureInfoRequest: ".$url);
- header("Content-Type: ".$reqParams['info_format']);
- if (func_num_args() == 2) { //new for HTTP Authentication
- $auth = func_get_arg(1);
- echo getDocumentContent($url,$auth);
- }
- else
- {
- echo getDocumentContent($url);
- }
+function getFeatureInfo($url)
+{
+ global $reqParams;
+ $e = new mb_notice("owsproxy: Try to fetch FeatureInfoRequest: " . $url);
+ header("Content-Type: " . $reqParams['info_format']);
+ if (func_num_args() == 2) { //new for HTTP Authentication
+ $auth = func_get_arg(1);
+ echo getDocumentContent($url, $auth);
+ } else {
+ echo getDocumentContent($url);
+ }
}
+function matchUrls($content)
+{
+ if (!session_is_registered("owsproxyUrls")) {
+ $_SESSION["owsproxyUrls"] = array();
+ $_SESSION["owsproxyUrls"]["id"] = array();
+ $_SESSION["owsproxyUrls"]["url"] = array();
+ }
+ $pattern = "/[\"|\'](https*:\/\/[^\"|^\']*)[\"|\']/";
+ preg_match_all($pattern, $content, $matches);
+ for ($i = 0; $i < count($matches[1]); $i++) {
+ $req = $matches[1][$i];
+ $e = new mb_exception("Gefundene URL " . $i . ": " . $req);
+ #$notice = new mb_notice("owsproxy id:".$req);
+ $id = registerURL($req);
+ $extReq = setExternalRequest($id);
+ $e = new mb_exception("MD5 URL " . $id . "-Externer Link: " . $extReq);
+ $content = str_replace($req, $extReq, $content);
+ }
+ return $content;
+}
+function setExternalRequest($id)
+{
+ global $reqParams, $query;
+ $extReq = "http://" . $_SESSION['HTTP_HOST'] . "/owsproxy/" . $reqParams['sid'] . "/" . $id . "?request=external";
+ return $extReq;
+}
+function getExternalRequest($id)
+{
+ for ($i = 0; $i < count($_SESSION["owsproxyUrls"]["url"]); $i++) {
+ if ($id == $_SESSION["owsproxyUrls"]["id"][$i]) {
+ $cUrl = $_SESSION["owsproxyUrls"]["url"][$i];
+ $query_string = removeOWSGetParams($_SERVER["QUERY_STRING"]);
+ if ($query_string != '') {
+ $cUrl .= getConjunctionCharacter($cUrl) . $query_string;
+ }
+ $metainfo = get_headers($cUrl, 1);
+ // just for the stupid InternetExplorer
+ header('Pragma: private');
+ header('Cache-control: private, must-revalidate');
-function matchUrls($content){
- if(!session_is_registered("owsproxyUrls")){
- $_SESSION["owsproxyUrls"] = array();
- $_SESSION["owsproxyUrls"]["id"] = array();
- $_SESSION["owsproxyUrls"]["url"] = array();
- }
- $pattern = "/[\"|\'](https*:\/\/[^\"|^\']*)[\"|\']/";
- preg_match_all($pattern,$content,$matches);
- for($i=0; $i<count($matches[1]); $i++){
- $req = $matches[1][$i];
- $e = new mb_exception("Gefundene URL ".$i.": ".$req);
- #$notice = new mb_notice("owsproxy id:".$req);
- $id = registerURL($req);
- $extReq = setExternalRequest($id);
- $e = new mb_exception("MD5 URL ".$id."-Externer Link: ".$extReq);
- $content = str_replace($req,$extReq,$content);
- }
- return $content;
+ header("Content-Type: " . $metainfo['Content-Type']);
+
+ $content = getDocumentContent($cUrl, false);
+ #$content = matchUrls($content); //In the case of http_auth - this is not possible cause we cannot save them in the header - maybe we could create a special session to do so later on?
+ echo $content;
+ }
+ }
}
-function setExternalRequest($id){
- global $reqParams,$query;
- $extReq = "http://".$_SESSION['HTTP_HOST'] ."/owsproxy/". $reqParams['sid'] ."/".$id."?request=external";
- return $extReq;
+function removeOWSGetParams($query_string)
+{
+ $r = preg_replace("/.*request=external&/", "", $query_string);
+ #return $r;
+ return "";
}
-function getExternalRequest($id){
- for($i=0; $i<count($_SESSION["owsproxyUrls"]["url"]); $i++){
- if($id == $_SESSION["owsproxyUrls"]["id"][$i]){
- $cUrl = $_SESSION["owsproxyUrls"]["url"][$i];
- $query_string = removeOWSGetParams($_SERVER["QUERY_STRING"]);
- if($query_string != ''){
- $cUrl .= getConjunctionCharacter($cUrl).$query_string;
- }
- $metainfo = get_headers($cUrl,1);
- // just for the stupid InternetExplorer
- header('Pragma: private');
- header('Cache-control: private, must-revalidate');
-
- header("Content-Type: ".$metainfo['Content-Type']);
-
- $content = getDocumentContent($cUrl,false);
- #$content = matchUrls($content); //In the case of http_auth - this is not possible cause we cannot save them in the header - maybe we could create a special session to do so later on?
- echo $content;
- }
- }
+
+function getConjunctionCharacter($url)
+{
+ if (strpos($url, "?")) {
+ if (strpos($url, "?") == strlen($url)) {
+ $cchar = "";
+ } else if (strpos($url, "&") == strlen($url)) {
+ $cchar = "";
+ } else {
+ $cchar = "&";
+ }
+ }
+ if (strpos($url, "?") === false) {
+ $cchar = "?";
+ }
+ return $cchar;
}
-function removeOWSGetParams($query_string){
- $r = preg_replace("/.*request=external&/","",$query_string);
- #return $r;
- return "";
+
+function registerUrl($url)
+{
+ if (!in_array($url, $_SESSION["owsproxyUrls"]["url"])) {
+ $e = new mb_exception("Is noch net drin!");
+ $id = md5($url);
+ $e = new mb_exception("ID: " . $id . " URL: " . $url . " will be written to session");
+ array_push($_SESSION["owsproxyUrls"]["url"], $url);
+ array_push($_SESSION["owsproxyUrls"]["id"], $id);
+ } else {
+ $e = new mb_exception("It was found! Search content and return ID!");
+ for ($i = 0; $i < count($_SESSION["owsproxyUrls"]["url"]); $i++) {
+ $e = new mb_exception("Content " . $i . " : proxyurl:" . $_SESSION["owsproxyUrls"]["url"][$i] . " - new: " . $url);
+ if ($url == $_SESSION["owsproxyUrls"]["url"][$i]) {
+ $e = new mb_exception("Identical! ID:" . $_SESSION["owsproxyUrls"]["id"][$i] . " will be used");
+ $id = $_SESSION["owsproxyUrls"]["id"][$i];
+ }
+ }
+ }
+ return $id;
}
-function getConjunctionCharacter($url){
- if(strpos($url,"?")){
- if(strpos($url,"?") == strlen($url)){
- $cchar = "";
- }else if(strpos($url,"&") == strlen($url)){
- $cchar = "";
- }else{
- $cchar = "&";
- }
- }
- if(strpos($url,"?") === false){
- $cchar = "?";
- }
- return $cchar;
-}
-function registerUrl($url){
- if(!in_array($url,$_SESSION["owsproxyUrls"]["url"])){
- $e = new mb_exception("Is noch net drin!");
- $id = md5($url);
- $e = new mb_exception("ID: ".$id." URL: ".$url." will be written to session");
- array_push($_SESSION["owsproxyUrls"]["url"],$url);
- array_push($_SESSION["owsproxyUrls"]["id"], $id);
- }
- else{
- $e = new mb_exception("It was found! Search content and return ID!");
- for($i=0; $i<count($_SESSION["owsproxyUrls"]["url"]); $i++){
- $e = new mb_exception("Content ".$i." : proxyurl:".$_SESSION["owsproxyUrls"]["url"][$i]." - new: ".$url);
- if($url == $_SESSION["owsproxyUrls"]["url"][$i]){
- $e = new mb_exception("Identical! ID:".$_SESSION["owsproxyUrls"]["id"][$i]." will be used");
- $id = $_SESSION["owsproxyUrls"]["id"][$i];
- }
- }
- }
- return $id;
-}
-function getCapabilities($request,$requestFull){
- global $arrayOnlineresources;
- global $layerId;
- header("Content-Type: application/xml");
- if (func_num_args() == 3) { //new for HTTP Authentication
- $auth = func_get_arg(2);
- $content = getDocumentContent($requestFull,$auth);
- }
- else
- {
- $content = getDocumentContent($requestFull);
- }
- //show temporal content fo capabilities
- $e = new mb_notice("content from wms.php fascade after going thru curl: ".$content);
- //loading as xml
- libxml_use_internal_errors(true);
- try {
- $capFromFascadeXmlObject = simplexml_load_string($content);
- if ( $capFromFascadeXmlObject === false) {
- foreach(libxml_get_errors() as $error) {
- $err = new mb_exception("http_auth/index.php: ".$error->message);
- }
- throw new Exception("http_auth/index.php: ".'Cannot parse Metadata XML!');
- echo "<error>http_auth/index.php: Cannot parse Capabilities XML!</error>";
- die();
- }
- }
- catch (Exception $e) {
- $err = new mb_exception("http_auth/index.php: ".$e->getMessage());
- echo "<error>http_auth/index.php: ".$e->getMessage()."</error>";
- die();
- }
- //exchanging urls in some special fields
- //
+function getCapabilities($request, $requestFull)
+{
+ global $arrayOnlineresources;
+ global $layerId;
+ header("Content-Type: application/xml");
+ if (func_num_args() == 3) { //new for HTTP Authentication
+ $auth = func_get_arg(2);
+ $content = getDocumentContent($requestFull, $auth);
+ } else {
+ $content = getDocumentContent($requestFull);
+ }
+ //show temporal content fo capabilities
+ $e = new mb_notice("content from wms.php fascade after going thru curl: " . $content);
+ //loading as xml
+ libxml_use_internal_errors(true);
+ try {
+ $capFromFascadeXmlObject = simplexml_load_string($content);
+ if ($capFromFascadeXmlObject === false) {
+ foreach (libxml_get_errors() as $error) {
+ $err = new mb_exception("http_auth/index.php: " . $error->message);
+ }
+ throw new Exception("http_auth/index.php: " . 'Cannot parse Metadata XML!');
+ echo "<error>http_auth/index.php: Cannot parse Capabilities XML!</error>";
+ die();
+ }
+ } catch (Exception $e) {
+ $err = new mb_exception("http_auth/index.php: " . $e->getMessage());
+ echo "<error>http_auth/index.php: " . $e->getMessage() . "</error>";
+ die();
+ }
+ //exchanging urls in some special fields
+ //
//GetCapabilities, GetMap, GetFeatureInfo, GetLegendGraphics, ...
- $capFromFascadeXmlObject->registerXPathNamespace("xlink", "http://www.w3.org/1999/xlink");
- //Mapping of urls for wms 1.1.1 which should be exchanged
- $urlsToChange = array(
- '/WMT_MS_Capabilities/Capability/Request/GetCapabilities/DCPType/HTTP/Get/OnlineResource/@xlink:href',
- '/WMT_MS_Capabilities/Capability/Request/GetCapabilities/DCPType/HTTP/Post/OnlineResource/@xlink:href',
- '/WMT_MS_Capabilities/Capability/Request/GetMap/DCPType/HTTP/Get/OnlineResource/@xlink:href',
- '/WMT_MS_Capabilities/Capability/Request/GetMap/DCPType/HTTP/Post/OnlineResource/@xlink:href',
- '/WMT_MS_Capabilities/Capability/Request/GetFeatureInfo/DCPType/HTTP/Get/OnlineResource/@xlink:href',
- '/WMT_MS_Capabilities/Capability/Request/GetFeatureInfo/DCPType/HTTP/Post/OnlineResource/@xlink:href',
- '/WMT_MS_Capabilities/Capability/Layer/Layer/Style/LegendURL/OnlineResource/@xlink:href'
- );
- foreach($urlsToChange as $xpath) {
- $href = $capFromFascadeXmlObject->xpath($xpath);
- $e = new mb_notice("old href: ".$href[0]);
- $e = new mb_notice("href replaced: ".replaceOwsUrls($href[0], $layerId));
- $href[0][0] = replaceOwsUrls($href[0], $layerId);
- }
- echo $capFromFascadeXmlObject->asXML();
+ $capFromFascadeXmlObject->registerXPathNamespace("xlink", "http://www.w3.org/1999/xlink");
+ //Mapping of urls for wms 1.1.1 which should be exchanged
+ $urlsToChange = array(
+ '/WMT_MS_Capabilities/Capability/Request/GetCapabilities/DCPType/HTTP/Get/OnlineResource/@xlink:href',
+ '/WMT_MS_Capabilities/Capability/Request/GetCapabilities/DCPType/HTTP/Post/OnlineResource/@xlink:href',
+ '/WMT_MS_Capabilities/Capability/Request/GetMap/DCPType/HTTP/Get/OnlineResource/@xlink:href',
+ '/WMT_MS_Capabilities/Capability/Request/GetMap/DCPType/HTTP/Post/OnlineResource/@xlink:href',
+ '/WMT_MS_Capabilities/Capability/Request/GetFeatureInfo/DCPType/HTTP/Get/OnlineResource/@xlink:href',
+ '/WMT_MS_Capabilities/Capability/Request/GetFeatureInfo/DCPType/HTTP/Post/OnlineResource/@xlink:href',
+ '/WMT_MS_Capabilities/Capability/Layer/Layer/Style/LegendURL/OnlineResource/@xlink:href'
+ );
+ foreach ($urlsToChange as $xpath) {
+ $href = $capFromFascadeXmlObject->xpath($xpath);
+ $e = new mb_notice("old href: " . $href[0]);
+ $e = new mb_notice("href replaced: " . replaceOwsUrls($href[0], $layerId));
+ $href[0][0] = replaceOwsUrls($href[0], $layerId);
+ }
+ echo $capFromFascadeXmlObject->asXML();
}
-function replaceOwsUrls($owsUrl, $layerId) {
- $new = "http_auth/". $layerId."?";
- $pattern = "#owsproxy/[a-z0-9]{32}\/[a-z0-9]{32}\?#m";
- $httpAuthUrl = preg_replace($pattern,$new,$owsUrl);
- //replace
- //also replace the getcapabilities url with authenticated one ;-)
- if (defined("MAPBENDER_PATH") && MAPBENDER_PATH != '') {
- $wmsUrl = parse_url(MAPBENDER_PATH);
- $path = $wmsUrl['path'];
- $pattern = "#".$path."/php/wms.php\?layer_id=".$layerId."&#m";
- } else {
- $pattern = "#mapbender/php/wms.php\?layer_id=".$layerId."&#m";
- }
- $httpAuthUrl = preg_replace($pattern,"/".$new,$httpAuthUrl);
- //use always https for url
- if (defined("HTTP_AUTH_PROXY") && HTTP_AUTH_PROXY != '') {
- $parsed_url = parse_url(HTTP_AUTH_PROXY);
- if ($parsed_url['scheme'] == "https") {
- $httpAuthUrl = preg_replace("#http:#","https:",$httpAuthUrl);
- $httpAuthUrl = preg_replace("#:80/#",":443/",$httpAuthUrl);
- }
- }
- return $httpAuthUrl;
+function replaceOwsUrls($owsUrl, $layerId)
+{
+ $new = "http_auth/" . $layerId . "?";
+ $pattern = "#owsproxy/[a-z0-9]{32}\/[a-z0-9]{32}\?#m";
+ $httpAuthUrl = preg_replace($pattern, $new, $owsUrl);
+ //replace
+ //also replace the getcapabilities url with authenticated one ;-)
+ if (defined("MAPBENDER_PATH") && MAPBENDER_PATH != '') {
+ $wmsUrl = parse_url(MAPBENDER_PATH);
+ $path = $wmsUrl['path'];
+ $pattern = "#" . $path . "/php/wms.php\?layer_id=" . $layerId . "&#m";
+ } else {
+ $pattern = "#mapbender/php/wms.php\?layer_id=" . $layerId . "&#m";
+ }
+ $httpAuthUrl = preg_replace($pattern, "/" . $new, $httpAuthUrl);
+ //use always https for url
+ if (defined("HTTP_AUTH_PROXY") && HTTP_AUTH_PROXY != '') {
+ $parsed_url = parse_url(HTTP_AUTH_PROXY);
+ if ($parsed_url['scheme'] == "https") {
+ $httpAuthUrl = preg_replace("#http:#", "https:", $httpAuthUrl);
+ $httpAuthUrl = preg_replace("#:80/#", ":443/", $httpAuthUrl);
+ }
+ }
+ return $httpAuthUrl;
}
/**
@@ -490,120 +511,130 @@
* @param string owsproxy md5
* @return string url to legend graphic
*/
-function getLegendUrl($wmsId){
- global $reqParams;
- //get wms_getlegendurl
- $sql = "SELECT wms_getlegendurl FROM wms WHERE wms_id = $1";
- $v = array($wmsId);
- $t = array("i");
- $res = db_prep_query($sql, $v, $t);
- if($row = db_fetch_array($res)) {
- $getLegendUrl = $row["wms_getlegendurl"];
- } else {
- throwE(array("No wms data available."));
- die();
- }
- //get the url
- $sql = "SELECT layer_style.legendurl ";
- $sql .= "FROM layer_style JOIN layer ";
- $sql .= "ON layer_style.fkey_layer_id = layer.layer_id ";
- $sql .= "WHERE layer.layer_name = $2 AND layer.fkey_wms_id = $1 ";
- $sql .= "AND layer_style.name = $3 AND layer_style.legendurlformat = $4";
- if ($reqParams['style'] == ''){
- $style = 'default';
- } else {
- $style = $reqParams['style'];
- }
-
- $v = array($wmsId, $reqParams['layer'], $style, $reqParams['format']);
- $t = array("i", "s", "s", "s");
- $res = db_prep_query($sql, $v, $t);
- if($row = db_fetch_array($res)) {
- if (strpos($row["legendurl"],'http') !== 0) {
- $e = new mb_notice("combine legendurls!");
- return $getLegendUrl.$row["legendurl"];
- }
- return $row["legendurl"];
- } else {
- throwE(array("No legendurl available."));
- die();
- }
+function getLegendUrl($wmsId)
+{
+ global $reqParams;
+ //get wms_getlegendurl
+ $sql = "SELECT wms_getlegendurl FROM wms WHERE wms_id = $1";
+ $v = array($wmsId);
+ $t = array("i");
+ $res = db_prep_query($sql, $v, $t);
+ if ($row = db_fetch_array($res)) {
+ $getLegendUrl = $row["wms_getlegendurl"];
+ } else {
+ throwE(array("No wms data available."));
+ die();
+ }
+ //get the url
+ $sql = "SELECT layer_style.legendurl ";
+ $sql .= "FROM layer_style JOIN layer ";
+ $sql .= "ON layer_style.fkey_layer_id = layer.layer_id ";
+ $sql .= "WHERE layer.layer_name = $2 AND layer.fkey_wms_id = $1 ";
+ $sql .= "AND layer_style.name = $3 AND layer_style.legendurlformat = $4";
+ if ($reqParams['style'] == '') {
+ $style = 'default';
+ } else {
+ $style = $reqParams['style'];
+ }
+
+ $v = array($wmsId, $reqParams['layer'], $style, $reqParams['format']);
+ $t = array("i", "s", "s", "s");
+ $res = db_prep_query($sql, $v, $t);
+ if ($row = db_fetch_array($res)) {
+ if (strpos($row["legendurl"], 'http') !== 0) {
+ $e = new mb_notice("combine legendurls!");
+ return $getLegendUrl . $row["legendurl"];
+ }
+ return $row["legendurl"];
+ } else {
+ throwE(array("No legendurl available."));
+ die();
+ }
}
+
/**
* validated access permission on requested wms
*
* @param wmsId integer, userId - integer
* @return array array with detailed information about requested wms
*/
-function checkWmsPermission($wmsId,$userId){
- global $con, $n;
- $myguis = $n->getGuisByPermission($userId,true);
- $mywms = $n->getWmsByOwnGuis($myguis);
+function checkWmsPermission($wmsId, $userId)
+{
+ global $con, $n;
+ $myguis = $n->getGuisByPermission($userId, true);
+ $mywms = $n->getWmsByOwnGuis($myguis);
- $sql = "SELECT * FROM wms WHERE wms_id = $1";
- $v = array($wmsId);
- $t = array("s");
- $res = db_prep_query($sql, $v, $t);
- $service = array();
- if($row = db_fetch_array($res)){
- $service["wms_id"] = $row["wms_id"];
- $service["wms_getcapabilities"] = $row["wms_getcapabilities"];
- $service["wms_getmap"] = $row["wms_getmap"];
- $service["wms_getfeatureinfo"] = $row["wms_getfeatureinfo"];
- $service["wms_getcapabilities_doc"] = $row["wms_getcapabilities_doc"];
- }
- if(!$row || count($mywms) == 0){
- throwE(array("No wms data available."));
- die();
- }
-
- if(!in_array($service["wms_id"], $mywms)){
- throwE(array("Permission denied."," -> ".$service["wms_id"], implode(",", $mywms)));
- die();
- }
- return $service;
+ $sql = "SELECT * FROM wms WHERE wms_id = $1";
+ $v = array($wmsId);
+ $t = array("s");
+ $res = db_prep_query($sql, $v, $t);
+ $service = array();
+ if ($row = db_fetch_array($res)) {
+ $service["wms_id"] = $row["wms_id"];
+ $service["wms_getcapabilities"] = $row["wms_getcapabilities"];
+ $service["wms_getmap"] = $row["wms_getmap"];
+ $service["wms_getfeatureinfo"] = $row["wms_getfeatureinfo"];
+ $service["wms_getcapabilities_doc"] = $row["wms_getcapabilities_doc"];
+// $service["wms_spatialsec"] = $row["wms_spatialsec"];
+ }
+ if (!$row || count($mywms) == 0) {
+ throwE(array("No wms data available."));
+ die();
+ }
+
+ if (!in_array($service["wms_id"], $mywms)) {
+ throwE(array("Permission denied.", " -> " . $service["wms_id"], implode(",", $mywms)));
+ die();
+ }
+ return $service;
}
-function checkLayerPermission($wms_id,$l,$userId){
- global $n, $owsproxyService;
- $e = new mb_notice("owsproxy: checkLayerpermission: wms: ".$wms_id.", layer: ".$l.' user_id: '.$userId);
- $myl = split(",",$l);
- $r = array();
- foreach($myl as $mysl){
- if($n->getLayerPermission($wms_id, $mysl, $userId) === true){
- array_push($r, $mysl);
- }
- }
- $ret = implode(",",$r);
- return $ret;
+function checkLayerPermission($wms_id, $l, $userId)
+{
+ global $n, $owsproxyService;
+ $e = new mb_notice("owsproxy: checkLayerpermission: wms: " . $wms_id . ", layer: " . $l . ' user_id: ' . $userId);
+ $myl = explode(",", $l);
+ $r = array();
+ foreach ($myl as $mysl) {
+ if ($n->getLayerPermission($wms_id, $mysl, $userId) === true) {
+ array_push($r, $mysl);
+ }
+ }
+ $ret = implode(",", $r);
+ return $ret;
}
-function getDocumentContent($url){
- if (func_num_args() == 2) { //new for HTTP Authentication
- $auth = func_get_arg(1);
- $d = new connector($url, $auth);
- }
- else {
- $d = new connector($url);
- }
- return $d->file;
+
+function getDocumentContent($url)
+{
+ if (func_num_args() == 2) { //new for HTTP Authentication
+ $auth = func_get_arg(1);
+ $d = new connector($url, $auth);
+ } else {
+ $d = new connector($url);
+ }
+ return $d->file;
}
+
//**********************************************************************************************
//extra functions TODO: push them in class_administration.php
/**
- * selects the wms id for a given layer id.
- *
- * @param <integer> the layer id
- * @return <string|boolean> either the id of the wms as integer or false when none exists
- */
- function getWmsIdByLayerId($id){
- $sql = "SELECT fkey_wms_id FROM layer WHERE layer_id = $1";
- $v = array($id);
- $t = array('i');
- $res = db_prep_query($sql,$v,$t);
- $row = db_fetch_array($res);
- if ($row) return $row["fkey_wms_id"]; else return false;
- }
+ * selects the wms id for a given layer id.
+ *
+ * @param <integer> the layer id
+ * @return <string|boolean> either the id of the wms as integer or false when none exists
+ */
+function getWmsIdByLayerId($id)
+{
+ $sql = "SELECT fkey_wms_id FROM layer WHERE layer_id = $1";
+ $v = array($id);
+ $t = array('i');
+ $res = db_prep_query($sql, $v, $t);
+ $row = db_fetch_array($res);
+ if ($row)
+ return $row["fkey_wms_id"];
+ else
+ return false;
+}
-
?>
Modified: trunk/mapbender/owsproxy/http/index.php
===================================================================
--- trunk/mapbender/owsproxy/http/index.php 2014-02-28 11:51:21 UTC (rev 8785)
+++ trunk/mapbender/owsproxy/http/index.php 2014-02-28 12:57:18 UTC (rev 8786)
@@ -1,4 +1,5 @@
<?php
+
# $Id$
# http://www.mapbender.org/index.php/Owsproxy
# Module maintainer Uli
@@ -17,335 +18,372 @@
# 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(dirname(__FILE__)."/../../core/globalSettings.php");
+
+require(dirname(__FILE__) . "/../../conf/mapbender.conf");
require_once(dirname(__FILE__) . "/../../http/classes/class_administration.php");
require_once(dirname(__FILE__) . "/../../http/classes/class_connector.php");
+require_once(dirname(__FILE__) . "/../../http/classes/class_mb_exception.php");
require_once(dirname(__FILE__) . "/./classes/class_QueryHandler.php");
-/***** conf *****/
-$imageformats = array("image/png","image/gif","image/jpeg", "image/jpg");
+/* * *** conf **** */
+$imageformats = array("image/png", "image/gif", "image/jpeg", "image/jpg");
$width = 400;
$height = 400;
-/***** conf *****/
+/* * *** conf **** */
+
+$con = db_connect(DBSERVER, OWNER, PW);
+db_select_db(DB, $con);
+
$postdata = $HTTP_RAW_POST_DATA;
$owsproxyService = $_REQUEST['wms']; //ToDo: change this to 'service' in the apache url-rewriting
$query = new QueryHandler();
// an array with keys and values toLowerCase -> caseinsensitiv
$reqParams = $query->getRequestParams();
-$e = new mb_notice("incoming request: ".OWSPROXY."/".$_REQUEST['sid']."/".$_REQUEST['wms'].$query->getRequest());
-$e = new mb_notice("owsproxy requested from: ".$_SERVER["REMOTE_ADDR"]);
+$e = new mb_notice("incoming request: " . OWSPROXY . "/" . $_REQUEST['sid'] . "/" . $_REQUEST['wms'] . $query->getRequest());
+$e = new mb_notice("owsproxy requested from: " . $_SERVER["REMOTE_ADDR"]);
if (defined("OWSPROXY_SESSION_GRABBING_WHITELIST")) {
- $whiteListArray = explode(",", OWSPROXY_SESSION_GRABBING_WHITELIST);
- if (in_array($_SERVER["REMOTE_ADDR"], $whiteListArray)) {
- $grabbingAllowed = true;
- $e = new mb_notice("Grabbing allowed for IP: ".$_SERVER["REMOTE_ADDR"]);
- } else {
- $grabbingAllowed = false;
- $e = new mb_notice("Grabbing not allowed for IP: ".$_SERVER["REMOTE_ADDR"]."!");
- }
+ $whiteListArray = explode(",", OWSPROXY_SESSION_GRABBING_WHITELIST);
+ if (in_array($_SERVER["REMOTE_ADDR"], $whiteListArray)) {
+ $grabbingAllowed = true;
+ $e = new mb_notice("Grabbing allowed for IP: " . $_SERVER["REMOTE_ADDR"]);
+ } else {
+ $grabbingAllowed = false;
+ $e = new mb_notice("Grabbing not allowed for IP: " . $_SERVER["REMOTE_ADDR"] . "!");
+ }
} else {
- $grabbingAllowed = false;
+ $grabbingAllowed = false;
}
-$e = new mb_notice("Initial session_id: ".session_id());
+$e = new mb_notice("Initial session_id: " . session_id());
//The session can be set by a given cookie value or was newly created by core/globalSettings.php
//either empty (without mb_user_id value) - when the corresponding session file was lost or timed out
//or filled, when there was an actual mapbender session before
-//
//check if mb_user_id is given and is an string with an integer:
-$e = new mb_notice("userFromSession: ".getUserFromSession());
+$e = new mb_notice("userFromSession: " . getUserFromSession());
-//Possibility to grab an existing session:
+//Possibility to grap an existing session:
if (defined("OWSPROXY_ALLOW_SESSION_GRABBING") && OWSPROXY_ALLOW_SESSION_GRABBING == true) {
- if ($grabbingAllowed) { //for this ip
- $currentSession = session_id();
- //check for existing session in session storage - maybe the request came from outside - e.g. other browser, other application
- $existSession = Mapbender::session()->storageExists($_REQUEST["sid"]);
- if ($existSession) {
- $e = new mb_notice("storage exists");
- } else {
- $e = new mb_notice("storage does not exist!");
- }
- if ($existSession && $currentSession !== $_REQUEST["sid"]) {
- //there is a current session for the requested url
- $e = new mb_notice("A current session exists for this url and will be used!");
- //$oldsessionId = session_id();
- $tmpSession = session_id();
- //do the following only, if a user is in this session - maybe it is a session which was generated from an external application and therefor it is empty!
- //grab session, cause it is allowed
- session_id($_REQUEST["sid"]);
- $e = new mb_notice("Grabbed session with id: ".session_id());
- //kill dynamical session
- //@unlink($tmpSessionFile);
- $e = new mb_notice("Following user was found and will be used for authorization: ".Mapbender::session()->get('mb_user_id'));
- //$foundUserId = Mapbender::session()->get('mb_user_id');
- if (getUserFromSession() == false || getUserFromSession() <= 0) {
- $e = new mb_notice("No user found in the existing session - switch to the initial old one!");
- session_id($tmpSession);
- } else {
- //delete session as it will not be needed any longer
- $e = new mb_notice("Some reasonable user id found in grabbed session. Following temporary session will be deleted: ".$tmpSession);
- Mapbender::session()->storageDestroy($tmpSession);
- unset($tmpSession);
- }
- } else {
- $e = new mb_notice("Maybe either a session does not exist for the requested SID and/or the current session is equal to the requested SID. No grabbing should be done! The variable tmpSession will not be created.");
- }
- }
+ if ($grabbingAllowed) { //for this ip
+ $currentSession = session_id();
+ //check for existing session in session storage - maybe the request came from outside - e.g. other browser, other application
+ $existSession = Mapbender::session()->storageExists($_REQUEST["sid"]);
+ if ($existSession) {
+ $e = new mb_notice("storage exists");
+ } else {
+ $e = new mb_notice("storage does not exist!");
+ }
+ if ($existSession && $currentSession !== $_REQUEST["sid"]) {
+ //there is a current session for the requested url
+ $e = new mb_notice("A current session exists for this url and will be used!");
+ //$oldsessionId = session_id();
+ $tmpSession = session_id();
+ //do the following only, if a user is in this session - maybe it is a session which was generated from an external application and therefor it is empty!
+ //grab session, cause it is allowed
+ session_id($_REQUEST["sid"]);
+ $e = new mb_notice("Grabbed session with id: " . session_id());
+ //kill dynamical session
+ //@unlink($tmpSessionFile);
+ $e = new mb_notice("Following user was found and will be used for authorization: " . Mapbender::session()->get('mb_user_id'));
+ //$foundUserId = Mapbender::session()->get('mb_user_id');
+ if (getUserFromSession() == false || getUserFromSession() <= 0) {
+ $e = new mb_notice("No user found in the existing session - switch to the initial old one!");
+ session_id($tmpSession);
+ } else {
+ //delete session as it will not be needed any longer
+ $e = new mb_notice("Some reasonable user id found in grabbed session. Following temporary session will be deleted: " . $tmpSession);
+ Mapbender::session()->storageDestroy($tmpSession);
+ unset($tmpSession);
+ }
+ } else {
+ $e = new mb_notice("Maybe either a session does not exist for the requested SID and/or the current session is equal to the requested SID. No grabbing should be done! The variable tmpSession will not be created.");
+ }
+ }
}
+
//After this there maybe the variable $tmpSession or not. If it is not there, an existing session was grabbed and shouldn't be deleted after, because a user is logged in or the logged in user requested the service!!!
-
//check if current session has the same id as the session which is requested in the owsproxy url
//exchange them, if they differ and redirect to an new one with the current session, they don't differ if the session was grabbed - e.g. when printing secured services via mapbender itself.
if (session_id() !== $_REQUEST["sid"]) {
- //get all request params which are original
- //build reuquest
- $redirectUrl = OWSPROXY."/".session_id()."/".$_REQUEST['wms'].$query->getRequest();
- $redirectUrl = str_replace(":80:80",":80",$redirectUrl);
- $e = new mb_notice("IDs differ - redirect to new owsproxy url: ".$redirectUrl);
- header("Location: ".$redirectUrl);
- die();
+ //get all request params which are original
+ //build reuquest
+ $redirectUrl = OWSPROXY . "/" . session_id() . "/" . $_REQUEST['wms'] . $query->getRequest();
+ $redirectUrl = str_replace(":80:80", ":80", $redirectUrl);
+ $e = new mb_notice("IDs differ - redirect to new owsproxy url: " . $redirectUrl);
+ header("Location: " . $redirectUrl);
+ die();
} else {
- $e = new mb_notice("Current session_id() identical to requested SID!");
+ $e = new mb_notice("Current session_id() identical to requested SID!");
}
//this is the request which may have been redirected
//check for given user session with user_id which can be tested against the authorization
-/*$foundUserId = Mapbender::session()->get('mb_user_id');
-$e = new mb_exception("Found user id: ".$foundUserId ." of type: ".gettype($foundUserId));
-$foundUserId = (integer)$_SESSION['mb_user_id'];
-$e = new mb_exception("Found user id: ".$foundUserId ." of type: ".gettype($foundUserId));
-$foundUserId = getUserFromSession();*/
+/* $foundUserId = Mapbender::session()->get('mb_user_id');
+ $e = new mb_exception("Found user id: ".$foundUserId ." of type: ".gettype($foundUserId));
+ $foundUserId = (integer)$_SESSION['mb_user_id'];
+ $e = new mb_exception("Found user id: ".$foundUserId ." of type: ".gettype($foundUserId));
+ $foundUserId = getUserFromSession(); */
-if(getUserFromSession() == false || getUserFromSession() <= 0){
- //Define the session to be temporary - it should be deleted afterwards, cause there is no user in it! This file can be deleted after the request was more or less successful. It will be generated every time again.
- $tmpSession = session_id();
- $e = new mb_notice(" session_id(): ".session_id());
- $e = new mb_notice("user_id not found in session!");
- //if configured in mapbender.conf, create guest session so that also proxied service can be watched in external applications when they are available to the anonymous user
- //only possible for webapplications - in case of desktop applications the user have to use his credentials and http_auth module
- if (defined("OWSPROXY_ALLOW_PUBLIC_USER") && OWSPROXY_ALLOW_PUBLIC_USER && defined("PUBLIC_USER") && PUBLIC_USER != "") {
- //setSession();
- Mapbender::session()->set("mb_user_id",PUBLIC_USER);
- Mapbender::session()->set("external_proxy_user",true);
- Mapbender::session()->set("mb_user_ip",$_SERVER['REMOTE_ADDR']);
- $e = new mb_notice("Permission allowed for public user with id: ".PUBLIC_USER);
- } else {
- $e = new mb_notice("Permission denied - public user not allowed to access ressource!");
- //kill actual session
- $e = new mb_notice("delete temporary session file: ".$tmpSession);
- Mapbender::session()->storageDestroy($tmpSession);
- throwE(array("Permission denied"," - no current session found and ","public user not allowed to access ressource!"));
- unset($tmpSession);
- die();
- }
+if (getUserFromSession() == false || getUserFromSession() <= 0) {
+ //Define the session to be temporary - it should be deleted afterwards, cause there is no user in it! This file can be deleted after the request was more or less successful. It will be generated every time again.
+ $tmpSession = session_id();
+ $e = new mb_notice(" session_id(): " . session_id());
+ $e = new mb_notice("user_id not found in session!");
+ //if configured in mapbender.conf, create guest session so that also proxied service can be watched in external applications when they are available to the anonymous user
+ //only possible for webapplications - in case of desktop applications the user have to use his credentials and http_auth module
+ if (defined("OWSPROXY_ALLOW_PUBLIC_USER") && OWSPROXY_ALLOW_PUBLIC_USER && defined("PUBLIC_USER") && PUBLIC_USER != "") {
+ //setSession();
+ Mapbender::session()->set("mb_user_id", PUBLIC_USER);
+ Mapbender::session()->set("external_proxy_user", true);
+ Mapbender::session()->set("mb_user_ip", $_SERVER['REMOTE_ADDR']);
+ $e = new mb_notice("Permission allowed for public user with id: " . PUBLIC_USER);
+ } else {
+ $e = new mb_notice("Permission denied - public user not allowed to access ressource!");
+ //kill actual session
+ $e = new mb_notice("delete temporary session file: " . $tmpSession);
+ Mapbender::session()->storageDestroy($tmpSession);
+ throwE(array("Permission denied", " - no current session found and ", "public user not allowed to access ressource!"));
+ unset($tmpSession);
+ die();
+ }
} else {
- /*$e = new mb_exception("mb_user_id found in session: ".getUserFromSession());
- if (isset($tmpSession)) {
- $e = new mb_exception("tmpSessionFile: exists! - It was set before grabbing!");
- } else {
- $e = new mb_exception("tmpSessionFile: does not exist!");
- }*/
+ /* $e = new mb_exception("mb_user_id found in session: ".getUserFromSession());
+ if (isset($tmpSession)) {
+ $e = new mb_exception("tmpSessionFile: exists! - It was set before grabbing!");
+ } else {
+ $e = new mb_exception("tmpSessionFile: does not exist!");
+ } */
}
//start the session to be able to write urls to it - for
-session_start();//maybe it was started by globalSettings.php
+session_start(); //maybe it was started by globalSettings.php
$n = new administration;
//Extra security - IP check
if (defined("OWSPROXY_BIND_IP") && OWSPROXY_BIND_IP == true) {
- if(Mapbender::session()->get('mb_user_ip') != $_SERVER['REMOTE_ADDR']){
- throwE(array("Session not identified.","Permission denied.","Please authenticate."));
- die();
- }
+ if (Mapbender::session()->get('mb_user_ip') != $_SERVER['REMOTE_ADDR']) {
+ throwE(array("Session not identified.", "Permission denied.", "Please authenticate."));
+ die();
+ }
}
-$e = new mb_notice("user id for authorization test: ".getUserFromSession());
+$e = new mb_notice("user id for authorization test: " . getUserFromSession());
$wmsId = $n->getWmsIdFromOwsproxyString($query->getOwsproxyServiceId());
//get authentication infos if they are available in wms table! if not $auth = false
$auth = $n->getAuthInfoOfWMS($wmsId);
-if ($auth['auth_type']==''){
- unset($auth);
+if ($auth['auth_type'] == '') {
+ unset($auth);
}
-/************* workflow ************/
+/* * *********** workflow *********** */
$n = new administration();
+
+if (count($_REQUEST) > 0) {
+ foreach ($_REQUEST as $key => $value) {
+ if (strtoupper($key) === "SERVICE")
+ $found = true;
+ }
+ if (!$found)
+ $query->setParam("service", "WMS");
+}
switch (strtolower($reqParams['request'])) {
- case 'getcapabilities':
- $arrayOnlineresources = checkWmsPermission($query->getOwsproxyServiceId());
- $query->setOnlineResource($arrayOnlineresources['wms_getcapabilities']);
- $request = $query->getRequest();
- if(isset($auth)){
- getCapabilities($request,$auth);
- }
- else {
- getCapabilities($request);
- }
- break;
- case 'getfeatureinfo':
- $arrayOnlineresources = checkWmsPermission($query->getOwsproxyServiceId());
- $query->setOnlineResource($arrayOnlineresources['wms_getfeatureinfo']);
- $request = $query->getRequest();
- if(isset($auth)){
- getFeatureInfo($request,$auth);
- }
- else {
- getFeatureInfo($request);
- }
- break;
- case 'getmap':
- $arrayOnlineresources = checkWmsPermission($owsproxyService);
- $query->setOnlineResource($arrayOnlineresources['wms_getmap']);
- $layers = checkLayerPermission($arrayOnlineresources['wms_id'],$reqParams['layers']);
- if($layers===""){
- throwE("Permission denied");
- die();
- }
- $query->setParam("layers",urldecode($layers));//the decoding of layernames dont make problems - but not really good names will be requested also ;-)
- //Following is only needed for high quality print and is vendor specific for mapservers mapfiles!
- if (defined("OWSPROXY_SUPPORT_HQ_PRINTING") && OWSPROXY_SUPPORT_HQ_PRINTING) {
- //if url has integrated mapfile - exchange it
- //$e = new mb_notice("owsproxy/http/index.php: OWSPROXY_SUPPORT_HQ_PRINTING is set");
- if ($reqParams['mapbenderhighqualityprint'] === "true") {
- //exchange mapfiles with high quality ones
- $request = preg_replace("/\.map/","_4.map",$query->getRequest());
- } else {
- $request = $query->getRequest();
- }
- } else {
- $request = $query->getRequest();
- }
- //log proxy requests
- if($n->getWmsLogTag($arrayOnlineresources['wms_id'])==1) {
- #do log to db
- #TODO read out size of bbox and calculate price
- #get price out of db
- $price=intval($n->getWmsPrice($arrayOnlineresources['wms_id']));
- $n->logWmsProxyRequest($arrayOnlineresources['wms_id'],$_SESSION['mb_user_id'],$request,$price);
- }
- //$e = new mb_notice("owsproxy/http/index.php: ".$request);
- if(isset($auth)){
- getImage($request,$auth);
- }
- else {
- getImage($request);
- }
- break;
- case 'map':
- $arrayOnlineresources = checkWmsPermission($owsproxyService);
- $query->setOnlineResource($arrayOnlineresources['wms_getmap']);
- $layers = checkLayerPermission($arrayOnlineresources['wms_id'],$reqParams['layers']);
- if($layers===""){
- throwE("Permission denied");
- die();
- }
- $query->setParam("layers",urldecode($layers));
- $request = $query->getRequest();
- if(isset($auth)){
- getImage($url,$auth);
- }
- else {
- getImage($url);
- }
- break;
- case 'getlegendgraphic':
- $url = getLegendUrl($query->getOwsproxyServiceId());
- if (isset ($reqParams['sld']) && $reqParams['sld'] != "") {
- $url = $url . getConjunctionCharacter($url) . "SLD=".$reqParams['sld'];
- }
- if(isset($auth)){
- getImage($url,$auth);
- }
- else {
- getImage($url);
- }
- break;
- case 'external':
- getExternalRequest($query->getOwsproxyServiceId());
- break;
- case 'getfeature':
- $arrayFeatures = array($reqParams['typename']);
- $arrayOnlineresources = checkWfsPermission($query->getOwsproxyServiceId(), $arrayFeatures);
- $query->setOnlineResource($arrayOnlineresources['wfs_getfeature']);
- $request = $query->getRequest();
- $request = stripslashes($request);
- getFeature($request);
- break;
- // case wfs transaction (because of raw POST the request param is empty)
- case '':
- $arrayFeatures = getWfsFeaturesFromTransaction($HTTP_RAW_POST_DATA);
- $arrayOnlineresources = checkWfsPermission($query->getOwsproxyServiceId(), $arrayFeatures);
- $query->setOnlineResource($arrayOnlineresources['wfs_transaction']);
- $request = $query->getRequest();
- doTransaction($request, $HTTP_RAW_POST_DATA);
- break;
- default:
-
+ case 'getcapabilities':
+ $arrayOnlineresources = checkWmsPermission($query->getOwsproxyServiceId());
+ $query->setOnlineResource($arrayOnlineresources['wms_getcapabilities']);
+ $request = $query->getRequest();
+ if (isset($auth)) {
+ getCapabilities($request, $auth);
+ } else {
+ getCapabilities($request);
+ }
+ break;
+ case 'getfeatureinfo':
+ $arrayOnlineresources = checkWmsPermission($query->getOwsproxyServiceId());
+ $query->setOnlineResource($arrayOnlineresources['wms_getfeatureinfo']);
+ $request = $query->getRequest();
+ //Ergaenzungen secured UMN Requests
+ $log_id = false;
+ if ($n->getWmsfiLogTag($arrayOnlineresources['wms_id']) == 1) {
+ #do log to db
+ #get price out of db
+ $price = intval($n->getWmsfiPrice($arrayOnlineresources['wms_id']));
+ $log_id = $n->logWmsGFIProxyRequest($arrayOnlineresources['wms_id'], $_SESSION['mb_user_id'], $request,
+ $price);
+ }
+ if (isset($auth)) {
+ getFeatureInfo($log_id, $request, $auth);
+ } else {
+ getFeatureInfo($log_id, $request);
+ }
+ break;
+ case 'getmap':
+ $arrayOnlineresources = checkWmsPermission($owsproxyService);
+ $query->setOnlineResource($arrayOnlineresources['wms_getmap']);
+ $layers = checkLayerPermission($arrayOnlineresources['wms_id'], $reqParams['layers']);
+ if ($layers === "") {
+ throwE("Permission denied");
+ die();
+ }
+ $query->setParam("layers", urldecode($layers)); //the decoding of layernames dont make problems - but not really good names will be requested also ;-)
+ //Following is only needed for high quality print and is vendor specific for mapservers mapfiles!
+ if (defined("OWSPROXY_SUPPORT_HQ_PRINTING") && OWSPROXY_SUPPORT_HQ_PRINTING) {
+ //if url has integrated mapfile - exchange it
+ //$e = new mb_notice("owsproxy/http/index.php: OWSPROXY_SUPPORT_HQ_PRINTING is set");
+ if ($reqParams['mapbenderhighqualityprint'] === "true") {
+ //exchange mapfiles with high quality ones
+ $request = preg_replace("/\.map/", "_4.map", $query->getRequest());
+ } else {
+ $request = $query->getRequest();
+ }
+ } else {
+ $request = $query->getRequest();
+ }
+ //$request = $query->getRequest();
+ // Ergaenzungen secured UMN Requests
+ #log proxy requests
+ if ($n->getWmsLogTag($arrayOnlineresources['wms_id']) == 1) {#do log to db
+ #get price out of db
+ $price = intval($n->getWmsPrice($arrayOnlineresources['wms_id']));
+ $log_id = $n->logFullWmsProxyRequest($arrayOnlineresources['wms_id'], $_SESSION['mb_user_id'], $request,
+ $price);
+ }
+ if (isset($auth)) {
+ #$mb_exception = new mb_exception("auth: ".$auth['auth_type']);
+ getImage($log_id, $request, $auth);
+ } else {
+ getImage($log_id, $request);
+ }
+ break;
+ case 'map':
+ $arrayOnlineresources = checkWmsPermission($owsproxyService);
+ $query->setOnlineResource($arrayOnlineresources['wms_getmap']);
+ $layers = checkLayerPermission($arrayOnlineresources['wms_id'], $reqParams['layers']);
+ if ($layers === "") {
+ throwE("Permission denied");
+ die();
+ }
+ $query->setParam("layers", urldecode($layers));
+ $request = $query->getRequest();
+ if (isset($auth)) {
+ getImage(false, $url, $auth);
+ } else {
+ getImage(false, $url);
+ }
+ break;
+ case 'getlegendgraphic':
+ $url = getLegendUrl($query->getOwsproxyServiceId());
+ if (isset($reqParams['sld']) && $reqParams['sld'] != "") {
+ $url = $url . getConjunctionCharacter($url) . "SLD=" . $reqParams['sld'];
+ }
+ if (isset($auth)) {
+ getImage(false, $url, $auth);
+ } else {
+ getImage(false, $url);
+ }
+ break;
+ case 'external':
+ getExternalRequest($query->getOwsproxyServiceId());
+ break;
+ case 'getfeature':
+ $arrayFeatures = array($reqParams['typename']);
+ $arrayOnlineresources = checkWfsPermission($query->getOwsproxyServiceId(), $arrayFeatures);
+ $query->setOnlineResource($arrayOnlineresources['wfs_getfeature']);
+ $request = $query->getRequest();
+ $request = stripslashes($request);
+ getFeature($request);
+ break;
+ // case wfs transaction (because of raw POST the request param is empty)
+ case '':
+ $arrayFeatures = getWfsFeaturesFromTransaction($HTTP_RAW_POST_DATA);
+ $arrayOnlineresources = checkWfsPermission($query->getOwsproxyServiceId(), $arrayFeatures);
+ $query->setOnlineResource($arrayOnlineresources['wfs_transaction']);
+ $request = $query->getRequest();
+ doTransaction($request, $HTTP_RAW_POST_DATA);
+ break;
+ default:
}
//why delete session here - only if it was temporary?
if (isset($tmpSession) && Mapbender::session()->storageExists($tmpSession)) {
- $e = new mb_notice("Following temporary session will be deleted: ".$tmpSession);
- Mapbender::session()->storageDestroy($tmpSession);
+ $e = new mb_notice("Following temporary session will be deleted: " . $tmpSession);
+ Mapbender::session()->storageDestroy($tmpSession);
}
-/*********************************************************/
-function throwE($e){
- global $reqParams, $imageformats;
- if(in_array($reqParams['format'],$imageformats)){
- throwImage($e);
- }
- else{
- throwText($e);
- }
+/* * ****************************************************** */
+
+function throwE($e)
+{
+ global $reqParams, $imageformats;
+ if (in_array($reqParams['format'], $imageformats)) {
+ throwImage($e);
+ } else {
+ throwText($e);
+ }
}
-function throwImage($e){
- global $width,$height;
- $image = imagecreate($width,$height);
- $transparent = ImageColorAllocate($image,155,155,155);
- ImageFilledRectangle($image,0,0,$width,$height,$transparent);
- imagecolortransparent($image, $transparent);
- $text_color = ImageColorAllocate ($image, 233, 14, 91);
- if (count($e) > 1){
- for($i=0; $i<count($e); $i++){
- $imageString = $e[$i];
- ImageString ($image, 3, 5, $i*20, $imageString, $text_color);
- }
- } else {
- if (is_array($e)) {
- $imageString = $e[0];
- } else {
- $imageString = $e;
- }
- if ($imageString == "") {
- $imageString = "An unknown error occured!";
- }
- ImageString ($image, 3, 5, $i*20, $imageString, $text_color);
- }
- responseImage($image);
+function throwImage($e)
+{
+ global $width, $height;
+ $image = imagecreate($width, $height);
+ $transparent = ImageColorAllocate($image, 155, 155, 155);
+ ImageFilledRectangle($image, 0, 0, $width, $height, $transparent);
+ imagecolortransparent($image, $transparent);
+ $text_color = ImageColorAllocate($image, 233, 14, 91);
+ if (count($e) > 1) {
+ for ($i = 0; $i < count($e); $i++) {
+ $imageString = $e[$i];
+ ImageString($image, 3, 5, $i * 20, $imageString, $text_color);
+ }
+ } else {
+ if (is_array($e)) {
+ $imageString = $e[0];
+ } else {
+ $imageString = $e;
+ }
+ if ($imageString == "") {
+ $imageString = "An unknown error occured!";
+ }
+ ImageString($image, 3, 5, $i * 20, $imageString, $text_color);
+ }
+ responseImage($image);
}
-function throwText($e){
- echo join(" ", $e);
+function throwText($e)
+{
+ echo join(" ", $e);
}
-function responseImage($im){
- global $reqParams;
- $format = $reqParams['format'];
- $format="image/gif";
- if($format == 'image/png'){header("Content-Type: image/png");}
- if($format == 'image/jpeg' || $format == 'image/jpg'){header("Content-Type: image/jpeg");}
- if($format == 'image/gif'){header("Content-Type: image/gif");}
-
- if($format == 'image/png'){imagepng($im);}
- if($format == 'image/jpeg' || $format == 'image/jpg'){imagejpeg($im);}
- if($format == 'image/gif'){imagegif($im);}
+function responseImage($im)
+{
+ global $reqParams;
+ $format = $reqParams['format'];
+ $format = "image/gif";
+ if ($format == 'image/png') {
+ header("Content-Type: image/png");
+ }
+ if ($format == 'image/jpeg' || $format == 'image/jpg') {
+ header("Content-Type: image/jpeg");
+ }
+ if ($format == 'image/gif') {
+ header("Content-Type: image/gif");
+ }
+
+ if ($format == 'image/png') {
+ imagepng($im);
+ }
+ if ($format == 'image/jpeg' || $format == 'image/jpg') {
+ imagejpeg($im);
+ }
+ if ($format == 'image/gif') {
+ imagegif($im);
+ }
}
-function completeURL($url){
- global $reqParams;
- $mykeys = array_keys($reqParams);
- for($i=0; $i<count($mykeys);$i++){
- if($i > 0){ $url .= "&"; }
- $url .= $mykeys[$i]."=".urlencode($reqParams[$mykeys[$i]]);
- }
- return $url;
+function completeURL($url)
+{
+ global $reqParams;
+ $mykeys = array_keys($reqParams);
+ for ($i = 0; $i < count($mykeys); $i++) {
+ if ($i > 0) {
+ $url .= "&";
+ }
+ $url .= $mykeys[$i] . "=" . urlencode($reqParams[$mykeys[$i]]);
+ }
+ return $url;
}
/**
@@ -353,24 +391,20 @@
*
* @param string the original url of the image to send
*/
-
-function getImage($or){
- global $reqParams;
- header("Content-Type: ".$reqParams['format']);
- #log the image_requests to database
- #log the following to table mb_proxy_log
- #timestamp,user_id,getmaprequest,amount pixel,price - but do this only for wms to log - therefor first get log tag out of wms!
+function getImage($log_id, $or)
+{
+ global $reqParams;
+ #log the image_requests to database
+ #log the following to table mb_proxy_log
+ #timestamp,user_id,getmaprequest,amount pixel,price - but do this only for wms to log - therefor first get log tag out of wms!
+ #
#
- #
- if (func_num_args() == 2) { //new for HTTP Authentication
- $auth = func_get_arg(1);
- echo getDocumentContent($or,$auth);
- }
- else
- {
- echo getDocumentContent($or);
- }
-
+ if (func_num_args() == 3) { //new for HTTP Authentication
+ $auth = func_get_arg(2);
+ getDocumentContent($log_id, $or, $auth);
+ } else {
+ getDocumentContent($log_id, $or);
+ }
}
/**
@@ -379,20 +413,15 @@
* @param string the url of the FeatureInfoRequest
* @return string the content of the FeatureInfo document
*/
-function getFeatureInfo($url){
- global $reqParams;
- //$e = new mb_notice("owsproxy: Try to fetch FeatureInfoRequest: ".$url);
- header("Content-Type: ".$reqParams['info_format']);
-
- if (func_num_args() == 2) { //new for HTTP Authentication
- $auth = func_get_arg(1);
- $content = getDocumentContent($url,$auth);
- }
- else {
- $content = getDocumentContent($url);
- }
- $content = matchUrls($content);
- echo $content;
+function getFeatureInfo($log_id, $url)
+{
+ global $reqParams;
+ if (func_num_args() == 3) { //new for HTTP Authentication
+ $auth = func_get_arg(2);
+ getDocumentContent($log_id, $url, $auth);
+ } else {
+ getDocumentContent($log_id, $url);
+ }
}
/**
@@ -401,12 +430,14 @@
* @param string the url of the GetFeature request
* @return echo the content of the GetFeature document
*/
-function getFeature($url){
- global $reqParams;
- header("Content-Type: ".$reqParams['info_format']);
- $content = getDocumentContent($url);
- $content = matchUrls($content);
- echo $content;
+function getFeature($url)
+{
+ global $reqParams;
+
+ header("Content-Type: " . $reqParams['info_format']);
+ $content = getDocumentContent(false, $url);
+ $content = matchUrls($content);
+ echo $content;
}
/**
@@ -419,19 +450,21 @@
* @param string data to send to host
* @return string hosts response
*/
-
-function sendToHost($host,$port,$method,$path,$data){
+function sendToHost($host, $port, $method, $path, $data)
+{
$buf = '';
- if (empty($method)) $method = 'POST';
+ if (empty($method))
+ $method = 'POST';
$method = mb_strtoupper($method);
$fp = fsockopen($host, $port);
fputs($fp, "$method $path HTTP/1.1\r\n");
fputs($fp, "Host: $host\r\n");
- fputs($fp,"Content-type: application/xml\r\n");
+ fputs($fp, "Content-type: application/xml\r\n");
fputs($fp, "Content-length: " . strlen($data) . "\r\n");
fputs($fp, "Connection: close\r\n\r\n");
- if ($method == 'POST') fputs($fp, $data);
- while (!feof($fp)) $buf .= fgets($fp,4096);
+ if ($method == 'POST')
+ fputs($fp, $data);
+ while (!feof($fp)) $buf .= fgets($fp, 4096);
fclose($fp);
return $buf;
}
@@ -442,51 +475,53 @@
* @param string XML that contains the tansaction request
* @return array array of touched feature names
*/
+function getWfsFeaturesFromTransaction($data)
+{
+ new mb_notice("owsproxy.getWfsFeaturesFromTransaction.data: " . $data);
+ if (!$data || $data == "") {
+ return false;
+ }
+ $features = array();
+ $values = NULL;
+ $tags = NULL;
+ $parser = xml_parser_create();
+ xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
+ xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
+ xml_parse_into_struct($parser, $data, $values, $tags);
-function getWfsFeaturesFromTransaction($data){
- new mb_notice("owsproxy.getWfsFeaturesFromTransaction.data: ".$data);
- if(!$data || $data == ""){
- return false;
- }
- $features = array();
- $values = NULL;
- $tags = NULL;
- $parser = xml_parser_create();
- xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
- xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,1);
- xml_parse_into_struct($parser,$data,$values,$tags);
- $code = xml_get_error_code ($parser);
- if ($code) {
- $line = xml_get_current_line_number($parser);
- $col = xml_get_current_column_number($parser);
- $mb_notice = new mb_notice("OWSPROXY invalid Tansaction XML: ".xml_error_string($code) . " in line " . $line. " at character ". $col);
- die();
- }
- xml_parser_free($parser);
- $insert = false;
- $insertlevel = 0;
- foreach ($values as $element) {
- //features touched by insert
- if(strtoupper($element[tag]) == "WFS:INSERT" && $element[type] == "open"){
- $insert = true;
- $insertlevel = $element[level];
- }
- if($insert && $element[level] == $insertlevel + 1 && $element[type] == "open"){
- array_push($features, $element[tag]);
- }
- if(strtoupper($element[tag]) == "WFS:INSERT" && $element[type] == "close"){
- $insert = false;
- }
- //updated features
- if(strtoupper($element[tag]) == "WFS:UPDATE" && $element[type] == "open"){
- array_push($features, $element[attributes]["typeName"]);
- }
- //deleted features
- if(strtoupper($element[tag]) == "WFS:DELETE" && $element[type] == "open"){
- array_push($features, $element[attributes]["typeName"]);
- }
- }
- return $features;
+ $code = xml_get_error_code($parser);
+ if ($code) {
+ $line = xml_get_current_line_number($parser);
+ $col = xml_get_current_column_number($parser);
+ $mb_notice = new mb_notice("OWSPROXY invalid Tansaction XML: " . xml_error_string($code) . " in line " . $line . " at character " . $col);
+ die();
+ }
+ xml_parser_free($parser);
+
+ $insert = false;
+ $insertlevel = 0;
+ foreach ($values as $element) {
+ //features touched by insert
+ if (strtoupper($element['tag']) == "WFS:INSERT" && $element['type'] == "open") {
+ $insert = true;
+ $insertlevel = $element[level];
+ }
+ if ($insert && $element[level] == $insertlevel + 1 && $element['type'] == "open") {
+ array_push($features, $element['tag']);
+ }
+ if (strtoupper($element['tag']) == "WFS:INSERT" && $element['type'] == "close") {
+ $insert = false;
+ }
+ //updated features
+ if (strtoupper($element['tag']) == "WFS:UPDATE" && $element['type'] == "open") {
+ array_push($features, $element['attributes']["typeName"]);
+ }
+ //deleted features
+ if (strtoupper($element['tag']) == "WFS:DELETE" && $element['type'] == "open") {
+ array_push($features, $element['attributes']["typeName"]);
+ }
+ }
+ return $features;
}
/**
@@ -495,116 +530,127 @@
* @param string url to send the WFS Transaction to
* @param string WFS Transaction data
*/
+function doTransaction($url, $data)
+{
+ $arURL = parse_url($url);
+ $host = $arURL["host"];
+ $port = $arURL["port"];
+ if ($port == '')
+ $port = 80;
-function doTransaction($url, $data){
- $arURL = parse_url($url);
- $host = $arURL["host"];
- $port = $arURL["port"];
- if($port == '') $port = 80;
- $path = $arURL["path"];
- $method = "POST";
- $result = sendToHost($host,$port,$method,html_entity_decode($path),$data);
- //delete header from result
- $result = mb_eregi_replace("^[^<]*", "", $result);
- $result = mb_eregi_replace("[^>]*$", "", $result);
-
- echo $result;
+ $path = $arURL["path"];
+ $method = "POST";
+ $result = sendToHost($host, $port, $method, html_entity_decode($path), $data);
+
+ //delete header from result
+ $result = mb_eregi_replace("^[^<]*", "", $result);
+ $result = mb_eregi_replace("[^>]*$", "", $result);
+
+ echo $result;
}
-function matchUrls($content){
- if(!isset($_SESSION["owsproxyUrls"])){
- $_SESSION["owsproxyUrls"] = array();
- $_SESSION["owsproxyUrls"]["id"] = array();
- $_SESSION["owsproxyUrls"]["url"] = array();
- }
- $pattern = "/[\"|\'](https*:\/\/[^\"|^\']*)[\"|\']/";
- preg_match_all($pattern,$content,$matches);
- for($i=0; $i<count($matches[1]); $i++){
- $req = $matches[1][$i];
- $notice = new mb_notice("owsproxy found URL ".$i.": ".$req);
- #$notice = new mb_notice("owsproxy id:".$req);
- $id = registerURL($req);
- $extReq = setExternalRequest($id);
- $notice = new mb_notice("MD5 URL ".$id." - external link: ".$extReq);
- $content = str_replace($req,$extReq,$content);
- }
- return $content;
+function matchUrls($content)
+{
+ if (!isset($_SESSION["owsproxyUrls"])) {
+ $_SESSION["owsproxyUrls"] = array();
+ $_SESSION["owsproxyUrls"]["id"] = array();
+ $_SESSION["owsproxyUrls"]["url"] = array();
+ }
+ $pattern = "/[\"|\'](https*:\/\/[^\"|^\']*)[\"|\']/";
+ preg_match_all($pattern, $content, $matches);
+ for ($i = 0; $i < count($matches[1]); $i++) {
+ $req = $matches[1][$i];
+ $notice = new mb_notice("owsproxy found URL " . $i . ": " . $req);
+ #$notice = new mb_exception("owsproxy id:".$req);
+ $id = registerURL($req);
+ $extReq = setExternalRequest($id);
+ $notice = new mb_notice("MD5 URL " . $id . " - external link: " . $extReq);
+ $content = str_replace($req, $extReq, $content);
+ }
+ return $content;
}
-function setExternalRequest($id){
- global $reqParams,$query;
+function setExternalRequest($id)
+{
+ global $reqParams, $query;
// $extReq = "http://".$_SESSION['HTTP_HOST'] ."/owsproxy/". $reqParams['sid'] ."/".$id."?request=external";
- $extReq = OWSPROXY ."/". $reqParams['sid'] ."/".$id."?request=external";
- return $extReq;
+ $extReq = OWSPROXY . "/" . $reqParams['sid'] . "/" . $id . "?request=external";
+ return $extReq;
}
-function getExternalRequest($id){
- for($i=0; $i<count($_SESSION["owsproxyUrls"]["url"]); $i++){
- if($id == $_SESSION["owsproxyUrls"]["id"][$i]){
- $cUrl = $_SESSION["owsproxyUrls"]["url"][$i];
- $query_string = removeOWSGetParams($_SERVER["QUERY_STRING"]);
- if($query_string != ''){
- $cUrl .= getConjunctionCharacter($cUrl).$query_string;
- }
- $metainfo = get_headers($cUrl,1);
- // just for the stupid InternetExplorer
- header('Pragma: private');
- header('Cache-control: private, must-revalidate');
-
- header("Content-Type: ".$metainfo['Content-Type']);
-
- $content = getDocumentContent($cUrl);
- #$content = matchUrls($content);
- echo $content;
- }
- }
+function getExternalRequest($id)
+{
+ for ($i = 0; $i < count($_SESSION["owsproxyUrls"]["url"]); $i++) {
+ if ($id == $_SESSION["owsproxyUrls"]["id"][$i]) {
+ $cUrl = $_SESSION["owsproxyUrls"]["url"][$i];
+ $query_string = removeOWSGetParams($_SERVER["QUERY_STRING"]);
+ if ($query_string != '') {
+ $cUrl .= getConjunctionCharacter($cUrl) . $query_string;
+ }
+ $metainfo = get_headers($cUrl, 1);
+ // just for the stupid InternetExplorer
+ header('Pragma: private');
+ header('Cache-control: private, must-revalidate');
+
+ header("Content-Type: " . $metainfo['Content-Type']);
+
+ $content = getDocumentContent(false, $cUrl);
+ #$content = matchUrls($content);
+ echo $content;
+ }
+ }
}
-function removeOWSGetParams($query_string){
- $r = preg_replace("/.*request=external&/","",$query_string);
- #return $r;
- return "";
+function removeOWSGetParams($query_string)
+{
+ $r = preg_replace("/.*request=external&/", "", $query_string);
+ #return $r;
+ return "";
}
-function getConjunctionCharacter($url){
- if(strpos($url,"?")){
- if(strpos($url,"?") == strlen($url)){
- $cchar = "";
- }else if(strpos($url,"&") == strlen($url)){
- $cchar = "";
- }else{
- $cchar = "&";
- }
- }
- if(strpos($url,"?") === false){
- $cchar = "?";
- }
- return $cchar;
+
+function getConjunctionCharacter($url)
+{
+ if (strpos($url, "?")) {
+ if (strpos($url, "?") == strlen($url)) {
+ $cchar = "";
+ } else if (strpos($url, "&") == strlen($url)) {
+ $cchar = "";
+ } else {
+ $cchar = "&";
+ }
+ }
+ if (strpos($url, "?") === false) {
+ $cchar = "?";
+ }
+ return $cchar;
}
-function registerUrl($url){
- if(!in_array($url,$_SESSION["owsproxyUrls"]["url"])){
- $id = md5($url);
- array_push($_SESSION["owsproxyUrls"]["url"],$url);
- array_push($_SESSION["owsproxyUrls"]["id"], $id);
- }
- else{
- for($i=0; $i<count($_SESSION["owsproxyUrls"]["url"]); $i++){
- if($url == $_SESSION["owsproxyUrls"]["url"][$i]){
- $id = $_SESSION["owsproxyUrls"]["id"][$i];
- }
- }
- }
- return $id;
+function registerUrl($url)
+{
+ if (!in_array($url, $_SESSION["owsproxyUrls"]["url"])) {
+ $id = md5($url);
+ array_push($_SESSION["owsproxyUrls"]["url"], $url);
+ array_push($_SESSION["owsproxyUrls"]["id"], $id);
+ } else {
+ for ($i = 0; $i < count($_SESSION["owsproxyUrls"]["url"]); $i++) {
+ if ($url == $_SESSION["owsproxyUrls"]["url"][$i]) {
+ $id = $_SESSION["owsproxyUrls"]["id"][$i];
+ }
+ }
+ }
+ return $id;
}
-function getCapabilities($url){
- global $arrayOnlineresources;
- global $sid,$wms;
- $t = array(htmlentities($arrayOnlineresources["wms_getcapabilities"]),htmlentities($arrayOnlineresources["wms_getmap"]),htmlentities($arrayOnlineresources["wms_getfeatureinfo"]));
- $new = OWSPROXY ."/". $sid ."/".$wms."?";
- $r = str_replace($t,$new,$arrayOnlineresources["wms_getcapabilities_doc"]);
- header("Content-Type: application/xml");
- echo $r;
+function getCapabilities($url)
+{
+ global $arrayOnlineresources;
+ global $sid, $wms;
+ $t = array(htmlentities($arrayOnlineresources["wms_getcapabilities"]), htmlentities($arrayOnlineresources["wms_getmap"]),
+ htmlentities($arrayOnlineresources["wms_getfeatureinfo"]));
+ $new = OWSPROXY . "/" . $sid . "/" . $wms . "?";
+ $r = str_replace($t, $new, $arrayOnlineresources["wms_getcapabilities_doc"]);
+ header("Content-Type: application/xml");
+ echo $r;
}
/**
@@ -613,74 +659,79 @@
* @param string owsproxy md5
* @return string url to legend graphic
*/
-function getLegendUrl($wms){
- global $reqParams;
- //get wms id
- $sql = "SELECT * FROM wms WHERE wms_owsproxy = $1";
- $v = array($wms);
- $t = array("s");
- $res = db_prep_query($sql, $v, $t);
- if($row = db_fetch_array($res)) {
- $wmsid = $row["wms_id"];
- $getLegendUrl = $row["wms_getlegendurl"];
- } else {
- throwE(array("No wms data available."));
- die();
- }
- //get the url
- $sql = "SELECT layer_style.legendurl ";
- $sql .= "FROM layer_style JOIN layer ";
- $sql .= "ON layer_style.fkey_layer_id = layer.layer_id ";
- $sql .= "WHERE layer.layer_name = $2 AND layer.fkey_wms_id = $1 ";
- $sql .= "AND layer_style.name = $3 AND layer_style.legendurlformat = $4";
- $v = array($wmsid, $reqParams['layer'], $reqParams['style'], $reqParams['format']);
- $t = array("i", "s", "s", "s");
- $res = db_prep_query($sql, $v, $t);
- if($row = db_fetch_array($res)) {
- if (strpos($row["legendurl"],'http') !== 0) {
- $e = new mb_notice("combine legendurls!");
- return $getLegendUrl.$row["legendurl"];
- }
- return $row["legendurl"];
- } else {
- throwE(array("No legend available."));
- die();
- }
+function getLegendUrl($wms)
+{
+ global $reqParams;
+ //get wms id
+ $sql = "SELECT * FROM wms WHERE wms_owsproxy = $1";
+ $v = array($wms);
+ $t = array("s");
+ $res = db_prep_query($sql, $v, $t);
+ if ($row = db_fetch_array($res)) {
+ $wmsid = $row["wms_id"];
+ $getLegendUrl = $row["wms_getlegendurl"];
+ } else {
+ throwE(array("No wms data available."));
+ die();
+ }
+ //get the url
+ $sql = "SELECT layer_style.legendurl ";
+ $sql .= "FROM layer_style JOIN layer ";
+ $sql .= "ON layer_style.fkey_layer_id = layer.layer_id ";
+ $sql .= "WHERE layer.layer_name = $2 AND layer.fkey_wms_id = $1 ";
+ $sql .= "AND layer_style.name = $3 AND layer_style.legendurlformat = $4";
+ $v = array($wmsid, $reqParams['layer'], $reqParams['style'], $reqParams['format']);
+ $t = array("i", "s", "s", "s");
+ $res = db_prep_query($sql, $v, $t);
+ if ($row = db_fetch_array($res)) {
+ if (strpos($row["legendurl"], 'http') !== 0) {
+ $e = new mb_notice("combine legendurls!");
+ return $getLegendUrl . $row["legendurl"];
+ }
+ return $row["legendurl"];
+ } else {
+ throwE(array("No legend available."));
+ die();
+ }
}
+
/**
* validated access permission on requested wms
*
* @param string OWSPROXY md5
* @return array array with detailed information about requested wms
*/
-function checkWmsPermission($wms){
- global $con, $n;
- $myguis = $n->getGuisByPermission($_SESSION["mb_user_id"],true);
- $mywms = $n->getWmsByOwnGuis($myguis);
- $sql = "SELECT * FROM wms WHERE wms_owsproxy = $1";
- $v = array($wms);
- $t = array("s");
- $res = db_prep_query($sql, $v, $t);
- $service = array();
- if($row = db_fetch_array($res)){
- $service["wms_id"] = $row["wms_id"];
- $service["wms_getcapabilities"] = $row["wms_getcapabilities"];
- $service["wms_getmap"] = $row["wms_getmap"];
- $service["wms_getfeatureinfo"] = $row["wms_getfeatureinfo"];
- $service["wms_getcapabilities_doc"] = $row["wms_getcapabilities_doc"];
- }
-
- if(!$row || count($mywms) == 0){
- throwE(array("No wms data for this user available."));
- die();
- }
-
- if(!in_array($service["wms_id"], $mywms)){
- throwE(array("Permission denied."," -> ".$service["wms_id"], implode(",", $mywms)));
- die();
- }
- return $service;
+function checkWmsPermission($wms)
+{
+ global $con, $n;
+ $myguis = $n->getGuisByPermission($_SESSION["mb_user_id"], true);
+ $mywms = $n->getWmsByOwnGuis($myguis);
+ $sql = "SELECT * FROM wms WHERE wms_owsproxy = $1";
+ $v = array($wms);
+ $t = array("s");
+ $res = db_prep_query($sql, $v, $t);
+ $service = array();
+ if ($row = db_fetch_array($res)) {
+ $service["wms_id"] = $row["wms_id"];
+ $service["wms_getcapabilities"] = $row["wms_getcapabilities"];
+ $service["wms_getmap"] = $row["wms_getmap"];
+ $service["wms_getfeatureinfo"] = $row["wms_getfeatureinfo"];
+ $service["wms_getcapabilities_doc"] = $row["wms_getcapabilities_doc"];
+ $service["wms_spatialsec"] = $row["wms_spatialsec"];
+ }
+
+ if (!$row || count($mywms) == 0) {
+ throwE(array("No wms data available."));
+ die();
+ }
+
+ if (!in_array($service["wms_id"], $mywms)) {
+ throwE(array("Permission denied.", " -> " . $service["wms_id"], implode(",", $mywms)));
+ die();
+ }
+ return $service;
}
+
/**
* validates the access permission by getting the appropriate wfs_conf
* to each feature requested and check the wfs_conf permission
@@ -689,100 +740,164 @@
* @param array array of requested featuretype names
* @return array array with detailed information on reqested wfs
*/
-function checkWfsPermission($wfsOws, $features){
- global $con, $n;
- $myconfs = $n->getWfsConfByPermission($_SESSION["mb_user_id"]);
- //check if we know the features requested
- if(count($features) == 0){
- throwE(array("No wfs_feature data available."));
- die();
- }
- //get wfs
- $sql = "SELECT * FROM wfs WHERE wfs_owsproxy = $1";
- $v = array($wfsOws);
- $t = array("s");
- $res = db_prep_query($sql, $v, $t);
- $service = array();
- if($row = db_fetch_array($res)){
- $service["wfs_id"] = $row["wfs_id"];
- $service["wfs_getcapabilities"] = $row["wfs_getcapabilities"];
- $service["wfs_getfeature"] = $row["wfs_getfeature"];
- $service["wfs_describefeaturetype"] = $row["wfs_describefeaturetype"];
- $service["wfs_transaction"] = $row["wfs_transaction"];
- $service["wfs_getcapabilities_doc"] = $row["wfs_getcapabilities_doc"];
- }
- else{
- throwE(array("No wfs data available."));
- die();
- }
-
- foreach($features as $feature){
- //get appropriate wfs_conf
- $sql = "SELECT wfs_conf.wfs_conf_id FROM wfs_conf ";
- $sql.= "JOIN wfs_featuretype ";
- $sql.= "ON wfs_featuretype.featuretype_id = wfs_conf.fkey_featuretype_id ";
- $sql.= "WHERE wfs_featuretype.featuretype_name = $2 ";
- $sql.= "AND wfs_featuretype.fkey_wfs_id = $1";
- $v = array($service["wfs_id"], $feature);
- $t = array("i","s");
- $res = db_prep_query($sql, $v, $t);
- if(!($row = db_fetch_array($res))){
- $notice = new mb_notice("Permissioncheck failed no wfs conf for wfs ".$service["wfs_id"]." with feturetype ".$feature);
- throwE(array("No wfs_conf data for featuretype ".$feature));
- die();
- }
- $conf_id = $row["wfs_conf_id"];
- //check permission
- if(!in_array($conf_id, $myconfs)){
- $notice = new mb_notice("Permissioncheck failed:".$conf_id." not in ".implode(",", $myconfs));
- throwE(array("Permission denied."," -> ".$conf_id, implode(",", $myconfs)));
- die();
- }
- }
- return $service;
+function checkWfsPermission($wfsOws, $features)
+{
+ global $con, $n;
+ $myconfs = $n->getWfsConfByPermission($_SESSION["mb_user_id"]);
+
+ //check if we know the features requested
+ if (count($features) == 0) {
+ throwE(array("No wfs_feature data available."));
+ die();
+ }
+
+ //get wfs
+ $sql = "SELECT * FROM wfs WHERE wfs_owsproxy = $1";
+ $v = array($wfsOws);
+ $t = array("s");
+ $res = db_prep_query($sql, $v, $t);
+ $service = array();
+ if ($row = db_fetch_array($res)) {
+ $service["wfs_id"] = $row["wfs_id"];
+ $service["wfs_getcapabilities"] = $row["wfs_getcapabilities"];
+ $service["wfs_getfeature"] = $row["wfs_getfeature"];
+ $service["wfs_describefeaturetype"] = $row["wfs_describefeaturetype"];
+ $service["wfs_transaction"] = $row["wfs_transaction"];
+ $service["wfs_getcapabilities_doc"] = $row["wfs_getcapabilities_doc"];
+ } else {
+ throwE(array("No wfs data available."));
+ die();
+ }
+
+ foreach ($features as $feature) {
+
+ //get appropriate wfs_conf
+ $sql = "SELECT wfs_conf.wfs_conf_id FROM wfs_conf ";
+ $sql.= "JOIN wfs_featuretype ";
+ $sql.= "ON wfs_featuretype.featuretype_id = wfs_conf.fkey_featuretype_id ";
+ $sql.= "WHERE wfs_featuretype.featuretype_name = $2 ";
+ $sql.= "AND wfs_featuretype.fkey_wfs_id = $1";
+ $v = array($service["wfs_id"], $feature);
+ $t = array("i", "s");
+ $res = db_prep_query($sql, $v, $t);
+ if (!($row = db_fetch_array($res))) {
+ $notice = new mb_exception("Permissioncheck failed no wfs conf for wfs " . $service["wfs_id"] . " with feturetype " . $feature);
+ throwE(array("No wfs_conf data for featuretype " . $feature));
+ die();
+ }
+ $conf_id = $row["wfs_conf_id"];
+
+ //check permission
+ if (!in_array($conf_id, $myconfs)) {
+ $notice = new mb_exception("Permissioncheck failed:" . $conf_id . " not in " . implode(",", $myconfs));
+ throwE(array("Permission denied.", " -> " . $conf_id, implode(",", $myconfs)));
+ die();
+ }
+ }
+
+ return $service;
}
-function checkLayerPermission($wms_id,$l){
- global $n, $owsproxyService;
+function checkLayerPermission($wms_id, $l)
+{
+ global $n, $owsproxyService;
// $notice = new mb_exception("owsproxy: checkLayerpermission: wms: ".$wms_id.", layer: ".$l);
- $myl = explode(",",$l);
- $r = array();
- foreach($myl as $mysl){
- if($n->getLayerPermission($wms_id, $mysl, $_SESSION["mb_user_id"]) === true){
- array_push($r, $mysl);
- }
- }
- $ret = implode(",",$r);
- return $ret;
+ $myl = explode(",", $l);
+ $r = array();
+ foreach ($myl as $mysl) {
+ if ($n->getLayerPermission($wms_id, $mysl, $_SESSION["mb_user_id"]) === true) {
+ array_push($r, $mysl);
+ }
+ }
+ $ret = implode(",", $r);
+ return $ret;
}
-function getDocumentContent($url){
- if (func_num_args() == 2) { //new for HTTP Authentication
- $auth = func_get_arg(1);
- $d = new connector($url, $auth);
- }
- else {
- $d = new connector($url);
- }
+function getDocumentContent($log_id, $url)
+{
+ global $reqParams, $n;
+ if (func_num_args() == 3) { //new for HTTP Authentication
+ $auth = func_get_arg(2);
+ $d = new connector($url, $auth);
+ } else {
+ $d = new connector($url);
+ }
+ $content = $d->file;
+ if (strtoupper($reqParams["request"]) == "GETMAP") { // getmap
+ $pattern_exc = '~EXCEPTION~i';
+ preg_match($pattern_exc, $content, $exception);
+ if (!$content) {
+ if ($log_id != null && is_integer($log_id)) {
+ $n->updateWmsLog(0, "Mb2OWSPROXY - unable to load: " . $url, "text/plain", $log_id);
+ }
+ header("Content-Type: text/plain");
+ echo "Mb2OWSPROXY - unable to load: " . $url;
+ } else if (count($exception) > 0) {
+ if ($log_id != null && is_integer($log_id)) {
+ $n->updateWmsLog(0, $content, $reqParams["exceptions"], $log_id);
+ }
+ header("Content-Type: " . $reqParams["exceptions"]);
+ echo $content;
+ } else {
+ $source = new Imagick();
+ $source->readImageBlob($content);
+ $numColors = $source->getImageColors();
+ if ($log_id != null && is_integer($log_id)) {
+ $n->updateWmsLog($numColors <= 1 ? -1 : 1, null, null, $log_id);
+ }
+ header("Content-Type: " . $reqParams['format']);
+ echo $content;
+ }
+ return true;
+ } else if (strtoupper($reqParams["request"]) == "GETFEATUREINFO") { // getmap
+// header("Content-Type: ".$reqParams['info_format']);
+// $content = matchUrls($content);
+// echo $content;
+ $pattern_exc = '~EXCEPTION~i';
+ preg_match($pattern_exc, $content, $exception);
+ if (!$content) {
+ if ($log_id != null) {
+ $n->updateWmsFiLog("Mb2OWSPROXY - unable to load: " . $url, "text/plain", $log_id);
+ }
+ header("Content-Type: text/plain");
+ echo "Mb2OWSPROXY - unable to load: " . $url;
+ } else if (count($exception) > 0) {
+ if ($log_id != null) {
+ $n->updateWmsFiLog($content, "application/xml", $log_id);
+ }
+ header("Content-Type: application/xml");
+ echo $content;
+ } else {
+ header("Content-Type: " . $reqParams['info_format']);
+ if ($log_id != null) {
+ $n->updateWmsFiLog(null, null, $log_id);
+ }
+ $content = matchUrls($content);
+ echo $content;
+ }
+ return true;
+ } else {
+ return $content;
+ }
+}
- return $d->file;
+function getUserFromSession()
+{
+ if (Mapbender::session()->get('mb_user_id')) {
+ if ((integer) Mapbender::session()->get('mb_user_id') >= 0) {
+ $foundUserId = (integer) Mapbender::session()->get('mb_user_id');
+ //$e = new mb_exception("user id: ".$foundUserId." found in session");
+ } else {
+ $foundUserId = false;
+ //$e = new mb_exception("user id not found or not casted to integer");
+ //$e = new mb_exception("Newly initialized session - no logged in mapbender user for this session!");
+ }
+ } else {
+ $foundUserId = false;
+ //$e = new mb_exception("user id not found or not casted to integer");
+ //$e = new mb_exception("Newly initialized session - no logged in mapbender user for this session!");
+ }
+ return $foundUserId;
}
-function getUserFromSession() {
- if (Mapbender::session()->get('mb_user_id')) {
- if ((integer)Mapbender::session()->get('mb_user_id') >= 0) {
- $foundUserId = (integer)Mapbender::session()->get('mb_user_id');
- //$e = new mb_exception("user id: ".$foundUserId." found in session");
- } else {
- $foundUserId = false;
- //$e = new mb_exception("user id not found or not casted to integer");
- //$e = new mb_exception("Newly initialized session - no logged in mapbender user for this session!");
- }
- } else {
- $foundUserId = false;
- //$e = new mb_exception("user id not found or not casted to integer");
- //$e = new mb_exception("Newly initialized session - no logged in mapbender user for this session!");
- }
- return $foundUserId;
-}
?>
Added: trunk/mapbender/owsproxy_api/http/index.php
===================================================================
--- trunk/mapbender/owsproxy_api/http/index.php (rev 0)
+++ trunk/mapbender/owsproxy_api/http/index.php 2014-02-28 12:57:18 UTC (rev 8786)
@@ -0,0 +1,142 @@
+<?php
+require(dirname(__FILE__) . "/../../conf/mapbender.conf");
+//require(dirname(__FILE__) . "/../../http/classes/class_administration.php");
+//require(dirname(__FILE__) . "/../../http/classes/class_connector.php");
+//require_once(dirname(__FILE__) . "/../../http/classes/class_mb_exception.php");
+//require(dirname(__FILE__) . "/../../owsproxy/http/classes/class_QueryHandler.php");
+require_once dirname(__FILE__) . "/../../http/classes/class_wms_owsproxy_log.php";
+
+//database connection
+$db = db_connect($DBSERVER,$OWNER,$PW);
+db_select_db(DB,$db);
+
+//control if digest auth is set, if not set, generate the challenge with getNonce()
+if (empty($_SERVER['PHP_AUTH_DIGEST'])) {
+ header('HTTP/1.1 401 Unauthorized');
+ header('WWW-Authenticate: Digest realm="'.REALM.
+ '",qop="auth",nonce="'.getNonce().'",opaque="'.md5(REALM).'"');
+ die('Text to send if user hits Cancel button');
+}
+
+//read out the header in an array
+$requestHeaderArray = http_digest_parse($_SERVER['PHP_AUTH_DIGEST']);
+
+//error if header could not be read
+if (!($requestHeaderArray)) {
+ echo 'Following Header information cannot be validated - check your clientsoftware!<br>';
+ echo $_SERVER['PHP_AUTH_DIGEST'].'<br>';
+ die();
+}
+
+//get mb_username and email out of http_auth username string
+$userIdentification = explode(';',$requestHeaderArray['username']);
+$mbUsername = $userIdentification[0];
+$mbEmail = $userIdentification[1];
+
+$userInformation = getUserInfo($mbUsername,$mbEmail);
+
+if ($userInformation[0] == '-1') {
+ die('User with name: '.$mbUsername.' and email: '.$mbEmail.' not known to security proxy!');
+}
+
+if ($userInformation[1]=='') { //check if digest exists in db - if no digest exists it should be a null string!
+ die('User with name: '.$mbUsername.' and email: '.$mbEmail.' has no digest - please set a new password and try again!');
+}
+
+//first check the stale!
+if($requestHeaderArray['nonce'] == getNonce()) {
+ // Up-to-date nonce received
+ $stale = false;
+} else {
+ // Stale nonce received (probably more than x seconds old)
+ $stale = true;
+ //give another chance to authenticate
+ header('HTTP/1.1 401 Unauthorized');
+ header('WWW-Authenticate: Digest realm="'.REALM.'",qop="auth",nonce="'.getNonce().'",opaque="'.md5(REALM).'" ,stale=true');
+}
+// generate the valid response to check the request of the client
+$A1 = $userInformation[1];
+$A2 = md5($_SERVER['REQUEST_METHOD'].':'.$requestHeaderArray['uri']);
+$valid_response = $A1.':'.getNonce().':'.$requestHeaderArray['nc'];
+$valid_response .= ':'.$requestHeaderArray['cnonce'].':'.$requestHeaderArray['qop'].':'.$A2;
+
+$valid_response=md5($valid_response);
+
+if ($requestHeaderArray['response'] != $valid_response) {//the user have to authenticate new - cause something in the authentication went wrong
+ die('Authentication failed - sorry, you have to authenticate once more!');
+}
+
+//functions for http_auth
+//**********************************************************************************************
+
+// function to parse the http auth header
+function http_digest_parse($txt)
+{
+ // protect against missing data
+ $needed_parts = array('nonce'=>1, 'nc'=>1, 'cnonce'=>1, 'qop'=>1, 'username'=>1, 'uri'=>1, 'response'=>1);
+ $data = array();
+ $keys = implode('|', array_keys($needed_parts));
+ preg_match_all('@(' . $keys . ')=(?:([\'"])([^\2]+?)\2|([^\s,]+))@', $txt, $matches, PREG_SET_ORDER);
+ foreach ($matches as $m) {
+ $data[$m[1]] = $m[3] ? $m[3] : $m[4];
+ unset($needed_parts[$m[1]]);
+ }
+ return $needed_parts ? false : $data;
+}
+// function to get relevant user information from mb db
+function getUserInfo($mbUsername,$mbEmail) {
+ $result = array();
+ $sql = "SELECT mb_user_id, mb_user_digest FROM mb_user where mb_user_name = $1 AND mb_user_email= $2";
+ $v = array($mbUsername, $mbEmail);
+ $t = array("s","s");
+ $res = db_prep_query($sql, $v, $t);
+ if(!($row = db_fetch_array($res))){
+ $result[0] = "-1";
+ }
+ else {
+ $result[0] = $row['mb_user_id'];
+ $result[1] = $row['mb_user_digest'];
+ }
+ return $result;
+}
+
+function getNonce() {
+ global $nonceLife;
+ $time = ceil(time() / $nonceLife) * $nonceLife;
+ return md5(date('Y-m-d H:i', $time).':'.$_SERVER['REMOTE_ADDR'].':'.NONCEKEY);
+}
+
+//if we are here - authentication has been done well!
+
+$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
+
+$userId = isset($_REQUEST['userId']) ? $_REQUEST['userId'] : null;#XXX
+$wmsId = isset($_REQUEST['wmsId']) ? $_REQUEST['wmsId'] : 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){
+ die ("Der Parameter 'serviceType' wurde nicht uebergeben.");
+}
+
+if($serviceType == "wms"){
+ $mb_user_id = $userInformation[0];
+ $wmslog = WmsOwsLogCsv::create($mb_user_id, $function, $userId, $wmsId,
+ $listType, $timeFrom, $timeTo, $withContactData);
+ $wmslog->handle();
+ header("Content-Type: text/csv; charset=".CHARSET);
+ header("Content-Disposition: attachment; filename=csv_export.csv");
+ header("Pragma: no-cache");
+ header("Expires: 0");
+ $csv = $wmslog->getAsCsv();
+ print $csv;
+ die();
+} else {
+ die ("Der 'serviceType'".$serviceType." ist nicht unterstuetzt.");
+}
+
+?>
Modified: trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7.4_to_2.8_pgsql_UTF-8.sql
===================================================================
--- trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7.4_to_2.8_pgsql_UTF-8.sql 2014-02-28 11:51:21 UTC (rev 8785)
+++ trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7.4_to_2.8_pgsql_UTF-8.sql 2014-02-28 12:57:18 UTC (rev 8786)
@@ -279,3 +279,83 @@
UPDATE wfs SET wfs_password = '' WHERE wfs_password IS NULL;
UPDATE wfs SET wfs_auth_type = '' WHERE wfs_auth_type IS NULL;
+--Erweiterung Tabelle mb_proxy_log
+ALTER TABLE mb_proxy_log ADD COLUMN got_result integer;
+ALTER TABLE mb_proxy_log ADD COLUMN error_message text;
+ALTER TABLE mb_proxy_log ADD COLUMN error_mime_type character varying(50);
+ALTER TABLE mb_proxy_log ADD COLUMN layer_featuretype_list text;
+ALTER TABLE mb_proxy_log ADD COLUMN request_type character varying(15);
+ALTER TABLE mb_proxy_log ADD COLUMN log_id serial;
+ALTER TABLE mb_proxy_log ADD PRIMARY KEY (log_id);
+
+
+--neue Anwendung Owsproxy_csv
+INSERT INTO gui (gui_id, gui_name, gui_description, gui_public) VALUES ('Owsproxy_csv','Owsproxy_csv','GUI combining most of the Mapbender functionality',1);
+INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element,e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires,e_url) VALUES ('Owsproxy_csv','i18n',1,0,'Internationalization module, collects data from all elements and sends them to the server in a single POST request. The strings are translated via gettext only.','Internationalization','div','','',NULL ,NULL,NULL ,NULL,NULL ,'','','div','../plugins/mb_i18n.js','','','','http://www.mapbender.org/Gettext');
+INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element,e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires,e_url) VALUES ('Owsproxy_csv','jq_upload',1,1,'','','','','',NULL ,NULL,NULL ,NULL,NULL ,'','','','','../plugins/jq_upload.js','','','');
+INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element,e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires,e_url) VALUES ('Owsproxy_csv','jq_validate',1,0,'The jQuery validation plugin','','','','',NULL ,NULL,NULL ,NULL,NULL ,'','','','../javascripts/jq_validate.js','../extensions/jquery-validate/jquery.validate.min.js','','','http://docs.jquery.com/Plugins/Validation');
+INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES ('Owsproxy_csv','jq_validate','css','label.error { float: none; color: red; padding-left: .5em; vertical-align: top; }','','text/css');
+INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element,e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires,e_url) VALUES ('Owsproxy_csv','jq_datatables',1,1,'Includes the jQuery plugin datatables, use like this
+$(selector).datatables(options)','','','','',NULL ,NULL,NULL ,NULL,NULL ,'','','','../plugins/jq_datatables.js','../extensions/dataTables-1.5/media/js/jquery.dataTables.min.js','','','http://www.datatables.net/');
+INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES ('Owsproxy_csv','jq_datatables','defaultCss','../extensions/dataTables-1.5/media/css/demo_table_jui.css','','file/css');
+INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element,e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires,e_url) VALUES ('Owsproxy_csv','jq_ui_widget',1,1,'jQuery UI widget','','','','',NULL ,NULL,NULL ,NULL,NULL ,'','','','','../extensions/jquery-ui-1.8.16.custom/development-bundle/ui/jquery.ui.widget.js','','','');
+INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element,e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires,e_url) VALUES ('Owsproxy_csv','jq_ui',1,1,'The jQuery UI core','','','','',NULL ,NULL,NULL ,NULL,NULL ,'','','','','../extensions/jquery-ui-1.8.16.custom/development-bundle/ui/jquery.ui.core.js','','','');
+INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES ('Owsproxy_csv','jq_ui','css','../extensions/jquery-ui-1.7.2.custom/css/ui-lightness/jquery-ui-1.7.2.custom.css','','file/css');
+INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element,e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires,e_url) VALUES ('Owsproxy_csv','body',1,1,'body (obligatory)','','body','','',NULL ,NULL,NULL ,550,NULL ,'position:relative !important;overflow:visible;','','body','','','','','');
+INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES ('Owsproxy_csv','body','css_file_body','../css/mapbender.css','file/css','file/css');
+INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES ('Owsproxy_csv','body','css_file_feedtree','../css/feedtree.css','file/css','file/css');
+INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES ('Owsproxy_csv','body','css_file_wfstree','../css/wfsconftree.css','file/css','file/css');
+--INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES ('Owsproxy_csv','body','css_mapviewer','../css/map_sl.css','','file/css');
+INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES ('Owsproxy_csv','body','favicon','../img/favicon.ico','favicon','php_var');
+INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES ('Owsproxy_csv','body','includeWhileLoading','../include/gui1_splash.php','','php_var');
+INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES ('Owsproxy_csv','body','jq_ui_theme','../extensions/jquery-ui-1.7.2.custom/css/smoothness/jquery-ui-1.7.2.custom.css','UI Theme from Themeroller','file/css');
+INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES ('Owsproxy_csv','body','jquery_datatables','../extensions/dataTables-1.5/media/css/demo_table_jui.css','','file/css');
+INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES ('Owsproxy_csv','body','popupcss','../css/popup.css','file css','file/css');
+INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES ('Owsproxy_csv','body','print_css','../css/print_div.css','','file/css');
+INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES ('Owsproxy_csv','body','tablesortercss','../css/tablesorter.css','file css','file/css');
+INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES ('Owsproxy_csv','body','use_load_message','true','','php_var');
+INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES ('Owsproxy_csv','body','css_owsproxy_log','../css/owsproxy_logs.css','','file/css');
+INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element,e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires,e_url) VALUES ('Owsproxy_csv','jq_ui_position',2,1,'jQuery UI position','','','','',NULL ,NULL,NULL ,NULL,NULL ,'','','','','../extensions/jquery-ui-1.8.16.custom/development-bundle/ui/jquery.ui.position.js','','','');
+INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element,e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires,e_url) VALUES ('Owsproxy_csv','jq_ui_mouse',2,1,'jQuery UI mouse','','','','',NULL ,NULL,NULL ,NULL,NULL ,'','','','','../extensions/jquery-ui-1.8.16.custom/development-bundle/ui/jquery.ui.mouse.js','','jq_ui_widget','');
+INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element,e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires,e_url) VALUES ('Owsproxy_csv','tabs',2,0,'vertical tabs to handle iframes','','div','','',5,295,195,20,3,'font-family: Arial,Helvetica;font-weight:bold;','','div','mod_tab.php','','','','');
+INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES ('Owsproxy_csv','tabs','tab_frameHeight[0]','230','','var');
+INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES ('Owsproxy_csv','tabs','tab_frameHeight[1]','230','','var');
+INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES ('Owsproxy_csv','tabs','tab_frameHeight[2]','230','','var');
+INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES ('Owsproxy_csv','tabs','tab_ids[1]','wfsConfTree','','php_var');
+INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES ('Owsproxy_csv','tabs','tab_ids[2]','feeds','','php_var');
+INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES ('Owsproxy_csv','tabs','open_tab','0','define which tab should be opened when a gui is opened','var');
+INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES ('Owsproxy_csv','tabs','tab_ids[0]','treeGDE','','php_var');
+INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES ('Owsproxy_csv','tabs','tab_prefix',' ','','var');
+INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES ('Owsproxy_csv','tabs','expandable','0','1 = expand the tabs to fit the document vertically, default is 0','php_var');
+INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES ('Owsproxy_csv','tabs','tab_style','position:absolute;visibility:visible;cursor:pointer;','','var');
+INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element,e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires,e_url) VALUES ('Owsproxy_csv','logout',2,0,'Logout','Abmelden','img','../img/button_blue_red/logout_off.png','onClick="window.location.href=''../php/mod_logout.php?sessionID''" border=''0'' onmouseover=''this.src="../img/button_blink_red/logout_over.png"'' onmouseout=''this.src="../img/button_blink_red/logout_off.png"'' ',704,126,24,24,1,'','','','','','','','http://www.mapbender.org/index.php/Logout');
+INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES ('Owsproxy_csv','logout','logout_location','http://www.mapbender.org/','webside to show after logout','php_var');
+INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element,e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires,e_url) VALUES ('Owsproxy_csv','owsproxy_log_csv',2,1,'Load owsproxy log data as csv','Load oxsproxy log csv','div','','',NULL ,NULL,NULL ,NULL,2,'overflow:auto;background-color: white;width:100%;height:100%;padding:20px;','','div','../plugins/mb_owsproxy_log_csv.js','','','','');
+INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES ('Owsproxy_csv','owsproxy_log_csv','owsproxy_log_css','#owsproxy-log-query{width:500px;}
+#owsproxy-log-query div.field label { width:150px;}','','text/css');
+INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element,e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires,e_url) VALUES ('Owsproxy_csv','jq_ui_droppable',4,1,'jQuery UI droppable','','','','',NULL ,NULL,NULL ,NULL,NULL ,'','','','','../extensions/jquery-ui-1.8.16.custom/development-bundle/ui/jquery.ui.droppable.js','','jq_ui,jq_ui_widget,jq_ui_mouse,jq_ui_draggable','');
+INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element,e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires,e_url) VALUES ('Owsproxy_csv','jq_ui_button',4,1,'jQuery UI button','','','','',NULL ,NULL,NULL ,NULL,NULL ,'','','','','../extensions/jquery-ui-1.8.16.custom/development-bundle/ui/jquery.ui.button.js','','jq_ui,jq_ui_widget','');
+INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element,e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires,e_url) VALUES ('Owsproxy_csv','jq_ui_resizable',5,1,'Resizable from the jQuery UI framework','','','','',NULL ,NULL,NULL ,NULL,NULL ,'','','','../plugins/jq_ui_resizable.js','../extensions/jquery-ui-1.8.16.custom/development-bundle/ui/jquery.ui.resizable.js','','jq_ui,jq_ui_mouse,jq_ui_widget','http://jqueryui.com/demos/resizable/');
+INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element,e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires,e_url) VALUES ('Owsproxy_csv','jq_ui_draggable',5,1,'Draggable from the jQuery UI framework','','','','',NULL ,NULL,NULL ,NULL,NULL ,'','','','','../extensions/jquery-ui-1.8.16.custom/development-bundle/ui/jquery.ui.draggable.js','','jq_ui,jq_ui_mouse,jq_ui_widget','http://jqueryui.com/demos/draggable/');
+INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element,e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires,e_url) VALUES ('Owsproxy_csv','jq_ui_tabs',5,1,'horizontal tabs from the jQuery UI framework','','','','',NULL ,NULL,NULL ,NULL,NULL ,'','','','','../extensions/jquery-ui-1.8.16.custom/development-bundle/ui/jquery.ui.tabs.js','','jq_ui,jq_ui_widget','');
+INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element,e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires,e_url) VALUES ('Owsproxy_csv','jq_ui_dialog',5,1,'Module to manage jQuery UI dialog windows with multiple options for customization.','','div','','',-1,79,15,15,NULL ,'','','div','','../extensions/jquery-ui-1.8.16.custom/development-bundle/ui/jquery.ui.dialog.js','','jq_ui,jq_ui_widget,jq_ui_button,jq_ui_draggable,jq_ui_mouse,jq_ui_position,jq_ui_resizable','');
+INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element,e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires,e_url) VALUES ('Owsproxy_csv','ig_ui_timepicker',5,1,'Includes the jQuery plugin timepicker','','','','',NULL ,NULL,NULL ,NULL,NULL ,'','','','../extensions/jquery-ui-1.8.16.custom/development-bundle/ui/jquery.ui.timepicker.js','','','','');
+INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element,e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires,e_url) VALUES ('Owsproxy_csv','jq_ui_slider',5,1,'slider from the jQuery UI framework','','','','',NULL ,NULL,NULL ,NULL,NULL ,'','','','','../extensions/jquery-ui-1.8.16.custom/development-bundle/ui/minified/jquery.ui.slider.min.js','','jq_ui,jq_ui_mouse,jq_ui_widget','');
+INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element,e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires,e_url) VALUES ('Owsproxy_csv','iq_ui_datepicker',5,1,'Includes the jQuery plugin datepicker','','','','',NULL ,NULL,NULL ,NULL,NULL ,'','','','../extensions/jquery-ui-1.8.16.custom/development-bundle/ui/jquery.ui.datepicker.js','','','','');
+
+--Eintragen der neuen Owsproxy-Calc-Elemente in Gui Administration_DE
+INSERT INTO gui_element(fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element, e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires, e_url) VALUES('Administration_DE','owsproxy_calc',2,1,'secure services','OWSProxy WMS Calculation','a','','href = "../frames/index.php?guiID=Owsproxy_csv"',80,10,NULL ,NULL ,NULL ,'font-family: Arial, Helvetica, sans-serif; font-size : 12px; text-decoration : none; color: #808080;','Sicherheits Proxy (Abrechnung)','a','','','','','');
+
+INSERT INTO gui_element(fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element, e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires, e_url) VALUES('Administration_DE','owsproxy_calc_collection',2,1,'Put existing divs in new div object. List the elements comma-separated under target, and make sure they have a title.','','div','','',0,200,200,30,NULL ,'','','div','../plugins/mb_div_collection.js','','owsproxy_calc,owsproxy_calc_icon','','');
+
+INSERT INTO gui_element(fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element, e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires, e_url) VALUES('Administration_DE','owsproxy_calc_icon',2,1,'icon','','img','../img/gnome/emblem-readonly.png','',0,0,NULL ,NULL ,2,'','','','','','','','');
+
+--Eintragen der neuen Gui Owsproxy_csv für User root in Tabelle gui_mb_user
+INSERT INTO gui_mb_user (fkey_gui_id, fkey_mb_user_id, mb_user_type) VALUES ('Owsproxy_csv', '1', 'owner');
+
+--ergänze Eintrag owsproxy_calc_collection in Target von Element menu_wms in Administration_DE
+UPDATE gui_element SET e_target = replace(e_target, 'owsproxy_collection', 'owsproxy_collection,owsproxy_calc_collection') WHERE fkey_gui_id = 'Administration_DE' AND e_id = 'menu_wms';
+
+
+
+
More information about the Mapbender_commits
mailing list