applyManualStatus((int)$instanceId, $status, $reason, (int)$userId); if (isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false) { header('Content-Type: application/json'); echo json_encode(['message' => 'Status updated successfully.']); } else { header('Location: index.php'); } exit;