'Home page')); exit(); } // 验证输入是否符合预期格式 elseif (!preg_match('/^[a-zA-Z0-9_]+$/', $api_class) || !preg_match('/^[a-zA-Z0-9_]+$/', $api)) { header("Content-Type: application/json"); http_response_code(400); // Bad Request echo json_encode(array('error' => 'Invalid input')); exit(); } // 构建文件路径 $file_path = 'includes/' . $api_class . '/' . $api . '.php'; // 检查文件是否存在 if (!file_exists($file_path)) { header("Content-Type: application/json"); http_response_code(404); // Not Found echo json_encode(array('error' => '404 Not Found', 'message' => 'The requested resource could not be found')); exit(); } // 如果不是 public API,则启用路由 if ($api_class != 'public') { header("Content-Type: application/json"); include 'core/router.php'; } else { header("Content-Type: application/json"); } // 包含文件 include $file_path; ?>