/**
  * Loads WFS conf data from the database
  * 
  * @return Object WFS conf data.
  * @param $idOrIdArray Object May be an integer or an array of integers representing WFS conf IDs.
  */
 public function load($idOrIdArray)
 {
     // Check parameter and set idArray
     if (isset($idOrIdArray)) {
         // parameter is a number
         if (!is_array($idOrIdArray) && is_numeric($idOrIdArray)) {
             $idOrIdArray = array(intval($idOrIdArray));
         }
         // parameter is an array of numbers
         if (is_array($idOrIdArray)) {
             $idArray = array();
             foreach ($idOrIdArray as $id) {
                 if (!is_numeric($id)) {
                     $e = new mb_exception("Wfs_conf: constructor: wrong parameter: " . $id . " is not a number.");
                     return array();
                 }
                 array_push($idArray, intval($id));
             }
             // If a user ID is given, remove the ones the user has no access to
             if (Mapbender::session()->get("mb_user_id")) {
                 $user = new User(Mapbender::session()->get("mb_user_id"));
                 $idArray = array_intersect($idArray, $user->getWfsConfByPermission());
             }
             return $this->getWfsConfFromDb($idArray);
         } else {
             $e = new mb_exception("Wfs_conf: constructor: parameter must be number or an array of numbers.");
             return array();
         }
     } else {
         $e = new mb_exception("Wfs_conf: constructor: parameter is not valid");
         return null;
     }
 }
 /**
  * Inserts a new WFS into the database.
  * 
  * @return Boolean
  * @param $aWfs Wfs
  */
 public static function insert($aWfs)
 {
     db_begin();
     $uuid = new Uuid();
     $sql = "INSERT INTO wfs (wfs_version, wfs_name, wfs_title, wfs_abstract, ";
     $sql .= "wfs_getcapabilities, wfs_getcapabilities_doc, wfs_upload_url, ";
     $sql .= "wfs_describefeaturetype, wfs_getfeature, wfs_transaction, fees, ";
     $sql .= "accessconstraints, wfs_owner, wfs_timestamp, uuid) ";
     $sql .= "VALUES (\$1, \$2, \$3, \$4, \$5, \$6, \$7, \$8, \$9, \$10, \$11, \$12, \$13, \$14,\$15)";
     $v = array($aWfs->getVersion(), $aWfs->name, $aWfs->title, $aWfs->summary, $aWfs->getCapabilities, $aWfs->getCapabilitiesDoc, $aWfs->uploadUrl, $aWfs->describeFeatureType, $aWfs->getFeature, $aWfs->transaction, $aWfs->fees, $aWfs->accessconstraints, Mapbender::session()->get("mb_user_id"), strtotime("now"), $uuid);
     $t = array('s', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 'i', 'i', 's');
     $res = db_prep_query($sql, $v, $t);
     if (!$res) {
         $e = new mb_exception("Error while inserting WFS into database.");
         return false;
     }
     // set the WFS id
     $aWfs->id = db_insert_id($con, 'wfs', 'wfs_id');
     // Insert the feature types
     for ($i = 0; $i < count($aWfs->featureTypeArray); $i++) {
         $currentFeatureType = $aWfs->featureTypeArray[$i];
         if (!WfsToDb::insertFeatureType($currentFeatureType)) {
             db_rollback();
             return false;
         }
     }
     db_commit();
     return true;
 }
