domain-ip-whois/index.php

223 lines
9.4 KiB
PHP
Raw Normal View History

2024-01-08 13:32:25 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Domain Name, IP Whois Search System - NibbleGap</title>
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" type="text/css" href="dark.css">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="Welcome to Domain Name, IP WHOIS Search. You can check domain whois and ipv4 ipv6 whois." />
<link rel="icon" type="image/png" href="https://nibblecdn.com/logo/nibblegap.svg">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<h1><a href="https://whois.nibblegap.com"><img style="vertical-align:middle" src="https://nibblecdn.com/logo/nibblegap.svg" alt="nibblegap logo" width="30" height="30"></a> <a style="vertical-align:middle" href="https://whois.nibblegap.com"> Domain Name, IP Whois Search System</a></h1>
<form method="post" action="">
<input type="text" name="query" placeholder="Please enter and press Enquiry." required value="<?php echo isset($_POST['query']) ? htmlspecialchars(removeSpaces($_POST['query']), ENT_QUOTES, 'UTF-8') : ''; ?>">
<select name="type">
<?php
$options = [
'whois' => 'Domain WHOIS Search',
'ipwhois' => 'IP WHOIS Search',
];
foreach ($options as $value => $label) {
$selected = (isset($_POST['type']) && $_POST['type'] === $value) ? 'selected' : '';
echo '<option value="' . $value . '" ' . $selected . '>' . $label . '</option>';
}
?>
</select>
<input type="submit" name="submit" value="Enquiry">
</form>
<?php
function removeSpaces($input)
{
return preg_replace('/\s+/', '', $input);
}
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['submit'])) {
$query = removeSpaces($_POST['query']);
$type = $_POST['type'];
$query = idn_to_ascii($query);
switch ($type) {
case 'whois':
performWhoisQuery($query);
break;
case 'ipwhois':
performIPWhoisQuery($query);
break;
}
}
function performWhoisQuery($domain)
{
require_once __DIR__ . '/whois_servers.php';
$extension = getDomainExtension($domain);
if (isset($whoisServers[$extension])) {
$server = $whoisServers[$extension];
$result = queryWhoisServer($server, $domain);
$isRegistered = isDomainRegistered($result);
$hasRegistrarInfo = false;
echo '<div class="result">';
if (!empty($result)) {
echo '<h2>' . $domain . ' WHOIS Information</h2>';
echo '<div class="info-container">';
echo '<p>Searched from: ' . $server . '</p>';
echo '<p>Domain Registration: ' . ($isRegistered ? 'Registered' : 'Unregistered') . '</p>';
echo '<p>Reserved domain name: ' . (isDomainReserved($result) ? 'Reserved' : 'Not Reserved') . '&nbsp;(Only Reference)' . '</p>';
foreach ($result as $line) {
if (strpos($line, 'Expiration Date') !== false || strpos($line, 'Registrar Registration Expiration Date') !== false || strpos($line, 'Registry Expiry Date') !== false || strpos($line, 'Expiry Date:') !== false || strpos($line, 'Expiration Time:') !== false) {
echo '<p>Expiration Date: ' . trim(str_replace(['Expiration Date:', 'Registrar Registration Expiration Date:', 'Registry Expiry Date:', 'Expiry Date:', 'Expiration Time:'], '', $line)) . '</p>';
}
elseif (strpos($line, 'Creation Date') !== false || strpos($line, 'Domain Registration Date') !== false || strpos($line, 'created:') !== false || strpos($line, 'Registration Time:') !== false) {
echo '<p>Registration Date: ' . trim(str_replace(['Creation Date:', 'Domain Registration Date:', 'created:', 'Registration Time:'], '', $line)) . '</p>';
}
elseif (strpos($line, 'Updated Date') !== false || strpos($line, 'Last Updated') !== false || strpos($line, 'last-update:') !== false) {
echo '<p>Last Updated Date: ' . trim(str_replace(['Updated Date:', 'Last Updated:', 'last-update:'], '', $line)) . '</p>';
}
elseif (strpos($line, 'Name Server') !== false || strpos($line, 'Name Servers') !== false || strpos($line, 'NS') !== false || strpos($line, 'nserver:') !== false) {
echo '<p>DNS: ' . trim(str_replace(['Name Server:', 'Name Servers:', 'NS:', 'nserver:'], '', $line)) . '</p>';
}
elseif (strpos($line, 'Registrant:') !== false || strpos($line, 'Registrant Name:') !== false || strpos($line, 'Registrant Organization:') !== false) {
echo '<p>Registrant: ' . trim(str_replace(['Registrant:', 'Registrant Name:', 'Registrant Organization:'], '', $line)) . '</p>';
}
elseif (strpos($line, 'Registrant Email') !== false) {
echo '<p>Registrant Email: ' . trim(str_replace('Registrant Email:', '', $line)) . '</p>';
}
elseif (!$hasRegistrarInfo && (strpos($line, 'Registrar:') !== false || strpos($line, 'Registrar WHOIS Server') !== false || strpos($line, 'registrar:') !== false)) {
echo '<p>Registrar: ' . trim(str_replace(['Registrar:', 'Registrar WHOIS Server:', 'registrar:'], '', $line)) . '</p>';
$hasRegistrarInfo = true;
}
elseif (strpos($line, 'Status:') !== false) {
echo '<p>Status: ' . trim(str_replace('Status:', '', $line)) . '</p>';
}
}
echo '</div>';
echo '<button class="btn btn-link" onclick="toggleDetails()">Show Details</button>';
echo '<div class="details-content" id="details-content">';
echo '<div class="info-container">';
echo '<ul>';
foreach ($result as $line) {
echo '<li>' . $line . '</li>';
}
echo '</ul>';
echo '</div>';
echo '</div>';
} else {
echo '<h3>WHOIS information for the domain name could not be found. The domain name may not be registered or the domain Whois server is not accessible.</h3>';
}
echo '</div>';
} else {
echo '<div class="result">';
echo '<h3>WHOIS search for this domain name is not supported.</h3>';
echo '</div>';
}
}
function performIPWhoisQuery($ip)
{
$server = 'whois.apnic.net';
$result = queryWhoisServer($server, $ip);
echo '<div class="result">';
if (!empty($result)) {
echo '<h2>' . $ip . ' WHOIS information</h2>';
echo '<p>Searched from: ' . $server . '</p>';
echo '<ul>';
foreach ($result as $line) {
echo '<li>' . $line . '</li>';
}
echo '</ul>';
} else {
echo '<h2>IP WHOIS information not available.</h2>';
}
echo '</div>';
}
function getDomainExtension($domain)
{
$parts = explode('.', $domain);
$extension = end($parts);
return strtolower($extension);
}
function queryWhoisServer($server, $query)
{
$result = array();
$fp = @fsockopen($server, 43, $errno, $errstr, 10);
if ($fp) {
fputs($fp, $query . "\r\n");
while (!feof($fp)) {
$result[] = fgets($fp);
}
fclose($fp);
}
return $result;
}
function isDomainReserved($whoisResult)
{
$reservedKeywords = array('reserved', 'reserved domain name', 'keep', 'clientHold', 'serverHold');
foreach ($whoisResult as $line) {
foreach ($reservedKeywords as $keyword) {
if (stripos($line, $keyword) !== false) {
return true;
}
}
}
return false;
}
function isDomainRegistered($whoisResult)
{
$registeredPatterns = array(
'/^\s*Registrar:\s+/i',
'/^\s*Creation Date:\s+/i',
'/^\s*Domain Name:\s+/i',
'/^\s*Registry Domain ID:\s+/i',
'/^\s*connect\s+/i',
'/^\s*Status:\s+connect/i',
'/^\s*Status:\s+active/i'
);
foreach ($whoisResult as $line) {
foreach ($registeredPatterns as $pattern) {
if (preg_match($pattern, $line)) {
return true;
}
}
}
return false;
}
?>
</body>
<footer><br><br>
<p><a href="https://nibblegap.com" target="_blank">NibbleGap</a></p>
</footer>
<script>
function toggleDetails() {
var detailsContent = document.getElementById('details-content');
var detailsToggle = document.querySelector('.details-toggle');
if (detailsContent.style.display === 'none') {
detailsContent.style.display = 'block';
detailsToggle.classList.add('open');
} else {
detailsContent.style.display = 'none';
detailsToggle.classList.remove('open');
}
}
</script>
2024-01-08 13:29:26 +00:00
</html>