Added Borderpoint status to Preorder
This commit is contained in:
@@ -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]);
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user