forked from HelgeSverre/Domain-Availability
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.php
66 lines (57 loc) · 1.64 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
<!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>
<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>