mirror of
https://github.com/getnamingo/registry.git
synced 2025-07-24 19:38:26 +02:00
Further updates on automation
This commit is contained in:
parent
db75518533
commit
28c68a4e57
7 changed files with 918 additions and 882 deletions
|
@ -16,98 +16,104 @@ try {
|
|||
$log->error('DB Connection failed: ' . $e->getMessage());
|
||||
}
|
||||
|
||||
$query_domain = "SELECT id, name, registrant, crdate, exdate, `update`, clid, crid, upid, trdate, trstatus, reid, redate, acid, acdate, transfer_exdate FROM domain WHERE CURRENT_TIMESTAMP > acdate AND trstatus = 'pending'";
|
||||
$stmt_domain = $dbh->prepare($query_domain);
|
||||
$stmt_domain->execute();
|
||||
try {
|
||||
$query_domain = "SELECT id, name, registrant, crdate, exdate, `update`, clid, crid, upid, trdate, trstatus, reid, redate, acid, acdate, transfer_exdate FROM domain WHERE CURRENT_TIMESTAMP > acdate AND trstatus = 'pending'";
|
||||
$stmt_domain = $dbh->prepare($query_domain);
|
||||
$stmt_domain->execute();
|
||||
|
||||
while ($row = $stmt_domain->fetch(PDO::FETCH_ASSOC)) {
|
||||
// Extracting data from the result set
|
||||
extract($row);
|
||||
while ($row = $stmt_domain->fetch(PDO::FETCH_ASSOC)) {
|
||||
// Extracting data from the result set
|
||||
extract($row);
|
||||
|
||||
$date_add = 0;
|
||||
$price = 0;
|
||||
$date_add = 0;
|
||||
$price = 0;
|
||||
|
||||
[$registrar_balance, $creditLimit] = $dbh->query("SELECT accountBalance,creditLimit FROM registrar WHERE id = '$reid' LIMIT 1")->fetch(PDO::FETCH_NUM);
|
||||
[$registrar_balance, $creditLimit] = $dbh->query("SELECT accountBalance,creditLimit FROM registrar WHERE id = '$reid' LIMIT 1")->fetch(PDO::FETCH_NUM);
|
||||
|
||||
if ($transfer_exdate) {
|
||||
[$date_add] = $dbh->query("SELECT PERIOD_DIFF(DATE_FORMAT(transfer_exdate, '%Y%m'), DATE_FORMAT(exdate, '%Y%m')) AS intval FROM domain WHERE name = '$name' LIMIT 1")->fetch(PDO::FETCH_NUM);
|
||||
if ($transfer_exdate) {
|
||||
[$date_add] = $dbh->query("SELECT PERIOD_DIFF(DATE_FORMAT(transfer_exdate, '%Y%m'), DATE_FORMAT(exdate, '%Y%m')) AS intval FROM domain WHERE name = '$name' LIMIT 1")->fetch(PDO::FETCH_NUM);
|
||||
|
||||
preg_match('/^([^\.]+)\.(.+)$/', $name, $matches);
|
||||
$label = $matches[1];
|
||||
$domain_extension = $matches[2];
|
||||
preg_match('/^([^\.]+)\.(.+)$/', $name, $matches);
|
||||
$label = $matches[1];
|
||||
$domain_extension = $matches[2];
|
||||
|
||||
$tld_id = null;
|
||||
$stmt_tld = $dbh->prepare("SELECT id, tld FROM domain_tld");
|
||||
$stmt_tld->execute();
|
||||
$tld_id = null;
|
||||
$stmt_tld = $dbh->prepare("SELECT id, tld FROM domain_tld");
|
||||
$stmt_tld->execute();
|
||||
|
||||
while ($tld_row = $stmt_tld->fetch(PDO::FETCH_ASSOC)) {
|
||||
if ('.' . strtoupper($domain_extension) === strtoupper($tld_row['tld'])) {
|
||||
$tld_id = $tld_row['id'];
|
||||
break;
|
||||
while ($tld_row = $stmt_tld->fetch(PDO::FETCH_ASSOC)) {
|
||||
if ('.' . strtoupper($domain_extension) === strtoupper($tld_row['tld'])) {
|
||||
$tld_id = $tld_row['id'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
[$price] = $dbh->query("SELECT m$date_add FROM domain_price WHERE tldid = '$tld_id' AND command = 'transfer' LIMIT 1")->fetch(PDO::FETCH_NUM);
|
||||
|
||||
if (($registrar_balance + $creditLimit) < $price) {
|
||||
$log->notice($name . ': The registrar who took over this domain has no money to pay the renewal period that resulted from the transfer request');
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
[$price] = $dbh->query("SELECT m$date_add FROM domain_price WHERE tldid = '$tld_id' AND command = 'transfer' LIMIT 1")->fetch(PDO::FETCH_NUM);
|
||||
$from = $dbh->query("SELECT exdate FROM domain WHERE id = '$domain_id' LIMIT 1")->fetchColumn();
|
||||
|
||||
if (($registrar_balance + $creditLimit) < $price) {
|
||||
$log->notice($name . ': The registrar who took over this domain has no money to pay the renewal period that resulted from the transfer request');
|
||||
$stmt_update = $dbh->prepare("UPDATE domain SET exdate = DATE_ADD(exdate, INTERVAL $date_add MONTH), `update` = CURRENT_TIMESTAMP, clid = '$reid', upid = '$clid', trdate = CURRENT_TIMESTAMP, trstatus = 'serverApproved', acdate = CURRENT_TIMESTAMP, transfer_exdate = NULL WHERE id = '$domain_id'");
|
||||
$stmt_update->execute();
|
||||
|
||||
$stmt_update_host = $dbh->prepare("UPDATE host SET clid = '$reid', upid = NULL, `update` = CURRENT_TIMESTAMP, trdate = CURRENT_TIMESTAMP WHERE domain_id = '$domain_id'");
|
||||
$stmt_update_host->execute();
|
||||
|
||||
if ($stmt_update->errorCode() != "00000") {
|
||||
$log->error($name . ': The domain transfer was not successful, something is wrong | DB Update failed:' . implode(", ", $stmt_update->errorInfo()));
|
||||
continue;
|
||||
} else {
|
||||
$dbh->exec("UPDATE registrar SET accountBalance = (accountBalance - $price) WHERE id = '$reid'");
|
||||
$dbh->exec("INSERT INTO payment_history (registrar_id,date,description,amount) VALUES('$reid',CURRENT_TIMESTAMP,'transfer domain $name for period $date_add MONTH','-$price')");
|
||||
|
||||
$to = $dbh->query("SELECT exdate FROM domain WHERE id = '$domain_id' LIMIT 1")->fetchColumn();
|
||||
|
||||
$stmt_insert_statement = $dbh->prepare("INSERT INTO statement (registrar_id,date,command,domain_name,length_in_months,from,to,amount) VALUES(?,CURRENT_TIMESTAMP,?,?,?,?,?,?)");
|
||||
$stmt_insert_statement->execute([$reid, 'transfer', $name, $date_add, $from, $to, $price]);
|
||||
|
||||
$stmt_select_domain = $dbh->prepare("SELECT id,registrant,crdate,exdate,`update`,clid,crid,upid,trdate,trstatus,reid,redate,acid,acdate,transfer_exdate FROM domain WHERE name = ? LIMIT 1");
|
||||
$stmt_select_domain->execute([$name]);
|
||||
$domain_data = $stmt_select_domain->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
$stmt_auto_approve_transfer = $dbh->prepare("INSERT INTO domain_auto_approve_transfer (name,registrant,crdate,exdate,`update`,clid,crid,upid,trdate,trstatus,reid,redate,acid,acdate,transfer_exdate) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
||||
$stmt_auto_approve_transfer->execute(array_values($domain_data));
|
||||
}
|
||||
|
||||
}
|
||||
$stmt_domain = null;
|
||||
|
||||
$stmt_contact = $dbh->prepare("SELECT id, crid, crdate, upid, `update`, trdate, trstatus, reid, redate, acid, acdate FROM contact WHERE CURRENT_TIMESTAMP > acdate AND trstatus = 'pending'");
|
||||
$stmt_contact->execute();
|
||||
|
||||
while ($contact_data = $stmt_contact->fetch(PDO::FETCH_ASSOC)) {
|
||||
$contact_id = $contact_data['id'];
|
||||
$reid = $contact_data['reid'];
|
||||
|
||||
// The losing registrar has five days once the contact is pending to respond.
|
||||
$stmt_update_contact = $dbh->prepare("UPDATE contact SET `update` = CURRENT_TIMESTAMP, clid = ?, upid = NULL, trdate = CURRENT_TIMESTAMP, trstatus = 'serverApproved', acdate = CURRENT_TIMESTAMP WHERE id = ?");
|
||||
$stmt_update_contact->execute([$reid, $contact_id]);
|
||||
|
||||
if ($stmt_update_contact->errorCode() != "00000") {
|
||||
$log->error($contact_id . ': The contact transfer was not successful, something is wrong | DB Update failed:' . implode(", ", $stmt_update_contact->errorInfo()));
|
||||
continue;
|
||||
} else {
|
||||
$stmt_select_contact = $dbh->prepare("SELECT identifier, crid, crdate, upid, `update`, trdate, trstatus, reid, redate, acid, acdate FROM contact WHERE id = ? LIMIT 1");
|
||||
$stmt_select_contact->execute([$contact_id]);
|
||||
$contact_selected_data = $stmt_select_contact->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
$stmt_auto_approve_transfer = $dbh->prepare("INSERT INTO contact_auto_approve_transfer (identifier, crid, crdate, upid, `update`, trdate, trstatus, reid, redate, acid, acdate) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||
$stmt_auto_approve_transfer->execute(array_values($contact_selected_data));
|
||||
}
|
||||
}
|
||||
|
||||
$from = $dbh->query("SELECT exdate FROM domain WHERE id = '$domain_id' LIMIT 1")->fetchColumn();
|
||||
|
||||
$stmt_update = $dbh->prepare("UPDATE domain SET exdate = DATE_ADD(exdate, INTERVAL $date_add MONTH), `update` = CURRENT_TIMESTAMP, clid = '$reid', upid = '$clid', trdate = CURRENT_TIMESTAMP, trstatus = 'serverApproved', acdate = CURRENT_TIMESTAMP, transfer_exdate = NULL WHERE id = '$domain_id'");
|
||||
$stmt_update->execute();
|
||||
|
||||
$stmt_update_host = $dbh->prepare("UPDATE host SET clid = '$reid', upid = NULL, `update` = CURRENT_TIMESTAMP, trdate = CURRENT_TIMESTAMP WHERE domain_id = '$domain_id'");
|
||||
$stmt_update_host->execute();
|
||||
|
||||
if ($stmt_update->errorCode() != "00000") {
|
||||
$log->error($name . ': The domain transfer was not successful, something is wrong | DB Update failed:' . implode(", ", $stmt_update->errorInfo()));
|
||||
continue;
|
||||
} else {
|
||||
$dbh->exec("UPDATE registrar SET accountBalance = (accountBalance - $price) WHERE id = '$reid'");
|
||||
$dbh->exec("INSERT INTO payment_history (registrar_id,date,description,amount) VALUES('$reid',CURRENT_TIMESTAMP,'transfer domain $name for period $date_add MONTH','-$price')");
|
||||
|
||||
$to = $dbh->query("SELECT exdate FROM domain WHERE id = '$domain_id' LIMIT 1")->fetchColumn();
|
||||
|
||||
$stmt_insert_statement = $dbh->prepare("INSERT INTO statement (registrar_id,date,command,domain_name,length_in_months,from,to,amount) VALUES(?,CURRENT_TIMESTAMP,?,?,?,?,?,?)");
|
||||
$stmt_insert_statement->execute([$reid, 'transfer', $name, $date_add, $from, $to, $price]);
|
||||
|
||||
$stmt_select_domain = $dbh->prepare("SELECT id,registrant,crdate,exdate,`update`,clid,crid,upid,trdate,trstatus,reid,redate,acid,acdate,transfer_exdate FROM domain WHERE name = ? LIMIT 1");
|
||||
$stmt_select_domain->execute([$name]);
|
||||
$domain_data = $stmt_select_domain->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
$stmt_auto_approve_transfer = $dbh->prepare("INSERT INTO domain_auto_approve_transfer (name,registrant,crdate,exdate,`update`,clid,crid,upid,trdate,trstatus,reid,redate,acid,acdate,transfer_exdate) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
||||
$stmt_auto_approve_transfer->execute(array_values($domain_data));
|
||||
}
|
||||
|
||||
}
|
||||
$stmt_domain = null;
|
||||
|
||||
$stmt_contact = $dbh->prepare("SELECT id, crid, crdate, upid, `update`, trdate, trstatus, reid, redate, acid, acdate FROM contact WHERE CURRENT_TIMESTAMP > acdate AND trstatus = 'pending'");
|
||||
$stmt_contact->execute();
|
||||
|
||||
while ($contact_data = $stmt_contact->fetch(PDO::FETCH_ASSOC)) {
|
||||
$contact_id = $contact_data['id'];
|
||||
$reid = $contact_data['reid'];
|
||||
|
||||
// The losing registrar has five days once the contact is pending to respond.
|
||||
$stmt_update_contact = $dbh->prepare("UPDATE contact SET `update` = CURRENT_TIMESTAMP, clid = ?, upid = NULL, trdate = CURRENT_TIMESTAMP, trstatus = 'serverApproved', acdate = CURRENT_TIMESTAMP WHERE id = ?");
|
||||
$stmt_update_contact->execute([$reid, $contact_id]);
|
||||
|
||||
if ($stmt_update_contact->errorCode() != "00000") {
|
||||
$log->error($contact_id . ': The contact transfer was not successful, something is wrong | DB Update failed:' . implode(", ", $stmt_update_contact->errorInfo()));
|
||||
continue;
|
||||
} else {
|
||||
$stmt_select_contact = $dbh->prepare("SELECT identifier, crid, crdate, upid, `update`, trdate, trstatus, reid, redate, acid, acdate FROM contact WHERE id = ? LIMIT 1");
|
||||
$stmt_select_contact->execute([$contact_id]);
|
||||
$contact_selected_data = $stmt_select_contact->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
$stmt_auto_approve_transfer = $dbh->prepare("INSERT INTO contact_auto_approve_transfer (identifier, crid, crdate, upid, `update`, trdate, trstatus, reid, redate, acid, acdate) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||
$stmt_auto_approve_transfer->execute(array_values($contact_selected_data));
|
||||
}
|
||||
}
|
||||
$stmt_contact = null;
|
||||
$log->info('job finished successfully.');
|
||||
$stmt_contact = null;
|
||||
$log->info('job finished successfully.');
|
||||
} catch (PDOException $e) {
|
||||
$log->error('Database error: ' . $e->getMessage());
|
||||
} catch (Throwable $e) {
|
||||
$log->error('Error: ' . $e->getMessage());
|
||||
}
|
|
@ -60,9 +60,7 @@ try {
|
|||
$log->info('job finished successfully.');
|
||||
|
||||
} catch (PDOException $e) {
|
||||
// Handle database errors
|
||||
$log->error('Database error: ' . $e->getMessage());
|
||||
} catch (Exception $e) {
|
||||
// Handle other types of errors
|
||||
} catch (Throwable $e) {
|
||||
$log->error('Error: ' . $e->getMessage());
|
||||
}
|
|
@ -16,200 +16,206 @@ try {
|
|||
$log->error('DB Connection failed: ' . $e->getMessage());
|
||||
}
|
||||
|
||||
// Auto-Renew Grace Period
|
||||
$auto_renew = 0;
|
||||
try {
|
||||
// Auto-Renew Grace Period
|
||||
$auto_renew = 0;
|
||||
|
||||
if ($auto_renew) {
|
||||
$sth_autorenewperiod = $dbh->prepare("SELECT id, name, tldid, exdate, clid FROM domain WHERE CURRENT_TIMESTAMP > exdate AND rgpstatus IS NULL");
|
||||
$sth_autorenewperiod->execute();
|
||||
while ($row = $sth_autorenewperiod->fetch(PDO::FETCH_ASSOC)) {
|
||||
if ($auto_renew) {
|
||||
$sth_autorenewperiod = $dbh->prepare("SELECT id, name, tldid, exdate, clid FROM domain WHERE CURRENT_TIMESTAMP > exdate AND rgpstatus IS NULL");
|
||||
$sth_autorenewperiod->execute();
|
||||
while ($row = $sth_autorenewperiod->fetch(PDO::FETCH_ASSOC)) {
|
||||
$domain_id = $row['id'];
|
||||
$name = $row['name'];
|
||||
$tldid = $row['tldid'];
|
||||
$exdate = $row['exdate'];
|
||||
$clid = $row['clid'];
|
||||
|
||||
$sth_status = $dbh->prepare("SELECT status FROM domain_status WHERE domain_id = ?");
|
||||
$sth_status->execute([$domain_id]);
|
||||
|
||||
$set_autorenewPeriod = 1;
|
||||
while ($status_row = $sth_status->fetch(PDO::FETCH_ASSOC)) {
|
||||
$status = $status_row['status'];
|
||||
if (preg_match("/(serverUpdateProhibited|serverDeleteProhibited)$/", $status) || preg_match("/^pending/", $status)) {
|
||||
$set_autorenewPeriod = 0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ($set_autorenewPeriod) {
|
||||
list($registrar_balance, $creditLimit) = $dbh->query("SELECT accountBalance, creditLimit FROM registrar WHERE id = '$clid' LIMIT 1")->fetch(PDO::FETCH_NUM);
|
||||
$price = $dbh->query("SELECT m12 FROM domain_price WHERE tldid = '$tldid' AND command = 'renew' LIMIT 1")->fetchColumn();
|
||||
|
||||
if (($registrar_balance + $creditLimit) > $price) {
|
||||
$dbh->exec("UPDATE domain SET rgpstatus = 'autoRenewPeriod', exdate = DATE_ADD(exdate, INTERVAL 12 MONTH), autoRenewPeriod = '12', renewedDate = exdate WHERE id = '$domain_id'");
|
||||
$dbh->exec("UPDATE registrar SET accountBalance = (accountBalance - $price) WHERE id = '$clid'");
|
||||
$dbh->exec("INSERT INTO payment_history (registrar_id, date, description, amount) VALUES('$clid', CURRENT_TIMESTAMP, 'autoRenew domain $name for period 12 MONTH', '-$price')");
|
||||
list($to) = $dbh->query("SELECT exdate FROM domain WHERE id = '$domain_id' LIMIT 1")->fetch(PDO::FETCH_NUM);
|
||||
$sth = $dbh->prepare("INSERT INTO statement (registrar_id, date, command, domain_name, length_in_months, from, to, amount) VALUES(?, CURRENT_TIMESTAMP, ?, ?, ?, ?, ?, ?)");
|
||||
$sth->execute([$clid, 'autoRenew', $name, '12', $exdate, $to, $price]);
|
||||
if (!$dbh->query("SELECT id FROM statistics WHERE date = CURDATE()")->fetchColumn()) {
|
||||
$dbh->exec("INSERT IGNORE INTO statistics (date) VALUES(CURDATE())");
|
||||
}
|
||||
$dbh->exec("UPDATE statistics SET renewed_domains = renewed_domains + 1 WHERE date = CURDATE()");
|
||||
} else {
|
||||
$dbh->exec("DELETE FROM domain_status WHERE domain_id = '$domain_id'");
|
||||
$dbh->exec("UPDATE domain SET rgpstatus = 'redemptionPeriod', delTime = exdate WHERE id = '$domain_id'");
|
||||
$dbh->exec("INSERT INTO domain_status (domain_id, status) VALUES('$domain_id', 'pendingDelete')");
|
||||
}
|
||||
}
|
||||
$log->info($name . ' (ID ' . $domain_id . ') rgpStatus:autoRenewPeriod exdate: ' . $exdate);
|
||||
}
|
||||
} else {
|
||||
$grace_period = 30;
|
||||
$sth_graceperiod = $dbh->prepare("SELECT id, name, exdate FROM domain WHERE CURRENT_TIMESTAMP > DATE_ADD(exdate, INTERVAL $grace_period DAY) AND rgpstatus IS NULL");
|
||||
$sth_graceperiod->execute();
|
||||
while ($row = $sth_graceperiod->fetch(PDO::FETCH_ASSOC)) {
|
||||
$domain_id = $row['id'];
|
||||
$name = $row['name'];
|
||||
$exdate = $row['exdate'];
|
||||
|
||||
$sth_status = $dbh->prepare("SELECT status FROM domain_status WHERE domain_id = ?");
|
||||
$sth_status->execute([$domain_id]);
|
||||
|
||||
$set_graceperiod = 1;
|
||||
while ($status_row = $sth_status->fetch(PDO::FETCH_ASSOC)) {
|
||||
$status = $status_row['status'];
|
||||
if (preg_match("/(serverUpdateProhibited|serverDeleteProhibited)$/", $status) || preg_match("/^pending/", $status)) {
|
||||
$set_graceperiod = 0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ($set_graceperiod) {
|
||||
$dbh->exec("DELETE FROM domain_status WHERE domain_id = '$domain_id'");
|
||||
$dbh->exec("UPDATE domain SET rgpstatus = 'redemptionPeriod', delTime = DATE_ADD(exdate, INTERVAL $grace_period DAY) WHERE id = '$domain_id'");
|
||||
$dbh->exec("INSERT INTO domain_status (domain_id, status) VALUES('$domain_id', 'pendingDelete')");
|
||||
}
|
||||
$log->info($name . ' (ID ' . $domain_id . ') rgpStatus:redemptionPeriod exdate: ' . $exdate);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
// clean autoRenewPeriod after 45 days
|
||||
$sql1 = "UPDATE domain SET rgpstatus = NULL WHERE CURRENT_TIMESTAMP > DATE_ADD(exdate, INTERVAL 45 DAY) AND rgpstatus = 'autoRenewPeriod'";
|
||||
$dbh->exec($sql1);
|
||||
|
||||
// clean addPeriod after 5 days
|
||||
$sql2 = "UPDATE domain SET rgpstatus = NULL WHERE CURRENT_TIMESTAMP > DATE_ADD(crdate, INTERVAL 5 DAY) AND rgpstatus = 'addPeriod'";
|
||||
$dbh->exec($sql2);
|
||||
|
||||
// clean renewPeriod after 5 days
|
||||
$sql3 = "UPDATE domain SET rgpstatus = NULL WHERE CURRENT_TIMESTAMP > DATE_ADD(renewedDate, INTERVAL 5 DAY) AND rgpstatus = 'renewPeriod'";
|
||||
$dbh->exec($sql3);
|
||||
|
||||
// clean transferPeriod after 5 days
|
||||
$sql4 = "UPDATE domain SET rgpstatus = NULL WHERE CURRENT_TIMESTAMP > DATE_ADD(trdate, INTERVAL 5 DAY) AND rgpstatus = 'transferPeriod'";
|
||||
$dbh->exec($sql4);
|
||||
|
||||
} catch (PDOException $e) {
|
||||
$log->error('DB Error: ' . $e->getMessage());
|
||||
}
|
||||
|
||||
// Pending Delete
|
||||
// The current value of the redemptionPeriod is 30 calendar days.
|
||||
$sth_pendingdelete = $dbh->prepare("SELECT id, name, exdate FROM domain WHERE CURRENT_TIMESTAMP > DATE_ADD(delTime, INTERVAL 30 DAY) AND rgpstatus = 'redemptionPeriod'");
|
||||
$sth_pendingdelete->execute();
|
||||
|
||||
while ($row = $sth_pendingdelete->fetch(PDO::FETCH_ASSOC)) {
|
||||
$domain_id = $row['id'];
|
||||
$name = $row['name'];
|
||||
$tldid = $row['tldid'];
|
||||
$exdate = $row['exdate'];
|
||||
$clid = $row['clid'];
|
||||
|
||||
$sth_status = $dbh->prepare("SELECT status FROM domain_status WHERE domain_id = ?");
|
||||
$sth_status->execute([$domain_id]);
|
||||
|
||||
$set_autorenewPeriod = 1;
|
||||
$set_pendingDelete = 1;
|
||||
while ($status_row = $sth_status->fetch(PDO::FETCH_ASSOC)) {
|
||||
$status = $status_row['status'];
|
||||
if (preg_match("/(serverUpdateProhibited|serverDeleteProhibited)$/", $status) || preg_match("/^pending/", $status)) {
|
||||
$set_autorenewPeriod = 0;
|
||||
if (preg_match("/(serverUpdateProhibited|serverDeleteProhibited)$/", $status)) {
|
||||
$set_pendingDelete = 0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ($set_autorenewPeriod) {
|
||||
list($registrar_balance, $creditLimit) = $dbh->query("SELECT accountBalance, creditLimit FROM registrar WHERE id = '$clid' LIMIT 1")->fetch(PDO::FETCH_NUM);
|
||||
$price = $dbh->query("SELECT m12 FROM domain_price WHERE tldid = '$tldid' AND command = 'renew' LIMIT 1")->fetchColumn();
|
||||
if ($set_pendingDelete) {
|
||||
$dbh->exec("UPDATE domain SET rgpstatus = 'pendingDelete' WHERE id = '$domain_id'");
|
||||
}
|
||||
$log->info($name . ' (ID ' . $domain_id . ') rgpStatus:pendingDelete exdate: ' . $exdate);
|
||||
}
|
||||
|
||||
if (($registrar_balance + $creditLimit) > $price) {
|
||||
$dbh->exec("UPDATE domain SET rgpstatus = 'autoRenewPeriod', exdate = DATE_ADD(exdate, INTERVAL 12 MONTH), autoRenewPeriod = '12', renewedDate = exdate WHERE id = '$domain_id'");
|
||||
$dbh->exec("UPDATE registrar SET accountBalance = (accountBalance - $price) WHERE id = '$clid'");
|
||||
$dbh->exec("INSERT INTO payment_history (registrar_id, date, description, amount) VALUES('$clid', CURRENT_TIMESTAMP, 'autoRenew domain $name for period 12 MONTH', '-$price')");
|
||||
list($to) = $dbh->query("SELECT exdate FROM domain WHERE id = '$domain_id' LIMIT 1")->fetch(PDO::FETCH_NUM);
|
||||
$sth = $dbh->prepare("INSERT INTO statement (registrar_id, date, command, domain_name, length_in_months, from, to, amount) VALUES(?, CURRENT_TIMESTAMP, ?, ?, ?, ?, ?, ?)");
|
||||
$sth->execute([$clid, 'autoRenew', $name, '12', $exdate, $to, $price]);
|
||||
// Pending Restore
|
||||
$sth_pendingRestore = $dbh->prepare("SELECT id, name, exdate FROM domain WHERE rgpstatus = 'pendingRestore' AND (CURRENT_TIMESTAMP > DATE_ADD(resTime, INTERVAL 7 DAY))");
|
||||
$sth_pendingRestore->execute();
|
||||
|
||||
while ($row = $sth_pendingRestore->fetch(PDO::FETCH_ASSOC)) {
|
||||
$domain_id = $row['id'];
|
||||
$name = $row['name'];
|
||||
$exdate = $row['exdate'];
|
||||
|
||||
$dbh->exec("UPDATE domain SET rgpstatus = 'redemptionPeriod' WHERE id = '$domain_id'");
|
||||
|
||||
$log->info($name . ' (ID ' . $domain_id . ') back to redemptionPeriod from pendingRestore exdate: ' . $exdate);
|
||||
}
|
||||
|
||||
// Domain Deletion
|
||||
$sth_delete = $dbh->prepare("SELECT id, name, exdate FROM domain WHERE CURRENT_TIMESTAMP > DATE_ADD(delTime, INTERVAL 35 DAY) AND rgpstatus = 'pendingDelete'");
|
||||
$sth_delete->execute();
|
||||
|
||||
while ($row = $sth_delete->fetch(PDO::FETCH_ASSOC)) {
|
||||
$domain_id = $row['id'];
|
||||
$name = $row['name'];
|
||||
$exdate = $row['exdate'];
|
||||
|
||||
$sth_status = $dbh->prepare("SELECT status FROM domain_status WHERE domain_id = ?");
|
||||
$sth_status->execute([$domain_id]);
|
||||
|
||||
$delete_domain = 0;
|
||||
while ($status_row = $sth_status->fetch(PDO::FETCH_ASSOC)) {
|
||||
$status = $status_row['status'];
|
||||
if ($status == 'pendingDelete') {
|
||||
$delete_domain = 1;
|
||||
}
|
||||
if (preg_match("/(serverUpdateProhibited|serverDeleteProhibited)$/", $status)) {
|
||||
$delete_domain = 0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ($delete_domain) {
|
||||
// Actual deletion process
|
||||
$sth = $dbh->prepare("SELECT id FROM host WHERE domain_id = ?");
|
||||
$sth->execute([$domain_id]);
|
||||
while ($host_row = $sth->fetch(PDO::FETCH_ASSOC)) {
|
||||
$host_id = $host_row['id'];
|
||||
$dbh->exec("DELETE FROM host_addr WHERE host_id = '$host_id'");
|
||||
$dbh->exec("DELETE FROM host_status WHERE host_id = '$host_id'");
|
||||
$dbh->exec("DELETE FROM domain_host_map WHERE host_id = '$host_id'");
|
||||
}
|
||||
|
||||
$dbh->exec("DELETE FROM domain_contact_map WHERE domain_id = '$domain_id'");
|
||||
$dbh->exec("DELETE FROM domain_host_map WHERE domain_id = '$domain_id'");
|
||||
$dbh->exec("DELETE FROM domain_authInfo WHERE domain_id = '$domain_id'");
|
||||
$dbh->exec("DELETE FROM domain_status WHERE domain_id = '$domain_id'");
|
||||
$dbh->exec("DELETE FROM host WHERE domain_id = '$domain_id'");
|
||||
|
||||
$sth = $dbh->prepare("DELETE FROM domain WHERE id = ?");
|
||||
$sth->execute([$domain_id]);
|
||||
if ($sth->errorCode() !== '00000') {
|
||||
$errorInfo = $sth->errorInfo();
|
||||
$log->error($domain_id . '|' . $name . ' The domain name has not been deleted, there is a database issue: ' . $errorInfo[2]);
|
||||
} else {
|
||||
if (!$dbh->query("SELECT id FROM statistics WHERE date = CURDATE()")->fetchColumn()) {
|
||||
$dbh->exec("INSERT IGNORE INTO statistics (date) VALUES(CURDATE())");
|
||||
}
|
||||
$dbh->exec("UPDATE statistics SET renewed_domains = renewed_domains + 1 WHERE date = CURDATE()");
|
||||
} else {
|
||||
$dbh->exec("DELETE FROM domain_status WHERE domain_id = '$domain_id'");
|
||||
$dbh->exec("UPDATE domain SET rgpstatus = 'redemptionPeriod', delTime = exdate WHERE id = '$domain_id'");
|
||||
$dbh->exec("INSERT INTO domain_status (domain_id, status) VALUES('$domain_id', 'pendingDelete')");
|
||||
$dbh->exec("UPDATE statistics SET deleted_domains = deleted_domains + 1 WHERE date = CURDATE()");
|
||||
}
|
||||
}
|
||||
$log->info($name . ' (ID ' . $domain_id . ') rgpStatus:autoRenewPeriod exdate: ' . $exdate);
|
||||
$log->info($name . ' (ID ' . $domain_id . ') domain:Deleted exdate: ' . $exdate);
|
||||
}
|
||||
} else {
|
||||
$grace_period = 30;
|
||||
$sth_graceperiod = $dbh->prepare("SELECT id, name, exdate FROM domain WHERE CURRENT_TIMESTAMP > DATE_ADD(exdate, INTERVAL $grace_period DAY) AND rgpstatus IS NULL");
|
||||
$sth_graceperiod->execute();
|
||||
while ($row = $sth_graceperiod->fetch(PDO::FETCH_ASSOC)) {
|
||||
$domain_id = $row['id'];
|
||||
$name = $row['name'];
|
||||
$exdate = $row['exdate'];
|
||||
|
||||
$sth_status = $dbh->prepare("SELECT status FROM domain_status WHERE domain_id = ?");
|
||||
$sth_status->execute([$domain_id]);
|
||||
|
||||
$set_graceperiod = 1;
|
||||
while ($status_row = $sth_status->fetch(PDO::FETCH_ASSOC)) {
|
||||
$status = $status_row['status'];
|
||||
if (preg_match("/(serverUpdateProhibited|serverDeleteProhibited)$/", $status) || preg_match("/^pending/", $status)) {
|
||||
$set_graceperiod = 0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ($set_graceperiod) {
|
||||
$dbh->exec("DELETE FROM domain_status WHERE domain_id = '$domain_id'");
|
||||
$dbh->exec("UPDATE domain SET rgpstatus = 'redemptionPeriod', delTime = DATE_ADD(exdate, INTERVAL $grace_period DAY) WHERE id = '$domain_id'");
|
||||
$dbh->exec("INSERT INTO domain_status (domain_id, status) VALUES('$domain_id', 'pendingDelete')");
|
||||
}
|
||||
$log->info($name . ' (ID ' . $domain_id . ') rgpStatus:redemptionPeriod exdate: ' . $exdate);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
// clean autoRenewPeriod after 45 days
|
||||
$sql1 = "UPDATE domain SET rgpstatus = NULL WHERE CURRENT_TIMESTAMP > DATE_ADD(exdate, INTERVAL 45 DAY) AND rgpstatus = 'autoRenewPeriod'";
|
||||
$dbh->exec($sql1);
|
||||
|
||||
// clean addPeriod after 5 days
|
||||
$sql2 = "UPDATE domain SET rgpstatus = NULL WHERE CURRENT_TIMESTAMP > DATE_ADD(crdate, INTERVAL 5 DAY) AND rgpstatus = 'addPeriod'";
|
||||
$dbh->exec($sql2);
|
||||
|
||||
// clean renewPeriod after 5 days
|
||||
$sql3 = "UPDATE domain SET rgpstatus = NULL WHERE CURRENT_TIMESTAMP > DATE_ADD(renewedDate, INTERVAL 5 DAY) AND rgpstatus = 'renewPeriod'";
|
||||
$dbh->exec($sql3);
|
||||
|
||||
// clean transferPeriod after 5 days
|
||||
$sql4 = "UPDATE domain SET rgpstatus = NULL WHERE CURRENT_TIMESTAMP > DATE_ADD(trdate, INTERVAL 5 DAY) AND rgpstatus = 'transferPeriod'";
|
||||
$dbh->exec($sql4);
|
||||
|
||||
$log->info('job finished successfully.');
|
||||
} catch (PDOException $e) {
|
||||
$log->error('DB Error: ' . $e->getMessage());
|
||||
}
|
||||
|
||||
// Pending Delete
|
||||
// The current value of the redemptionPeriod is 30 calendar days.
|
||||
$sth_pendingdelete = $dbh->prepare("SELECT id, name, exdate FROM domain WHERE CURRENT_TIMESTAMP > DATE_ADD(delTime, INTERVAL 30 DAY) AND rgpstatus = 'redemptionPeriod'");
|
||||
$sth_pendingdelete->execute();
|
||||
|
||||
while ($row = $sth_pendingdelete->fetch(PDO::FETCH_ASSOC)) {
|
||||
$domain_id = $row['id'];
|
||||
$name = $row['name'];
|
||||
$exdate = $row['exdate'];
|
||||
|
||||
$sth_status = $dbh->prepare("SELECT status FROM domain_status WHERE domain_id = ?");
|
||||
$sth_status->execute([$domain_id]);
|
||||
|
||||
$set_pendingDelete = 1;
|
||||
while ($status_row = $sth_status->fetch(PDO::FETCH_ASSOC)) {
|
||||
$status = $status_row['status'];
|
||||
if (preg_match("/(serverUpdateProhibited|serverDeleteProhibited)$/", $status)) {
|
||||
$set_pendingDelete = 0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ($set_pendingDelete) {
|
||||
$dbh->exec("UPDATE domain SET rgpstatus = 'pendingDelete' WHERE id = '$domain_id'");
|
||||
}
|
||||
$log->info($name . ' (ID ' . $domain_id . ') rgpStatus:pendingDelete exdate: ' . $exdate);
|
||||
}
|
||||
|
||||
// Pending Restore
|
||||
$sth_pendingRestore = $dbh->prepare("SELECT id, name, exdate FROM domain WHERE rgpstatus = 'pendingRestore' AND (CURRENT_TIMESTAMP > DATE_ADD(resTime, INTERVAL 7 DAY))");
|
||||
$sth_pendingRestore->execute();
|
||||
|
||||
while ($row = $sth_pendingRestore->fetch(PDO::FETCH_ASSOC)) {
|
||||
$domain_id = $row['id'];
|
||||
$name = $row['name'];
|
||||
$exdate = $row['exdate'];
|
||||
|
||||
$dbh->exec("UPDATE domain SET rgpstatus = 'redemptionPeriod' WHERE id = '$domain_id'");
|
||||
|
||||
$log->info($name . ' (ID ' . $domain_id . ') back to redemptionPeriod from pendingRestore exdate: ' . $exdate);
|
||||
}
|
||||
|
||||
// Domain Deletion
|
||||
$sth_delete = $dbh->prepare("SELECT id, name, exdate FROM domain WHERE CURRENT_TIMESTAMP > DATE_ADD(delTime, INTERVAL 35 DAY) AND rgpstatus = 'pendingDelete'");
|
||||
$sth_delete->execute();
|
||||
|
||||
while ($row = $sth_delete->fetch(PDO::FETCH_ASSOC)) {
|
||||
$domain_id = $row['id'];
|
||||
$name = $row['name'];
|
||||
$exdate = $row['exdate'];
|
||||
|
||||
$sth_status = $dbh->prepare("SELECT status FROM domain_status WHERE domain_id = ?");
|
||||
$sth_status->execute([$domain_id]);
|
||||
|
||||
$delete_domain = 0;
|
||||
while ($status_row = $sth_status->fetch(PDO::FETCH_ASSOC)) {
|
||||
$status = $status_row['status'];
|
||||
if ($status == 'pendingDelete') {
|
||||
$delete_domain = 1;
|
||||
}
|
||||
if (preg_match("/(serverUpdateProhibited|serverDeleteProhibited)$/", $status)) {
|
||||
$delete_domain = 0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ($delete_domain) {
|
||||
// Actual deletion process
|
||||
$sth = $dbh->prepare("SELECT id FROM host WHERE domain_id = ?");
|
||||
$sth->execute([$domain_id]);
|
||||
while ($host_row = $sth->fetch(PDO::FETCH_ASSOC)) {
|
||||
$host_id = $host_row['id'];
|
||||
$dbh->exec("DELETE FROM host_addr WHERE host_id = '$host_id'");
|
||||
$dbh->exec("DELETE FROM host_status WHERE host_id = '$host_id'");
|
||||
$dbh->exec("DELETE FROM domain_host_map WHERE host_id = '$host_id'");
|
||||
}
|
||||
|
||||
$dbh->exec("DELETE FROM domain_contact_map WHERE domain_id = '$domain_id'");
|
||||
$dbh->exec("DELETE FROM domain_host_map WHERE domain_id = '$domain_id'");
|
||||
$dbh->exec("DELETE FROM domain_authInfo WHERE domain_id = '$domain_id'");
|
||||
$dbh->exec("DELETE FROM domain_status WHERE domain_id = '$domain_id'");
|
||||
$dbh->exec("DELETE FROM host WHERE domain_id = '$domain_id'");
|
||||
|
||||
$sth = $dbh->prepare("DELETE FROM domain WHERE id = ?");
|
||||
$sth->execute([$domain_id]);
|
||||
if ($sth->errorCode() !== '00000') {
|
||||
$errorInfo = $sth->errorInfo();
|
||||
$log->error($domain_id . '|' . $name . ' The domain name has not been deleted, there is a database issue: ' . $errorInfo[2]);
|
||||
} else {
|
||||
if (!$dbh->query("SELECT id FROM statistics WHERE date = CURDATE()")->fetchColumn()) {
|
||||
$dbh->exec("INSERT IGNORE INTO statistics (date) VALUES(CURDATE())");
|
||||
}
|
||||
$dbh->exec("UPDATE statistics SET deleted_domains = deleted_domains + 1 WHERE date = CURDATE()");
|
||||
}
|
||||
}
|
||||
$log->info($name . ' (ID ' . $domain_id . ') domain:Deleted exdate: ' . $exdate);
|
||||
}
|
||||
$log->info('job finished successfully.');
|
||||
$log->error('Database error: ' . $e->getMessage());
|
||||
} catch (Throwable $e) {
|
||||
$log->error('Error: ' . $e->getMessage());
|
||||
}
|
|
@ -23,475 +23,481 @@ try {
|
|||
$log->error('DB Connection failed: ' . $e->getMessage());
|
||||
}
|
||||
|
||||
$domainCount = fetchCount($dbh, 'domain');
|
||||
$hostCount = fetchCount($dbh, 'host');
|
||||
$contactCount = fetchCount($dbh, 'contact');
|
||||
$registrarCount = fetchCount($dbh, 'registrar');
|
||||
try {
|
||||
$domainCount = fetchCount($dbh, 'domain');
|
||||
$hostCount = fetchCount($dbh, 'host');
|
||||
$contactCount = fetchCount($dbh, 'contact');
|
||||
$registrarCount = fetchCount($dbh, 'registrar');
|
||||
|
||||
// Fetching TLDs
|
||||
$stmt = $dbh->query("SELECT id,tld FROM domain_tld;");
|
||||
$tlds = $stmt->fetchAll();
|
||||
// Fetching TLDs
|
||||
$stmt = $dbh->query("SELECT id,tld FROM domain_tld;");
|
||||
$tlds = $stmt->fetchAll();
|
||||
|
||||
// Fetching details from rde_escrow_deposits table
|
||||
$stmt = $dbh->prepare("SELECT deposit_id, revision FROM rde_escrow_deposits;");
|
||||
$stmt->execute();
|
||||
$deposit_id = $stmt->fetch();
|
||||
|
||||
// Determine the next revision number
|
||||
$nextRevisionNumber = is_null($deposit_id['deposit_id']) ? 1 : ($deposit_id['revision'] + 1);
|
||||
|
||||
// Format the revision number (001, 002, 003, ..., 010, ...)
|
||||
$finalDepositId = str_pad($nextRevisionNumber, 3, '0', STR_PAD_LEFT);
|
||||
|
||||
foreach ($tlds as $tld) {
|
||||
$tldname = strtoupper(ltrim($tld['tld'], '.'));
|
||||
|
||||
// Skip subdomains
|
||||
if (strpos($tldname, '.') !== false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Starting the XML for this TLD
|
||||
// Initializing XMLWriter
|
||||
$xml = new XMLWriter();
|
||||
$xml->openMemory();
|
||||
$xml->startDocument('1.0', 'UTF-8');
|
||||
$xml->startElementNS('rde', 'deposit', 'urn:ietf:params:xml:ns:rde-1.0');
|
||||
$xml->writeAttributeNS('xmlns', 'rdeHeader', null, 'urn:ietf:params:xml:ns:rdeHeader-1.0');
|
||||
$xml->writeAttributeNS('xmlns', 'rdeDom', null, 'urn:ietf:params:xml:ns:rdeDomain-1.0');
|
||||
$xml->writeAttributeNS('xmlns', 'rdeContact', null, 'urn:ietf:params:xml:ns:rdeContact-1.0');
|
||||
$xml->writeAttributeNS('xmlns', 'rdeHost', null, 'urn:ietf:params:xml:ns:rdeHost-1.0');
|
||||
$xml->writeAttributeNS('xmlns', 'rdeRegistrar', null, 'urn:ietf:params:xml:ns:rdeRegistrar-1.0');
|
||||
|
||||
// Fetch domain details for this TLD
|
||||
$stmt = $dbh->prepare("SELECT * FROM domain WHERE tldid = :tldid;");
|
||||
$stmt->bindParam(':tldid', $tld['id']);
|
||||
// Fetching details from rde_escrow_deposits table
|
||||
$stmt = $dbh->prepare("SELECT deposit_id, revision FROM rde_escrow_deposits;");
|
||||
$stmt->execute();
|
||||
$domains = $stmt->fetchAll();
|
||||
$deposit_id = $stmt->fetch();
|
||||
|
||||
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');
|
||||
// Determine the next revision number
|
||||
$nextRevisionNumber = is_null($deposit_id['deposit_id']) ? 1 : ($deposit_id['revision'] + 1);
|
||||
|
||||
// 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');
|
||||
// Format the revision number (001, 002, 003, ..., 010, ...)
|
||||
$finalDepositId = str_pad($nextRevisionNumber, 3, '0', STR_PAD_LEFT);
|
||||
|
||||
$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
|
||||
$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(':domain_id', $domain['id']);
|
||||
$stmt->execute();
|
||||
$domain_hosts = $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']);
|
||||
$xml->writeElement('rdeDom:crRr', $domain['crid']);
|
||||
$crDate = DateTime::createFromFormat('Y-m-d H:i:s.v', $domain['crdate']);
|
||||
$xml->writeElement('rdeDom:crDate', $crDate->format("Y-m-d\\TH:i:s.v\\Z"));
|
||||
$exDate = DateTime::createFromFormat('Y-m-d H:i:s.v', $domain['exdate']);
|
||||
$xml->writeElement('rdeDom:exDate', $exDate->format("Y-m-d\\TH:i:s.v\\Z"));
|
||||
foreach ($tlds as $tld) {
|
||||
$tldname = strtoupper(ltrim($tld['tld'], '.'));
|
||||
|
||||
$xml->endElement(); // Closing rdeDom:domain
|
||||
}
|
||||
// Skip subdomains
|
||||
if (strpos($tldname, '.') !== false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Starting the XML for this TLD
|
||||
// Initializing XMLWriter
|
||||
$xml = new XMLWriter();
|
||||
$xml->openMemory();
|
||||
$xml->startDocument('1.0', 'UTF-8');
|
||||
$xml->startElementNS('rde', 'deposit', 'urn:ietf:params:xml:ns:rde-1.0');
|
||||
$xml->writeAttributeNS('xmlns', 'rdeHeader', null, 'urn:ietf:params:xml:ns:rdeHeader-1.0');
|
||||
$xml->writeAttributeNS('xmlns', 'rdeDom', null, 'urn:ietf:params:xml:ns:rdeDomain-1.0');
|
||||
$xml->writeAttributeNS('xmlns', 'rdeContact', null, 'urn:ietf:params:xml:ns:rdeContact-1.0');
|
||||
$xml->writeAttributeNS('xmlns', 'rdeHost', null, 'urn:ietf:params:xml:ns:rdeHost-1.0');
|
||||
$xml->writeAttributeNS('xmlns', 'rdeRegistrar', null, 'urn:ietf:params:xml:ns:rdeRegistrar-1.0');
|
||||
|
||||
// Fetch and incorporate registrar details
|
||||
$stmt = $dbh->prepare("SELECT * FROM registrar;");
|
||||
$stmt->execute();
|
||||
$registrars = $stmt->fetchAll();
|
||||
|
||||
$xml->startElement('rdeRegistrar:registrar');
|
||||
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']);
|
||||
// Fetch domain details for this TLD
|
||||
$stmt = $dbh->prepare("SELECT * FROM domain WHERE tldid = :tldid;");
|
||||
$stmt->bindParam(':tldid', $tld['id']);
|
||||
$stmt->execute();
|
||||
$registrar_contacts = $stmt->fetchAll();
|
||||
$domains = $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']);
|
||||
}
|
||||
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');
|
||||
|
||||
$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
|
||||
// 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');
|
||||
|
||||
$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
|
||||
$xml->writeElement('rdeDom:registrant', $domain['registrant']);
|
||||
|
||||
// Fetch and incorporate host details
|
||||
$stmt = $dbh->prepare("SELECT * FROM host;");
|
||||
$stmt->execute();
|
||||
$hosts = $stmt->fetchAll();
|
||||
|
||||
foreach ($hosts as $host) {
|
||||
$xml->startElement('rdeHost:host');
|
||||
$xml->writeElement('rdeHost:name', $host['name']);
|
||||
$xml->writeElement('rdeHost:roid', 'H' . $host['id']);
|
||||
|
||||
$xml->startElement('rdeHost:status');
|
||||
$xml->writeAttribute('s', 'ok');
|
||||
$xml->text('ok');
|
||||
$xml->endElement(); // Closing rdeHost:status
|
||||
|
||||
$xml->writeElement('rdeHost:clID', $host['clid']);
|
||||
$xml->writeElement('rdeHost:crRr', $host['crid']);
|
||||
$crDate = DateTime::createFromFormat('Y-m-d H:i:s.v', $host['crdate']);
|
||||
$xml->writeElement('rdeHost:crDate', $crDate->format("Y-m-d\\TH:i:s.v\\Z"));
|
||||
$xml->endElement(); // Closing rdeHost:host
|
||||
}
|
||||
|
||||
// Fetch and incorporate contact details
|
||||
$stmt = $dbh->prepare("SELECT * FROM contact;");
|
||||
$stmt->execute();
|
||||
$contacts = $stmt->fetchAll();
|
||||
|
||||
foreach ($contacts as $contact) {
|
||||
$xml->startElement('rdeContact:contact');
|
||||
$xml->writeElement('rdeContact:id', $contact['identifier']);
|
||||
$xml->writeElement('rdeContact:roid', 'C' . $contact['id']);
|
||||
$xml->startElement('rdeContact:status');
|
||||
$xml->writeAttribute('s', 'ok');
|
||||
$xml->text('ok');
|
||||
$xml->endElement(); // Closing rdeContact:status
|
||||
|
||||
// Fetch postalInfo for the current contact
|
||||
$stmtPostal = $dbh->prepare("SELECT * FROM contact_postalInfo WHERE contact_id = :contact_id;");
|
||||
$stmtPostal->bindParam(':contact_id', $contact['id']);
|
||||
$stmtPostal->execute();
|
||||
$postalInfo = $stmtPostal->fetch();
|
||||
|
||||
if ($postalInfo) {
|
||||
$xml->startElement('rdeContact:postalInfo');
|
||||
$xml->writeAttribute('type', 'int');
|
||||
$xml->writeElement('contact:name', $postalInfo['name']);
|
||||
$xml->writeElement('contact:org', $postalInfo['org']);
|
||||
$xml->startElement('contact:addr');
|
||||
$xml->writeElement('contact:street', $postalInfo['street1']);
|
||||
$xml->writeElement('contact:city', $postalInfo['city']);
|
||||
$xml->writeElement('contact:pc', $postalInfo['pc']);
|
||||
$xml->writeElement('contact:cc', $postalInfo['cc']);
|
||||
$xml->endElement(); // Closing contact:addr
|
||||
$xml->endElement(); // Closing rdeContact:postalInfo
|
||||
}
|
||||
|
||||
$xml->writeElement('rdeContact:voice', $contact['voice']);
|
||||
$xml->writeElement('rdeContact:fax', $contact['fax']);
|
||||
$xml->writeElement('rdeContact:email', $contact['email']);
|
||||
$xml->writeElement('rdeContact:clID', $contact['clid']);
|
||||
$xml->writeElement('rdeContact:crRr', $contact['crid']);
|
||||
$crDate = DateTime::createFromFormat('Y-m-d H:i:s.v', $contact['crdate']);
|
||||
$xml->writeElement('rdeContact:crDate', $crDate->format("Y-m-d\\TH:i:s.v\\Z"));
|
||||
if (!empty($contact['upid'])) {
|
||||
$xml->writeElement('rdeContact:upRr', $contact['upid']);
|
||||
$upDate = DateTime::createFromFormat('Y-m-d H:i:s.v', $contact['update']);
|
||||
$xml->writeElement('rdeContact:upDate', $upDate->format("Y-m-d\\TH:i:s.v\\Z"));
|
||||
}
|
||||
$xml->endElement(); // Closing rdeContact:contact
|
||||
}
|
||||
|
||||
// Writing the rdeHeader section to XML
|
||||
$xml->startElement('rdeIDN:idnTableRef');
|
||||
$xml->writeAttribute('id', 'Latn');
|
||||
$xml->writeElement('rdeIDN:url', 'https://namingo.org');
|
||||
$xml->writeElement('rdeIDN:urlPolicy', 'https://namingo.org');
|
||||
$xml->endElement(); // Closing rdeIDN:idnTableRef
|
||||
|
||||
$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:rdeRegistrar-1.0');
|
||||
$xml->text($registrarCount);
|
||||
$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:rdeNNDN-1.0');
|
||||
$xml->text('0');
|
||||
$xml->endElement();
|
||||
|
||||
$xml->startElement('rdeHeader:count');
|
||||
$xml->writeAttribute('uri', 'urn:ietf:params:xml:ns:rdeIDN-1.0');
|
||||
$xml->text('0');
|
||||
$xml->endElement();
|
||||
|
||||
$xml->endElement(); // Closing rdeHeader:header
|
||||
|
||||
$xml->endElement(); // Closing the 'rde:deposit' element
|
||||
$es = $xml->outputMemory();
|
||||
|
||||
// Define the base name without the extension
|
||||
$baseFileName = "{$tldname}_".date('Y-m-d')."_full_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, $es, 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']));
|
||||
$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']));
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
$encryptedFilePath = $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($encryptedFilePath);
|
||||
$signature = $gpg->sign($encryptedData);
|
||||
|
||||
// Save the signature to a .sig file
|
||||
$signatureFilePath = $c['escrow_deposit_path'] . '/' . pathinfo($encryptedFilePath, PATHINFO_FILENAME) . '.sig';
|
||||
file_put_contents($signatureFilePath, $signature);
|
||||
|
||||
// Optionally, delete the encrypted file if you don't need it anymore
|
||||
// unlink($encryptedFilePath);
|
||||
|
||||
// Start XMLWriter for the report
|
||||
$reportXML = new XMLWriter();
|
||||
$reportXML->openMemory();
|
||||
$reportXML->startDocument('1.0', 'UTF-8');
|
||||
|
||||
$reportXML->startElement('rdeReport:report');
|
||||
$reportXML->writeAttribute('xmlns:rdeReport', 'urn:ietf:params:xml:ns:rdeReport-1.0');
|
||||
$reportXML->writeAttribute('xmlns:rdeHeader', 'urn:ietf:params:xml:ns:rdeHeader-1.0');
|
||||
|
||||
$reportXML->writeElement('rdeReport:id', $finalDepositId);
|
||||
$reportXML->writeElement('rdeReport:version', '1');
|
||||
$reportXML->writeElement('rdeReport:rydeSpecEscrow', 'RFC8909');
|
||||
$reportXML->writeElement('rdeReport:rydeSpecMapping', 'RFC9022');
|
||||
$reportXML->writeElement('rdeReport:resend', '0');
|
||||
$currentDateTime = new DateTime();
|
||||
$crDateWithMilliseconds = $currentDateTime->format("Y-m-d\TH:i:s.v\Z");
|
||||
$reportXML->writeElement('rdeReport:crDate', $crDateWithMilliseconds);
|
||||
$reportXML->writeElement('rdeReport:kind', 'FULL');
|
||||
$reportXML->writeElement('rdeReport:watermark', date('Y-m-d\\T00:00:00.000\\Z'));
|
||||
|
||||
$reportXML->startElement('rdeHeader:header');
|
||||
$reportXML->writeElement('rdeHeader:tld', $tld['tld']);
|
||||
$reportXML->startElement('rdeHeader:count');
|
||||
$reportXML->writeAttribute('uri', 'urn:ietf:params:xml:ns:rdeDomain-1.0');
|
||||
$reportXML->text($domainCount);
|
||||
$reportXML->endElement();
|
||||
|
||||
$reportXML->startElement('rdeHeader:count');
|
||||
$reportXML->writeAttribute('uri', 'urn:ietf:params:xml:ns:rdeHost-1.0');
|
||||
$reportXML->text($hostCount);
|
||||
$reportXML->endElement();
|
||||
|
||||
$reportXML->startElement('rdeHeader:count');
|
||||
$reportXML->writeAttribute('uri', 'urn:ietf:params:xml:ns:rdeContact-1.0');
|
||||
$reportXML->text($contactCount);
|
||||
$reportXML->endElement();
|
||||
|
||||
$reportXML->startElement('rdeHeader:count');
|
||||
$reportXML->writeAttribute('uri', 'urn:ietf:params:xml:ns:rdeRegistrar-1.0');
|
||||
$reportXML->text($registrarCount);
|
||||
$reportXML->endElement();
|
||||
|
||||
$reportXML->startElement('rdeHeader:count');
|
||||
$reportXML->writeAttribute('uri', 'urn:ietf:params:xml:ns:rdeIDN-1.0');
|
||||
$reportXML->text('0');
|
||||
$reportXML->endElement();
|
||||
|
||||
$reportXML->startElement('rdeHeader:count');
|
||||
$reportXML->writeAttribute('uri', 'urn:ietf:params:xml:ns:rdeNNDN-1.0');
|
||||
$reportXML->text('0');
|
||||
$reportXML->endElement();
|
||||
|
||||
$reportXML->startElement('rdeHeader:count');
|
||||
$reportXML->writeAttribute('uri', 'urn:ietf:params:xml:ns:rdeEppParams-1.0');
|
||||
$reportXML->text('0');
|
||||
$reportXML->endElement();
|
||||
|
||||
$reportXML->endElement(); // Closing rdeHeader:header
|
||||
$reportXML->endElement(); // Closing rdeReport:report
|
||||
|
||||
$reps = $reportXML->outputMemory();
|
||||
|
||||
// Save the report file
|
||||
$reportFilePath = $c['escrow_deposit_path']."/{$tldname}_".date('Y-m-d')."_full_R{$finalDepositId}.rep";
|
||||
file_put_contents($reportFilePath, $reps, LOCK_EX);
|
||||
|
||||
if ($c['escrow_RDEupload']) {
|
||||
// Connect to the SFTP server
|
||||
$sftp = new SFTP($c['escrow_sftp_host']);
|
||||
|
||||
// Login with username and password
|
||||
if (!$sftp->login($c['escrow_sftp_username'], $c['escrow_sftp_password'])) {
|
||||
$log->error('SFTP Login failed');
|
||||
}
|
||||
|
||||
// Define the remote directory where you want to upload the files
|
||||
$remoteDir = $c['escrow_sftp_remotepath'];
|
||||
|
||||
// Upload the files
|
||||
$filesToUpload = [
|
||||
$encryptedFilePath,
|
||||
$signatureFilePath,
|
||||
$reportFilePath
|
||||
];
|
||||
|
||||
foreach ($filesToUpload as $filePath) {
|
||||
$remoteFile = $remoteDir . basename($filePath);
|
||||
if (!$sftp->put($remoteFile, $filePath, SFTP::SOURCE_LOCAL_FILE)) {
|
||||
$log->error('Failed to upload ' . basename($filePath));
|
||||
} else {
|
||||
$log->info('Successfully uploaded ' . basename($filePath));
|
||||
// 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
|
||||
$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(':domain_id', $domain['id']);
|
||||
$stmt->execute();
|
||||
$domain_hosts = $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']);
|
||||
$xml->writeElement('rdeDom:crRr', $domain['crid']);
|
||||
$crDate = DateTime::createFromFormat('Y-m-d H:i:s.v', $domain['crdate']);
|
||||
$xml->writeElement('rdeDom:crDate', $crDate->format("Y-m-d\\TH:i:s.v\\Z"));
|
||||
$exDate = DateTime::createFromFormat('Y-m-d H:i:s.v', $domain['exdate']);
|
||||
$xml->writeElement('rdeDom:exDate', $exDate->format("Y-m-d\\TH:i:s.v\\Z"));
|
||||
|
||||
$xml->endElement(); // Closing rdeDom:domain
|
||||
}
|
||||
|
||||
// Fetch and incorporate registrar details
|
||||
$stmt = $dbh->prepare("SELECT * FROM registrar;");
|
||||
$stmt->execute();
|
||||
$registrars = $stmt->fetchAll();
|
||||
|
||||
$xml->startElement('rdeRegistrar:registrar');
|
||||
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
|
||||
|
||||
// Fetch and incorporate host details
|
||||
$stmt = $dbh->prepare("SELECT * FROM host;");
|
||||
$stmt->execute();
|
||||
$hosts = $stmt->fetchAll();
|
||||
|
||||
foreach ($hosts as $host) {
|
||||
$xml->startElement('rdeHost:host');
|
||||
$xml->writeElement('rdeHost:name', $host['name']);
|
||||
$xml->writeElement('rdeHost:roid', 'H' . $host['id']);
|
||||
|
||||
$xml->startElement('rdeHost:status');
|
||||
$xml->writeAttribute('s', 'ok');
|
||||
$xml->text('ok');
|
||||
$xml->endElement(); // Closing rdeHost:status
|
||||
|
||||
$xml->writeElement('rdeHost:clID', $host['clid']);
|
||||
$xml->writeElement('rdeHost:crRr', $host['crid']);
|
||||
$crDate = DateTime::createFromFormat('Y-m-d H:i:s.v', $host['crdate']);
|
||||
$xml->writeElement('rdeHost:crDate', $crDate->format("Y-m-d\\TH:i:s.v\\Z"));
|
||||
$xml->endElement(); // Closing rdeHost:host
|
||||
}
|
||||
|
||||
// Fetch and incorporate contact details
|
||||
$stmt = $dbh->prepare("SELECT * FROM contact;");
|
||||
$stmt->execute();
|
||||
$contacts = $stmt->fetchAll();
|
||||
|
||||
foreach ($contacts as $contact) {
|
||||
$xml->startElement('rdeContact:contact');
|
||||
$xml->writeElement('rdeContact:id', $contact['identifier']);
|
||||
$xml->writeElement('rdeContact:roid', 'C' . $contact['id']);
|
||||
$xml->startElement('rdeContact:status');
|
||||
$xml->writeAttribute('s', 'ok');
|
||||
$xml->text('ok');
|
||||
$xml->endElement(); // Closing rdeContact:status
|
||||
|
||||
// Fetch postalInfo for the current contact
|
||||
$stmtPostal = $dbh->prepare("SELECT * FROM contact_postalInfo WHERE contact_id = :contact_id;");
|
||||
$stmtPostal->bindParam(':contact_id', $contact['id']);
|
||||
$stmtPostal->execute();
|
||||
$postalInfo = $stmtPostal->fetch();
|
||||
|
||||
if ($postalInfo) {
|
||||
$xml->startElement('rdeContact:postalInfo');
|
||||
$xml->writeAttribute('type', 'int');
|
||||
$xml->writeElement('contact:name', $postalInfo['name']);
|
||||
$xml->writeElement('contact:org', $postalInfo['org']);
|
||||
$xml->startElement('contact:addr');
|
||||
$xml->writeElement('contact:street', $postalInfo['street1']);
|
||||
$xml->writeElement('contact:city', $postalInfo['city']);
|
||||
$xml->writeElement('contact:pc', $postalInfo['pc']);
|
||||
$xml->writeElement('contact:cc', $postalInfo['cc']);
|
||||
$xml->endElement(); // Closing contact:addr
|
||||
$xml->endElement(); // Closing rdeContact:postalInfo
|
||||
}
|
||||
|
||||
$xml->writeElement('rdeContact:voice', $contact['voice']);
|
||||
$xml->writeElement('rdeContact:fax', $contact['fax']);
|
||||
$xml->writeElement('rdeContact:email', $contact['email']);
|
||||
$xml->writeElement('rdeContact:clID', $contact['clid']);
|
||||
$xml->writeElement('rdeContact:crRr', $contact['crid']);
|
||||
$crDate = DateTime::createFromFormat('Y-m-d H:i:s.v', $contact['crdate']);
|
||||
$xml->writeElement('rdeContact:crDate', $crDate->format("Y-m-d\\TH:i:s.v\\Z"));
|
||||
if (!empty($contact['upid'])) {
|
||||
$xml->writeElement('rdeContact:upRr', $contact['upid']);
|
||||
$upDate = DateTime::createFromFormat('Y-m-d H:i:s.v', $contact['update']);
|
||||
$xml->writeElement('rdeContact:upDate', $upDate->format("Y-m-d\\TH:i:s.v\\Z"));
|
||||
}
|
||||
$xml->endElement(); // Closing rdeContact:contact
|
||||
}
|
||||
|
||||
$reportFileData = file_get_contents($reportFilePath);
|
||||
|
||||
$ch = curl_init();
|
||||
|
||||
// Set cURL options
|
||||
curl_setopt($ch, CURLOPT_URL, $c['escrow_report_url']);
|
||||
curl_setopt($ch, CURLOPT_USERPWD, $c['escrow_report_username'].':'.$c['escrow_report_password']);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $reportFileData);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/octet-stream',
|
||||
'Content-Length: ' . strlen($reportFileData)
|
||||
));
|
||||
|
||||
$response = curl_exec($ch);
|
||||
|
||||
if ($response === false) {
|
||||
$log->error('Upload error occurred: ' . curl_error($ch));
|
||||
}
|
||||
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
if ($httpCode >= 200 && $httpCode < 300) {
|
||||
$log->info('Escrow deposit uploaded successfully');
|
||||
} else {
|
||||
$log->error('Failed to upload escrow deposit. HTTP Status Code: ' . $httpCode);
|
||||
}
|
||||
|
||||
curl_close($ch);
|
||||
// Writing the rdeHeader section to XML
|
||||
$xml->startElement('rdeIDN:idnTableRef');
|
||||
$xml->writeAttribute('id', 'Latn');
|
||||
$xml->writeElement('rdeIDN:url', 'https://namingo.org');
|
||||
$xml->writeElement('rdeIDN:urlPolicy', 'https://namingo.org');
|
||||
$xml->endElement(); // Closing rdeIDN:idnTableRef
|
||||
|
||||
$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:rdeRegistrar-1.0');
|
||||
$xml->text($registrarCount);
|
||||
$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:rdeNNDN-1.0');
|
||||
$xml->text('0');
|
||||
$xml->endElement();
|
||||
|
||||
$xml->startElement('rdeHeader:count');
|
||||
$xml->writeAttribute('uri', 'urn:ietf:params:xml:ns:rdeIDN-1.0');
|
||||
$xml->text('0');
|
||||
$xml->endElement();
|
||||
|
||||
$xml->endElement(); // Closing rdeHeader:header
|
||||
|
||||
$xml->endElement(); // Closing the 'rde:deposit' element
|
||||
$es = $xml->outputMemory();
|
||||
|
||||
// Define the base name without the extension
|
||||
$baseFileName = "{$tldname}_".date('Y-m-d')."_full_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, $es, 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']));
|
||||
$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']));
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
$encryptedFilePath = $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($encryptedFilePath);
|
||||
$signature = $gpg->sign($encryptedData);
|
||||
|
||||
// Save the signature to a .sig file
|
||||
$signatureFilePath = $c['escrow_deposit_path'] . '/' . pathinfo($encryptedFilePath, PATHINFO_FILENAME) . '.sig';
|
||||
file_put_contents($signatureFilePath, $signature);
|
||||
|
||||
// Optionally, delete the encrypted file if you don't need it anymore
|
||||
// unlink($encryptedFilePath);
|
||||
|
||||
// Start XMLWriter for the report
|
||||
$reportXML = new XMLWriter();
|
||||
$reportXML->openMemory();
|
||||
$reportXML->startDocument('1.0', 'UTF-8');
|
||||
|
||||
$reportXML->startElement('rdeReport:report');
|
||||
$reportXML->writeAttribute('xmlns:rdeReport', 'urn:ietf:params:xml:ns:rdeReport-1.0');
|
||||
$reportXML->writeAttribute('xmlns:rdeHeader', 'urn:ietf:params:xml:ns:rdeHeader-1.0');
|
||||
|
||||
$reportXML->writeElement('rdeReport:id', $finalDepositId);
|
||||
$reportXML->writeElement('rdeReport:version', '1');
|
||||
$reportXML->writeElement('rdeReport:rydeSpecEscrow', 'RFC8909');
|
||||
$reportXML->writeElement('rdeReport:rydeSpecMapping', 'RFC9022');
|
||||
$reportXML->writeElement('rdeReport:resend', '0');
|
||||
$currentDateTime = new DateTime();
|
||||
$crDateWithMilliseconds = $currentDateTime->format("Y-m-d\TH:i:s.v\Z");
|
||||
$reportXML->writeElement('rdeReport:crDate', $crDateWithMilliseconds);
|
||||
$reportXML->writeElement('rdeReport:kind', 'FULL');
|
||||
$reportXML->writeElement('rdeReport:watermark', date('Y-m-d\\T00:00:00.000\\Z'));
|
||||
|
||||
$reportXML->startElement('rdeHeader:header');
|
||||
$reportXML->writeElement('rdeHeader:tld', $tld['tld']);
|
||||
$reportXML->startElement('rdeHeader:count');
|
||||
$reportXML->writeAttribute('uri', 'urn:ietf:params:xml:ns:rdeDomain-1.0');
|
||||
$reportXML->text($domainCount);
|
||||
$reportXML->endElement();
|
||||
|
||||
$reportXML->startElement('rdeHeader:count');
|
||||
$reportXML->writeAttribute('uri', 'urn:ietf:params:xml:ns:rdeHost-1.0');
|
||||
$reportXML->text($hostCount);
|
||||
$reportXML->endElement();
|
||||
|
||||
$reportXML->startElement('rdeHeader:count');
|
||||
$reportXML->writeAttribute('uri', 'urn:ietf:params:xml:ns:rdeContact-1.0');
|
||||
$reportXML->text($contactCount);
|
||||
$reportXML->endElement();
|
||||
|
||||
$reportXML->startElement('rdeHeader:count');
|
||||
$reportXML->writeAttribute('uri', 'urn:ietf:params:xml:ns:rdeRegistrar-1.0');
|
||||
$reportXML->text($registrarCount);
|
||||
$reportXML->endElement();
|
||||
|
||||
$reportXML->startElement('rdeHeader:count');
|
||||
$reportXML->writeAttribute('uri', 'urn:ietf:params:xml:ns:rdeIDN-1.0');
|
||||
$reportXML->text('0');
|
||||
$reportXML->endElement();
|
||||
|
||||
$reportXML->startElement('rdeHeader:count');
|
||||
$reportXML->writeAttribute('uri', 'urn:ietf:params:xml:ns:rdeNNDN-1.0');
|
||||
$reportXML->text('0');
|
||||
$reportXML->endElement();
|
||||
|
||||
$reportXML->startElement('rdeHeader:count');
|
||||
$reportXML->writeAttribute('uri', 'urn:ietf:params:xml:ns:rdeEppParams-1.0');
|
||||
$reportXML->text('0');
|
||||
$reportXML->endElement();
|
||||
|
||||
$reportXML->endElement(); // Closing rdeHeader:header
|
||||
$reportXML->endElement(); // Closing rdeReport:report
|
||||
|
||||
$reps = $reportXML->outputMemory();
|
||||
|
||||
// Save the report file
|
||||
$reportFilePath = $c['escrow_deposit_path']."/{$tldname}_".date('Y-m-d')."_full_R{$finalDepositId}.rep";
|
||||
file_put_contents($reportFilePath, $reps, LOCK_EX);
|
||||
|
||||
if ($c['escrow_RDEupload']) {
|
||||
// Connect to the SFTP server
|
||||
$sftp = new SFTP($c['escrow_sftp_host']);
|
||||
|
||||
// Login with username and password
|
||||
if (!$sftp->login($c['escrow_sftp_username'], $c['escrow_sftp_password'])) {
|
||||
$log->error('SFTP Login failed');
|
||||
}
|
||||
|
||||
// Define the remote directory where you want to upload the files
|
||||
$remoteDir = $c['escrow_sftp_remotepath'];
|
||||
|
||||
// Upload the files
|
||||
$filesToUpload = [
|
||||
$encryptedFilePath,
|
||||
$signatureFilePath,
|
||||
$reportFilePath
|
||||
];
|
||||
|
||||
foreach ($filesToUpload as $filePath) {
|
||||
$remoteFile = $remoteDir . basename($filePath);
|
||||
if (!$sftp->put($remoteFile, $filePath, SFTP::SOURCE_LOCAL_FILE)) {
|
||||
$log->error('Failed to upload ' . basename($filePath));
|
||||
} else {
|
||||
$log->info('Successfully uploaded ' . basename($filePath));
|
||||
}
|
||||
}
|
||||
|
||||
$reportFileData = file_get_contents($reportFilePath);
|
||||
|
||||
$ch = curl_init();
|
||||
|
||||
// Set cURL options
|
||||
curl_setopt($ch, CURLOPT_URL, $c['escrow_report_url']);
|
||||
curl_setopt($ch, CURLOPT_USERPWD, $c['escrow_report_username'].':'.$c['escrow_report_password']);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $reportFileData);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/octet-stream',
|
||||
'Content-Length: ' . strlen($reportFileData)
|
||||
));
|
||||
|
||||
$response = curl_exec($ch);
|
||||
|
||||
if ($response === false) {
|
||||
$log->error('Upload error occurred: ' . curl_error($ch));
|
||||
}
|
||||
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
if ($httpCode >= 200 && $httpCode < 300) {
|
||||
$log->info('Escrow deposit uploaded successfully');
|
||||
} else {
|
||||
$log->error('Failed to upload escrow deposit. HTTP Status Code: ' . $httpCode);
|
||||
}
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
$log->info('job finished successfully.');
|
||||
$log->info('job finished successfully.');
|
||||
} catch (PDOException $e) {
|
||||
$log->error('Database error: ' . $e->getMessage());
|
||||
} catch (Throwable $e) {
|
||||
$log->error('Error: ' . $e->getMessage());
|
||||
}
|
|
@ -19,176 +19,182 @@ try {
|
|||
$log->error('DB Connection failed: ' . $e->getMessage());
|
||||
}
|
||||
|
||||
// Fetch all TLDs
|
||||
$query = "SELECT tld FROM domain_tld";
|
||||
$tlds = $dbh->query($query)->fetchAll(PDO::FETCH_COLUMN);
|
||||
try {
|
||||
// Fetch all TLDs
|
||||
$query = "SELECT tld FROM domain_tld";
|
||||
$tlds = $dbh->query($query)->fetchAll(PDO::FETCH_COLUMN);
|
||||
|
||||
foreach ($tlds as $tld) {
|
||||
// Skip TLDs with a dot inside, apart from the beginning
|
||||
if (strpos(substr($tld, 1), '.') !== false) {
|
||||
continue; // Skip this iteration if an additional dot is found
|
||||
}
|
||||
|
||||
// Initialize activity and transaction data arrays for each TLD
|
||||
$activityData = [];
|
||||
$transactionData = [];
|
||||
foreach ($tlds as $tld) {
|
||||
// Skip TLDs with a dot inside, apart from the beginning
|
||||
if (strpos(substr($tld, 1), '.') !== false) {
|
||||
continue; // Skip this iteration if an additional dot is found
|
||||
}
|
||||
|
||||
// Initialize activity and transaction data arrays for each TLD
|
||||
$activityData = [];
|
||||
$transactionData = [];
|
||||
|
||||
// Construct activity data for each TLD
|
||||
$activityData[] = [
|
||||
'operational-registrars' => getOperationalRegistrars($dbh),
|
||||
'zfa-passwords' => getZfaPasswords($dbh),
|
||||
'whois-43-queries' => getWhois43Queries($dbh),
|
||||
'web-whois-queries' => getWebWhoisQueries($dbh),
|
||||
'searchable-whois-queries' => getSearchableWhoisQueries($dbh),
|
||||
'dns-udp-queries-received' => getDnsUdpQueriesReceived($dbh),
|
||||
'dns-udp-queries-responded' => getDnsUdpQueriesResponded($dbh),
|
||||
'dns-tcp-queries-received' => getDnsTcpQueriesReceived($dbh),
|
||||
'dns-tcp-queries-responded' => getDnsTcpQueriesResponded($dbh),
|
||||
'srs-dom-check' => getSrsCommand($dbh, 'check', 'domain'),
|
||||
'srs-dom-create' => getSrsCommand($dbh, 'create', 'domain'),
|
||||
'srs-dom-delete' => getSrsCommand($dbh, 'delete', 'domain'),
|
||||
'srs-dom-info' => getSrsCommand($dbh, 'info', 'domain'),
|
||||
'srs-dom-renew' => getSrsCommand($dbh, 'renew', 'domain'),
|
||||
'srs-dom-rgp-restore-report' => getSrsDomRgpRestoreReport($dbh),
|
||||
'srs-dom-rgp-restore-request' => getSrsDomRgpRestoreRequest($dbh),
|
||||
'srs-dom-transfer-approve' => getSrsDomTransferApprove($dbh),
|
||||
'srs-dom-transfer-cancel' => getSrsDomTransferCancel($dbh),
|
||||
'srs-dom-transfer-query' => getSrsDomTransferQuery($dbh),
|
||||
'srs-dom-transfer-reject' => getSrsDomTransferReject($dbh),
|
||||
'srs-dom-transfer-request' => getSrsDomTransferRequest($dbh),
|
||||
'srs-dom-update' => getSrsCommand($dbh, 'update', 'domain'),
|
||||
'srs-host-check' => getSrsCommand($dbh, 'check', 'host'),
|
||||
'srs-host-create' => getSrsCommand($dbh, 'create', 'host'),
|
||||
'srs-host-delete' => getSrsCommand($dbh, 'delete', 'host'),
|
||||
'srs-host-info' => getSrsCommand($dbh, 'info', 'host'),
|
||||
'srs-host-update' => getSrsCommand($dbh, 'update', 'host'),
|
||||
'srs-cont-check' => getSrsCommand($dbh, 'check', 'contact'),
|
||||
'srs-cont-create' => getSrsCommand($dbh, 'create', 'contact'),
|
||||
'srs-cont-delete' => getSrsCommand($dbh, 'delete', 'contact'),
|
||||
'srs-cont-info' => getSrsCommand($dbh, 'info', 'contact'),
|
||||
'srs-cont-transfer-approve' => getSrsContTransferApprove($dbh),
|
||||
'srs-cont-transfer-cancel' => getSrsContTransferCancel($dbh),
|
||||
'srs-cont-transfer-query' => getSrsContTransferQuery($dbh),
|
||||
'srs-cont-transfer-reject' => getSrsContTransferReject($dbh),
|
||||
'srs-cont-transfer-request' => getSrsContTransferRequest($dbh),
|
||||
'srs-cont-update' => getSrsCommand($dbh, 'update', 'contact'),
|
||||
];
|
||||
|
||||
// Loop through registrars and get transaction data
|
||||
$registrars = getRegistrars($dbh);
|
||||
foreach ($registrars as $registrar) {
|
||||
$transactionData[] = [
|
||||
'registrar-name' => $registrar['name'],
|
||||
'iana-id' => $registrar['iana_id'],
|
||||
'total-domains' => getTotalDomains($dbh, $registrar),
|
||||
'total-nameservers' => getTotalNameservers($dbh, $registrar),
|
||||
'net-adds-1-yr' => getNetAddsByYear($dbh, $registrar, 1),
|
||||
'net-adds-2-yr' => getNetAddsByYear($dbh, $registrar, 2),
|
||||
'net-adds-3-yr' => getNetAddsByYear($dbh, $registrar, 3),
|
||||
'net-adds-4-yr' => getNetAddsByYear($dbh, $registrar, 4),
|
||||
'net-adds-5-yr' => getNetAddsByYear($dbh, $registrar, 5),
|
||||
'net-adds-6-yr' => getNetAddsByYear($dbh, $registrar, 6),
|
||||
'net-adds-7-yr' => getNetAddsByYear($dbh, $registrar, 7),
|
||||
'net-adds-8-yr' => getNetAddsByYear($dbh, $registrar, 8),
|
||||
'net-adds-9-yr' => getNetAddsByYear($dbh, $registrar, 9),
|
||||
'net-adds-10-yr' => getNetAddsByYear($dbh, $registrar, 10),
|
||||
'net-renews-1-yr' => getNetRenewsByYear($dbh, $registrar, 1),
|
||||
'net-renews-2-yr' => getNetRenewsByYear($dbh, $registrar, 2),
|
||||
'net-renews-3-yr' => getNetRenewsByYear($dbh, $registrar, 3),
|
||||
'net-renews-4-yr' => getNetRenewsByYear($dbh, $registrar, 4),
|
||||
'net-renews-5-yr' => getNetRenewsByYear($dbh, $registrar, 5),
|
||||
'net-renews-6-yr' => getNetRenewsByYear($dbh, $registrar, 6),
|
||||
'net-renews-7-yr' => getNetRenewsByYear($dbh, $registrar, 7),
|
||||
'net-renews-8-yr' => getNetRenewsByYear($dbh, $registrar, 8),
|
||||
'net-renews-9-yr' => getNetRenewsByYear($dbh, $registrar, 9),
|
||||
'net-renews-10-yr' => getNetRenewsByYear($dbh, $registrar, 10),
|
||||
'transfer-gaining-successful' => getTransferGainingSuccessful($dbh, $registrar),
|
||||
'transfer-gaining-nacked' => getTransferGainingNacked($dbh, $registrar),
|
||||
'transfer-losing-successful' => getTransferLosingSuccessful($dbh, $registrar),
|
||||
'transfer-losing-nacked' => getTransferLosingNacked($dbh, $registrar),
|
||||
'transfer-disputed-won' => getTransferDisputedWon($dbh, $registrar),
|
||||
'transfer-disputed-lost' => getTransferDisputedLost($dbh, $registrar),
|
||||
'transfer-disputed-nodecision' => getTransferDisputedNoDecision($dbh, $registrar),
|
||||
'deleted-domains-grace' => getDeletedDomainsGrace($dbh, $registrar),
|
||||
'deleted-domains-nograce' => getDeletedDomainsNoGrace($dbh, $registrar),
|
||||
'restored-domains' => getRestoredDomains($dbh, $registrar),
|
||||
'restored-noreport' => getRestoredNoReport($dbh, $registrar),
|
||||
'agp-exemption-requests' => getAgpExemptionRequests($dbh, $registrar),
|
||||
'agp-exemptions-granted' => getAgpExemptionsGranted($dbh, $registrar),
|
||||
'agp-exempted-domains' => getAgpExemptedDomains($dbh, $registrar),
|
||||
'attempted-adds' => getAttemptedAdds($dbh, $registrar),
|
||||
// Construct activity data for each TLD
|
||||
$activityData[] = [
|
||||
'operational-registrars' => getOperationalRegistrars($dbh),
|
||||
'zfa-passwords' => getZfaPasswords($dbh),
|
||||
'whois-43-queries' => getWhois43Queries($dbh),
|
||||
'web-whois-queries' => getWebWhoisQueries($dbh),
|
||||
'searchable-whois-queries' => getSearchableWhoisQueries($dbh),
|
||||
'dns-udp-queries-received' => getDnsUdpQueriesReceived($dbh),
|
||||
'dns-udp-queries-responded' => getDnsUdpQueriesResponded($dbh),
|
||||
'dns-tcp-queries-received' => getDnsTcpQueriesReceived($dbh),
|
||||
'dns-tcp-queries-responded' => getDnsTcpQueriesResponded($dbh),
|
||||
'srs-dom-check' => getSrsCommand($dbh, 'check', 'domain'),
|
||||
'srs-dom-create' => getSrsCommand($dbh, 'create', 'domain'),
|
||||
'srs-dom-delete' => getSrsCommand($dbh, 'delete', 'domain'),
|
||||
'srs-dom-info' => getSrsCommand($dbh, 'info', 'domain'),
|
||||
'srs-dom-renew' => getSrsCommand($dbh, 'renew', 'domain'),
|
||||
'srs-dom-rgp-restore-report' => getSrsDomRgpRestoreReport($dbh),
|
||||
'srs-dom-rgp-restore-request' => getSrsDomRgpRestoreRequest($dbh),
|
||||
'srs-dom-transfer-approve' => getSrsDomTransferApprove($dbh),
|
||||
'srs-dom-transfer-cancel' => getSrsDomTransferCancel($dbh),
|
||||
'srs-dom-transfer-query' => getSrsDomTransferQuery($dbh),
|
||||
'srs-dom-transfer-reject' => getSrsDomTransferReject($dbh),
|
||||
'srs-dom-transfer-request' => getSrsDomTransferRequest($dbh),
|
||||
'srs-dom-update' => getSrsCommand($dbh, 'update', 'domain'),
|
||||
'srs-host-check' => getSrsCommand($dbh, 'check', 'host'),
|
||||
'srs-host-create' => getSrsCommand($dbh, 'create', 'host'),
|
||||
'srs-host-delete' => getSrsCommand($dbh, 'delete', 'host'),
|
||||
'srs-host-info' => getSrsCommand($dbh, 'info', 'host'),
|
||||
'srs-host-update' => getSrsCommand($dbh, 'update', 'host'),
|
||||
'srs-cont-check' => getSrsCommand($dbh, 'check', 'contact'),
|
||||
'srs-cont-create' => getSrsCommand($dbh, 'create', 'contact'),
|
||||
'srs-cont-delete' => getSrsCommand($dbh, 'delete', 'contact'),
|
||||
'srs-cont-info' => getSrsCommand($dbh, 'info', 'contact'),
|
||||
'srs-cont-transfer-approve' => getSrsContTransferApprove($dbh),
|
||||
'srs-cont-transfer-cancel' => getSrsContTransferCancel($dbh),
|
||||
'srs-cont-transfer-query' => getSrsContTransferQuery($dbh),
|
||||
'srs-cont-transfer-reject' => getSrsContTransferReject($dbh),
|
||||
'srs-cont-transfer-request' => getSrsContTransferRequest($dbh),
|
||||
'srs-cont-update' => getSrsCommand($dbh, 'update', 'contact'),
|
||||
];
|
||||
}
|
||||
|
||||
$totals = [
|
||||
'registrar-name' => 'Totals',
|
||||
'iana-id' => '',
|
||||
'total-domains' => getTotalDomainsAllRegistrars($dbh),
|
||||
'total-nameservers' => getTotalNameserversAllRegistrars($dbh),
|
||||
'net-adds-1-yr' => getNetAddsByYearAllRegistrars($dbh, 1),
|
||||
'net-adds-2-yr' => getNetAddsByYearAllRegistrars($dbh, 2),
|
||||
'net-adds-3-yr' => getNetAddsByYearAllRegistrars($dbh, 3),
|
||||
'net-adds-4-yr' => getNetAddsByYearAllRegistrars($dbh, 4),
|
||||
'net-adds-5-yr' => getNetAddsByYearAllRegistrars($dbh, 5),
|
||||
'net-adds-6-yr' => getNetAddsByYearAllRegistrars($dbh, 6),
|
||||
'net-adds-7-yr' => getNetAddsByYearAllRegistrars($dbh, 7),
|
||||
'net-adds-8-yr' => getNetAddsByYearAllRegistrars($dbh, 8),
|
||||
'net-adds-9-yr' => getNetAddsByYearAllRegistrars($dbh, 9),
|
||||
'net-adds-10-yr' => getNetAddsByYearAllRegistrars($dbh, 10),
|
||||
'net-renews-1-yr' => getNetRenewsByYearAllRegistrars($dbh, 1),
|
||||
'net-renews-2-yr' => getNetRenewsByYearAllRegistrars($dbh, 2),
|
||||
'net-renews-3-yr' => getNetRenewsByYearAllRegistrars($dbh, 3),
|
||||
'net-renews-4-yr' => getNetRenewsByYearAllRegistrars($dbh, 4),
|
||||
'net-renews-5-yr' => getNetRenewsByYearAllRegistrars($dbh, 5),
|
||||
'net-renews-6-yr' => getNetRenewsByYearAllRegistrars($dbh, 6),
|
||||
'net-renews-7-yr' => getNetRenewsByYearAllRegistrars($dbh, 7),
|
||||
'net-renews-8-yr' => getNetRenewsByYearAllRegistrars($dbh, 8),
|
||||
'net-renews-9-yr' => getNetRenewsByYearAllRegistrars($dbh, 9),
|
||||
'net-renews-10-yr' => getNetRenewsByYearAllRegistrars($dbh, 10),
|
||||
'transfer-gaining-successful' => getTransferGainingSuccessfulAllRegistrars($dbh),
|
||||
'transfer-gaining-nacked' => getTransferGainingNackedAllRegistrars($dbh),
|
||||
'transfer-losing-successful' => getTransferLosingSuccessfulAllRegistrars($dbh),
|
||||
'transfer-losing-nacked' => getTransferLosingNackedAllRegistrars($dbh),
|
||||
'transfer-disputed-won' => getTransferDisputedWonAllRegistrars($dbh),
|
||||
'transfer-disputed-lost' => getTransferDisputedLostAllRegistrars($dbh),
|
||||
'transfer-disputed-nodecision' => getTransferDisputedNoDecisionAllRegistrars($dbh),
|
||||
'deleted-domains-grace' => getDeletedDomainsGraceAllRegistrars($dbh),
|
||||
'deleted-domains-nograce' => getDeletedDomainsNoGraceAllRegistrars($dbh),
|
||||
'restored-domains' => getRestoredDomainsAllRegistrars($dbh),
|
||||
'restored-noreport' => getRestoredNoReportAllRegistrars($dbh),
|
||||
'agp-exemption-requests' => getAgpExemptionRequestsAllRegistrars($dbh),
|
||||
'agp-exemptions-granted' => getAgpExemptionsGrantedAllRegistrars($dbh),
|
||||
'agp-exempted-domains' => getAgpExemptedDomainsAllRegistrars($dbh),
|
||||
'attempted-adds' => getAttemptedAddsAllRegistrars($dbh),
|
||||
];
|
||||
|
||||
$transactionData[] = $totals;
|
||||
// Loop through registrars and get transaction data
|
||||
$registrars = getRegistrars($dbh);
|
||||
foreach ($registrars as $registrar) {
|
||||
$transactionData[] = [
|
||||
'registrar-name' => $registrar['name'],
|
||||
'iana-id' => $registrar['iana_id'],
|
||||
'total-domains' => getTotalDomains($dbh, $registrar),
|
||||
'total-nameservers' => getTotalNameservers($dbh, $registrar),
|
||||
'net-adds-1-yr' => getNetAddsByYear($dbh, $registrar, 1),
|
||||
'net-adds-2-yr' => getNetAddsByYear($dbh, $registrar, 2),
|
||||
'net-adds-3-yr' => getNetAddsByYear($dbh, $registrar, 3),
|
||||
'net-adds-4-yr' => getNetAddsByYear($dbh, $registrar, 4),
|
||||
'net-adds-5-yr' => getNetAddsByYear($dbh, $registrar, 5),
|
||||
'net-adds-6-yr' => getNetAddsByYear($dbh, $registrar, 6),
|
||||
'net-adds-7-yr' => getNetAddsByYear($dbh, $registrar, 7),
|
||||
'net-adds-8-yr' => getNetAddsByYear($dbh, $registrar, 8),
|
||||
'net-adds-9-yr' => getNetAddsByYear($dbh, $registrar, 9),
|
||||
'net-adds-10-yr' => getNetAddsByYear($dbh, $registrar, 10),
|
||||
'net-renews-1-yr' => getNetRenewsByYear($dbh, $registrar, 1),
|
||||
'net-renews-2-yr' => getNetRenewsByYear($dbh, $registrar, 2),
|
||||
'net-renews-3-yr' => getNetRenewsByYear($dbh, $registrar, 3),
|
||||
'net-renews-4-yr' => getNetRenewsByYear($dbh, $registrar, 4),
|
||||
'net-renews-5-yr' => getNetRenewsByYear($dbh, $registrar, 5),
|
||||
'net-renews-6-yr' => getNetRenewsByYear($dbh, $registrar, 6),
|
||||
'net-renews-7-yr' => getNetRenewsByYear($dbh, $registrar, 7),
|
||||
'net-renews-8-yr' => getNetRenewsByYear($dbh, $registrar, 8),
|
||||
'net-renews-9-yr' => getNetRenewsByYear($dbh, $registrar, 9),
|
||||
'net-renews-10-yr' => getNetRenewsByYear($dbh, $registrar, 10),
|
||||
'transfer-gaining-successful' => getTransferGainingSuccessful($dbh, $registrar),
|
||||
'transfer-gaining-nacked' => getTransferGainingNacked($dbh, $registrar),
|
||||
'transfer-losing-successful' => getTransferLosingSuccessful($dbh, $registrar),
|
||||
'transfer-losing-nacked' => getTransferLosingNacked($dbh, $registrar),
|
||||
'transfer-disputed-won' => getTransferDisputedWon($dbh, $registrar),
|
||||
'transfer-disputed-lost' => getTransferDisputedLost($dbh, $registrar),
|
||||
'transfer-disputed-nodecision' => getTransferDisputedNoDecision($dbh, $registrar),
|
||||
'deleted-domains-grace' => getDeletedDomainsGrace($dbh, $registrar),
|
||||
'deleted-domains-nograce' => getDeletedDomainsNoGrace($dbh, $registrar),
|
||||
'restored-domains' => getRestoredDomains($dbh, $registrar),
|
||||
'restored-noreport' => getRestoredNoReport($dbh, $registrar),
|
||||
'agp-exemption-requests' => getAgpExemptionRequests($dbh, $registrar),
|
||||
'agp-exemptions-granted' => getAgpExemptionsGranted($dbh, $registrar),
|
||||
'agp-exempted-domains' => getAgpExemptedDomains($dbh, $registrar),
|
||||
'attempted-adds' => getAttemptedAdds($dbh, $registrar),
|
||||
];
|
||||
}
|
||||
|
||||
$totals = [
|
||||
'registrar-name' => 'Totals',
|
||||
'iana-id' => '',
|
||||
'total-domains' => getTotalDomainsAllRegistrars($dbh),
|
||||
'total-nameservers' => getTotalNameserversAllRegistrars($dbh),
|
||||
'net-adds-1-yr' => getNetAddsByYearAllRegistrars($dbh, 1),
|
||||
'net-adds-2-yr' => getNetAddsByYearAllRegistrars($dbh, 2),
|
||||
'net-adds-3-yr' => getNetAddsByYearAllRegistrars($dbh, 3),
|
||||
'net-adds-4-yr' => getNetAddsByYearAllRegistrars($dbh, 4),
|
||||
'net-adds-5-yr' => getNetAddsByYearAllRegistrars($dbh, 5),
|
||||
'net-adds-6-yr' => getNetAddsByYearAllRegistrars($dbh, 6),
|
||||
'net-adds-7-yr' => getNetAddsByYearAllRegistrars($dbh, 7),
|
||||
'net-adds-8-yr' => getNetAddsByYearAllRegistrars($dbh, 8),
|
||||
'net-adds-9-yr' => getNetAddsByYearAllRegistrars($dbh, 9),
|
||||
'net-adds-10-yr' => getNetAddsByYearAllRegistrars($dbh, 10),
|
||||
'net-renews-1-yr' => getNetRenewsByYearAllRegistrars($dbh, 1),
|
||||
'net-renews-2-yr' => getNetRenewsByYearAllRegistrars($dbh, 2),
|
||||
'net-renews-3-yr' => getNetRenewsByYearAllRegistrars($dbh, 3),
|
||||
'net-renews-4-yr' => getNetRenewsByYearAllRegistrars($dbh, 4),
|
||||
'net-renews-5-yr' => getNetRenewsByYearAllRegistrars($dbh, 5),
|
||||
'net-renews-6-yr' => getNetRenewsByYearAllRegistrars($dbh, 6),
|
||||
'net-renews-7-yr' => getNetRenewsByYearAllRegistrars($dbh, 7),
|
||||
'net-renews-8-yr' => getNetRenewsByYearAllRegistrars($dbh, 8),
|
||||
'net-renews-9-yr' => getNetRenewsByYearAllRegistrars($dbh, 9),
|
||||
'net-renews-10-yr' => getNetRenewsByYearAllRegistrars($dbh, 10),
|
||||
'transfer-gaining-successful' => getTransferGainingSuccessfulAllRegistrars($dbh),
|
||||
'transfer-gaining-nacked' => getTransferGainingNackedAllRegistrars($dbh),
|
||||
'transfer-losing-successful' => getTransferLosingSuccessfulAllRegistrars($dbh),
|
||||
'transfer-losing-nacked' => getTransferLosingNackedAllRegistrars($dbh),
|
||||
'transfer-disputed-won' => getTransferDisputedWonAllRegistrars($dbh),
|
||||
'transfer-disputed-lost' => getTransferDisputedLostAllRegistrars($dbh),
|
||||
'transfer-disputed-nodecision' => getTransferDisputedNoDecisionAllRegistrars($dbh),
|
||||
'deleted-domains-grace' => getDeletedDomainsGraceAllRegistrars($dbh),
|
||||
'deleted-domains-nograce' => getDeletedDomainsNoGraceAllRegistrars($dbh),
|
||||
'restored-domains' => getRestoredDomainsAllRegistrars($dbh),
|
||||
'restored-noreport' => getRestoredNoReportAllRegistrars($dbh),
|
||||
'agp-exemption-requests' => getAgpExemptionRequestsAllRegistrars($dbh),
|
||||
'agp-exemptions-granted' => getAgpExemptionsGrantedAllRegistrars($dbh),
|
||||
'agp-exempted-domains' => getAgpExemptedDomainsAllRegistrars($dbh),
|
||||
'attempted-adds' => getAttemptedAddsAllRegistrars($dbh),
|
||||
];
|
||||
|
||||
// Write data to CSV
|
||||
$tld_save = strtolower(ltrim($tld, '.'));
|
||||
writeCSV("{$c['reporting_path']}/{$tld_save}-activity-" . date('Ym') . "-en.csv", $activityData);
|
||||
writeCSV("{$c['reporting_path']}/{$tld_save}-transactions-" . date('Ym') . "-en.csv", $transactionData);
|
||||
|
||||
// Upload if the $c['reporting_upload'] variable is true
|
||||
if ($c['reporting_upload']) {
|
||||
// Calculate the period (previous month from now)
|
||||
$previousMonth = date('Ym', strtotime('-1 month'));
|
||||
|
||||
// Paths to the files you created
|
||||
$activityFile = "{$tld_save}-activity-" . $previousMonth . "-en.csv";
|
||||
$transactionFile = "{$tld_save}-transactions-" . $previousMonth . "-en.csv";
|
||||
|
||||
// URLs for upload
|
||||
$activityUploadUrl = 'https://ry-api.icann.org/report/registry-functions-activity/' . $tld_save . '/' . $previousMonth;
|
||||
$transactionUploadUrl = 'https://ry-api.icann.org/report/registrar-transactions/' . $tld_save . '/' . $previousMonth;
|
||||
|
||||
// Perform the upload
|
||||
//uploadFile($activityUploadUrl, $activityFile, $c['reporting_username'], $c['reporting_password'], $log);
|
||||
//uploadFile($transactionUploadUrl, $transactionFile, $c['reporting_username'], $c['reporting_password'], $log);
|
||||
$transactionData[] = $totals;
|
||||
|
||||
// Write data to CSV
|
||||
$tld_save = strtolower(ltrim($tld, '.'));
|
||||
writeCSV("{$c['reporting_path']}/{$tld_save}-activity-" . date('Ym') . "-en.csv", $activityData);
|
||||
writeCSV("{$c['reporting_path']}/{$tld_save}-transactions-" . date('Ym') . "-en.csv", $transactionData);
|
||||
|
||||
// Upload if the $c['reporting_upload'] variable is true
|
||||
if ($c['reporting_upload']) {
|
||||
// Calculate the period (previous month from now)
|
||||
$previousMonth = date('Ym', strtotime('-1 month'));
|
||||
|
||||
// Paths to the files you created
|
||||
$activityFile = "{$tld_save}-activity-" . $previousMonth . "-en.csv";
|
||||
$transactionFile = "{$tld_save}-transactions-" . $previousMonth . "-en.csv";
|
||||
|
||||
// URLs for upload
|
||||
$activityUploadUrl = 'https://ry-api.icann.org/report/registry-functions-activity/' . $tld_save . '/' . $previousMonth;
|
||||
$transactionUploadUrl = 'https://ry-api.icann.org/report/registrar-transactions/' . $tld_save . '/' . $previousMonth;
|
||||
|
||||
// Perform the upload
|
||||
uploadFile($activityUploadUrl, $activityFile, $c['reporting_username'], $c['reporting_password']);
|
||||
uploadFile($transactionUploadUrl, $transactionFile, $c['reporting_username'], $c['reporting_password']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$log->info('job finished successfully.');
|
||||
} catch (PDOException $e) {
|
||||
$log->error('DB Connection failed: ' . $e->getMessage());
|
||||
} catch (Throwable $e) {
|
||||
$log->error('Error: ' . $e->getMessage());
|
||||
}
|
||||
$log->info('job finished successfully.');
|
||||
|
||||
// HELPER FUNCTIONS
|
||||
function getOperationalRegistrars($dbh) {
|
||||
|
@ -202,12 +208,25 @@ function getRegistrars($dbh) {
|
|||
}
|
||||
|
||||
function writeCSV($filename, $data) {
|
||||
if (!is_array($data) || empty($data)) {
|
||||
throw new Exception("Data for CSV writing must be a non-empty array.");
|
||||
}
|
||||
|
||||
$file = fopen($filename, 'w');
|
||||
if ($file === false) {
|
||||
throw new Exception("Unable to open file '{$filename}' for writing.");
|
||||
}
|
||||
|
||||
fputcsv($file, array_keys($data[0]));
|
||||
foreach ($data as $row) {
|
||||
fputcsv($file, $row);
|
||||
if (false === fputcsv($file, $row)) {
|
||||
throw new Exception("Failed to write data to CSV file.");
|
||||
}
|
||||
}
|
||||
|
||||
if (false === fclose($file)) {
|
||||
throw new Exception("Unable to close the file '{$filename}'.");
|
||||
}
|
||||
fclose($file);
|
||||
}
|
||||
|
||||
function getZfaPasswords($dbh) {
|
||||
|
@ -566,7 +585,7 @@ function getAttemptedAddsAllRegistrars($dbh) {
|
|||
}
|
||||
|
||||
// Upload function using cURL
|
||||
function uploadFile($url, $filePath, $username, $password, $log) {
|
||||
function uploadFile($url, $filePath, $username, $password) {
|
||||
$ch = curl_init();
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
|
@ -578,7 +597,7 @@ function uploadFile($url, $filePath, $username, $password, $log) {
|
|||
|
||||
$response = curl_exec($ch);
|
||||
if (curl_errno($ch)) {
|
||||
$log->error('Report upload error: ' . curl_error($ch));
|
||||
throw new Exception('Report upload error: ' . curl_error($ch));
|
||||
}
|
||||
|
||||
curl_close($ch);
|
||||
|
|
|
@ -34,6 +34,6 @@ try {
|
|||
|
||||
} catch (PDOException $e) {
|
||||
$log->error('Database error: ' . $e->getMessage());
|
||||
} catch (Exception $e) {
|
||||
} catch (Throwable $e) {
|
||||
$log->error('Error: ' . $e->getMessage());
|
||||
}
|
|
@ -76,7 +76,8 @@ try {
|
|||
$log->info('job finished successfully.');
|
||||
} catch (Exception $e) {
|
||||
$log->error('IMAP connection error: ' . $e->getMessage());
|
||||
return;
|
||||
} catch (Throwable $e) {
|
||||
$log->error('Error: ' . $e->getMessage());
|
||||
}
|
||||
|
||||
function extractDomainNameFromEmail($emailBody) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue