0) return substr($s,$c+1); return $s; } function sendToHost($host,$port,$method,$path,$data){ $buf = ''; if (empty($method)) $method = 'POST'; $method = strtoupper($method); $fp = fsockopen($host, $port); fputs($fp, "$method $path HTTP/1.1\r\n"); fputs($fp, "Host: $host\r\n"); fputs($fp,"Content-type: application/xml\r\n"); fputs($fp, "Content-length: " . strlen($data) . "\r\n"); fputs($fp, "Connection: close\r\n\r\n"); if ($method == 'POST') fputs($fp, $data); while (!feof($fp)) $buf .= fgets($fp,4096); fclose($fp); return $buf; } $result=""; $error = false; $arURL = parse_url($_REQUEST["url"]); $host = $arURL["host"]; $port = $arURL["port"]; if($port == '') $port = 80; $path = $arURL["path"]; $method = "POST"; $filter = stripslashes($_REQUEST["filter"]); $data = sendToHost($host,$port,$method,html_entity_decode($path),$filter); $data = eregi_replace("^[^<]*", "", $data); $data = eregi_replace("[^>]*$", "", $data); /* $parser = xml_parser_create(CHARSET); xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0); xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,1); xml_parser_set_option($parser,XML_OPTION_TARGET_ENCODING,CHARSET); xml_parse_into_struct($parser,$data,$values,$tags); $code = xml_get_error_code ($parser); if ($code) { $result = "Error " . $code . " (" . xml_error_string($code) . ")"; $error = true; } xml_parser_free($parser); if (!$error) { $section; foreach ($values as $element) { $element[tag] = sepNameSpace($element[tag]); if(strtoupper($element[tag]) == "SERVICEEXCEPTIONREPORT" && $element[type] == "open"){ $section = "serviceexceptionreport"; } if ($section == "serviceexceptionreport" && strtoupper($element[tag]) == "SERVICEEXCEPTION") { // $result = $element[value]; $result = "An error occured."; $error = true; } if(strtoupper($element[tag]) == "STATUS" && $element[type] == "open"){ $section = "status"; } if ($section == "status" && strtoupper($element[tag]) == "SUCCESS") { $result = "Success."; $error = false; } } } if ($error) { $e = new mb_exception('WFS error at: host: '.$host.' port: '.$port.' filter: '.$_REQUEST["filter"].' - error message: '.$result); } else { $e = new mb_exception('WFS successfull host: '.$host.' port: '.$port.' filter: '.$_REQUEST["filter"]); } */ $e = new mb_exception('WFS-T: '.$filter); echo "{"; if (stristr($data, "success") !== false) { $response = "success"; if (ereg("^.*ogc:FeatureId fid=\"(.+)\"/>.*$", $data)) { $fid = ereg_replace("^.*ogc:FeatureId fid=\"(.+)\"/>.*$", "\\1", $data); echo "\"fid\":\"".$fid."\","; } echo "\"success confirmation\":\"".str_replace("\"", "'", str_replace("\n", "", str_replace("\r", "", $data)))."\","; } else { $response = "error"; echo "\"error message\":\"".addslashes($data)."\","; } echo "\"response\":\"".$response."\"}"; ?>