<?php
require_once '../../config.php';

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $id = trim($_POST['id']);

    if (empty($id)) {
        echo json_encode(['success' => 0, 'message' => 'DNS zone ID is required.']);
        exit;
    }

    // Sanitize variable to prevent SQL injection
    $id = $db->escape_string($id);

    // Delete the record
    $delete_query = "DELETE FROM evp_dnsbl WHERE id = '$id'";
    $delete_result = $db->delete($delete_query);

    if ($delete_result === false) {
        echo json_encode(['success' => 0, 'message' => 'Failed to delete DNSBL record.']);
        exit;
    }

    echo json_encode(['success' => 1, 'message' => 'DNSBL record deleted successfully.']);
}
?>
