mirror of
https://github.com/getnamingo/registry.git
synced 2025-07-22 18:45:59 +02:00
Web lookup (whois and rdap) now completed
This commit is contained in:
parent
8a6d8630ed
commit
69a670b4b1
6 changed files with 54 additions and 26 deletions
|
@ -294,23 +294,18 @@ This command will install the dependencies defined in your ```composer.json``` f
|
||||||
|
|
||||||
5. Remove the Script: Once verified, delete the script to maintain system security.
|
5. Remove the Script: Once verified, delete the script to maintain system security.
|
||||||
|
|
||||||
## 8. Setup Web WHOIS:
|
## 8. Setup Web Lookup:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
mkdir -p /var/www/whois
|
mkdir -p /var/www/whois
|
||||||
cd /opt/registry/whois/web
|
cd /opt/registry/whois/web
|
||||||
cp -r * /var/www/whois
|
cp -r * /var/www/whois
|
||||||
```
|
cd /var/www/whois/
|
||||||
|
|
||||||
Change your working directory to ```/var/www/whois/``` using a command line interface. This can be done with the command ```cd /var/www/whois/```.
|
|
||||||
|
|
||||||
Once in the correct directory, run the following command to install necessary dependencies:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
composer require gregwar/captcha
|
composer require gregwar/captcha
|
||||||
|
mv config.php.dist config.php
|
||||||
```
|
```
|
||||||
|
|
||||||
This command will install the **gregwar/captcha** package, which is required for the WHOIS web interface functionality.
|
- Configure all options in ```config.php```.
|
||||||
|
|
||||||
## 9. Setup WHOIS:
|
## 9. Setup WHOIS:
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,14 @@ use Gregwar\Captcha\CaptchaBuilder;
|
||||||
require 'vendor/autoload.php';
|
require 'vendor/autoload.php';
|
||||||
|
|
||||||
$captcha = new CaptchaBuilder;
|
$captcha = new CaptchaBuilder;
|
||||||
$captcha->build();
|
//$captcha->setBackgroundColor(255, 255, 255);
|
||||||
|
$captcha->setMaxAngle(25);
|
||||||
|
//$captcha->setMaxBehindLines(0);
|
||||||
|
//$captcha->setMaxFrontLines(0);
|
||||||
|
$captcha->setTextColor(0, 0, 0);
|
||||||
|
$captcha->setInterpolation(false);
|
||||||
|
$captcha->setDistortion(false);
|
||||||
|
$captcha->build($width = 100, $height = 40);
|
||||||
|
|
||||||
$_SESSION['captcha'] = $captcha->getPhrase();
|
$_SESSION['captcha'] = $captcha->getPhrase();
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
$c = require_once 'config.php';
|
||||||
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||||
echo json_encode(['error' => 'Invalid request method.']);
|
echo json_encode(['error' => 'Invalid request method.']);
|
||||||
|
@ -7,20 +8,31 @@ if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_POST['captcha'] !== $_SESSION['captcha']) {
|
if ($_POST['captcha'] !== $_SESSION['captcha']) {
|
||||||
die('Captcha verification failed');
|
echo json_encode(['error' => 'Captcha verification failed.']);
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$domain = $_POST['domain'];
|
$domain = $_POST['domain'];
|
||||||
$type = $_POST['type'];
|
$type = $_POST['type'];
|
||||||
$whoisServer = 'whois.example.com';
|
$whoisServer = $c['whois_url'];
|
||||||
$rdapServer = 'https://rdap.example.com/domain/';
|
$rdapServer = 'https://' . $c['rdap_url'] . '/domain/';
|
||||||
|
|
||||||
|
$sanitized_domain = filter_var($domain, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME);
|
||||||
|
|
||||||
|
if ($sanitized_domain) {
|
||||||
|
$domain = $sanitized_domain;
|
||||||
|
} else {
|
||||||
|
echo json_encode(['error' => 'Invalid domain.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
$sanitized_type = filter_var($type, FILTER_SANITIZE_STRING);
|
$sanitized_type = filter_var($type, FILTER_SANITIZE_STRING);
|
||||||
|
|
||||||
if ($sanitized_type === 'whois' || $sanitized_type === 'rdap') {
|
if ($sanitized_type === 'whois' || $sanitized_type === 'rdap') {
|
||||||
$type = $sanitized_type;
|
$type = $sanitized_type;
|
||||||
} else {
|
} else {
|
||||||
$type = null; // or throw new Exception("Invalid input");
|
echo json_encode(['error' => 'Invalid input.']);
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type === 'whois') {
|
if ($type === 'whois') {
|
||||||
|
@ -28,7 +40,7 @@ if ($type === 'whois') {
|
||||||
$socket = fsockopen($whoisServer, 43, $errno, $errstr, 30);
|
$socket = fsockopen($whoisServer, 43, $errno, $errstr, 30);
|
||||||
|
|
||||||
if (!$socket) {
|
if (!$socket) {
|
||||||
echo json_encode(['error' => "Error connecting to the Whois server."]);
|
echo json_encode(['error' => "Error fetching WHOIS data."]);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,11 +55,9 @@ if ($type === 'whois') {
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||||
|
|
||||||
// Execute cURL session and close it
|
|
||||||
$output = curl_exec($ch);
|
$output = curl_exec($ch);
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
|
|
||||||
// Check for errors
|
|
||||||
if (!$output) {
|
if (!$output) {
|
||||||
echo json_encode(['error' => 'Error fetching RDAP data.']);
|
echo json_encode(['error' => 'Error fetching RDAP data.']);
|
||||||
exit;
|
exit;
|
||||||
|
|
3
whois/web/chota.min.css
vendored
Normal file
3
whois/web/chota.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
6
whois/web/config.php.dist
Normal file
6
whois/web/config.php.dist
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'whois_url' => 'whois.example.com',
|
||||||
|
'rdap_url' => 'rdap.example.com'
|
||||||
|
];
|
|
@ -7,20 +7,25 @@ session_start();
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Domain Lookup</title>
|
<title>Domain Lookup</title>
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/milligram/1.4.1/milligram.min.css">
|
<link rel="stylesheet" href="chota.min.css">
|
||||||
|
<style>
|
||||||
|
#bottom {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h1>Domain Lookup</h1>
|
<h1>Domain Lookup</h1>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="column"><input type="text" id="domainInput" placeholder="Enter Domain Name" autocapitalize="none"></div>
|
<div class="col col-4-md col-8-lg"><input type="text" id="domainInput" placeholder="Enter Domain Name" autocapitalize="none"></div>
|
||||||
<div class="column"><img id="captchaImg" src="captcha.php" onclick="this.src='captcha.php?'+Math.random();"></div>
|
<div class="col col-2-md col-4-lg"><img id="captchaImg" src="captcha.php" onclick="this.src='captcha.php?'+Math.random();"></div>
|
||||||
<div class="column"><input type="text" id="captchaInput" placeholder="Enter Captcha" autocapitalize="none"></div>
|
<div class="col col-3-md col-6-lg"><input type="text" id="captchaInput" placeholder="Enter Captcha" autocapitalize="none"></div>
|
||||||
<div class="column"><button class="button" id="whoisButton">WHOIS</button> <button class="button button-outline" id="rdapButton">RDAP</button></div>
|
<div class="col col-3-md col-6-lg"><button class="button primary" id="whoisButton">WHOIS</button> <button class="button secondary" id="rdapButton">RDAP</button></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row" id="bottom">
|
||||||
<div class="column"><pre><code><div id="result"></div></code></pre></div>
|
<div class="col col-12-lg"><pre><code><div id="result"></div></code></pre></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -41,6 +46,7 @@ session_start();
|
||||||
.then(response => response.text())
|
.then(response => response.text())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
document.getElementById('result').innerText = data;
|
document.getElementById('result').innerText = data;
|
||||||
|
document.getElementById('bottom').style.display = 'block';
|
||||||
// Reload captcha after a successful response
|
// Reload captcha after a successful response
|
||||||
document.getElementById('captchaImg').src = 'captcha.php?' + Math.random();
|
document.getElementById('captchaImg').src = 'captcha.php?' + Math.random();
|
||||||
})
|
})
|
||||||
|
@ -67,9 +73,10 @@ session_start();
|
||||||
// Parse and display RDAP data
|
// Parse and display RDAP data
|
||||||
let output = parseRdapResponse(data);
|
let output = parseRdapResponse(data);
|
||||||
document.getElementById('result').innerText = output;
|
document.getElementById('result').innerText = output;
|
||||||
|
document.getElementById('bottom').style.display = 'block';
|
||||||
|
// Reload captcha
|
||||||
|
document.getElementById('captchaImg').src = 'captcha.php?' + Math.random();
|
||||||
}
|
}
|
||||||
// Reload captcha
|
|
||||||
document.getElementById('captchaImg').src = 'captcha.php?' + Math.random();
|
|
||||||
})
|
})
|
||||||
.catch(error => console.error('Error:', error));
|
.catch(error => console.error('Error:', error));
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue