encode($resObj);
die;
}
$command = $_POST["command"];
$pattern = "/[a-z]/i";
if (!preg_match($pattern, $command)) {
sendErrorMessage("Invalid command " . htmlentities($command, ENT_QUOTES, CHARSET));
}
switch ($command) {
case "getHtml" :
getHtmlForm();
break;
case "searchGemeinden" :
startSearch($command);
break;
case "searchStrassen" :
startSearch($command);
break;
case "searchHauskoordinaten" :
startSearch($command);
break;
case "searchPlz" :
startSearch($command);
break;
default :
getHtmlForm();
break;
}
function getHtmlForm() {
$htmlFormString = "
";
echo $htmlFormString;
}
function startSearch($command) {
$wfsUrl = $_POST["wfsUrl"];
$pattern = "/^(http(s?):\/\/{1})((\w+\.){1,})\w{2,}(\/?)$/i";
$searchString = $_POST["searchFor"];
$pattern = "/[a-z0-9]/i";
if (!preg_match($pattern, $searchString)) {
sendErrorMessage("Invalid searchString " . htmlentities($searchString, ENT_QUOTES, CHARSET));
}
$searchFeaturetype = $_POST["searchFeaturetype"];
$pattern = "/[a-z0-9]/i";
if (!preg_match($pattern, $searchFeaturetype)) {
sendErrorMessage("Invalid searchFeaturetype " . htmlentities($searchFeaturetype, ENT_QUOTES, CHARSET));
}
$admin = new administration();
$searchConditions = explode("|", $searchString);
$propertyConditions = "";
for ($i = 0; $i < count($searchConditions);$i++) {
$conditionParams = explode("=",$searchConditions[$i]);
if($command == "searchHauskoordinaten" || $command == "searchPlz") {
$propertyConditions .= '
' . $conditionParams[0] . '
' . $conditionParams[1] . '
';
}
else {
$propertyConditions .= '
' . $conditionParams[0] . '
' . $conditionParams[1] . '*
';
}
}
if(count($searchConditions) > 1) {
$propertyConditionsString = "" . $propertyConditions . "";
}
else {
$propertyConditionsString = $propertyConditions;
}
$filter = '
' . utf8_encode($propertyConditionsString) . '
';
$admin = new administration();
$filter = $admin->char_decode(stripslashes($filter));
$connection = new connector();
$connection->set("httpType", "post");
$connection->set("httpContentType", "xml");
$connection->set("httpPostData", $filter);
$data = $connection->load($wfsUrl);
if ($data === null) die('{}');
$gml = new gml2();
$geoJson = $gml->parseXML($data);
header("Content-type:application/json; charset=utf-8");
echo $geoJson;
#$e = new mb_exception($filter);
#$wfsUrl = $wfsUrl . "/services?REQUEST=GetFeature&SERVICE=WFS&VERSION=1.1.0&MAXFEATURES=5&TYPENAME=" . $featuretypeGemeinden . "&filter="; #REQUEST=GetFeature&SERVICE=WFS&VERSION=1.1.0&MAXFEATURES=5&TYPENAME=" . $featuretypeGemeinden . "&
//$wfsUrl = $wfsUrl . "/services&filter=";
//$req = urldecode($wfsUrl).urlencode($admin->char_decode(stripslashes($filter)));
//$e = new mb_exception($req);
//$mygml = new gml2();
#$auth = array();
#$auth['username'] = $authUserName;
#$auth['password'] = $authUserPassword;
#$auth['auth_type'] = "basic";
#$mygml->parseFile($req);
#print_r($mygml); die;
#header("Content-type:application/x-json; charset=utf-8");
#echo $mygml->toGeoJSON();
}
?>