<?php
header('Content-Type: application/json');
// Get query parameters
$domain = isset($_GET['domain']) ? trim($_GET['domain']) : '';$tld = isset($_GET['tld']) ? trim($_GET['tld']) : '';
if (empty($domain) \vert{}\vert{} empty($tld)) {
echo json_encode(['error' => 'Missing parameters']);
exit;
}
// Clean input
$domain = preg_replace('/[^a-zA-Z0-9-]/', '', $domain);$fullDomain = $domain . '.' .$tld;
// Famous global brand check simulation or actual DNS check
$famousTaken = ['google', 'facebook', 'microsoft', 'apple', 'amazon', 'netflix', 'github'];$isTaken = false;
if (in_array(strtolower($domain), $famousTaken)) {$isTaken = true;
} else {
// Check DNS record (A orAAAA or MX) to verify registration status
// If checkdnsrr returns true, the domain has active nameservers/DNS setup (Taken)
$isTaken = checkdnsrr($fullDomain, 'ANY');
}
echo json_encode([
'domain' => $fullDomain,
'status' => $isTaken ? 'taken' : 'available'
]);
?>