FIX: addressdb/preorder API now uses gemeinde as City
This commit is contained in:
@@ -79,7 +79,7 @@ class mfBaseApicontroller {
|
||||
|
||||
private function logRequest() {
|
||||
$this->requestLog->debug("==================================================================");
|
||||
$this->requestLog->debug("new API request for ".$_SERVER['REQUEST_URI']);
|
||||
$this->requestLog->debug("new API request for ".$_SERVER['REQUEST_URI']. " from ".$_SERVER['REMOTE_ADDR']);
|
||||
$this->requestLogstr = "";
|
||||
foreach($_GET as $key => $value) {
|
||||
$this->requestLogstr .= "; $key='$value'";
|
||||
@@ -93,6 +93,7 @@ class mfBaseApicontroller {
|
||||
$this->requestLog->debug("POST: ".print_r($_POST, true));
|
||||
}
|
||||
|
||||
// things to log after loadRequest()
|
||||
private function logRequest2() {
|
||||
$this->requestLog->debug("POST Raw: ".$this->raw_post_body);
|
||||
$this->requestLog->debug("POST JSON: ".$this->request_json);
|
||||
@@ -182,13 +183,39 @@ class mfBaseApicontroller {
|
||||
}
|
||||
|
||||
private function getRequestBody() {
|
||||
$this->raw_post_body = file_get_contents('php://input');
|
||||
if(strtolower($this->headers['content-type']) == "application/json") {
|
||||
return $this->raw_post_body;
|
||||
$request_charset = "utf-8";
|
||||
if(preg_match('#application/json#i', $_SERVER["CONTENT_TYPE"])) {
|
||||
// request body is JSON
|
||||
$request_body = file_get_contents('php://input');
|
||||
|
||||
$m = [];
|
||||
|
||||
if(preg_match('#charset\s*=\s*["\']?([^ "\']+)["\']?\s*;?#i', $_SERVER["CONTENT_TYPE"], $m)) {
|
||||
$request_charset = strtolower($m[1]);
|
||||
}
|
||||
|
||||
if($request_charset != "utf-8") {
|
||||
$request_body = mb_convert_encoding($request_body, "utf-8", $request_charset);
|
||||
}
|
||||
//var_dump(mb_detect_encoding($request_body), $charset);
|
||||
return $request_body;
|
||||
}
|
||||
|
||||
return $_POST;
|
||||
// Request body is urlencoded or multipart-formdata
|
||||
if(preg_match('#charset\s*=\s*["\']?([^ "\']+)["\']?\s*;?#i', $_SERVER["CONTENT_TYPE"], $m)) {
|
||||
$request_charset = strtolower($m[1]);
|
||||
}
|
||||
|
||||
$post = [];
|
||||
if($request_charset == "utf-8") {
|
||||
$post = $_POST;
|
||||
} else {
|
||||
foreach($_POST as $key => $value) {
|
||||
$post[mb_convert_encoding($key, "utf-8", $request_charset)] = mb_convert_encoding($value, "utf-8", $request_charset);
|
||||
}
|
||||
}
|
||||
|
||||
return $post;
|
||||
}
|
||||
|
||||
protected function return($response) {
|
||||
|
||||
Reference in New Issue
Block a user