get("mb_user_id");
//check for parameter wmc_id
if(!isset($_GET["wmc_id"])){
echo 'Error: wmc_id not requested ';
die();
//must leave script
}
function _e ($str) {
return htmlentities($str, ENT_QUOTES, CHARSET);
}
if (!$userId) {
$userId = PUBLIC_USER;
}
if (isset($_REQUEST["wmc_id"]) & $_REQUEST["wmc_id"] != "") {
//validate to csv integer list
$testMatch = $_REQUEST["wmc_id"];
$pattern = '/^[0-9_]*$/';
if (!preg_match($pattern,$testMatch)){
echo 'wmc_id: '.$testMatch.' is not valid. ';
die();
}
$wmc_id = $testMatch;
$testMatch = NULL;
}
//dummy parameter for drawing georss points:
$pointRadius = "10";
$fillColor = "#666666"; //grey
if (isset($_REQUEST["pointRadius"]) & $_REQUEST["pointRadius"] != "") {
//validate to csv integer list
$testMatch = $_REQUEST["pointRadius"];
$pattern = '/^[0-9]{2}|^[1-9]{1}$/';
if (!preg_match($pattern,$testMatch)){
echo 'pointRadius: '.$testMatch.' is not valid. ';
die();
}
$pointRadius = $testMatch;
$testMatch = NULL;
}
if (isset($_REQUEST["fillColor"]) & $_REQUEST["fillColor"] != "") {
//validate to csv integer list
$testMatch = $_REQUEST["fillColor"];
$pattern = '/^#[0-9a-f]{3}|#[0-9a-f]{6}$/';
if (!preg_match($pattern,$testMatch)){
echo 'fillColor: '.$testMatch.' is not valid. ';
die();
}
$fillColor = $testMatch;
$testMatch = NULL;
}
if (isset($_REQUEST["markerUrl"]) & $_REQUEST["markerUrl"] != "") {
//validate to csv integer list
$testMatch = $_REQUEST["markerUrl"];
$pattern = '/^[\d,]*$/';
if (!preg_match($pattern,$testMatch)){
echo 'markerUrl: '.$testMatch.' is not valid. ';
die();
}
$fillColor = $testMatch;
$testMatch = NULL;
}
//the next functions should come from class administration, but they are not included as they are needed
//TODO
function getLayerPermission($wms_id, $layer_id, $user_id){
//$layer_id = $this->getLayerIdByLayerName($wms_id,$layer_name);
$array_guis = getGuisByPermission($user_id,true);
$v = array();
$t = array();
$sql = "SELECT * FROM gui_layer WHERE fkey_gui_id IN (";
$c = 1;
//generate guilist assigned to specific user
for($i=0; $i0){ $sql .= ",";}
$sql .= "$".$c;
$c++;
array_push($v, $array_guis[$i]);
array_push($t, 's');
}
$sql .= ") AND fkey_layer_id = $".$c." AND gui_layer_status = 1"; //status 1 must be
array_push($v,$layer_id);
array_push($t,'i');
$res = db_prep_query($sql,$v,$t);
if($row = db_fetch_array($res)){
return true;
}
else{
return false;
}
}
function getGuisByPermission($mb_user_id,$ignoreublic){
$arrayGuis = array();
$mb_user_groups = array();
$sql_groups = "SELECT fkey_mb_group_id FROM mb_user_mb_group WHERE fkey_mb_user_id = $1 ";
$v = array($mb_user_id);
$t = array("i");
$res_groups = db_prep_query($sql_groups,$v,$t);
$cnt_groups = 0;
while($row = db_fetch_array($res_groups)){
$mb_user_groups[$cnt_groups] = $row["fkey_mb_group_id"];
$cnt_groups++;
}
if($cnt_groups > 0){
$v = array();
$t = array();
$sql_g = "SELECT gui.gui_id FROM gui JOIN gui_mb_group ";
$sql_g .= " ON gui.gui_id = gui_mb_group.fkey_gui_id WHERE gui_mb_group.fkey_mb_group_id IN (";
for($i=0; $i 0){$sql_g .= ",";}
$sql_g .= "$".strval($i+1);
array_push($v,$mb_user_groups[$i]);
array_push($t,"i");
}
$sql_g .= ") GROUP BY gui.gui_id";
$res_g = db_prep_query($sql_g,$v,$t);
while($row = db_fetch_array($res_g)){
array_push($arrayGuis,$row["gui_id"]);
}
}
$sql_guis = "SELECT gui.gui_id FROM gui JOIN gui_mb_user ON gui.gui_id = gui_mb_user.fkey_gui_id";
$sql_guis .= " WHERE (gui_mb_user.fkey_mb_user_id = $1) ";
if (!isset($ignore_public) OR $ignore_public== false){
$sql_guis .= " AND gui.gui_public = 1 ";
}
$sql_guis .= " GROUP BY gui.gui_id";
$v = array($mb_user_id);
$t = array("i");
$res_guis = db_prep_query($sql_guis,$v,$t);
$guis = array();
while($row = db_fetch_array($res_guis)){
if(!in_array($row['gui_id'],$arrayGuis)){
array_push($arrayGuis,$row["gui_id"]);
}
}
return $arrayGuis;
}
//end of functions which m,ay be included from class_administration in next versions
#**************************************************************************
//Function to create an OpenLayers Javascript from a mapbender wmc document
function createOlFromWMC_id($wmc_id, $pointRadius, $fillColor){
global $userId;
//Get WMC out of mb Database
$sql = "SELECT wmc FROM mb_user_wmc WHERE wmc_serial_id = $1";
$res = db_prep_query($sql, array($wmc_id), array("s"));
$wmc = db_fetch_row($res);
//Read out WMC into XML object
$xml=simplexml_load_string($wmc[0], "SimpleXMLElement", LIBXML_NOBLANKS);
if ($_REQUEST['withoutBody'] == '1') {
} else {
//generate general html data
$html='';
$html.="\n";
$html.="\n";
}
//define global variables for extent out of WMC File
$windowWidth=$xml->General->Window->attributes()->width;
$windowHeight=$xml->General->Window->attributes()->height;
$htmlWidth=$windowWidth+40;
$htmlHeight=$windowHeight+70;
//define CSS
$html.="\n";
//don't show any html, title and/or body tag when integrate it into external website
if ($_REQUEST['withoutBody'] == '1') {
} else {
//Generate Title
$html.="".$xml->General->Title."\n";
}
//include OL libs from local source - must be minimized, for new functions use the newest openlayers lib - directly from ol site
$e = new mb_exception('georss request : '.$_REQUEST['GEORSS']);
if(isset($_REQUEST["withDigitize"]) or isset($_REQUEST["GEORSS"])){
if(($_REQUEST["withDigitize"]=='1') or ($_REQUEST["GEORSS"]!='')){
$html.="\n";
#$html.="\n";
}
} else {
//use the minimized version
//$html.="\n";
$html.="\n"; //TODO minimize this or use other lib
}
//begin part for javascript code
$html.="\n";
if ($_REQUEST['withoutBody'] == '1') {
} else {
$html.=" \n";
$html.="\n";
}
$html.="\n";
$html.="\n";//class dont exists
//show textareas with coordinates which are digitized
if(isset($_REQUEST["withDebug"])){
if($_REQUEST["withDebug"]=='1'){
$html.="\n";
$html.="\n";
}
}
//*******************************
//echo "";
$html.="
\n";
$html.="\n";
$html.="
\n";
//Show coords if wished
if($_REQUEST["mb_showCoords"]=='1'){
//$html.="