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,6 +16,7 @@ try {
|
|||
$log->error('DB Connection failed: ' . $e->getMessage());
|
||||
}
|
||||
|
||||
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();
|
||||
|
@ -111,3 +112,8 @@ while ($contact_data = $stmt_contact->fetch(PDO::FETCH_ASSOC)) {
|
|||
}
|
||||
$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,6 +16,7 @@ try {
|
|||
$log->error('DB Connection failed: ' . $e->getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
// Auto-Renew Grace Period
|
||||
$auto_renew = 0;
|
||||
|
||||
|
@ -213,3 +214,8 @@ while ($row = $sth_delete->fetch(PDO::FETCH_ASSOC)) {
|
|||
$log->info($name . ' (ID ' . $domain_id . ') domain:Deleted exdate: ' . $exdate);
|
||||
}
|
||||
$log->info('job finished successfully.');
|
||||
} catch (PDOException $e) {
|
||||
$log->error('Database error: ' . $e->getMessage());
|
||||
} catch (Throwable $e) {
|
||||
$log->error('Error: ' . $e->getMessage());
|
||||
}
|
|
@ -23,6 +23,7 @@ try {
|
|||
$log->error('DB Connection failed: ' . $e->getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
$domainCount = fetchCount($dbh, 'domain');
|
||||
$hostCount = fetchCount($dbh, 'host');
|
||||
$contactCount = fetchCount($dbh, 'contact');
|
||||
|
@ -495,3 +496,8 @@ foreach ($tlds as $tld) {
|
|||
|
||||
}
|
||||
$log->info('job finished successfully.');
|
||||
} catch (PDOException $e) {
|
||||
$log->error('Database error: ' . $e->getMessage());
|
||||
} catch (Throwable $e) {
|
||||
$log->error('Error: ' . $e->getMessage());
|
||||
}
|
|
@ -19,6 +19,7 @@ try {
|
|||
$log->error('DB Connection failed: ' . $e->getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
// Fetch all TLDs
|
||||
$query = "SELECT tld FROM domain_tld";
|
||||
$tlds = $dbh->query($query)->fetchAll(PDO::FETCH_COLUMN);
|
||||
|
@ -183,12 +184,17 @@ foreach ($tlds as $tld) {
|
|||
$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);
|
||||
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());
|
||||
}
|
||||
|
||||
// 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