Added minimum data set support for automation

This commit is contained in:
Pinga 2024-07-24 22:10:37 +03:00
parent 1a17fdfddc
commit 1e8ab1466d
3 changed files with 93 additions and 80 deletions

View file

@ -18,6 +18,7 @@ try {
try {
$dbh->beginTransaction();
$minimum_data = $c['minimum_data'];
$query_domain = "SELECT id, name, registrant, crdate, exdate, lastupdate, 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);
@ -60,6 +61,7 @@ try {
}
}
if (!$minimum_data) {
// Fetch contact map
$stmt = $dbh->prepare('SELECT contact_id, type FROM domain_contact_map WHERE domain_id = ?');
$stmt->execute([$domain_id]);
@ -99,12 +101,14 @@ try {
}
$stmt->execute();
}
}
// Insert auth info and status for the new registrant
$new_authinfo = generateAuthInfo();
$dbh->prepare('INSERT INTO contact_authInfo (contact_id, authtype, authinfo) VALUES (?, ?, ?)')->execute([$newRegistrantId, 'pw', $new_authinfo]);
$dbh->prepare('INSERT INTO contact_status (contact_id, status) VALUES (?, ?)')->execute([$newRegistrantId, 'ok']);
if (!$minimum_data) {
// Process each contact in the contact map
foreach ($contactMap as $contact) {
if (!array_key_exists($contact['contact_id'], $newContactIds)) {
@ -144,6 +148,7 @@ try {
$dbh->prepare('INSERT INTO contact_status (contact_id, status) VALUES (?, ?)')->execute([$newContactId, 'ok']);
}
}
}
$from = $dbh->query("SELECT exdate FROM domain WHERE id = '$domain_id' LIMIT 1")->fetchColumn();
@ -154,6 +159,7 @@ try {
$stmt_update_auth = $dbh->prepare("UPDATE domain_authInfo SET authinfo = '$new_authinfo' WHERE domain_id = '$domain_id'");
$stmt_update_auth->execute();
if (!$minimum_data) {
foreach ($contactMap as $contact) {
// Construct the SQL update query
$sql = "UPDATE domain_contact_map SET contact_id = :new_contact_id WHERE domain_id = :domain_id AND type = :type AND contact_id = :contact_id";
@ -170,6 +176,7 @@ try {
// Execute the update statement
$stmt->execute();
}
}
$stmt_update_host = $dbh->prepare("UPDATE host SET clid = '$reid', upid = NULL, lastupdate = CURRENT_TIMESTAMP, trdate = CURRENT_TIMESTAMP WHERE domain_id = '$domain_id'");
$stmt_update_host->execute();

View file

@ -19,6 +19,7 @@ try {
try {
// Auto-Renew Grace Period
$auto_renew = 0;
$minimum_data = $c['minimum_data'];
if ($auto_renew) {
$sth_autorenewperiod = $dbh->prepare("SELECT id, name, tldid, exdate, clid FROM domain WHERE CURRENT_TIMESTAMP > exdate AND rgpstatus IS NULL");
@ -194,7 +195,9 @@ try {
$dbh->exec("DELETE FROM domain_host_map WHERE host_id = '$host_id'");
}
if (!$minimum_data) {
$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'");

View file

@ -75,4 +75,7 @@ return [
// LORDN Configuration
'lordn_user' => 'your_username',
'lordn_pass' => 'your_password',
// Minimum Data Set
'minimum_data' => false,
];