|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the php-epp2 library. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Gunter Grodotzki <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE file |
|
9
|
|
|
* that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace AfriCC\EPP\Frame\Command\Update; |
|
13
|
|
|
|
|
14
|
|
|
use AfriCC\EPP\AddrTrait; |
|
15
|
|
|
use AfriCC\EPP\Frame\Command\Update as UpdateCommand; |
|
16
|
|
|
use AfriCC\EPP\ObjectSpec; |
|
17
|
|
|
use AfriCC\EPP\Random; |
|
18
|
|
|
use AfriCC\EPP\Validator; |
|
19
|
|
|
use Exception; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @see http://tools.ietf.org/html/rfc5731#section-3.2.5 |
|
23
|
|
|
*/ |
|
24
|
|
|
class Domain extends UpdateCommand |
|
25
|
|
|
{ |
|
26
|
|
|
use AddrTrait; |
|
27
|
|
|
|
|
28
|
|
|
public function setDomain($domain) |
|
29
|
|
|
{ |
|
30
|
|
|
if (!Validator::isHostname($domain)) { |
|
31
|
|
|
throw new Exception(sprintf('%s is not a valid domain name', $domain)); |
|
32
|
|
|
} |
|
33
|
|
|
$this->set('domain:name', $domain); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function addAdminContact($contact, $remove = false) |
|
37
|
|
|
{ |
|
38
|
|
|
if ($remove) { |
|
39
|
|
|
$key = 'rem'; |
|
40
|
|
|
} else { |
|
41
|
|
|
$key = 'add'; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
$this->set(sprintf('domain:%s/domain:contact[@type=\'admin\']', $key), $contact); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function addTechContact($contact, $remove = false) |
|
48
|
|
|
{ |
|
49
|
|
|
if ($remove) { |
|
50
|
|
|
$key = 'rem'; |
|
51
|
|
|
} else { |
|
52
|
|
|
$key = 'add'; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
$this->set(sprintf('domain:%s/domain:contact[@type=\'tech\']', $key), $contact); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function addBillingContact($contact, $remove = false) |
|
59
|
|
|
{ |
|
60
|
|
|
if ($remove) { |
|
61
|
|
|
$key = 'rem'; |
|
62
|
|
|
} else { |
|
63
|
|
|
$key = 'add'; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
$this->set(sprintf('domain:%s/domain:contact[@type=\'billing\']', $key), $contact); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
public function addHostObj($host, $remove = false) |
|
70
|
|
|
{ |
|
71
|
|
|
if (!Validator::isHostname($host)) { |
|
72
|
|
|
throw new Exception(sprintf('%s is not a valid host name', $host)); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
if ($remove) { |
|
76
|
|
|
$key = 'rem'; |
|
77
|
|
|
} else { |
|
78
|
|
|
$key = 'add'; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
$this->set(sprintf('domain:%s/domain:ns/domain:hostObj[]', $key), $host); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
public function addHostAttr($host, $ips = null, $remove = false) |
|
85
|
|
|
{ |
|
86
|
|
|
if ($remove) { |
|
87
|
|
|
$key = 'rem'; |
|
88
|
|
|
} else { |
|
89
|
|
|
$key = 'add'; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
$this->appendHostAttr(sprintf('domain:%s/domain:ns/domain:hostAttr[%%d]', $key), $host, $ips); |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
public function addStatus($status, $text, $remove = false) |
|
96
|
|
|
{ |
|
97
|
|
|
if ($remove) { |
|
98
|
|
|
$key = 'rem'; |
|
99
|
|
|
} else { |
|
100
|
|
|
$key = 'add'; |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
$node = $this->set(sprintf('domain:%s/domain:status[@s=\'%s\']', $key, $status)); |
|
104
|
|
|
if (!empty($text)) { |
|
105
|
|
|
$node->setAttribute('lang', 'en'); |
|
106
|
|
|
$node->nodeValue = $text; |
|
107
|
|
|
} |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* Add/remove SecDNS dsData - RFC 5910 |
|
112
|
|
|
* |
|
113
|
|
|
* @param int $keyTag |
|
114
|
|
|
* @param int $alg |
|
115
|
|
|
* @param int $digestType |
|
116
|
|
|
* @param string $digest |
|
117
|
|
|
* @param bool $remove whether to remove or add (default add) |
|
118
|
|
|
*/ |
|
119
|
|
|
public function addSecDNSdsData($keyTag, $alg, $digestType, $digest, $remove = false) |
|
120
|
|
|
{ |
|
121
|
|
|
$key = $remove ? 'rem' : 'add'; |
|
122
|
|
|
$node = $this->set(sprintf('//epp:epp/epp:command/epp:extension/secDNS:update/secDNS:%s/secDNS:dsData[]', $key)); |
|
123
|
|
|
$ns = ObjectSpec::xmlns('secDNS'); |
|
124
|
|
|
$keyTagNode = $this->createElementNS($ns, 'secDNS:keyTag', $keyTag); |
|
125
|
|
|
$algNode = $this->createElementNS($ns, 'secDNS:alg', $alg); |
|
126
|
|
|
$digestTypeNode = $this->createElementNS($ns, 'secDNS:digestType', $digestType); |
|
127
|
|
|
$digestNode = $this->createElementNS($ns, 'secDNS:digest', $digest); |
|
128
|
|
|
$node->appendChild($keyTagNode); |
|
129
|
|
|
$node->appendChild($algNode); |
|
130
|
|
|
$node->appendChild($digestTypeNode); |
|
131
|
|
|
$node->appendChild($digestNode); |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
/** |
|
135
|
|
|
* Add/remove SecDNS dsData - RFC 5910 |
|
136
|
|
|
* |
|
137
|
|
|
* @param int $keyTag |
|
138
|
|
|
* @param int $alg |
|
139
|
|
|
* @param int $digestType |
|
140
|
|
|
* @param string $digest |
|
141
|
|
|
*/ |
|
142
|
|
|
public function removeSecDNSdsData($keyTag, $alg, $digestType, $digest) |
|
143
|
|
|
{ |
|
144
|
|
|
$this->addSecDNSdsData($keyTag, $alg, $digestType, $digest, true); |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
/** |
|
148
|
|
|
* Remove all secDNS data - RFC 5910 |
|
149
|
|
|
* |
|
150
|
|
|
* @param bool $all - whether to remove ALL (true) or do nothing (false) |
|
151
|
|
|
*/ |
|
152
|
|
|
public function removeSecDNSAll($all = true) |
|
153
|
|
|
{ |
|
154
|
|
|
$this->set('//epp:epp/epp:command/epp:extension/secDNS:update/secDNS:rem/secDNS:all', $all ? 'true' : 'false'); |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
public function removeAdminContact($contact) |
|
158
|
|
|
{ |
|
159
|
|
|
$this->addAdminContact($contact, true); |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
public function removeTechContact($contact) |
|
163
|
|
|
{ |
|
164
|
|
|
$this->addTechContact($contact, true); |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
public function removeBillingContact($contact) |
|
168
|
|
|
{ |
|
169
|
|
|
$this->addBillingContact($contact, true); |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
|
|
public function removeHostObj($host) |
|
173
|
|
|
{ |
|
174
|
|
|
$this->addHostObj($host, true); |
|
175
|
|
|
} |
|
176
|
|
|
|
|
177
|
|
|
public function removeHostAttr($host, $ips = null) |
|
178
|
|
|
{ |
|
179
|
|
|
$this->addHostAttr($host, $ips, true); |
|
180
|
|
|
} |
|
181
|
|
|
|
|
182
|
|
|
public function removeStatus($status) |
|
183
|
|
|
{ |
|
184
|
|
|
$this->addStatus($status, null, true); |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
public function changeRegistrant($registrant) |
|
188
|
|
|
{ |
|
189
|
|
|
$this->set('domain:chg/domain:registrant', $registrant); |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
public function changeAuthInfo($pw = null) |
|
193
|
|
|
{ |
|
194
|
|
|
if ($pw === null) { |
|
195
|
|
|
$pw = Random::auth(12); |
|
196
|
|
|
} |
|
197
|
|
|
|
|
198
|
|
|
$this->set('domain:chg/domain:authInfo/domain:pw', $pw); |
|
199
|
|
|
|
|
200
|
|
|
return $pw; |
|
201
|
|
|
} |
|
202
|
|
|
} |
|
203
|
|
|
|