Domain sorgulamak için herhangi bir TLD servisine bağlanmadan kendi sunucunuz üzerinden Whois sorgulayabilirsiniz.
<!DOCTYPE html>
<html lang="tr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Whois Sorgulama</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
.available {
color: green;
font-weight: bold;
}
</style>
</head>
<body>
<div class="container mt-5">
<h1 class="text-center mb-4">Whois Sorgulama</h1>
<form method="POST" class="mb-4">
<div class="input-group">
<input type="text" name="domain" class="form-control" placeholder="domain.com" required>
<button type="submit" class="btn btn-primary">Sorgula</button>
</div>
</form>
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['domain'])) {
$domain = htmlspecialchars($_POST['domain']);
// WHOIS bilgilerini alma fonksiyonu
function getWhoisData($domain) {
$whois = shell_exec("whois " . escapeshellcmd($domain));
return $whois;
}
// Domain yaşını hesaplama fonksiyonu
function calculateDomainAge($startDate) {
$start = new DateTime($startDate);
$now = new DateTime();
$interval = $start->diff($now);
return $interval->y . " yıl, " . $interval->m . " ay, " . $interval->d . " gün";
}
// WHOIS verilerini ayrıştırma
function parseWhois($whoisData) {
$parsedData = [
'is_available' => false,
'registration_date' => '-',
'updated_date' => '-',
'expiry_date' => '-',
'age' => '-',
'remaining_time' => '-',
'registrar' => '-',
'dns_info' => []
];
if (strpos($whoisData, 'No match for') !== false || strpos($whoisData, 'NOT FOUND') !== false) {
$parsedData['is_available'] = true;
return $parsedData;
}
if (preg_match('/Creation Date:\s*(\d{4}-\d{2}-\d{2})/i', $whoisData, $matches)) {
$parsedData['registration_date'] = date("d.m.Y", strtotime(trim($matches[1])));
$parsedData['age'] = calculateDomainAge($matches[1]);
}
if (preg_match('/Updated Date:\s*(\d{4}-\d{2}-\d{2})/i', $whoisData, $matches)) {
$parsedData['updated_date'] = date("d.m.Y", strtotime(trim($matches[1])));
}
if (preg_match('/Registry Expiry Date:\s*(\d{4}-\d{2}-\d{2})/i', $whoisData, $matches)) {
$parsedData['expiry_date'] = date("d.m.Y", strtotime(trim($matches[1])));
$expiryDate = strtotime($matches[1]);
$remainingDays = ceil(($expiryDate - time()) / (24 * 60 * 60));
$parsedData['remaining_time'] = $remainingDays > 0 ? $remainingDays . " gün" : "Süresi dolmuş";
}
if (preg_match_all('/Name Server:\s*(.*)/i', $whoisData, $matches)) {
foreach ($matches[1] as $server) {
$dnsIP = gethostbyname($server);
$parsedData['dns_info'][] = [
'server' => trim($server),
'ip' => $dnsIP
];
}
}
if (preg_match('/Registrar:\s*(.*)/i', $whoisData, $matches)) {
$parsedData['registrar'] = trim($matches[1]);
}
return $parsedData;
}
// Whois ve DNS bilgilerini al
$whoisData = getWhoisData($domain);
$domainInfo = parseWhois($whoisData);
// Eğer domain müsaitse
if ($domainInfo['is_available']) {
echo "<div class='alert alert-secondary' role='alert'><b>{$domain}</b> - müsait!</div>";
} else {
// Tabloyu oluştur
echo '<table class="table table-striped table-bordered">';
echo '<thead class="table-dark">';
echo '<tr>
<th>Alan</th>
<th>Bilgi</th>
</tr>';
echo '</thead>';
echo '<tbody>';
echo "<tr><td>Domain Adı</td><td>{$domain} <span class='badge text-bg-success'>{$domainInfo['age']}</span></td></tr>";
echo "<tr><td>Kayıt - Bitiş</td><td>{$domainInfo['registration_date']} - {$domainInfo['expiry_date']}</td></tr>";
echo "<tr><td>Güncelleme</td><td>{$domainInfo['updated_date']}</td></tr>";
echo "<tr><td>Kalan Gün</td><td>{$domainInfo['remaining_time']}</td></tr>";
echo "<tr><td>Kayıtlı Firma</td><td>{$domainInfo['registrar']}</td></tr>";
echo "<tr><td>DNS Bilgisi</td><td>";
if (!empty($domainInfo['dns_info'])) {
foreach ($domainInfo['dns_info'] as $dns) {
echo "{$dns['server']} <span class='badge text-bg-success'>{$dns['ip']}</span><br>";
}
} else {
echo "DNS bilgisi bulunamadı.";
}
echo "</td></tr>";
echo "<tr><td>Whois Bilgisi</td><td><pre>{$whoisData}</pre></td></tr>";
echo '</tbody>';
echo '</table>';
}
}
?>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>