-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathepp.php
152 lines (142 loc) · 3.99 KB
/
epp.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?php
include_once('EPP/eppConnection.php');
include_once('EPP/eppRequests/eppIncludes.php');
include_once('EPP/eppResponses/eppIncludes.php');
include_once('EPP/eppData/eppIncludes.php');
include_once('EPP/sidnEppConnection.php');
class epp
{
private $conn;
private $connected;
private $loggedin;
public function __construct($username, $password)
{
$useliveserver = true;
$this->connected = false;
$this->loggedin = false;
$this->conn = new sidnEppConnection($username, $password, $useliveserver);
}
public function connect()
{
if ($this->conn->connect())
{
$this->connected = true;
if ($this->login())
{
return true;
}
$this->disconnect();
}
return false;
}
public function disconnect()
{
if ($this->loggedin)
{
$this->logout();
}
if ($this->connected)
{
$this->conn->disconnect();
$this->connected = false;
}
}
public function forcedisconnect()
{
// Empty buffers
$buffer = $this->conn->read();
$this->disconnect();
}
public function testconnection()
{
if ($this->conn->connect())
{
if ($this->login())
{
$this->logout();
$this->conn->disconnect();
return true;
}
else
{
$this->conn->disconnect();
}
}
return false;
}
private function login()
{
try
{
$login = new eppLoginRequest();
if ((($response = $this->conn->writeandread($login)) instanceof eppLoginResponse) && ($response->Success()))
{
$this->loggedin = true;
return true;
}
else
{
echo "Login failed with message: ".$response->getResultMessage()."\n";
return false;
}
}
catch (eppException $e)
{
echo "Login failed with message: ".$e->getMessage()."\n";
return false;
}
}
private function logout()
{
try
{
$logout = new eppLogoutRequest();
if ((($response = $this->conn->writeandread($logout)) instanceof eppLogoutResponse) && ($response->Success()))
{
$this->loggedin = false;
return true;
}
else
{
echo "Logout failed with message: ".$response->getResultMessage()."\n";
return false;
}
}
catch (eppException $e)
{
echo "Logout failed with message: ".$e->getMessage()."\n";
return false;
}
}
public function infodomainperiod($domainname)
{
$domain = new eppDomain($domainname);
$info = new eppInfoDomainRequest($domain, 'all');
if ((($response = $this->conn->writeandread($info)) instanceof sidnEppInfoDomainResponse) && ($response->Success()))
{
/* @var $response sidnEppInfoDomainResponse */
return $response->getDomainPeriod();
}
else
{
echo "InfoDomain failed with message: ".$response->getResultMessage()."\n";
return false;
}
}
public function setdomainperiod($domainname, $period)
{
$domain = new eppDomain($domainname);
$renew = new sidnEppRenewRequest($domain, '1970-01-01', $period);
if ((($response = $this->conn->writeandread($renew)) instanceof eppRenewResponse) && ($response->Success()))
{
/* @var $response eppRenewResponse */
echo $response->getResultMessage()."\n";
return true;
}
else
{
echo "RenewDomain failed with message: ".$response->getResultMessage()."\n";
return false;
}
}
}