function getConfiguration($key)
{
    //check if key param can be found in SESSION,
    // otherwise take it from GET
    if (Mapbender::session()->exists($key)) {
        return Mapbender::session()->get($key);
    }
    return $_GET[$key];
}
function getWmc($wmcId = null)
{
    $user = new User(Mapbender::session()->get("mb_user_id"));
    $wmcIdArray = $user->getWmcByOwner();
    //getAccessibleWmcs();
    if (!is_null($wmcId) && !in_array($wmcId, $wmcIdArray)) {
        abort(_mb("You are not allowed to access this WMC."));
    }
    return $wmcIdArray;
}
function displayCategories($sql)
{
    if (Mapbender::session()->get("mb_lang") === "de") {
        $sql = str_replace("category_code_en", "category_code_de", $sql);
    }
    $str = "";
    $res = db_query($sql);
    while ($row = db_fetch_assoc($res)) {
        $str .= "<option value='" . $row["id"] . "'>" . htmlentities($row["name"], ENT_QUOTES, CHARSET) . "</option>";
    }
    return $str;
}
function getLayer($layerId = null)
{
    $user = new User(Mapbender::session()->get("mb_user_id"));
    $wmsIdArray = $user->getOwnedWms();
    if (!is_array($wmsIdArray) || count($wmsIdArray) === 0) {
        abort(_mb("No metadata sets available."));
    }
    $wmsId = wms::getWmsIdByLayerId($layerId);
    if (is_null($wmsId) || !in_array($wmsId, $wmsIdArray)) {
        abort(_mb("You are not allowed to access WMS " . $wmsId));
    }
    return;
}
 /**
  * Constructor
  * @param $userId Integer 	the ID of the user that	is represented by 
  * 							this object.
  */
 public function __construct()
 {
     if (func_num_args() === 1) {
         $this->id = intval(func_get_arg(0));
     } else {
         $this->id = Mapbender::session()->get("mb_user_id");
     }
     try {
         $this->load();
     } catch (Exception $E) {
         new mb_exception($E->getMessage());
     }
 }
