Skip to content

Commit e4c0c71

Browse files
committed
Updates to support ICANN registrar accreditation
1 parent 20ac6b9 commit e4c0c71

File tree

2 files changed

+78
-6
lines changed

2 files changed

+78
-6
lines changed

epp.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -365,11 +365,15 @@ public function getDomainDetails(Registrar_Domain $domain)
365365
}
366366
$ns = array();
367367
$i = 0;
368-
foreach ($r->ns->hostObj as $hostObj) {
369-
$i++;
370-
$ns[$i] = (string)$hostObj;
368+
if (isset($r->ns->hostObj) && (is_array($r->ns->hostObj) || is_object($r->ns->hostObj))) {
369+
foreach ($r->ns->hostObj as $hostObj) {
370+
$i++;
371+
$ns[$i] = (string)$hostObj;
372+
}
373+
} else {
374+
$ns = [];
371375
}
372-
376+
373377
$crDate = strtotime($crDate);
374378
$exDate = strtotime($exDate);
375379

eppSync.php

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,11 @@ function connectEpp(string $registry, $config)
104104
$ns2 = isset($ns[2]) ? $ns[2] : null;
105105
$ns3 = isset($ns[3]) ? $ns[3] : null;
106106
$ns4 = isset($ns[4]) ? $ns[4] : null;
107-
107+
108108
$exDate = $domainInfo['exDate'];
109109
$datetime = new DateTime($exDate);
110110
$formattedExDate = $datetime->format('Y-m-d H:i:s');
111-
111+
112112
$statuses = $domainInfo['status'];
113113

114114
$clientStatuses = ['clientDeleteProhibited', 'clientTransferProhibited', 'clientUpdateProhibited'];
@@ -143,6 +143,74 @@ function connectEpp(string $registry, $config)
143143
// Execute the statement
144144
$stmt->execute();
145145

146+
$sqlCheck = 'SELECT COUNT(*) FROM extension WHERE name = :name AND status = :status';
147+
$stmtCheck = $pdo->prepare($sqlCheck);
148+
$stmtCheck->bindValue(':name', 'registrar');
149+
$stmtCheck->bindValue(':status', 'installed');
150+
$stmtCheck->execute();
151+
$count = $stmtCheck->fetchColumn();
152+
153+
if ($count > 0) {
154+
$selectStmt = $pdo->prepare('SELECT id FROM service_domain WHERE sld = :sld AND tld = :tld LIMIT 1');
155+
$selectStmt->bindValue(':sld', $domainRow['sld']);
156+
$selectStmt->bindValue(':tld', $domainRow['tld']);
157+
$selectStmt->execute();
158+
$domainId = $selectStmt->fetchColumn();
159+
160+
$sqlMeta = '
161+
INSERT INTO domain_meta (domain_id, registry_domain_id, registrant_contact_id, admin_contact_id, tech_contact_id, billing_contact_id, created_at, updated_at)
162+
VALUES (:domain_id, :registry_domain_id, :registrant_contact_id, :admin_contact_id, :tech_contact_id, :billing_contact_id, NOW(), NOW())
163+
ON DUPLICATE KEY UPDATE
164+
registry_domain_id = VALUES(registry_domain_id),
165+
registrant_contact_id = VALUES(registrant_contact_id),
166+
admin_contact_id = VALUES(admin_contact_id),
167+
tech_contact_id = VALUES(tech_contact_id),
168+
billing_contact_id = VALUES(billing_contact_id),
169+
updated_at = NOW();
170+
';
171+
$stmtMeta = $pdo->prepare($sqlMeta);
172+
$stmtMeta->bindValue(':domain_id', $domainId);
173+
$stmtMeta->bindValue(':registry_domain_id', $domainInfo['roid']);
174+
$stmtMeta->bindValue(':registrant_contact_id', $domainInfo['registrant']);
175+
$admin_contact_id = null;
176+
$tech_contact_id = null;
177+
$billing_contact_id = null;
178+
foreach ($domainInfo['contact'] as $contact) {
179+
if ($contact['type'] === 'admin') {
180+
$admin_contact_id = $contact['id'];
181+
} elseif ($contact['type'] === 'tech') {
182+
$tech_contact_id = $contact['id'];
183+
} elseif ($contact['type'] === 'billing') {
184+
$billing_contact_id = $contact['id'];
185+
}
186+
}
187+
$stmtMeta->bindValue(':admin_contact_id', $admin_contact_id);
188+
$stmtMeta->bindValue(':tech_contact_id', $tech_contact_id);
189+
$stmtMeta->bindValue(':billing_contact_id', $billing_contact_id);
190+
$stmtMeta->execute();
191+
192+
$status = $domainInfo['status'] ?? 'No status available';
193+
$sqlStatus = '
194+
INSERT INTO domain_status (domain_id, status, created_at)
195+
VALUES (:domain_id, :status, NOW())
196+
ON DUPLICATE KEY UPDATE
197+
status = VALUES(status),
198+
created_at = NOW();
199+
';
200+
$stmtStatus = $pdo->prepare($sqlStatus);
201+
202+
if (is_array($status)) {
203+
foreach ($status as $singleStatus) {
204+
$stmtStatus->bindValue(':domain_id', $domainId);
205+
$stmtStatus->bindValue(':status', $singleStatus);
206+
$stmtStatus->execute();
207+
}
208+
} else {
209+
$stmtStatus->bindValue(':domain_id', $domainId);
210+
$stmtStatus->bindValue(':status', $status);
211+
$stmtStatus->execute();
212+
}
213+
}
146214
echo "Update successful for domain: " . $domain . PHP_EOL;
147215
}
148216

0 commit comments

Comments
 (0)