From 1add432b9fc926a7661a91d021bcfdf46333b9a5 Mon Sep 17 00:00:00 2001 From: Pinga <121483313+getpinga@users.noreply.github.com> Date: Wed, 15 Nov 2023 18:17:34 +0200 Subject: [PATCH] Web whois is done --- whois/web/checkWhois.php | 39 ---------------- whois/web/index.php | 96 +++++++++++++++++++++------------------- whois/web/script.js | 31 ------------- whois/web/whois.php | 33 ++++++++++++++ 4 files changed, 83 insertions(+), 116 deletions(-) delete mode 100644 whois/web/checkWhois.php delete mode 100644 whois/web/script.js create mode 100644 whois/web/whois.php diff --git a/whois/web/checkWhois.php b/whois/web/checkWhois.php deleted file mode 100644 index 7235fc6..0000000 --- a/whois/web/checkWhois.php +++ /dev/null @@ -1,39 +0,0 @@ - 'Invalid request.']); - exit; - } - - if (PhraseBuilder::comparePhrases($_SESSION['captcha'], $_POST['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.']); - } \ No newline at end of file diff --git a/whois/web/index.php b/whois/web/index.php index eb3b276..49f3687 100644 --- a/whois/web/index.php +++ b/whois/web/index.php @@ -1,61 +1,65 @@ build(); session_start(); -$_SESSION['captcha'] = $builder->getPhrase(); +use Gregwar\Captcha\CaptchaBuilder; + +// Include this part only if the script is requested as an image (for the captcha) +if ($_SERVER['REQUEST_URI'] == '/captcha.php') { + require 'vendor/autoload.php'; // Adjust path as needed + + $captcha = new CaptchaBuilder; + $captcha->build(); + + $_SESSION['captcha'] = $captcha->getPhrase(); + + header('Content-type: image/jpeg'); + $captcha->output(); + exit; +} ?> +
-