|
42 | 42 | * @param null $nameservers string
|
43 | 43 | */
|
44 | 44 | function modifydomain($conn, $domainname, $registrant = null, $admincontact = null, $techcontact = null, $billingcontact = null, $nameservers = null) {
|
| 45 | + $response = null; |
45 | 46 | try {
|
46 | 47 | $domain = new Metaregistrar\EPP\eppDomain($domainname);
|
47 | 48 | // First, retrieve the current domain info. Nameservers can be unset and then set again.
|
48 | 49 | $del = null;
|
49 | 50 | $info = new Metaregistrar\EPP\eppInfoDomainRequest($domain);
|
50 | 51 | if ((($response = $conn->writeandread($info)) instanceof Metaregistrar\EPP\eppInfoDomainResponse) && ($response->Success())) {
|
51 |
| - /* @var $response Metaregistrar\EPP\eppInfoDomainResponse */ |
52 | 52 | // If new nameservers are given, get the old ones to remove them
|
53 | 53 | if (is_array($nameservers)) {
|
54 | 54 | /* @var Metaregistrar\EPP\eppInfoDomainResponse $response */
|
55 |
| - // Check if nameservers are not already set for this domain name |
56 | 55 | $oldns = $response->getDomainNameservers();
|
57 | 56 | if (is_array($oldns)) {
|
58 |
| - foreach($oldns as $index=>$ns) { |
59 |
| - /* @var $ns Metaregistrar\EPP\eppHost */ |
60 |
| - if (in_array($ns->getHostname(),$nameservers)) { |
61 |
| - unset($nameservers[array_search($ns->getHostname(),$nameservers)]); |
62 |
| - unset($oldns[$index]); |
63 |
| - } |
| 57 | + if (!$del) { |
| 58 | + $del = new Metaregistrar\EPP\eppDomain($domainname); |
64 | 59 | }
|
65 |
| - if (count($oldns)>0) { |
66 |
| - if (!$del) { |
67 |
| - $del = new Metaregistrar\EPP\eppDomain($domainname); |
68 |
| - } |
69 |
| - foreach ($oldns as $ns) { |
70 |
| - $del->addHost($ns); |
71 |
| - } |
| 60 | + foreach ($oldns as $ns) { |
| 61 | + $del->addHost($ns); |
72 | 62 | }
|
73 | 63 | }
|
74 |
| - // Remove DNSSEC keydata that is present on this domain name |
75 |
| - $keydata = $response->getKeydata(); |
76 |
| - if ((is_array($keydata)) && (count($keydata)>0)) { |
| 64 | + } |
| 65 | + if ($admincontact) { |
| 66 | + $oldadmin = $response->getDomainContact(Metaregistrar\EPP\eppContactHandle::CONTACT_TYPE_ADMIN); |
| 67 | + if ($oldadmin == $admincontact) { |
| 68 | + $admincontact = null; |
| 69 | + } else { |
77 | 70 | if (!$del) {
|
78 | 71 | $del = new Metaregistrar\EPP\eppDomain($domainname);
|
79 | 72 | }
|
80 |
| - $del->addSecdns($keydata[0]); |
| 73 | + $admin = new Metaregistrar\EPP\eppContactHandle($oldadmin, Metaregistrar\EPP\eppContactHandle::CONTACT_TYPE_ADMIN); |
| 74 | + $del->addContact($admin); |
81 | 75 | }
|
82 | 76 | }
|
83 |
| - if ($admincontact) { |
84 |
| - $oldadmin = $response->getDomainContact(Metaregistrar\EPP\eppContactHandle::CONTACT_TYPE_ADMIN); |
85 |
| - if (!$del) { |
86 |
| - $del = new Metaregistrar\EPP\eppDomain($domainname); |
| 77 | + if ($techcontact) { |
| 78 | + $oldtech = $response->getDomainContact(Metaregistrar\EPP\eppContactHandle::CONTACT_TYPE_TECH); |
| 79 | + if ($oldtech == $techcontact) { |
| 80 | + $techcontact = null; |
| 81 | + } else { |
| 82 | + if (!$del) { |
| 83 | + $del = new Metaregistrar\EPP\eppDomain($domainname); |
| 84 | + } |
| 85 | + $tech = new Metaregistrar\EPP\eppContactHandle($oldtech, Metaregistrar\EPP\eppContactHandle::CONTACT_TYPE_TECH); |
| 86 | + $del->addContact($tech); |
87 | 87 | }
|
88 |
| - $admin = new Metaregistrar\EPP\eppContactHandle($oldadmin, Metaregistrar\EPP\eppContactHandle::CONTACT_TYPE_ADMIN); |
89 |
| - $del->addContact($admin); |
90 | 88 | }
|
91 | 89 | }
|
92 | 90 | // In the UpdateDomain command you can set or add parameters
|
@@ -130,18 +128,15 @@ function modifydomain($conn, $domainname, $registrant = null, $admincontact = nu
|
130 | 128 | $add->addHost($host);
|
131 | 129 | }
|
132 | 130 | }
|
133 |
| - if ((!$add) && (!$del) && (!$mod)) { |
134 |
| - echo "Nothing to update"; |
135 |
| - return; |
136 |
| - } |
137 |
| - $update = new Metaregistrar\EPP\eppDnssecUpdateDomainRequest($domain, $add, $del, $mod); |
| 131 | + $update = new Metaregistrar\EPP\rrpproxyEppUpdateDomainRequest($domain, $add, $del, $mod); |
| 132 | + //echo $update->saveXML(); |
138 | 133 | if ((($response = $conn->writeandread($update)) instanceof Metaregistrar\EPP\eppUpdateResponse) && ($response->Success())) {
|
139 |
| - /* @var $response Metaregistrar\EPP\eppUpdateResponse */ |
| 134 | + /* @var Metaregistrar\EPP\eppUpdateResponse $response */ |
140 | 135 | echo $response->getResultMessage() . "\n";
|
141 | 136 | }
|
142 | 137 | } catch (Metaregistrar\EPP\eppException $e) {
|
143 | 138 | echo $e->getMessage() . "\n";
|
144 |
| - if ((isset($response)) && ($response instanceof Metaregistrar\EPP\eppUpdateResponse)) { |
| 139 | + if ($response instanceof Metaregistrar\EPP\eppUpdateResponse) { |
145 | 140 | echo $response->textContent . "\n";
|
146 | 141 | }
|
147 | 142 | }
|
|
0 commit comments