function getFeaturetype($featuretypeId = null)
{
    $user = new User(Mapbender::session()->get("mb_user_id"));
    $wfsIdArray = $user->getOwnedWfs();
    if (!is_array($wfsIdArray) || count($wfsIdArray) === 0) {
        abort(_mb("No metadata sets available."));
    }
    $wfsId = wfs::getWfsIdByFeaturetypeId($featuretypeId);
    if (is_null($wfsId) || !in_array($wfsId, $wfsIdArray)) {
        abort(_mb("You are not allowed to access this WFS " . $wfsId));
    }
    return;
}
function getWfsConfData($wfsID)
{
    global $con;
    // re-check permission
    $adm = new administration();
    $serviceList = $adm->getWfsByOwner(Mapbender::session()->get("mb_user_id"));
    if (in_array($wfsID, $serviceList)) {
        $wfsConf = array();
        $wfsConf['id'] = array();
        $wfsConf['abstract'] = array();
        $sql = "SELECT * FROM wfs_conf WHERE fkey_wfs_id = \$1 ORDER BY wfs_conf_abstract";
        $v = array($wfsID);
        $t = array('i');
        $res = db_prep_query($sql, $v, $t);
        $cnt = 0;
        while ($row = db_fetch_array($res)) {
            array_push($wfsConf['id'], $row['wfs_conf_id']);
            array_push($wfsConf['abstract'], $row['wfs_conf_abstract']);
            $cnt++;
        }
        if ($cnt == 0) {
            return false;
        } else {
            return $wfsConf;
        }
    }
    //	else if($wfsID==="gui_confs"){
    //		$wfsConf = array();
    //		$wfsConf['id'] = array();
    //		$wfsConf['abstract'] = array();
    //		$wfsConf['id'] = $adm->getWfsConfByPermission(Mapbender::session()->get("mb_user_id"));
    //		$cnt = 0;
    //		foreach($wfsConf['id'] as $wfscid){
    //			$sql = "SELECT wfs_conf_abstract FROM wfs_conf WHERE wfs_conf_id = $1";
    //			$v = array($wfscid);
    //			$t = array('i');
    //			$res = db_prep_query($sql,$v,$t);
    //			while($row = db_fetch_array($res)){
    //				array_push($wfsConf['abstract'], $row['wfs_conf_abstract']);
    //			}
    //			$cnt++;
    //		}
    //		if($cnt == 0){
    //			return false;
    //		}
    //		else{
    //			return $wfsConf;
    //		}
    //	}
}
 function log($module, $req, $time_client, $type = "")
 {
     $this->url = $req;
     if ($type == "") {
         $type = $this->logtype;
     }
     if ($type == "file") {
         if (is_dir($this->dir)) {
             $logfile = $this->dir . "mb_access_" . date("Y_m_d") . ".log";
             if (!($h = @fopen($logfile, "a"))) {
                 #exit;
             } else {
                 for ($i = 0; $i < count($this->url); $i++) {
                     $content = strtotime("now") . " ";
                     $content .= "[" . date("d/M/Y:H:i:s O") . "]";
                     $content .= " " . Mapbender::session()->get("mb_user_ip");
                     $content .= ' "';
                     if ($this->log_username == true) {
                         $content .= Mapbender::session()->get("mb_user_name");
                     }
                     $content .= '"';
                     $content .= " " . Mapbender::session()->get("mb_user_id");
                     $content .= " " . $module;
                     $content .= ' "' . $this->url[$i] . '"';
                     $content .= chr(13) . chr(10);
                     if (!fwrite($h, $content)) {
                         #exit;
                     }
                 }
                 fclose($h);
             }
         }
     } else {
         if ($type == 'db') {
             for ($i = 0; $i < count($this->url); $i++) {
                 $sql = "INSERT INTO mb_log (";
                 $sql .= "time_client, time_server, time_readable, mb_session, ";
                 $sql .= "gui, module, ip, username, userid, request";
                 $sql .= ") VALUES (\$1, \$2, \$3, \$4, \$5, \$6, \$7, \$8, \$9, \$10)";
                 $v = array($time_client, strtotime("now"), "[" . date("d/M/Y:H:i:s O") . "]", SID, Mapbender::session()->get("mb_user_gui"), $module, Mapbender::session()->get("mb_user_ip"), Mapbender::session()->get("mb_user_name"), Mapbender::session()->get("mb_user_id"), $this->url[$i]);
                 $t = array("s", "s", "s", "s", "s", "s", "s", "s", "s", "s");
                 $res = db_prep_query($sql, $v, $t) or die(db_error());
                 if (!$res) {
                     include_once dirname(__FILE__) . "/class_mb_exception.php";
                     $e = new mb_exception("class_log: Writing table mb_log failed.");
                 }
             }
         }
     }
 }
 public function select($id, $applicationId)
 {
     $sql = "SELECT fkey_gui_id, e_id, e_pos, e_public, e_comment, e_public, " . "gettext(\$1, e_title) as 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 FROM gui_element WHERE e_id = \$2 AND " . "fkey_gui_id = \$3 LIMIT 1";
     $v = array(Mapbender::session()->get("mb_lang"), $id, $applicationId);
     $t = array("s", "s", "s");
     $res = db_prep_query($sql, $v, $t);
     $row = db_fetch_array($res);
     if ($row) {
         $this->guiId = $applicationId;
         $this->id = $row["e_id"];
         $this->pos = $row["e_pos"];
         $this->isPublic = $row["e_public"];
         $this->comment = $row["e_comment"];
         $this->title = $row["e_title"];
         $this->element = $row["e_element"];
         $this->src = $row["e_src"];
         $this->attributes = $row["e_attributes"];
         $this->left = $row["e_left"];
         $this->top = $row["e_top"];
         $this->width = $row["e_width"];
         $this->height = $row["e_height"];
         $this->zIndex = $row["e_z_index"];
         $this->moreStyles = $row["e_more_styles"];
         $this->content = $row["e_content"];
         $this->closeTag = $row["e_closetag"];
         $this->jsFile = $row["e_js_file"];
         $this->mbMod = $row["e_mb_mod"];
         $this->target = $row["e_target"];
         $this->requires = $row["e_requires"];
         $this->helpUrl = $row["e_url"];
         $sql = "SELECT var_name FROM gui_element_vars WHERE fkey_gui_id = \$1 AND fkey_e_id = \$2;";
         $v = array($applicationId, $id);
         $t = array("s", "s");
         $res = db_prep_query($sql, $v, $t);
         while ($row = db_fetch_assoc($res)) {
             $name = $row["var_name"];
             $this->elementVars[] = new ElementVar($applicationId, $id, $name);
         }
         return true;
     }
     return false;
 }
 function check($serviceType, $serviceId)
 {
     if (!Mapbender::session()->exists("acceptedTou")) {
         $resultObj = array("accepted" => 0, "message" => "No session var acceptedTou exists til now");
         return $resultObj;
     } else {
         $acceptedTou = Mapbender::session()->get("acceptedTou");
         $acceptedTou = json_decode($acceptedTou);
         //read out service part
         $serviceIdArray = $acceptedTou->{$serviceType};
         #print_r($serviceIdArray);
         if (in_array($serviceId, $serviceIdArray)) {
             $resultObj = array("accepted" => 1, "message" => "Session var acceptedTou found - id was set before - don't show tou anymore");
             return $resultObj;
         } else {
             $resultObj = array("accepted" => 0, "message" => "Session var acceptedTou found - id was not set before - show tou before load resource");
             return $resultObj;
         }
     }
 }
