誤ったレスポンスコードを修正&追加・サーバー停止時にAPIでは専用のJSONを返答するように変更

This commit is contained in:
Last2014 2025-09-05 18:37:48 +09:00
parent 18f1a957b9
commit 00c7c8787b
6 changed files with 18 additions and 5 deletions

View File

@ -26,6 +26,7 @@ ErrorDocument 403 /errorpage/httperror.php
ErrorDocument 404 /errorpage/httperror.php
ErrorDocument 413 /errorpage/httperror.php
ErrorDocument 500 /errorpage/httperror.php
ErrorDocument 502 /errorpage/httperror.php
ErrorDocument 503 /errorpage/httperror.php
# --- セキュリティヘッダ ---

View File

@ -58,7 +58,9 @@ if(isset($_GET['token']) || (!(empty($Get_Post_Json)))) {
$response = array(
'error_code' => "critical_error_userdata_not_found",
);
http_response_code(500);
}else{
http_response_code(200);
$roles = explode(',', $userdata["role"]);
if(!(empty($roles))){
foreach ($roles as $roleId) {
@ -87,7 +89,7 @@ if(isset($_GET['token']) || (!(empty($Get_Post_Json)))) {
$role[] = $roleinfo;
}
}else{
$role[] = "";
$role = [];
}
if(!(empty($userdata["sacinfo"]))){

View File

@ -98,7 +98,7 @@ if(isset($_GET['session']) || (!(empty($Get_Post_Json)))) {
'error_code' => $err,
'success' => false
);
http_response_code(401);
http_response_code(400);
echo json_encode($response, JSON_UNESCAPED_UNICODE);
}
?>

View File

@ -74,7 +74,9 @@ if(isset($_GET['token']) || (!(empty($Get_Post_Json)))) {
$response = array(
'error_code' => "critical_error_userdata_not_found",
);
http_response_code(400);
}else{
http_response_code(200);
$roles = explode(',', $userdata["role"]);
if(!(empty($roles))){
foreach ($roles as $roleId) {
@ -103,7 +105,7 @@ if(isset($_GET['token']) || (!(empty($Get_Post_Json)))) {
$role[] = $roleinfo;
}
}else{
$role[] = "";
$role = [];
}
if(!(empty($userdata["sacinfo"]))){

View File

@ -0,0 +1,4 @@
{
"success": false,
"error_code": "server_down"
}

View File

@ -143,8 +143,12 @@ if( !empty($_POST['serverstop_btn_submit']) ) {
// htaccess用意
$htaccess = "
ErrorDocument 403 /errorpage/serverstop.php
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/api/.*$
RewriteRule ^.*$ /errorpage/serverstop.json [R=500,L]
ErrorDocument 403 /errorpage/serverstop.php
RewriteCond %{REQUEST_URI} !=/function/function.php
RewriteCond %{REQUEST_URI} !=/errorpage/serverstop.php
RewriteCond %{REQUEST_URI} !=/css/home.css
@ -244,4 +248,4 @@ require('../logout/logout.php');
}
});
});
</script>
</script>