mirror of
https://github.com/getnamingo/registry.git
synced 2025-05-15 17:16:59 +02:00
BRDA fixes
This commit is contained in:
parent
c06c7c3496
commit
0a4057f812
2 changed files with 307 additions and 299 deletions
|
@ -14,6 +14,7 @@ return [
|
||||||
'escrow_deleteXML' => false,
|
'escrow_deleteXML' => false,
|
||||||
'escrow_RDEupload' => false,
|
'escrow_RDEupload' => false,
|
||||||
'escrow_BRDAupload' => false,
|
'escrow_BRDAupload' => false,
|
||||||
|
'escrow_BRDAday' => 'Tuesday',
|
||||||
'escrow_keyPath' => '/opt/escrow/escrowKey.asc',
|
'escrow_keyPath' => '/opt/escrow/escrowKey.asc',
|
||||||
'escrow_keyPath_brda' => '/opt/escrow/icann-brda-gpg.pub',
|
'escrow_keyPath_brda' => '/opt/escrow/icann-brda-gpg.pub',
|
||||||
'escrow_privateKey' => '/opt/escrow/privatekey.asc',
|
'escrow_privateKey' => '/opt/escrow/privatekey.asc',
|
||||||
|
|
|
@ -530,7 +530,7 @@ try {
|
||||||
$reportXML->writeElement('rdeReport:version', '1');
|
$reportXML->writeElement('rdeReport:version', '1');
|
||||||
$reportXML->writeElement('rdeReport:rydeSpecEscrow', 'RFC8909');
|
$reportXML->writeElement('rdeReport:rydeSpecEscrow', 'RFC8909');
|
||||||
$reportXML->writeElement('rdeReport:rydeSpecMapping', 'RFC9022');
|
$reportXML->writeElement('rdeReport:rydeSpecMapping', 'RFC9022');
|
||||||
$reportXML->writeElement('rdeReport:resend', $deposit_id['revision']);
|
$reportXML->writeElement('rdeReport:resend', $finalDepositId);
|
||||||
$currentDateTime = new DateTime();
|
$currentDateTime = new DateTime();
|
||||||
$crDateWithMilliseconds = $currentDateTime->format("Y-m-d\TH:i:s.v\Z");
|
$crDateWithMilliseconds = $currentDateTime->format("Y-m-d\TH:i:s.v\Z");
|
||||||
$reportXML->writeElement('rdeReport:crDate', $crDateWithMilliseconds);
|
$reportXML->writeElement('rdeReport:crDate', $crDateWithMilliseconds);
|
||||||
|
@ -584,305 +584,310 @@ try {
|
||||||
$reportFilePath = $c['escrow_deposit_path']."/{$tldname}_".date('Y-m-d')."_full_R{$finalDepositId}.rep";
|
$reportFilePath = $c['escrow_deposit_path']."/{$tldname}_".date('Y-m-d')."_full_R{$finalDepositId}.rep";
|
||||||
file_put_contents($reportFilePath, $reps, LOCK_EX);
|
file_put_contents($reportFilePath, $reps, LOCK_EX);
|
||||||
|
|
||||||
// Start BRDA generation
|
$dayOfWeekToRunBRDA = $c['escrow_BRDAday'];
|
||||||
$xml = new XMLWriter();
|
$currentDayOfWeek = date('l');
|
||||||
$xml->openMemory();
|
|
||||||
$xml->startDocument('1.0', 'UTF-8');
|
|
||||||
|
|
||||||
// Start the rde:deposit element with the necessary attributes
|
if ($currentDayOfWeek === $dayOfWeekToRunBRDA) {
|
||||||
$xml->startElementNS('rde', 'deposit', 'urn:ietf:params:xml:ns:rde-1.0');
|
// Start BRDA generation
|
||||||
$xml->writeAttribute('type', 'FULL');
|
$xml = new XMLWriter();
|
||||||
$paddedFinalDepositId = str_pad($finalDepositId, 3, '0', STR_PAD_LEFT);
|
$xml->openMemory();
|
||||||
$depositId = date('Ymd') . $paddedFinalDepositId;
|
$xml->startDocument('1.0', 'UTF-8');
|
||||||
$xml->writeAttribute('id', $depositId);
|
|
||||||
|
|
||||||
// Add the necessary XML namespaces
|
// Start the rde:deposit element with the necessary attributes
|
||||||
$xml->writeAttributeNS('xmlns', 'domain', null, 'urn:ietf:params:xml:ns:domain-1.0');
|
$xml->startElementNS('rde', 'deposit', 'urn:ietf:params:xml:ns:rde-1.0');
|
||||||
$xml->writeAttributeNS('xmlns', 'contact', null, 'urn:ietf:params:xml:ns:contact-1.0');
|
$xml->writeAttribute('type', 'FULL');
|
||||||
$xml->writeAttributeNS('xmlns', 'secDNS', null, 'urn:ietf:params:xml:ns:secDNS-1.1');
|
$paddedFinalDepositId = str_pad($finalDepositId, 3, '0', STR_PAD_LEFT);
|
||||||
$xml->writeAttributeNS('xmlns', 'rdeHeader', null, 'urn:ietf:params:xml:ns:rdeHeader-1.0');
|
$depositId = date('Ymd') . $paddedFinalDepositId;
|
||||||
$xml->writeAttributeNS('xmlns', 'rdeDomain', null, 'urn:ietf:params:xml:ns:rdeDomain-1.0');
|
$xml->writeAttribute('id', $depositId);
|
||||||
$xml->writeAttributeNS('xmlns', 'rdeHost', null, 'urn:ietf:params:xml:ns:rdeHost-1.0');
|
|
||||||
$xml->writeAttributeNS('xmlns', 'rdeContact', null, 'urn:ietf:params:xml:ns:rdeContact-1.0');
|
|
||||||
$xml->writeAttributeNS('xmlns', 'rdeRegistrar', null, 'urn:ietf:params:xml:ns:rdeRegistrar-1.0');
|
|
||||||
$xml->writeAttributeNS('xmlns', 'rdeIDN', null, 'urn:ietf:params:xml:ns:rdeIDN-1.0');
|
|
||||||
$xml->writeAttributeNS('xmlns', 'rdeNNDN', null, 'urn:ietf:params:xml:ns:rdeNNDN-1.0');
|
|
||||||
$xml->writeAttributeNS('xmlns', 'rdeEppParams', null, 'urn:ietf:params:xml:ns:rdeEppParams-1.0');
|
|
||||||
$xml->writeAttributeNS('xmlns', 'rdePolicy', null, 'urn:ietf:params:xml:ns:rdePolicy-1.0');
|
|
||||||
$xml->writeAttributeNS('xmlns', 'epp', null, 'urn:ietf:params:xml:ns:epp-1.0');
|
|
||||||
|
|
||||||
$xml->startElementNS('rde', 'watermark', null);
|
// Add the necessary XML namespaces
|
||||||
$previousDayWatermark = date('Y-m-d', strtotime('-1 day')) . 'T23:59:59Z';
|
$xml->writeAttributeNS('xmlns', 'domain', null, 'urn:ietf:params:xml:ns:domain-1.0');
|
||||||
$xml->text($previousDayWatermark);
|
$xml->writeAttributeNS('xmlns', 'contact', null, 'urn:ietf:params:xml:ns:contact-1.0');
|
||||||
$xml->endElement(); // End rde:watermark
|
$xml->writeAttributeNS('xmlns', 'secDNS', null, 'urn:ietf:params:xml:ns:secDNS-1.1');
|
||||||
|
$xml->writeAttributeNS('xmlns', 'rdeHeader', null, 'urn:ietf:params:xml:ns:rdeHeader-1.0');
|
||||||
|
$xml->writeAttributeNS('xmlns', 'rdeDomain', null, 'urn:ietf:params:xml:ns:rdeDomain-1.0');
|
||||||
|
$xml->writeAttributeNS('xmlns', 'rdeHost', null, 'urn:ietf:params:xml:ns:rdeHost-1.0');
|
||||||
|
$xml->writeAttributeNS('xmlns', 'rdeContact', null, 'urn:ietf:params:xml:ns:rdeContact-1.0');
|
||||||
|
$xml->writeAttributeNS('xmlns', 'rdeRegistrar', null, 'urn:ietf:params:xml:ns:rdeRegistrar-1.0');
|
||||||
|
$xml->writeAttributeNS('xmlns', 'rdeIDN', null, 'urn:ietf:params:xml:ns:rdeIDN-1.0');
|
||||||
|
$xml->writeAttributeNS('xmlns', 'rdeNNDN', null, 'urn:ietf:params:xml:ns:rdeNNDN-1.0');
|
||||||
|
$xml->writeAttributeNS('xmlns', 'rdeEppParams', null, 'urn:ietf:params:xml:ns:rdeEppParams-1.0');
|
||||||
|
$xml->writeAttributeNS('xmlns', 'rdePolicy', null, 'urn:ietf:params:xml:ns:rdePolicy-1.0');
|
||||||
|
$xml->writeAttributeNS('xmlns', 'epp', null, 'urn:ietf:params:xml:ns:epp-1.0');
|
||||||
|
|
||||||
// Start the rde:rdeMenu element
|
$xml->startElementNS('rde', 'watermark', null);
|
||||||
$xml->startElementNS('rde', 'rdeMenu', null);
|
$previousDayWatermark = date('Y-m-d', strtotime('-1 day')) . 'T23:59:59Z';
|
||||||
|
$xml->text($previousDayWatermark);
|
||||||
|
$xml->endElement(); // End rde:watermark
|
||||||
|
|
||||||
// Write the rde:version element
|
// Start the rde:rdeMenu element
|
||||||
$xml->startElementNS('rde', 'version', null);
|
$xml->startElementNS('rde', 'rdeMenu', null);
|
||||||
$xml->text('1.0');
|
|
||||||
$xml->endElement(); // End rde:version
|
|
||||||
|
|
||||||
// Array of objURI values
|
// Write the rde:version element
|
||||||
$objURIs = [
|
$xml->startElementNS('rde', 'version', null);
|
||||||
'urn:ietf:params:xml:ns:rdeHeader-1.0',
|
$xml->text('1.0');
|
||||||
'urn:ietf:params:xml:ns:rdeContact-1.0',
|
$xml->endElement(); // End rde:version
|
||||||
'urn:ietf:params:xml:ns:rdeHost-1.0',
|
|
||||||
'urn:ietf:params:xml:ns:rdeDomain-1.0',
|
|
||||||
'urn:ietf:params:xml:ns:rdeRegistrar-1.0',
|
|
||||||
'urn:ietf:params:xml:ns:rdeIDN-1.0',
|
|
||||||
'urn:ietf:params:xml:ns:rdeNNDN-1.0',
|
|
||||||
'urn:ietf:params:xml:ns:rdeEppParams-1.0'
|
|
||||||
];
|
|
||||||
|
|
||||||
// Write each rde:objURI element
|
// Array of objURI values
|
||||||
foreach ($objURIs as $objURI) {
|
$objURIs = [
|
||||||
$xml->startElementNS('rde', 'objURI', null);
|
'urn:ietf:params:xml:ns:rdeHeader-1.0',
|
||||||
$xml->text($objURI);
|
'urn:ietf:params:xml:ns:rdeContact-1.0',
|
||||||
$xml->endElement(); // End rde:objURI
|
'urn:ietf:params:xml:ns:rdeHost-1.0',
|
||||||
}
|
'urn:ietf:params:xml:ns:rdeDomain-1.0',
|
||||||
|
'urn:ietf:params:xml:ns:rdeRegistrar-1.0',
|
||||||
|
'urn:ietf:params:xml:ns:rdeIDN-1.0',
|
||||||
|
'urn:ietf:params:xml:ns:rdeNNDN-1.0',
|
||||||
|
'urn:ietf:params:xml:ns:rdeEppParams-1.0'
|
||||||
|
];
|
||||||
|
|
||||||
// End the rde:rdeMenu element
|
// Write each rde:objURI element
|
||||||
$xml->endElement(); // End rde:rdeMenu
|
foreach ($objURIs as $objURI) {
|
||||||
|
$xml->startElementNS('rde', 'objURI', null);
|
||||||
$xml->startElementNS('rde', 'contents', null);
|
$xml->text($objURI);
|
||||||
|
$xml->endElement(); // End rde:objURI
|
||||||
$xml->startElement('rdeHeader:header');
|
|
||||||
$xml->writeElement('rdeHeader:tld', $tld['tld']);
|
|
||||||
|
|
||||||
$xml->startElement('rdeHeader:count');
|
|
||||||
$xml->writeAttribute('uri', 'urn:ietf:params:xml:ns:rdeDomain-1.0');
|
|
||||||
$xml->text($domainCount);
|
|
||||||
$xml->endElement();
|
|
||||||
|
|
||||||
$xml->startElement('rdeHeader:count');
|
|
||||||
$xml->writeAttribute('uri', 'urn:ietf:params:xml:ns:rdeHost-1.0');
|
|
||||||
$xml->text($hostCount);
|
|
||||||
$xml->endElement();
|
|
||||||
|
|
||||||
$xml->startElement('rdeHeader:count');
|
|
||||||
$xml->writeAttribute('uri', 'urn:ietf:params:xml:ns:rdeContact-1.0');
|
|
||||||
$xml->text($contactCount);
|
|
||||||
$xml->endElement();
|
|
||||||
|
|
||||||
$xml->startElement('rdeHeader:count');
|
|
||||||
$xml->writeAttribute('uri', 'urn:ietf:params:xml:ns:rdeRegistrar-1.0');
|
|
||||||
$xml->text($registrarCount);
|
|
||||||
$xml->endElement();
|
|
||||||
|
|
||||||
$xml->startElement('rdeHeader:count');
|
|
||||||
$xml->writeAttribute('uri', 'urn:ietf:params:xml:ns:rdeIDN-1.0');
|
|
||||||
$xml->text('0');
|
|
||||||
$xml->endElement();
|
|
||||||
|
|
||||||
$xml->startElement('rdeHeader:count');
|
|
||||||
$xml->writeAttribute('uri', 'urn:ietf:params:xml:ns:rdeNNDN-1.0');
|
|
||||||
$xml->text('0');
|
|
||||||
$xml->endElement();
|
|
||||||
|
|
||||||
$xml->startElement('rdeHeader:count');
|
|
||||||
$xml->writeAttribute('uri', 'urn:ietf:params:xml:ns:rdeEppParams-1.0');
|
|
||||||
$xml->text('0');
|
|
||||||
$xml->endElement();
|
|
||||||
|
|
||||||
$xml->endElement(); // Closing rdeHeader:header
|
|
||||||
|
|
||||||
// Fetch domain details for this TLD
|
|
||||||
$stmt = $dbh->prepare("SELECT * FROM domain WHERE tldid = :tldid AND crdate <= :endOfPreviousDay");
|
|
||||||
$stmt->bindParam(':tldid', $tld['id']);
|
|
||||||
$stmt->bindParam(':endOfPreviousDay', $endOfPreviousDay);
|
|
||||||
$stmt->execute();
|
|
||||||
$domains = $stmt->fetchAll();
|
|
||||||
|
|
||||||
foreach ($domains as $domain) {
|
|
||||||
$xml->startElement('rdeDom:domain');
|
|
||||||
$xml->writeElement('rdeDom:name', $domain['name']);
|
|
||||||
$xml->writeElement('rdeDom:roid', 'D' . $domain['id']);
|
|
||||||
$xml->writeElement('rdeDom:uName', $domain['name']);
|
|
||||||
$xml->writeElement('rdeDom:idnTableId', 'Latn');
|
|
||||||
|
|
||||||
// Fetch domain status
|
|
||||||
$stmt = $dbh->prepare("SELECT * FROM domain_status WHERE domain_id = :domain_id;");
|
|
||||||
$stmt->bindParam(':domain_id', $domain['id']);
|
|
||||||
$stmt->execute();
|
|
||||||
$status = $stmt->fetch();
|
|
||||||
$xml->writeElement('rdeDom:status', $status['status'] ?? 'okk');
|
|
||||||
|
|
||||||
$xml->writeElement('rdeDom:registrant', $domain['registrant']);
|
|
||||||
|
|
||||||
// Fetch domain contacts
|
|
||||||
$stmt = $dbh->prepare("SELECT * FROM domain_contact_map WHERE domain_id = :domain_id;");
|
|
||||||
$stmt->bindParam(':domain_id', $domain['id']);
|
|
||||||
$stmt->execute();
|
|
||||||
$domain_contacts = $stmt->fetchAll();
|
|
||||||
foreach ($domain_contacts as $contact) {
|
|
||||||
$xml->startElement('rdeDom:contact');
|
|
||||||
$xml->writeAttribute('type', $contact['type']);
|
|
||||||
$xml->text($contact['contact_id']);
|
|
||||||
$xml->endElement(); // Closing rdeDom:contact
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch domain hosts and incorporate into XML
|
// End the rde:rdeMenu element
|
||||||
$stmt = $dbh->prepare("SELECT host.name FROM domain_host_map JOIN host ON domain_host_map.host_id = host.id WHERE domain_host_map.domain_id = :domain_id;");
|
$xml->endElement(); // End rde:rdeMenu
|
||||||
$stmt->bindParam(':domain_id', $domain['id']);
|
|
||||||
|
$xml->startElementNS('rde', 'contents', null);
|
||||||
|
|
||||||
|
$xml->startElement('rdeHeader:header');
|
||||||
|
$xml->writeElement('rdeHeader:tld', $tld['tld']);
|
||||||
|
|
||||||
|
$xml->startElement('rdeHeader:count');
|
||||||
|
$xml->writeAttribute('uri', 'urn:ietf:params:xml:ns:rdeDomain-1.0');
|
||||||
|
$xml->text($domainCount);
|
||||||
|
$xml->endElement();
|
||||||
|
|
||||||
|
$xml->startElement('rdeHeader:count');
|
||||||
|
$xml->writeAttribute('uri', 'urn:ietf:params:xml:ns:rdeHost-1.0');
|
||||||
|
$xml->text($hostCount);
|
||||||
|
$xml->endElement();
|
||||||
|
|
||||||
|
$xml->startElement('rdeHeader:count');
|
||||||
|
$xml->writeAttribute('uri', 'urn:ietf:params:xml:ns:rdeContact-1.0');
|
||||||
|
$xml->text($contactCount);
|
||||||
|
$xml->endElement();
|
||||||
|
|
||||||
|
$xml->startElement('rdeHeader:count');
|
||||||
|
$xml->writeAttribute('uri', 'urn:ietf:params:xml:ns:rdeRegistrar-1.0');
|
||||||
|
$xml->text($registrarCount);
|
||||||
|
$xml->endElement();
|
||||||
|
|
||||||
|
$xml->startElement('rdeHeader:count');
|
||||||
|
$xml->writeAttribute('uri', 'urn:ietf:params:xml:ns:rdeIDN-1.0');
|
||||||
|
$xml->text('0');
|
||||||
|
$xml->endElement();
|
||||||
|
|
||||||
|
$xml->startElement('rdeHeader:count');
|
||||||
|
$xml->writeAttribute('uri', 'urn:ietf:params:xml:ns:rdeNNDN-1.0');
|
||||||
|
$xml->text('0');
|
||||||
|
$xml->endElement();
|
||||||
|
|
||||||
|
$xml->startElement('rdeHeader:count');
|
||||||
|
$xml->writeAttribute('uri', 'urn:ietf:params:xml:ns:rdeEppParams-1.0');
|
||||||
|
$xml->text('0');
|
||||||
|
$xml->endElement();
|
||||||
|
|
||||||
|
$xml->endElement(); // Closing rdeHeader:header
|
||||||
|
|
||||||
|
// Fetch domain details for this TLD
|
||||||
|
$stmt = $dbh->prepare("SELECT * FROM domain WHERE tldid = :tldid AND crdate <= :endOfPreviousDay");
|
||||||
|
$stmt->bindParam(':tldid', $tld['id']);
|
||||||
|
$stmt->bindParam(':endOfPreviousDay', $endOfPreviousDay);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$domain_hosts = $stmt->fetchAll();
|
$domains = $stmt->fetchAll();
|
||||||
$xml->startElement('rdeDom:ns');
|
|
||||||
foreach ($domain_hosts as $host) {
|
|
||||||
$xml->writeElement('domain:hostObj', $host['name']);
|
|
||||||
}
|
|
||||||
$xml->endElement(); // Closing rdeDom:ns
|
|
||||||
|
|
||||||
$xml->writeElement('rdeDom:clID', $domain['clid']);
|
foreach ($domains as $domain) {
|
||||||
$xml->writeElement('rdeDom:crRr', $domain['crid']);
|
$xml->startElement('rdeDom:domain');
|
||||||
$crDate = DateTime::createFromFormat('Y-m-d H:i:s.v', $domain['crdate']);
|
$xml->writeElement('rdeDom:name', $domain['name']);
|
||||||
$xml->writeElement('rdeDom:crDate', $crDate->format("Y-m-d\\TH:i:s.v\\Z"));
|
$xml->writeElement('rdeDom:roid', 'D' . $domain['id']);
|
||||||
$exDate = DateTime::createFromFormat('Y-m-d H:i:s.v', $domain['exdate']);
|
$xml->writeElement('rdeDom:uName', $domain['name']);
|
||||||
$xml->writeElement('rdeDom:exDate', $exDate->format("Y-m-d\\TH:i:s.v\\Z"));
|
$xml->writeElement('rdeDom:idnTableId', 'Latn');
|
||||||
|
|
||||||
$xml->endElement(); // Closing rdeDom:domain
|
// Fetch domain status
|
||||||
}
|
$stmt = $dbh->prepare("SELECT * FROM domain_status WHERE domain_id = :domain_id;");
|
||||||
|
$stmt->bindParam(':domain_id', $domain['id']);
|
||||||
|
$stmt->execute();
|
||||||
|
$status = $stmt->fetch();
|
||||||
|
$xml->writeElement('rdeDom:status', $status['status'] ?? 'okk');
|
||||||
|
|
||||||
// Fetch and incorporate registrar details
|
$xml->writeElement('rdeDom:registrant', $domain['registrant']);
|
||||||
$stmt = $dbh->prepare("SELECT * FROM registrar WHERE crdate <= :endOfPreviousDay");
|
|
||||||
$stmt->bindParam(':endOfPreviousDay', $endOfPreviousDay);
|
|
||||||
$stmt->execute();
|
|
||||||
$registrars = $stmt->fetchAll();
|
|
||||||
|
|
||||||
$xml->startElement('rdeRegistrar:registrar');
|
// Fetch domain contacts
|
||||||
foreach ($registrars as $registrar) {
|
$stmt = $dbh->prepare("SELECT * FROM domain_contact_map WHERE domain_id = :domain_id;");
|
||||||
$xml->writeElement('rdeRegistrar:id', $registrar['clid']);
|
$stmt->bindParam(':domain_id', $domain['id']);
|
||||||
$xml->writeElement('rdeRegistrar:name', $registrar['name']);
|
$stmt->execute();
|
||||||
$xml->writeElement('rdeRegistrar:gurid', $registrar['iana_id']);
|
$domain_contacts = $stmt->fetchAll();
|
||||||
$xml->writeElement('rdeRegistrar:status', 'ok');
|
foreach ($domain_contacts as $contact) {
|
||||||
|
$xml->startElement('rdeDom:contact');
|
||||||
|
$xml->writeAttribute('type', $contact['type']);
|
||||||
|
$xml->text($contact['contact_id']);
|
||||||
|
$xml->endElement(); // Closing rdeDom:contact
|
||||||
|
}
|
||||||
|
|
||||||
// Fetch and incorporate registrar contact details
|
// Fetch domain hosts and incorporate into XML
|
||||||
$stmt = $dbh->prepare("SELECT * FROM registrar_contact WHERE registrar_id = :registrar_id;");
|
$stmt = $dbh->prepare("SELECT host.name FROM domain_host_map JOIN host ON domain_host_map.host_id = host.id WHERE domain_host_map.domain_id = :domain_id;");
|
||||||
$stmt->bindParam(':registrar_id', $registrar['id']);
|
$stmt->bindParam(':domain_id', $domain['id']);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$registrar_contacts = $stmt->fetchAll();
|
$domain_hosts = $stmt->fetchAll();
|
||||||
|
$xml->startElement('rdeDom:ns');
|
||||||
|
foreach ($domain_hosts as $host) {
|
||||||
|
$xml->writeElement('domain:hostObj', $host['name']);
|
||||||
|
}
|
||||||
|
$xml->endElement(); // Closing rdeDom:ns
|
||||||
|
|
||||||
foreach ($registrar_contacts as $contact) {
|
$xml->writeElement('rdeDom:clID', $domain['clid']);
|
||||||
$xml->startElement('rdeRegistrar:postalInfo');
|
$xml->writeElement('rdeDom:crRr', $domain['crid']);
|
||||||
$xml->writeAttribute('type', 'int');
|
$crDate = DateTime::createFromFormat('Y-m-d H:i:s.v', $domain['crdate']);
|
||||||
$xml->startElement('rdeRegistrar:addr');
|
$xml->writeElement('rdeDom:crDate', $crDate->format("Y-m-d\\TH:i:s.v\\Z"));
|
||||||
$xml->writeElement('rdeRegistrar:street', $contact['street1']);
|
$exDate = DateTime::createFromFormat('Y-m-d H:i:s.v', $domain['exdate']);
|
||||||
$xml->writeElement('rdeRegistrar:city', $contact['city']);
|
$xml->writeElement('rdeDom:exDate', $exDate->format("Y-m-d\\TH:i:s.v\\Z"));
|
||||||
$xml->writeElement('rdeRegistrar:pc', $contact['pc']);
|
|
||||||
$xml->writeElement('rdeRegistrar:cc', $contact['cc']);
|
|
||||||
$xml->endElement(); // Closing rdeRegistrar:addr
|
|
||||||
$xml->endElement(); // Closing rdeRegistrar:postalInfo
|
|
||||||
|
|
||||||
$xml->writeElement('rdeRegistrar:voice', $contact['voice']);
|
$xml->endElement(); // Closing rdeDom:domain
|
||||||
$xml->writeElement('rdeRegistrar:fax', $contact['fax']);
|
|
||||||
$xml->writeElement('rdeRegistrar:email', $contact['email']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$xml->writeElement('rdeRegistrar:url', $registrar['url']);
|
// Fetch and incorporate registrar details
|
||||||
$xml->startElement('rdeRegistrar:whoisInfo');
|
$stmt = $dbh->prepare("SELECT * FROM registrar WHERE crdate <= :endOfPreviousDay");
|
||||||
$xml->writeElement('rdeRegistrar:name', $registrar['whois_server']);
|
$stmt->bindParam(':endOfPreviousDay', $endOfPreviousDay);
|
||||||
$xml->writeElement('rdeRegistrar:url', $registrar['whois_server']);
|
$stmt->execute();
|
||||||
$xml->endElement(); // Closing rdeRegistrar:whoisInfo
|
$registrars = $stmt->fetchAll();
|
||||||
|
|
||||||
$crDate = DateTime::createFromFormat('Y-m-d H:i:s.v', $registrar['crdate']);
|
$xml->startElement('rdeRegistrar:registrar');
|
||||||
$xml->writeElement('rdeRegistrar:crDate', $crDate->format("Y-m-d\\TH:i:s.v\\Z"));
|
foreach ($registrars as $registrar) {
|
||||||
|
$xml->writeElement('rdeRegistrar:id', $registrar['clid']);
|
||||||
|
$xml->writeElement('rdeRegistrar:name', $registrar['name']);
|
||||||
|
$xml->writeElement('rdeRegistrar:gurid', $registrar['iana_id']);
|
||||||
|
$xml->writeElement('rdeRegistrar:status', 'ok');
|
||||||
|
|
||||||
|
// Fetch and incorporate registrar contact details
|
||||||
|
$stmt = $dbh->prepare("SELECT * FROM registrar_contact WHERE registrar_id = :registrar_id;");
|
||||||
|
$stmt->bindParam(':registrar_id', $registrar['id']);
|
||||||
|
$stmt->execute();
|
||||||
|
$registrar_contacts = $stmt->fetchAll();
|
||||||
|
|
||||||
|
foreach ($registrar_contacts as $contact) {
|
||||||
|
$xml->startElement('rdeRegistrar:postalInfo');
|
||||||
|
$xml->writeAttribute('type', 'int');
|
||||||
|
$xml->startElement('rdeRegistrar:addr');
|
||||||
|
$xml->writeElement('rdeRegistrar:street', $contact['street1']);
|
||||||
|
$xml->writeElement('rdeRegistrar:city', $contact['city']);
|
||||||
|
$xml->writeElement('rdeRegistrar:pc', $contact['pc']);
|
||||||
|
$xml->writeElement('rdeRegistrar:cc', $contact['cc']);
|
||||||
|
$xml->endElement(); // Closing rdeRegistrar:addr
|
||||||
|
$xml->endElement(); // Closing rdeRegistrar:postalInfo
|
||||||
|
|
||||||
|
$xml->writeElement('rdeRegistrar:voice', $contact['voice']);
|
||||||
|
$xml->writeElement('rdeRegistrar:fax', $contact['fax']);
|
||||||
|
$xml->writeElement('rdeRegistrar:email', $contact['email']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$xml->writeElement('rdeRegistrar:url', $registrar['url']);
|
||||||
|
$xml->startElement('rdeRegistrar:whoisInfo');
|
||||||
|
$xml->writeElement('rdeRegistrar:name', $registrar['whois_server']);
|
||||||
|
$xml->writeElement('rdeRegistrar:url', $registrar['whois_server']);
|
||||||
|
$xml->endElement(); // Closing rdeRegistrar:whoisInfo
|
||||||
|
|
||||||
|
$crDate = DateTime::createFromFormat('Y-m-d H:i:s.v', $registrar['crdate']);
|
||||||
|
$xml->writeElement('rdeRegistrar:crDate', $crDate->format("Y-m-d\\TH:i:s.v\\Z"));
|
||||||
|
}
|
||||||
|
$xml->endElement(); // Closing rdeRegistrar:registrar
|
||||||
|
|
||||||
|
// End the rde:contents element
|
||||||
|
$xml->endElement(); // End rde:contents
|
||||||
|
|
||||||
|
$xml->endElement(); // Closing the 'rde:deposit' element
|
||||||
|
$deposit = $xml->outputMemory();
|
||||||
|
|
||||||
|
// Define the base name without the extension
|
||||||
|
$baseFileNameBrda = "{$tldname}_".date('Y-m-d')."_brda_S1_R{$finalDepositId}";
|
||||||
|
|
||||||
|
// XML, tar, and gzip filenames
|
||||||
|
$xmlFileName = $baseFileNameBrda . ".xml";
|
||||||
|
$tarFileName = $baseFileNameBrda . ".tar";
|
||||||
|
$gzipFileName = $baseFileNameBrda . ".tar.gz";
|
||||||
|
|
||||||
|
// Save the main XML file
|
||||||
|
file_put_contents($c['escrow_deposit_path']."/".$xmlFileName, $deposit, LOCK_EX);
|
||||||
|
|
||||||
|
// Compress the XML file using tar
|
||||||
|
$phar = new PharData($c['escrow_deposit_path']."/".$tarFileName);
|
||||||
|
$phar->addFile($c['escrow_deposit_path']."/".$xmlFileName, $xmlFileName);
|
||||||
|
|
||||||
|
// Compress the tar archive using gzip
|
||||||
|
$phar->compress(Phar::GZ);
|
||||||
|
|
||||||
|
// Delete the original tar file
|
||||||
|
unlink($c['escrow_deposit_path']."/".$tarFileName);
|
||||||
|
|
||||||
|
// Check if the $c['escrow_deleteXML'] variable is set to true and delete the original XML file
|
||||||
|
if ($c['escrow_deleteXML']) {
|
||||||
|
unlink($c['escrow_deposit_path']."/".$xmlFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize a GnuPG instance
|
||||||
|
$res = gnupg_init();
|
||||||
|
|
||||||
|
// Get information about the public key from its content
|
||||||
|
$publicKeyInfo = gnupg_import($res, file_get_contents($c['escrow_keyPath_brda']));
|
||||||
|
$fingerprint = $publicKeyInfo['fingerprint'];
|
||||||
|
|
||||||
|
// Check if the key is already in the keyring
|
||||||
|
$existingKeys = gnupg_keyinfo($res, $fingerprint);
|
||||||
|
|
||||||
|
if (!$existingKeys) {
|
||||||
|
// If not, import the public key
|
||||||
|
gnupg_import($res, file_get_contents($c['escrow_keyPath_brda']));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read the .tar.gz file contents
|
||||||
|
$fileData = file_get_contents($c['escrow_deposit_path'] . "/" . $gzipFileName);
|
||||||
|
|
||||||
|
// Add the encryption key
|
||||||
|
gnupg_addencryptkey($res, $fingerprint);
|
||||||
|
|
||||||
|
// Encrypt the file data using the public key
|
||||||
|
$encryptedData = gnupg_encrypt($res, $fileData);
|
||||||
|
|
||||||
|
if (!$encryptedData) {
|
||||||
|
$log->error('Error encrypting data: ' . gnupg_geterror($res));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save the encrypted data to a new file
|
||||||
|
file_put_contents($c['escrow_deposit_path'] . "/" . $baseFileNameBrda . ".ryde", $encryptedData);
|
||||||
|
|
||||||
|
// Delete the original .tar.gz file
|
||||||
|
unlink($c['escrow_deposit_path'] . "/" . $gzipFileName);
|
||||||
|
|
||||||
|
$encryptedFilePathBrda = $c['escrow_deposit_path'] . "/" . $baseFileNameBrda . ".ryde";
|
||||||
|
|
||||||
|
// Initialize the GnuPG extension
|
||||||
|
$gpg = new gnupg();
|
||||||
|
$gpg->seterrormode(gnupg::ERROR_EXCEPTION); // throw exceptions on errors
|
||||||
|
|
||||||
|
// Import your private key (if it's not already in the keyring)
|
||||||
|
$privateKeyData = file_get_contents($c['escrow_privateKey']);
|
||||||
|
$importResult = $gpg->import($privateKeyData);
|
||||||
|
|
||||||
|
// Set the key to be used for signing
|
||||||
|
$privateKeyId = $importResult['fingerprint'];
|
||||||
|
$gpg->addsignkey($privateKeyId);
|
||||||
|
|
||||||
|
// Specify the detached signature mode
|
||||||
|
$gpg->setsignmode(GNUPG_SIG_MODE_DETACH);
|
||||||
|
|
||||||
|
// Sign the encrypted data
|
||||||
|
$encryptedData = file_get_contents($encryptedFilePathBrda);
|
||||||
|
$signature = $gpg->sign($encryptedData);
|
||||||
|
|
||||||
|
// Save the signature to a .sig file
|
||||||
|
$signatureFilePathBrda = $c['escrow_deposit_path'] . '/' . pathinfo($encryptedFilePathBrda, PATHINFO_FILENAME) . '.sig';
|
||||||
|
file_put_contents($signatureFilePathBrda, $signature);
|
||||||
|
|
||||||
|
// Optionally, delete the encrypted file if you don't need it anymore
|
||||||
|
// unlink($encryptedFilePathBrda);
|
||||||
}
|
}
|
||||||
$xml->endElement(); // Closing rdeRegistrar:registrar
|
|
||||||
|
|
||||||
// End the rde:contents element
|
|
||||||
$xml->endElement(); // End rde:contents
|
|
||||||
|
|
||||||
$xml->endElement(); // Closing the 'rde:deposit' element
|
|
||||||
$deposit = $xml->outputMemory();
|
|
||||||
|
|
||||||
// Define the base name without the extension
|
|
||||||
$baseFileName = "{$tldname}_".date('Y-m-d')."_brda_S1_R{$finalDepositId}";
|
|
||||||
|
|
||||||
// XML, tar, and gzip filenames
|
|
||||||
$xmlFileName = $baseFileName . ".xml";
|
|
||||||
$tarFileName = $baseFileName . ".tar";
|
|
||||||
$gzipFileName = $baseFileName . ".tar.gz";
|
|
||||||
|
|
||||||
// Save the main XML file
|
|
||||||
file_put_contents($c['escrow_deposit_path']."/".$xmlFileName, $deposit, LOCK_EX);
|
|
||||||
|
|
||||||
// Compress the XML file using tar
|
|
||||||
$phar = new PharData($c['escrow_deposit_path']."/".$tarFileName);
|
|
||||||
$phar->addFile($c['escrow_deposit_path']."/".$xmlFileName, $xmlFileName);
|
|
||||||
|
|
||||||
// Compress the tar archive using gzip
|
|
||||||
$phar->compress(Phar::GZ);
|
|
||||||
|
|
||||||
// Delete the original tar file
|
|
||||||
unlink($c['escrow_deposit_path']."/".$tarFileName);
|
|
||||||
|
|
||||||
// Check if the $c['escrow_deleteXML'] variable is set to true and delete the original XML file
|
|
||||||
if ($c['escrow_deleteXML']) {
|
|
||||||
unlink($c['escrow_deposit_path']."/".$xmlFileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize a GnuPG instance
|
|
||||||
$res = gnupg_init();
|
|
||||||
|
|
||||||
// Get information about the public key from its content
|
|
||||||
$publicKeyInfo = gnupg_import($res, file_get_contents($c['escrow_keyPath_brda']));
|
|
||||||
$fingerprint = $publicKeyInfo['fingerprint'];
|
|
||||||
|
|
||||||
// Check if the key is already in the keyring
|
|
||||||
$existingKeys = gnupg_keyinfo($res, $fingerprint);
|
|
||||||
|
|
||||||
if (!$existingKeys) {
|
|
||||||
// If not, import the public key
|
|
||||||
gnupg_import($res, file_get_contents($c['escrow_keyPath_brda']));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read the .tar.gz file contents
|
|
||||||
$fileData = file_get_contents($c['escrow_deposit_path'] . "/" . $gzipFileName);
|
|
||||||
|
|
||||||
// Add the encryption key
|
|
||||||
gnupg_addencryptkey($res, $fingerprint);
|
|
||||||
|
|
||||||
// Encrypt the file data using the public key
|
|
||||||
$encryptedData = gnupg_encrypt($res, $fileData);
|
|
||||||
|
|
||||||
if (!$encryptedData) {
|
|
||||||
$log->error('Error encrypting data: ' . gnupg_geterror($res));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save the encrypted data to a new file
|
|
||||||
file_put_contents($c['escrow_deposit_path'] . "/" . $baseFileName . ".ryde", $encryptedData);
|
|
||||||
|
|
||||||
// Delete the original .tar.gz file
|
|
||||||
unlink($c['escrow_deposit_path'] . "/" . $gzipFileName);
|
|
||||||
|
|
||||||
$encryptedFilePathBrda = $c['escrow_deposit_path'] . "/" . $baseFileName . ".ryde";
|
|
||||||
|
|
||||||
// Initialize the GnuPG extension
|
|
||||||
$gpg = new gnupg();
|
|
||||||
$gpg->seterrormode(gnupg::ERROR_EXCEPTION); // throw exceptions on errors
|
|
||||||
|
|
||||||
// Import your private key (if it's not already in the keyring)
|
|
||||||
$privateKeyData = file_get_contents($c['escrow_privateKey']);
|
|
||||||
$importResult = $gpg->import($privateKeyData);
|
|
||||||
|
|
||||||
// Set the key to be used for signing
|
|
||||||
$privateKeyId = $importResult['fingerprint'];
|
|
||||||
$gpg->addsignkey($privateKeyId);
|
|
||||||
|
|
||||||
// Specify the detached signature mode
|
|
||||||
$gpg->setsignmode(GNUPG_SIG_MODE_DETACH);
|
|
||||||
|
|
||||||
// Sign the encrypted data
|
|
||||||
$encryptedData = file_get_contents($encryptedFilePathBrda);
|
|
||||||
$signature = $gpg->sign($encryptedData);
|
|
||||||
|
|
||||||
// Save the signature to a .sig file
|
|
||||||
$signatureFilePathBrda = $c['escrow_deposit_path'] . '/' . pathinfo($encryptedFilePathBrda, PATHINFO_FILENAME) . '.sig';
|
|
||||||
file_put_contents($signatureFilePathBrda, $signature);
|
|
||||||
|
|
||||||
// Optionally, delete the encrypted file if you don't need it anymore
|
|
||||||
// unlink($encryptedFilePathBrda);
|
|
||||||
|
|
||||||
if ($c['escrow_RDEupload']) {
|
if ($c['escrow_RDEupload']) {
|
||||||
// Connect to the SFTP server
|
// Connect to the SFTP server
|
||||||
|
@ -944,30 +949,32 @@ try {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($c['escrow_BRDAupload']) {
|
if ($currentDayOfWeek === $dayOfWeekToRunBRDA) {
|
||||||
// Connect to the SFTP server
|
if ($c['escrow_BRDAupload']) {
|
||||||
$sftp = new SFTP($c['brda_sftp_host']);
|
// Connect to the SFTP server
|
||||||
|
$sftp = new SFTP($c['brda_sftp_host']);
|
||||||
|
|
||||||
// Login with username and password
|
// Login with username and password
|
||||||
if (!$sftp->login($c['brda_sftp_username'], $c['brda_sftp_password'])) {
|
if (!$sftp->login($c['brda_sftp_username'], $c['brda_sftp_password'])) {
|
||||||
$log->error('SFTP Login failed');
|
$log->error('SFTP Login failed');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define the remote directory where you want to upload the files
|
// Define the remote directory where you want to upload the files
|
||||||
$remoteDir = $c['brda_sftp_remotepath'];
|
$remoteDir = $c['brda_sftp_remotepath'];
|
||||||
|
|
||||||
// Upload the files
|
// Upload the files
|
||||||
$filesToUpload = [
|
$filesToUpload = [
|
||||||
$encryptedFilePathBrda,
|
$encryptedFilePathBrda,
|
||||||
$signatureFilePathBrda
|
$signatureFilePathBrda
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($filesToUpload as $filePath) {
|
foreach ($filesToUpload as $filePath) {
|
||||||
$remoteFile = $remoteDir . basename($filePath);
|
$remoteFile = $remoteDir . basename($filePath);
|
||||||
if (!$sftp->put($remoteFile, $filePath, SFTP::SOURCE_LOCAL_FILE)) {
|
if (!$sftp->put($remoteFile, $filePath, SFTP::SOURCE_LOCAL_FILE)) {
|
||||||
$log->error('Failed to upload ' . basename($filePath));
|
$log->error('Failed to upload ' . basename($filePath));
|
||||||
} else {
|
} else {
|
||||||
$log->info('Successfully uploaded ' . basename($filePath));
|
$log->info('Successfully uploaded ' . basename($filePath));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue