false, 'error' => '无权限']); exit; } $input = json_decode(file_get_contents('php://input'), true); if ($input && isset($input['image_id']) && isset($input['is_public'])) { try { $stmt = $pdo->prepare("UPDATE images SET is_public = ? WHERE id = ?"); $stmt->execute([$input['is_public'], $input['image_id']]); echo json_encode(['success' => true]); } catch(PDOException $e) { echo json_encode(['success' => false, 'error' => $e->getMessage()]); } } else { echo json_encode(['success' => false, 'error' => '无效请求']); } ?>