Updated RDAP server

This commit is contained in:
Pinga 2023-08-07 12:40:03 +03:00
parent 9fa131f52b
commit 1a561a2aa3

View file

@ -106,21 +106,24 @@ function handleDomainQuery($request, $response, $pdo, $domainName) {
// ... // ...
// Query 6: Get nameservers // Query 6: Get nameservers
$stmt6 = $pdo->prepare("SELECT `name` FROM `domain_host_map`,`host` WHERE `domain_host_map`.`domain_id` = :domain_id AND `domain_host_map`.`host_id` = `host`.`id`"); $stmt6 = $pdo->prepare("
SELECT host.name, host.id as host_id
FROM domain_host_map, host
WHERE domain_host_map.domain_id = :domain_id
AND domain_host_map.host_id = host.id
");
$stmt6->bindParam(':domain_id', $domainDetails['id'], PDO::PARAM_INT); $stmt6->bindParam(':domain_id', $domainDetails['id'], PDO::PARAM_INT);
$stmt6->execute(); $stmt6->execute();
$nameservers = $stmt6->fetchAll(PDO::FETCH_COLUMN, 0); $nameservers = $stmt6->fetchAll(PDO::FETCH_ASSOC);
// Construct the RDAP response in JSON format // Construct the RDAP response in JSON format
$rdapResponse = [ $rdapResponse = [
'objectClassName' => 'domain', 'rdapConformance' => [
'ldhName' => $domain, 'rdap_level_0',
'status' => $statuses, 'icann_rdap_response_profile_0',
'events' => [ 'icann_rdap_technical_implementation_guide_0',
['eventAction' => 'registration', 'eventDate' => $domainDetails['crdate']],
['eventAction' => 'expiration', 'eventDate' => $domainDetails['exdate']],
// ... Additional events ...
], ],
'objectClassName' => 'domain',
'entities' => [ 'entities' => [
[ [
'objectClassName' => 'entity', 'objectClassName' => 'entity',
@ -149,23 +152,39 @@ function handleDomainQuery($request, $response, $pdo, $domainName) {
], ],
// ... Additional entities for admin, tech ... // ... Additional entities for admin, tech ...
], ],
'events' => [
['eventAction' => 'registration', 'eventDate' => $domainDetails['crdate']],
['eventAction' => 'expiration', 'eventDate' => $domainDetails['exdate']],
// ... Additional events ...
],
'handle' => $domainDetails['id'] . '',
'ldhName' => $domain,
'status' => $statuses,
'links' => [ 'links' => [
[ [
'value' => 'http://example.com/rdap/domain/' . $domain,
'rel' => 'self',
'href' => 'http://example.com/rdap/domain/' . $domain, 'href' => 'http://example.com/rdap/domain/' . $domain,
'rel' => 'self',
'type' => 'application/rdap+json', 'type' => 'application/rdap+json',
], ],
[ [
'value' => 'http://example.com/rdap/tos', 'href' => 'http://example.com/rdap/domain/' . $domain,
'rel' => 'terms-of-service', 'rel' => 'related',
'href' => 'http://example.com/rdap/tos', 'type' => 'application/rdap+json',
'type' => 'text/html', ]
],
// ... Additional RDAP links ...
], ],
'nameservers' => array_map(function ($name) { 'nameservers' => array_map(function ($nameserverDetails) {
return ['ldhName' => $name]; return [
'objectClassName' => 'nameserver',
'handle' => $nameserverDetails['host_id'] . '', // Use the 'host_id' from the query
'ldhName' => $nameserverDetails['name'], // Use the 'name' from the query
'links' => [
[
'href' => 'http://example.com/rdap/nameserver/' . $nameserverDetails['name'],
'rel' => 'self',
'type' => 'application/rdap+json',
],
],
];
}, $nameservers), }, $nameservers),
// ... Other RDAP fields ... // ... Other RDAP fields ...
]; ];