<?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__) . "/../php/mb_validateSession.php";
require_once dirname(__FILE__) . "/../classes/class_json.php";
$e = new mb_notice("locale: " . Mapbender::session()->get("mb_locale") . "; lang: " . Mapbender::session()->get("mb_lang"));
$e = new mb_notice(setlocale(LC_ALL, Mapbender::session()->get("mb_locale")));
//
// Messages
//
$msg_obj = array();
$msg_obj["messageDescriptionPolygon"] = _mb("polygon");
$msg_obj["messageDescriptionLine"] = _mb("line");
$msg_obj["messageDescriptionPoint"] = _mb("point");
$msg_obj["messageErrorNotAnInteger"] = _mb("Not an integer value.");
$msg_obj["messageErrorNotAFloat"] = _mb("Not a double value.");
$msg_obj["messageErrorFieldIsEmpty"] = _mb("This field may not be empty.");
$msg_obj["messageErrorFormEvaluation"] = _mb("Failure during form evaluation.");
$msg_obj["messageErrorWfsWrite"] = _mb("An error occured.");
$msg_obj["messageErrorMergeNotApplicable"] = _mb("At least two geometries must be available. Only polygons are allowed in the geometry list.");
$msg_obj["messageErrorSplitNotApplicable"] = _mb("Exactly two geometries must be available. The first geometry shall be a polygon or a line, the second geometry shall be a line.");
$msg_obj["messageErrorDifferenceNotApplicable"] = _mb("Exactly two polygons must be available.");
$msg_obj["messageErrorMergeLineNotApplicable"] = _mb("Exactly two lines must be available.");
$msg_obj["messageSuccessWfsWrite"] = _mb("Success.");
$msg_obj["messageConfirmDeleteGeomFromDb"] = _mb("Delete geometry from database?");
$msg_obj["messageConfirmDeleteAllGeomFromList"] = _mb("Clear list of geometries?");
$msg_obj["messageSelectAnOption"] = _mb("Please select an entry.");
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# 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";
$gui_id = Mapbender::session()->get("mb_user_gui");
$target = $_REQUEST["e_target"];
$e_id_css = $_REQUEST["e_id_css"];
$isLoaded = $_REQUEST["isLoaded"];
$con = db_connect($DBSERVER, $OWNER, $PW);
db_select_db($DB, $con);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset='<?php 
echo CHARSET;
?>
'">
<title>mod_wfsGazetteerEditor</title>
<STYLE TYPE="text/css">
     if(permission == true){
        document.form1.del.value = 1;
        document.form1.submit();
     }
   }
}
// -->
</script>
</head>
<body>

