Web whois improvements

This commit is contained in:
Pinga 2024-01-24 16:03:33 +02:00
parent 6e8666ce81
commit e64cd1de7a
4 changed files with 37 additions and 7 deletions

View file

@ -6,9 +6,9 @@ require 'vendor/autoload.php';
$captcha = new CaptchaBuilder; $captcha = new CaptchaBuilder;
//$captcha->setBackgroundColor(255, 255, 255); //$captcha->setBackgroundColor(255, 255, 255);
$captcha->setMaxAngle(25); $captcha->setMaxAngle(5);
//$captcha->setMaxBehindLines(0); $captcha->setMaxBehindLines(3);
//$captcha->setMaxFrontLines(0); $captcha->setMaxFrontLines(0);
$captcha->setTextColor(0, 0, 0); $captcha->setTextColor(0, 0, 0);
$captcha->setInterpolation(false); $captcha->setInterpolation(false);
$captcha->setDistortion(false); $captcha->setDistortion(false);

View file

@ -7,7 +7,7 @@ if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
exit; exit;
} }
if ($_POST['captcha'] !== $_SESSION['captcha']) { if ($c['ignore_captcha'] === false && $_POST['captcha'] !== $_SESSION['captcha']) {
echo json_encode(['error' => 'Captcha verification failed.']); echo json_encode(['error' => 'Captcha verification failed.']);
exit; exit;
} }

View file

@ -2,5 +2,6 @@
return [ return [
'whois_url' => 'whois.example.com', 'whois_url' => 'whois.example.com',
'rdap_url' => 'rdap.example.com' 'rdap_url' => 'rdap.example.com',
'ignore_captcha' => false
]; ];

View file

@ -1,5 +1,6 @@
<?php <?php
session_start(); session_start();
$c = require_once 'config.php';
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
@ -12,6 +13,13 @@ session_start();
#bottom { #bottom {
display: none; display: none;
} }
pre {
background-color: #f3f3f6;
border: 1px solid #3f4144;
}
code {
color: #333!important;
}
</style> </style>
</head> </head>
<body> <body>
@ -19,8 +27,10 @@ session_start();
<h1>Domain Lookup</h1> <h1>Domain Lookup</h1>
<div class="row"> <div class="row">
<div class="col col-4-md col-8-lg"><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>
<?php if ($c['ignore_captcha'] === false) { ?>
<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="col col-2-md col-4-lg"><img id="captchaImg" src="captcha.php" onclick="this.src='captcha.php?'+Math.random();"></div>
<div class="col col-3-md col-6-lg"><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>
<?php } ?>
<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 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>
@ -32,9 +42,24 @@ session_start();
<script> <script>
document.addEventListener('DOMContentLoaded', function() { document.addEventListener('DOMContentLoaded', function() {
document.getElementById('domainInput').addEventListener('keypress', function(event) {
// Check if the key pressed is 'Enter'
if (event.key === 'Enter') {
// Prevent the default action to avoid form submission or any other default behavior
event.preventDefault();
// Trigger the click event of the whoisButton
document.getElementById('whoisButton').click();
}
});
document.getElementById('whoisButton').addEventListener('click', function() { document.getElementById('whoisButton').addEventListener('click', function() {
var domain = document.getElementById('domainInput').value; var domain = document.getElementById('domainInput').value;
<?php if ($c['ignore_captcha'] === false) { ?>
var captcha = document.getElementById('captchaInput').value; var captcha = document.getElementById('captchaInput').value;
<?php } else { ?>
var captcha = '';
<?php } ?>
fetch('check.php', { fetch('check.php', {
method: 'POST', method: 'POST',
@ -55,7 +80,11 @@ session_start();
document.getElementById('rdapButton').addEventListener('click', function() { document.getElementById('rdapButton').addEventListener('click', function() {
var domain = document.getElementById('domainInput').value; var domain = document.getElementById('domainInput').value;
<?php if ($c['ignore_captcha'] === false) { ?>
var captcha = document.getElementById('captchaInput').value; var captcha = document.getElementById('captchaInput').value;
<?php } else { ?>
var captcha = '';
<?php } ?>
fetch('check.php', { fetch('check.php', {
method: 'POST', method: 'POST',