mirror of
https://github.com/getnamingo/registry.git
synced 2025-08-06 09:35:03 +02:00
Initial partial upload, testing needed
This commit is contained in:
parent
e51267f33c
commit
1203f890f1
7 changed files with 1054 additions and 0 deletions
1
whois/web/README.md
Normal file
1
whois/web/README.md
Normal file
|
@ -0,0 +1 @@
|
|||
composer require gregwar/captcha
|
36
whois/web/checkWhois.php
Normal file
36
whois/web/checkWhois.php
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
session_start();
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
if (!isset($_POST['domain']) || !isset($_POST['captcha'])) {
|
||||
echo json_encode(['error' => 'Invalid request.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($_POST['captcha'] !== $_SESSION['captcha']) {
|
||||
echo json_encode(['error' => 'Incorrect Captcha.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$domain = $_POST['domain'];
|
||||
$whoisServer = 'whois.example.com';
|
||||
|
||||
$output = '';
|
||||
$socket = fsockopen($whoisServer, 43, $errno, $errstr, 30);
|
||||
|
||||
if (!$socket) {
|
||||
echo json_encode(['error' => "Error connecting to the Whois server."]);
|
||||
exit;
|
||||
}
|
||||
|
||||
fwrite($socket, $domain . "\r\n");
|
||||
while (!feof($socket)) {
|
||||
$output .= fgets($socket);
|
||||
}
|
||||
fclose($socket);
|
||||
|
||||
echo json_encode(['result' => nl2br(htmlspecialchars($output))]);
|
||||
|
||||
} else {
|
||||
echo json_encode(['error' => 'Invalid request method.']);
|
||||
}
|
62
whois/web/index.php
Normal file
62
whois/web/index.php
Normal file
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Gregwar\Captcha\CaptchaBuilder;
|
||||
|
||||
session_start();
|
||||
|
||||
$builder = new CaptchaBuilder;
|
||||
$builder->build();
|
||||
$_SESSION['captcha'] = $builder->getPhrase();
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Whois Check</title>
|
||||
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Roboto:300,300italic,700,700italic">
|
||||
<link rel="stylesheet" href="//cdn.rawgit.com/milligram/milligram/master/dist/milligram.min.css">
|
||||
<script src="script.js"></script>
|
||||
<style>
|
||||
.row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.domain-input {
|
||||
width: 45%;
|
||||
}
|
||||
.captcha-input {
|
||||
width: 35%;
|
||||
margin-left:10px;
|
||||
}
|
||||
.captcha-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1 class="text-center">Whois Check</h1>
|
||||
<form id="whoisForm">
|
||||
<div class="row">
|
||||
<div class="domain-input">
|
||||
<label for="domain">Domain</label>
|
||||
<input type="text" id="domain" name="domain" placeholder="example.com" required>
|
||||
</div>
|
||||
<div class="captcha-input">
|
||||
<label for="captcha">Captcha</label>
|
||||
<div class="captcha-container">
|
||||
<input type="text" id="captcha" name="captcha" required>
|
||||
<img src="<?php echo $builder->inline(); ?>" id="captchaImage" style="margin-left:10px;">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="button-primary">Check Whois</button>
|
||||
</form>
|
||||
<div id="result" class="mt-4"></div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
31
whois/web/script.js
Normal file
31
whois/web/script.js
Normal file
|
@ -0,0 +1,31 @@
|
|||
document.addEventListener("DOMContentLoaded", function() {
|
||||
document.getElementById("whoisForm").addEventListener("submit", function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
var formData = new FormData(this);
|
||||
|
||||
xhr.open("POST", "checkWhois.php", true);
|
||||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState === 4) {
|
||||
var resultDiv = document.getElementById("result");
|
||||
if (xhr.status === 200) {
|
||||
var data = JSON.parse(xhr.responseText);
|
||||
if (data.error) {
|
||||
resultDiv.innerHTML = '<div class="alert alert-danger">' + data.error + '</div>';
|
||||
} else {
|
||||
resultDiv.innerHTML = '<div class="alert alert-success">' + data.result + '</div>';
|
||||
}
|
||||
} else {
|
||||
resultDiv.innerHTML = '<div class="alert alert-danger">An error occurred. Please try again.</div>';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
xhr.onloadstart = function() {
|
||||
document.getElementById("result").innerHTML = '<div class="loading">Loading...</div>';
|
||||
};
|
||||
|
||||
xhr.send(formData);
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue