]*>)(.*)()"; $replacement = "\\1\\2" . $element_name . "" . $user . "\\3"; $filter = mb_eregi_replace($pattern, $replacement, $filter); } else { $e = new mb_exception("mod_wfs_gazetteer_server: checkAccessConstraint: invalid value of variable containing user information!"); } } else { $e = new mb_exception("mod_wfs_gazetteer_server: checkAccessConstraint: var name is not valid! (" . $auth_varname . ")"); } } return $filter; } if ($command == "getWfsConf") { $wfsConfIdString = $_GET["wfsConfIdString"]; $user = new User($_SESSION["mb_user_id"]); if ($wfsConfIdString != "") { //array_keys(array_flip()) produces an array with unique entries $wfsConfIdArray = array_keys(array_flip(mb_split(",", $wfsConfIdString))); $availableWfsConfIds = $user->getWfsConfByPermission($_SESSION["gui_id"]); $wfsConfIdArray = array_intersect($wfsConfIdArray, $availableWfsConfIds); if (count($wfsConfIdArray) === 0) { echo "no wfs conf available."; die(); } } else { echo "please specify wfs conf id."; die(); } $obj = new WfsConf(); $obj->load($wfsConfIdArray); $json = new Mapbender_JSON(); $output = $json->encode($obj->confArray); echo $output; } elseif ($command == "getWfsConfsForThisApplication") { $user = new User($_SESSION["mb_user_id"]); // get all WFS conf IDs for this application $availableWfsConfIds = $user->getWfsConfByPermission($_SESSION["gui_id"]); $obj = new WfsConf(); $obj->load($availableWfsConfIds); $json = new Mapbender_JSON(); $output = $json->encode($obj->confArray); echo $output; } else if ($command == "getSearchResults") { $wfs_conf_id = $_REQUEST["wfs_conf_id"]; $backlink = $_REQUEST["backlink"]; $frame = $_REQUEST["frame"]; $filter = $_REQUEST["filter"]; $url = $_REQUEST["url"]; $typename = $_REQUEST["typename"]; $destSrs = $_REQUEST["destSrs"]; $wfsConf = WfsConfiguration::createFromDb($wfs_conf_id); if (is_null($wfsConf)) { sendErrorMessage("Invalid WFS conf: " . $wfs_conf_id); } // append authorisation condition to filter $filter = checkAccessConstraint($filter, $wfs_conf_id); $admin = new administration(); $filter = $admin->char_decode(stripslashes($filter)); $wfsId = $wfsConf->wfsId; $myWfsFactory = new UniversalWfsFactory(); $myWfs = $myWfsFactory->createFromDb($wfsId); $data = $myWfs->getFeature($typename, $filter,$destSrs); if ($data === null) die('{}'); // $geomColumn = WfsConf::getGeomColumnNameByConfId($wfs_conf_id); $gmlFactory = new UniversalGmlFactory(); $myGml = $gmlFactory->createFromXml($data, $wfsConf); if (!is_null($myGml)) { $geoJson = $myGml->toGeoJSON(); } else { $geoJson = "{}"; } header("Content-type:application/x-json; charset=utf-8"); echo $geoJson; } else { echo "please enter a valid command."; } ?>