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.
'; echo 'Parameter wmc_id is not valid (integer_integer or integer).
'; 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.
'; echo 'Parameter pointRadius is not valid (integer).
'; 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.
'; echo 'Parameter fillColor is not valid (html color code).
'; 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.
'; echo 'Parameter
markerUrl
is not valid.
'; die(); } $fillColor = $testMatch; $testMatch = NULL; } //************************************************************************** //functions which may be integrated from class_administration function getWmsGetMapUrl($wmsId){ $sql = "SELECT wms_getmap 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)){ return $row['wms_getmap']; } else { return false; } } //Function to pull layer names from database. They may have been updated since the wmc have been saved! function getLayerNames($wmsId){ $sql = "SELECT layer_id, layer_name FROM layer WHERE fkey_wms_id = $1"; $v = array($wmsId); $t = array("i"); $res = db_prep_query($sql,$v,$t); while($row = db_fetch_array($res)){ $layerNames[$row["layer_id"]] = $row["layer_name"]; } if (count($layerNames) > 0) { return $layerNames; } else { return false; } } //end of functions which may 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){ //$myWmc = new wmc(); global $user; global $userId; global $admin; //Get WMC out of mb Database $sql = "SELECT wmc, wmc_serial_id FROM mb_user_wmc WHERE wmc_serial_id = $1"; $res = db_prep_query($sql, array($wmc_id), array("s")); $wmc = db_fetch_row($res); //control if wmc was found else use old wmc_id if (!$wmc[0]) { $sql = "SELECT wmc, wmc_serial_id FROM mb_user_wmc WHERE wmc_id = $1"; $res = db_prep_query($sql, array($wmc_id), array("s")); $wmc = db_fetch_row($res); //echo "Wmc with this id was not found in Database!
"; //die; } //generate wmc object and update urls of services in this object: $wmcId = $wmc[1]; //$myWmc->createFromDb($wmcId); //$updatedWmc = $myWmc->updateUrlsFromDb();//TODO: check why this functions need a session?? //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.="\n"; $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_notice('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"; } } //******************************* //placeholder for use constraints //echo " "; $html.="
\n"; $html.="\n"; $html.="
\n"; //Show coords if wished if($_REQUEST["mb_showCoords"]=='1'){ //$html.="
Koordinaten in ".$xml->General->BoundingBox['SRS'].":
\n"; //only for geoportal.rlp $html.="
Koordinaten in ".$xml->General->BoundingBox['SRS'].":
\n"; } $html.="
\n"; $html.="
\n"; if ($_REQUEST['withoutBody'] == '1') { } else { $html.="\n"; $html.="\n"; } //Print out HTML code echo $html; } //end of function createOlfromWMC_id() createOlfromWMC_id($_GET["wmc_id"], $pointRadius, $fillColor); if (strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST']) === false) { $admin->logClientUsage($_SERVER['HTTP_REFERER'], $wmc_id, 1); } ?>