forked from metaregistrar/php-epp-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckdomain.php
84 lines (73 loc) · 1.85 KB
/
checkdomain.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
79
80
81
82
83
84
<?php
// Base EPP objects
include_once('Protocols/EPP/eppConnection.php');
include_once('Protocols/EPP/eppRequests/eppIncludes.php');
include_once('Protocols/EPP/eppResponses/eppIncludes.php');
include_once('Protocols/EPP/eppData/eppIncludes.php');
// Connection object to Metaregistrar EPP server - this contains your userid and passwords!
include_once('Registries/Metaregistrar/metaregEppConnection.php');
include_once('Registries/IIS/iisEppConnection.php');
include_once('Registries/SIDN/sidnEppConnection.php');
// Base EPP commands: hello, login and logout
include_once('base.php');
/*
* This script checks for the availability of domain names
*
* You can specify multiple domain names to be checked
*/
if ($argc <= 1)
{
echo "Usage: checkdomain.php <domainnames>\n";
echo "Please enter one or more domain names to check\n\n";
die();
}
for ($i=1; $i<$argc; $i++)
{
$domains[] = $argv[$i];
}
echo "Checking ".count($domains)." domain names\n";
try
{
$conn = new sidnEppConnection(true);
// Connect to the EPP server
if ($conn->connect())
{
if (login($conn))
{
checkdomains($conn, $domains);
logout($conn);
}
}
else
{
echo "ERROR CONNECTING\n";
}
}
catch (eppException $e)
{
echo "ERROR: ".$e->getMessage()."\n\n";
}
function checkdomains($conn, $domains)
{
try
{
$check = new eppCheckRequest($domains);
if ((($response = $conn->writeandread($check)) instanceof eppCheckResponse) && ($response->Success()))
{
$checks = $response->getCheckedDomains();
foreach ($checks as $check)
{
echo $check['domainname']." is ".($check['available'] ? 'free' : 'taken')." (".$check['reason'].")\n";
}
}
else
{
echo "ERROR2\n";
}
}
catch (eppException $e)
{
echo 'ERROR1';
echo $e->getMessage()."\n";
}
}