Merge branch 'fronkdev' into 'master'

Added Borderpoint status to Preorder

See merge request fronk/thetool!1311
This commit is contained in:
Frank Schubert
2025-05-07 16:33:42 +00:00
9 changed files with 336 additions and 143 deletions

View File

@@ -233,9 +233,9 @@ class mfBaseApicontroller {
//var_dump(mb_detect_encoding($request_body), $charset);
return $request_body;
}
// Request body is urlencoded or multipart-formdata
if(preg_match('#charset\s*=\s*["\']?([^ "\']+)["\']?\s*;?#i', $_SERVER["CONTENT_TYPE"], $m)) {
if(array_key_exists("CONTENT_TYPE", $_SERVER) && preg_match('#charset\s*=\s*["\']?([^ "\']+)["\']?\s*;?#i', $_SERVER["CONTENT_TYPE"], $m)) {
$request_charset = strtolower($m[1]);
}

View File

@@ -318,14 +318,30 @@ class mfBaseController
return $url;
}
public static function returnJson($data)
public static function returnJson($response)
{
if (is_array($data)) {
if(mfResponse::isResponse($response)) {
$code = $response['code'];
$status = $response['status'];
$data = $response['data'];
$proto = "HTTP/1.0";
if($_SERVER["SERVER_PROTOCOL"]) {
$proto = $_SERVER["SERVER_PROTOCOL"];
}
header("$proto $code $status");
header("Content-type: application/json");
//http_response_code($code);
echo json_encode(["status" => $status, "result" => $data]);
exit;
}
if (is_array($response)) {
header("Content-Type: application/json");
echo json_encode($data);
echo json_encode($response);
exit;
} else {
throw new Exception("Data not an array");
throw new Exception("Response data not an array");
}
}