-
Notifications
You must be signed in to change notification settings - Fork 137
/
example.php
79 lines (68 loc) · 2.07 KB
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<!DOCTYPE html>
<html>
<head>
<title>Domain Availability Checker</title>
</head>
<body>
<?php
require './vendor/autoload.php';
use Helge\Loader\JsonLoader;
use Helge\Client\SimpleWhoisClient;
use Helge\Service\DomainAvailability;
$whoisClient = new SimpleWhoisClient();
$dataLoader = new JsonLoader("src/data/servers.json");
$service = new DomainAvailability($whoisClient, $dataLoader);
?>
<div>
<form style="margin: 10px;" action="" method="get">
<label for="domain">Domain Name</label>
<input type="text" name="domain" id="domain">
<input type="submit" value="Go">
</form>
<form style="margin: 10px;" action="" method="get">
<input type="text" name="tld" id="tld" value="list" hidden>
<input type="submit" value="List All TLDs">
</form>
<?php if (isset($_GET["tld"]) && $_GET["tld"] == "list" ) : ?>
<ul>
<?php foreach ($service->supportedTlds() as $tld) : ?>
<li><?= $tld; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<table border="1" cellpadding="5">
<tr>
<td>Status</td>
<td>
<?php
try {
if (isset($_GET["domain"])) {
if ($service->isAvailable($_GET["domain"])) {
echo "<span style='color:green;'>Available</span>";
} else {
echo "<span style='color:red;'>Unavailable</span>";
}
}
} catch (\Exception $e) {
echo $e->getMessage();
}
?>
</td>
</tr>
<tr>
<td>WHOIS Server</td>
<td><?= $whoisClient->getServer() ?></td>
</tr>
<tr>
<td>Server Port</td>
<td><?= $whoisClient->getPort() ?></td>
</tr>
<tr>
<td colspan="2">
<pre><?= $whoisClient->getResponse(); ?></pre>
</td>
</tr>
</table>
</div>
</body>
</html>