diff --git a/whois/port43/start_whois.php b/whois/port43/start_whois.php index d717837..dde54c2 100644 --- a/whois/port43/start_whois.php +++ b/whois/port43/start_whois.php @@ -111,7 +111,13 @@ $server->on('receive', function ($server, $fd, $reactorId, $data) use ($c, $pool // Extract TLD from the domain and prepend a dot $parts = explode('.', $domain); - $tld = "." . end($parts); + + // Handle multi-segment TLDs (e.g., co.uk, ngo.us, etc.) + if (count($parts) > 2) { + $tld = "." . $parts[count($parts) - 2] . "." . $parts[count($parts) - 1]; + } else { + $tld = "." . end($parts); + } // Check if the TLD exists in the domain_tld table $stmtTLD = $pdo->prepare("SELECT COUNT(*) FROM domain_tld WHERE tld = :tld");