mirror of
https://github.com/getnamingo/registry.git
synced 2025-07-24 03:20:33 +02:00
Added rdap web client
This commit is contained in:
parent
a55c40ddff
commit
b722d515a5
2 changed files with 204 additions and 0 deletions
42
rdap/client/rdap.php
Normal file
42
rdap/client/rdap.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
session_start();
|
||||
|
||||
// Check for a valid POST request
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
echo json_encode(['error' => 'Invalid request method.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Captcha validation (if used)
|
||||
if ($_POST['captcha'] !== $_SESSION['captcha']) {
|
||||
echo json_encode(['error' => 'Captcha verification failed']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Invalidate the current captcha
|
||||
unset($_SESSION['captcha']);
|
||||
|
||||
// Domain name from the POST request
|
||||
$domain = $_POST['domain'];
|
||||
|
||||
// RDAP server URL
|
||||
$rdapServer = 'https://rdap.EXAMPLE.COM/domain/';
|
||||
|
||||
// Initialize cURL session
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $rdapServer . $domain);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
|
||||
// Execute cURL session and close it
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
// Check for errors
|
||||
if (!$response) {
|
||||
echo json_encode(['error' => 'Error fetching RDAP data.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Output the RDAP data
|
||||
echo $response;
|
Loading…
Add table
Add a link
Reference in a new issue