<?php 
require_once dirname(__FILE__) . "/../classes/class_administration.php";
require_once dirname(__FILE__) . "/../classes/class_gui.php";
$admin = new administration();
$permguis = $admin->getGuisByPermission(Mapbender::session()->get("mb_user_id"), true);
###export
if ($guiList) {
    $gui = gui::byName($guiList);
    try {
        $insert = $gui->toSql();
    } catch (Exception $e) {
        $insert = $e->message;
    }
    echo "<textarea rows=40 cols=80>";
    echo htmlentities($insert, ENT_QUOTES, CHARSET);
    echo "</textarea>";
}
###
if (!$guiList) {
    $v = array();
 /**
  * Selects all WMS of the current user from the database.
  * Then it creates the corresponding WMS object and returns
  * these objects as an array.
  * 
  * @return wms[]
  * @param $appId String
  */
 public static function selectMyWmsByApplication($appId)
 {
     // check if user is permitted to access the application
     $currentUser = new User(Mapbender::session()->get("mb_user_id"));
     $appArray = $currentUser->getApplicationsByPermission(false);
     if (!in_array($appId, $appArray)) {
         $e = new mb_warning("class_wms.php: selectMyWmsByApplication(): User '" . $currentUser . "' is not allowed to acces application '" . $appId . "'.");
         return array();
     }
     // get WMS of this application
     $sql = "SELECT fkey_wms_id FROM gui_wms WHERE " . "fkey_gui_id = \$1 ORDER BY gui_wms_position";
     $v = array($appId);
     $t = array('s');
     $res = db_prep_query($sql, $v, $t);
     // instantiate PHP objects and store in array
     $wmsArray = array();
     while ($row = db_fetch_array($res)) {
         $currentWms = new wms();
         $currentWms->createObjFromDB($appId, $row["fkey_wms_id"]);
         array_push($wmsArray, $currentWms);
     }
     return $wmsArray;
 }
     }
     if ($checkLayerIdValid) {
         $invalidIdsArray = $wmc->getInvalidWms();
         $invalidIdsTitles = array();
         foreach ($invalidIdsArray as $i) {
             $invalidIdsTitles[] = array("id" => $i["id"], "index" => $i["index"], "title" => $i["title"]);
         }
         $resultObj["invalidId"] = array("message" => "Folgende Dienste/Layer sind aus der " . "Registrierungsstelle gelöscht worden. Es kann daher nicht " . "überprüft werden, ob die Links verwaist sind oder ob " . "die Dienste überhaupt Daten liefern.", "wms" => $invalidIdsTitles);
     }
     if ($checkLayerPermission) {
         $deniedIdsArray = $wmc->getWmsWithoutPermission($currentUser);
         $deniedIdsTitles = array();
         foreach ($deniedIdsArray as $i) {
             $deniedIdsTitles[] = array("id" => $i["id"], "index" => $i["index"], "title" => $i["title"]);
         }
         $resultObj["noPermission"] = array("message" => "Sie als Nutzer '" . Mapbender::session()->get("mb_user_name") . "' " . "haben keine Berechtigung auf folgende Layer zuzugreifen.", "wms" => $deniedIdsTitles);
     }
     if ($checkLayerAvailability) {
         $unavailableIdsArray = $wmc->getUnavailableWms($currentUser);
         $unavailableIdsTitles = array();
         foreach ($unavailableIdsArray as $i) {
             $unavailableIdsTitles[] = array("id" => $i["id"], "index" => $i["index"], "title" => $i["title"]);
         }
         $resultObj["unavailable"] = array("message" => "Bei folgenden Diensten kam es während " . "des letzten Monitorings zu Problemen. Es ist möglich, dass " . "diese Dienste derzeit keine Informationen zur Verfügung stellen " . "können.", "wms" => $unavailableIdsTitles);
     }
     $ajaxResponse->setResult($resultObj);
     $ajaxResponse->setSuccess(true);
     break;
     // Invalid command
 // Invalid command
 default:
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# 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.
/********** Configuration*************************************************/
require_once dirname(__FILE__) . "/../php/mb_validatePermission.php";
require_once dirname(__FILE__) . "/../classes/class_json.php";
include dirname(__FILE__) . "/../include/dyn_js.php";
$tab_ids = array();
include dirname(__FILE__) . "/../include/dyn_php.php";
echo "var tab_titles = [];\n";
for ($i = 0; $i < count($tab_ids); $i++) {
    $sql = "SELECT gettext(\$1, e_title) AS e_title FROM gui_element WHERE fkey_gui_id = \$2 AND e_id = \$3";
    $v = array(Mapbender::session()->get("mb_lang"), $gui_id, $tab_ids[$i]);
    $t = array("s", "s", "s");
    $res = db_prep_query($sql, $v, $t);
    $row = db_fetch_array($res);
    echo "tab_titles[" . $i . "] = '" . $row["e_title"] . "';\n";
}
$json = new Mapbender_JSON();
$output = $json->encode($tab_ids);
echo "var tab_ids = " . $output . ";";
if (!isset($expandable) || !$expandable) {
    include dirname(__FILE__) . "/mod_tab.js";
} else {
    include dirname(__FILE__) . "/mod_tab_expandable.js";
}
     if ($wfsConfIds === null) {
         $wfsConfIds = array();
     }
     $result = array();
     foreach ($wfsConfIds as $id) {
         $currentWfsConf = WfsConfiguration::createFromDb($id);
         if ($currentWfsConf !== null) {
             $result[] = $currentWfsConf;
         }
     }
     $ajaxResponse->setResult($result);
     $ajaxResponse->send();
     break;
 case "getWfs":
     $aWFS = new wfs_conf();
     $aWFS->getallwfs(Mapbender::session()->get("mb_user_id"));
     $result = array();
     for ($i = 0; $i < count($aWFS->wfs_id); $i++) {
         // featuretypes
         $featuretypeArray = array();
         $aWFS->getfeatures($aWFS->wfs_id[$i]);
         for ($j = 0; $j < count($aWFS->features->featuretype_id); $j++) {
             // featuretype elements
             $ftElementArray = array();
             $aWFS->getelements($aWFS->features->featuretype_id[$j]);
             for ($k = 0; $k < count($aWFS->elements->element_id); $k++) {
                 $ftElementArray[] = array("id" => $aWFS->elements->element_id[$k], "name" => $aWFS->elements->element_name[$k], "type" => $aWFS->elements->element_type[$k]);
             }
             $featuretypeArray[] = array("id" => $aWFS->features->featuretype_id[$j], "name" => $aWFS->features->featuretype_name[$j], "srs" => $aWFS->features->featuretype_srs[$j], "elementArray" => $ftElementArray);
         }
         $result[] = array("id" => $aWFS->wfs_id[$i], "name" => $aWFS->wfs_name[$i], "title" => $aWFS->wfs_title[$i], "abstr" => $aWFS->wfs_abstract[$i], "getCapabilities" => $aWFS->wfs_getcapabilities[$i], "describeFeaturetype" => $aWFS->wfs_describefeaturetype[$i], "getFeature" => $aWFS->wfs_getfeature[$i], "featuretypeArray" => $featuretypeArray);
function getGuis()
{
    $adm = new administration();
    $guiList = $adm->getGuisByOwner(Mapbender::session()->get("mb_user_id"), 1);
    if (count($guiList) > 0) {
        return $guiList;
    }
    return false;
}
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# 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__) . "/../php/mb_validateSession.php";
require_once dirname(__FILE__) . "/../classes/class_json.php";
$e = new mb_notice("locale: " . Mapbender::session()->get("mb_locale") . "; lang: " . Mapbender::session()->get("mb_lang"));
setlocale(LC_ALL, Mapbender::session()->get("mb_locale"));
//
// Messages
//
$msg_obj = array();
$msg_obj["buttonLabelRectangle"] = _mb("select by rectangle");
$msg_obj["buttonLabelPolygon"] = _mb("select by polygon");
$msg_obj["buttonLabelPoint"] = _mb("select by point");
$msg_obj["buttonLabelExtent"] = _mb("select by extent");
$msg_obj["buttonLabelDialogue"] = _mb("open dialogue form");
$msg_obj["errorMessageInvalidExtent"] = _mb("Invalid box!");
$json = new Mapbender_JSON();
$output = $json->encode($msg_obj);
header("Content-type:application/x-json; charset=utf-8");
echo $output;
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# 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 dirname(__FILE__) . "/mb_validateSession.php";
$epsgObj = array();
$ajaxResponse = new AjaxResponse($_POST);
switch ($ajaxResponse->getMethod()) {
    case "changeEpsg":
        if (!Mapbender::postgisAvailable()) {
            $ajaxResponse->setSuccess(false);
            $ajaxResponse->setMessage(_mb("PostGIS is not available. Please contact the administrator."));
            $ajaxResponse->send();
        }
        $epsgArray = $ajaxResponse->getParameter("srs");
        $newSrs = $ajaxResponse->getParameter("newSrs");
        for ($i = 0; $i < count($epsgArray); $i++) {
            // check if parameters are valid geometries to
            // avoid SQL injections
            $currentEpsg = $epsgArray[$i];
            $oldEPSG = preg_replace("/EPSG:/", "", $currentEpsg->epsg);
            $newEPSG = preg_replace("/EPSG:/", "", $newSrs);
            $extArray = explode(",", $currentEpsg->extent);
            if (is_numeric($extArray[0]) && is_numeric($extArray[1]) && is_numeric($extArray[2]) && is_numeric($extArray[3]) && is_numeric($oldEPSG) && is_numeric($newEPSG)) {
                $con = db_connect($DBSERVER, $OWNER, $PW);
echo "<input type='hidden' size='30' name='resolution' value='" . htmlentities($resolution, ENT_QUOTES, "UTF-8") . "'>";
#   echo "</td>";
#echo "</tr>";
# blank row
echo "<tr>";
echo "<td colspan='2'>&nbsp;</td>";
echo "</tr>";
echo "<tr>";
echo "<td>&nbsp;</td>";
echo "<td>";
if ($selected_user == 'new' || !isset($selected_user)) {
    echo "<input type='button' value='save'  onclick='validate(\"save\")'>";
}
if (Mapbender::session()->get("mb_user_id") == $owner_id && $selected_user != 'new' && $selected_user != '') {
    echo "<input type='button' value='save'  onclick='validate(\"update\")'>";
    if ((!isset($editSelf) || !$editSelf) && intval(Mapbender::session()->get("mb_user_id")) !== intval($selected_user)) {
        echo "<input type='button' value='delete'  onclick='validate(\"delete\")'>";
    }
    if ($withPasswordInsertion != 'true') {
        echo "<input type='button' value='Send login data to user'  onclick='sendRegisterData();'>";
        echo "&nbsp;<input type='button' value='New password ticket'  onclick='validate(\"new_pw_ticket\");'>";
    }
}
echo "</td>";
echo "</tr>";
?>
<input type='hidden' name='action' value=''>
</table>
</form>
<script type="text/javascript">
<!--
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# 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.
?>
function mod_home_init(){
<?php 
require_once dirname(__FILE__) . "/../php/mb_validateSession.php";
echo "var url = '" . LOGIN . "';";
echo "var name = '" . urlencode(Mapbender::session()->get("mb_user_name")) . "';";
echo "var pw = '" . Mapbender::session()->get("mb_user_password") . "';";
?>
	
	var str = "<form name='myGuiList_form' method='POST' action='' target='_self'>";
	str += "<input type='hidden' name='name' value='"+name+"' />";
	str += "<input type='hidden' name='password' value='"+pw+"' />";
	str += "</form>";
	
	var mod_home_div = document.createElement('div');
	mod_home_div.setAttribute("id","mod_home_d");
	var tmp = document.body.appendChild(mod_home_div);
	document.getElementById("mod_home_d").innerHTML = str;
	document.forms.myGuiList_form.action = url;
	document.forms.myGuiList_form.submit();
	//document.location.href = url + "?name=" + name + "&password=" + pw;	
}
options.$target.each(function () {
	var map = $(this).mapbender();
	if (map && map.zoomToExtent) {
		var coordinates = '<?php 
echo Mapbender::session()->get("mb_myBBOX");
?>
';
		var c = coordinates.split(",");
		if (c.length === 4) {
			var b =	new OpenLayers.Bounds();
			b.extend(new OpenLayers.LonLat(
				parseFloat(c[0], 10),
				parseFloat(c[1], 10)
			));
			b.extend(new OpenLayers.LonLat(
				parseFloat(c[2], 10),
				parseFloat(c[3], 10)
			));
			map.mapbenderEvents.mapReady.register(function () {
				map.zoomToExtent(b);
			});
		}
	}			
});
#$Header: /cvsroot/mapbender/mapbender/http/javascripts/mod_insertWmcIntoDb.php,v 1.19 2006/03/09 14:02:42 uli_rothstein Exp $
# Copyright (C) 2002 CCGIS
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# 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__) . "/../php/mb_validateSession.php";
require_once dirname(__FILE__) . "/../classes/class_json.php";
require_once dirname(__FILE__) . "/../classes/class_mb_exception.php";
$buttonObj = array();
$sql = "SELECT e_id, gettext(\$1, e_title) AS e_title FROM gui_element, " . "(SELECT v.var_value AS current_e_id FROM gui_element AS e, " . "gui_element_vars AS v WHERE e.e_id = v.fkey_e_id AND " . "e.fkey_gui_id = v.fkey_gui_id AND e.e_id = 'tabs' AND " . "v.var_name LIKE 'tab_ids%' AND e.fkey_gui_id = \$2) " . "AS gui_element_temp WHERE gui_element_temp.current_e_id = e_id " . "AND fkey_gui_id = \$3";
$v = array(Mapbender::session()->get("mb_lang"), Mapbender::session()->get("mb_user_gui"), Mapbender::session()->get("mb_user_gui"));
$t = array("s", "s", "s");
$res = db_prep_query($sql, $v, $t);
while ($row = db_fetch_array($res)) {
    array_push($buttonObj, array("id" => $row["e_id"], "title" => $row["e_title"]));
}
$json = new Mapbender_JSON();
$output = $json->encode($buttonObj);
header("Content-type:text/plain; charset=utf-8");
echo $output;
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
ob_start();
//
// constants
//
require_once dirname(__FILE__) . "/../core/system.php";
//
// initiates the session-handling
//
session_start();
if (defined("SESSION_NAME") && is_string(SESSION_NAME)) {
    session_name(SESSION_NAME);
}
//
// Basic Mapbender classes, for session handling etc.
//
require_once dirname(__FILE__) . "/../lib/class_Mapbender.php";
//
// define LC_MESSAGES if unknown (for Windows platforms)
//
if (!defined("LC_MESSAGES")) {
    define("LC_MESSAGES", LC_CTYPE);
}
//
// I18n wrapper function, gettext
//
require_once dirname(__FILE__) . "/../core/i18n.php";
require_once dirname(__FILE__) . "/../http/classes/class_locale.php";
$localeObj = new Mb_locale(Mapbender::session()->get("mb_lang"));
echo "</tr>";
#logo
echo "<tr>";
echo "<td>Logo: </td>";
echo "<td>";
echo "<input type='text' size='30' name='logo_path' value='" . htmlentities($logo_path, ENT_QUOTES, "UTF-8") . "'>";
echo "</td>";
echo "</tr>";
# blank row
echo "<tr>";
echo "<td colspan='2'>&nbsp;</td>";
echo "</tr>";
# send form
echo "<tr>";
echo "<td>&nbsp;</td>";
echo "<td>";
if ($selected_group == 'new' || !isset($selected_group)) {
    echo "<input type='button' value='save'  onclick='validate(\"save\")'>";
}
if (Mapbender::session()->get("mb_user_id") == $owner_id && $selected_group != 'new' && $selected_group != '') {
    echo "<input type='button' value='save'  onclick='validate(\"update\")'>";
    echo "<input type='button' value='delete'  onclick='validate(\"delete\")'>";
}
echo "</td>";
echo "</tr>";
echo "</table>";
?>
<input type='hidden' name='action' value=''>
</form>
</body>
</html>
  	<!--
  	body{
      background-color: #ffffff;
  		font-family: Arial, Helvetica, sans-serif;
  		font-size : 12px;
  		color: #808080
  	}
  	
  	-->
</style>
</head>
<body>

<?php 
$logged_user_name = Mapbender::session()->get("mb_user_name");
$logged_user_id = Mapbender::session()->get("mb_user_id");
###delete
if ($del != '-1') {
    $sql = "DELETE FROM wfs WHERE wfs_id = '" . $del . "'";
    $res = db_query($sql);
}
//adopted for owned wfs and not all!!!!!!
$sql_wfs = "SELECT * FROM wfs ";
$sql_wfs .= " where wfs_owner=" . $_SESSION["mb_user_id"] . " ORDER BY wfs_name";
$res_wfs = db_query($sql_wfs);
$cnt_wfs = 0;
echo "<form name='form1' action='' method='post'>";
//" . $_SERVER["SCRIPT_NAME"] . "?".SID."
echo "<br><b>WFS List: <b><br><br>";
echo "<select class='wfsList' size='20' name='wfsList'  onchange='sel();'>";
//var wfsInfo = this.value.split(\"###\");document.form1.wfsList.value=wfsInfo[0];
 $mywms->updateObjInDB($myWMS);
 $mywms->displayWMS();
 // start (owners of the updated wms will be notified by email)
 if ($use_php_mailing) {
     $owner_ids = $admin->getOwnerByWms($myWMS);
     if ($owner_ids && count($owner_ids) > 0) {
         $owner_mail_addresses = array();
         $j = 0;
         for ($i = 0; $i < count($owner_ids); $i++) {
             $adr_tmp = $admin->getEmailByUserId($owner_ids[$i]);
             if (!in_array($adr_tmp, $owner_mail_addresses) && $adr_tmp) {
                 $owner_mail_addresses[$j] = $adr_tmp;
                 $j++;
             }
         }
         $replyto = $admin->getEmailByUserId(Mapbender::session()->get("mb_user_id"));
         $from = $replyto;
         $pathArray = explode("http/php/", $_SERVER["PATH_TRANSLATED"]);
         $path = $pathArray[0];
         $body = "WMS '" . $admin->getWmsTitleByWmsId($myWMS) . "' has been updated. \n\nServer name:  " . $_SERVER["SERVER_NAME"] . "\nInstallation Path: " . $path . "\n\nYou may want to check the changes as you are an owner of this WMS.";
         $error_msg = "";
         for ($i = 0; $i < count($owner_mail_addresses); $i++) {
             if (!$admin->sendEmail($replyto, $from, $owner_mail_addresses[$i], $owner_mail_addresses[$i], "[Mapbender] A user has updated one of your WMS", $body, $error)) {
                 if ($error) {
                     $error_msg .= $error . " ";
                 }
             }
         }
         if (!$error_msg) {
             echo "<script language='javascript'>";
             echo "alert('Other owners of this WMS have been informed about the changes!');";