mirror of
https://github.com/getnamingo/registry.git
synced 2025-07-03 17:43:22 +02:00
Added minimum data set support for automation
This commit is contained in:
parent
1a17fdfddc
commit
1e8ab1466d
3 changed files with 93 additions and 80 deletions
|
@ -18,6 +18,7 @@ try {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$dbh->beginTransaction();
|
$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'";
|
$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);
|
$stmt_domain = $dbh->prepare($query_domain);
|
||||||
|
@ -60,44 +61,46 @@ try {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch contact map
|
if (!$minimum_data) {
|
||||||
$stmt = $dbh->prepare('SELECT contact_id, type FROM domain_contact_map WHERE domain_id = ?');
|
// Fetch contact map
|
||||||
$stmt->execute([$domain_id]);
|
$stmt = $dbh->prepare('SELECT contact_id, type FROM domain_contact_map WHERE domain_id = ?');
|
||||||
$contactMap = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$stmt->execute([$domain_id]);
|
||||||
|
$contactMap = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
// Prepare an array to hold new contact IDs to prevent duplicating contacts
|
// Prepare an array to hold new contact IDs to prevent duplicating contacts
|
||||||
$newContactIds = [];
|
$newContactIds = [];
|
||||||
|
|
||||||
// Copy registrant data
|
// Copy registrant data
|
||||||
$stmt = $dbh->prepare('SELECT * FROM contact WHERE id = ?');
|
$stmt = $dbh->prepare('SELECT * FROM contact WHERE id = ?');
|
||||||
$stmt->execute([$registrant]);
|
$stmt->execute([$registrant]);
|
||||||
$registrantData = $stmt->fetch(PDO::FETCH_ASSOC);
|
$registrantData = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
unset($registrantData['id']);
|
unset($registrantData['id']);
|
||||||
$registrantData['identifier'] = generateAuthInfo();
|
$registrantData['identifier'] = generateAuthInfo();
|
||||||
$registrantData['clid'] = $reid;
|
$registrantData['clid'] = $reid;
|
||||||
|
|
||||||
$stmt = $dbh->prepare('INSERT INTO contact (' . implode(', ', array_keys($registrantData)) . ') VALUES (:' . implode(', :', array_keys($registrantData)) . ')');
|
$stmt = $dbh->prepare('INSERT INTO contact (' . implode(', ', array_keys($registrantData)) . ') VALUES (:' . implode(', :', array_keys($registrantData)) . ')');
|
||||||
foreach ($registrantData as $key => $value) {
|
foreach ($registrantData as $key => $value) {
|
||||||
$stmt->bindValue(':' . $key, $value);
|
|
||||||
}
|
|
||||||
$stmt->execute();
|
|
||||||
$newRegistrantId = $dbh->lastInsertId();
|
|
||||||
$newContactIds[$registrant] = $newRegistrantId;
|
|
||||||
|
|
||||||
// Copy postal info for the registrant
|
|
||||||
$stmt = $dbh->prepare('SELECT * FROM contact_postalInfo WHERE contact_id = ?');
|
|
||||||
$stmt->execute([$registrant]);
|
|
||||||
$postalInfos = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
||||||
|
|
||||||
foreach ($postalInfos as $postalInfo) {
|
|
||||||
unset($postalInfo['id']);
|
|
||||||
$postalInfo['contact_id'] = $newRegistrantId;
|
|
||||||
$columns = array_keys($postalInfo);
|
|
||||||
$stmt = $dbh->prepare('INSERT INTO contact_postalInfo (' . implode(', ', $columns) . ') VALUES (:' . implode(', :', $columns) . ')');
|
|
||||||
foreach ($postalInfo as $key => $value) {
|
|
||||||
$stmt->bindValue(':' . $key, $value);
|
$stmt->bindValue(':' . $key, $value);
|
||||||
}
|
}
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
$newRegistrantId = $dbh->lastInsertId();
|
||||||
|
$newContactIds[$registrant] = $newRegistrantId;
|
||||||
|
|
||||||
|
// Copy postal info for the registrant
|
||||||
|
$stmt = $dbh->prepare('SELECT * FROM contact_postalInfo WHERE contact_id = ?');
|
||||||
|
$stmt->execute([$registrant]);
|
||||||
|
$postalInfos = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
foreach ($postalInfos as $postalInfo) {
|
||||||
|
unset($postalInfo['id']);
|
||||||
|
$postalInfo['contact_id'] = $newRegistrantId;
|
||||||
|
$columns = array_keys($postalInfo);
|
||||||
|
$stmt = $dbh->prepare('INSERT INTO contact_postalInfo (' . implode(', ', $columns) . ') VALUES (:' . implode(', :', $columns) . ')');
|
||||||
|
foreach ($postalInfo as $key => $value) {
|
||||||
|
$stmt->bindValue(':' . $key, $value);
|
||||||
|
}
|
||||||
|
$stmt->execute();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert auth info and status for the new registrant
|
// Insert auth info and status for the new registrant
|
||||||
|
@ -105,43 +108,45 @@ try {
|
||||||
$dbh->prepare('INSERT INTO contact_authInfo (contact_id, authtype, authinfo) VALUES (?, ?, ?)')->execute([$newRegistrantId, 'pw', $new_authinfo]);
|
$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']);
|
$dbh->prepare('INSERT INTO contact_status (contact_id, status) VALUES (?, ?)')->execute([$newRegistrantId, 'ok']);
|
||||||
|
|
||||||
// Process each contact in the contact map
|
if (!$minimum_data) {
|
||||||
foreach ($contactMap as $contact) {
|
// Process each contact in the contact map
|
||||||
if (!array_key_exists($contact['contact_id'], $newContactIds)) {
|
foreach ($contactMap as $contact) {
|
||||||
$stmt = $dbh->prepare('SELECT * FROM contact WHERE id = ?');
|
if (!array_key_exists($contact['contact_id'], $newContactIds)) {
|
||||||
$stmt->execute([$contact['contact_id']]);
|
$stmt = $dbh->prepare('SELECT * FROM contact WHERE id = ?');
|
||||||
$contactData = $stmt->fetch(PDO::FETCH_ASSOC);
|
$stmt->execute([$contact['contact_id']]);
|
||||||
unset($contactData['id']);
|
$contactData = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
$contactData['identifier'] = generateAuthInfo();
|
unset($contactData['id']);
|
||||||
$contactData['clid'] = $reid;
|
$contactData['identifier'] = generateAuthInfo();
|
||||||
|
$contactData['clid'] = $reid;
|
||||||
|
|
||||||
$stmt = $dbh->prepare('INSERT INTO contact (' . implode(', ', array_keys($contactData)) . ') VALUES (:' . implode(', :', array_keys($contactData)) . ')');
|
$stmt = $dbh->prepare('INSERT INTO contact (' . implode(', ', array_keys($contactData)) . ') VALUES (:' . implode(', :', array_keys($contactData)) . ')');
|
||||||
foreach ($contactData as $key => $value) {
|
foreach ($contactData as $key => $value) {
|
||||||
$stmt->bindValue(':' . $key, $value);
|
|
||||||
}
|
|
||||||
$stmt->execute();
|
|
||||||
$newContactId = $dbh->lastInsertId();
|
|
||||||
$newContactIds[$contact['contact_id']] = $newContactId;
|
|
||||||
|
|
||||||
// Repeat postal info and auth info/status insertion for each new contact
|
|
||||||
$stmt = $dbh->prepare('SELECT * FROM contact_postalInfo WHERE contact_id = ?');
|
|
||||||
$stmt->execute([$contact['contact_id']]);
|
|
||||||
$postalInfos = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
||||||
|
|
||||||
foreach ($postalInfos as $postalInfo) {
|
|
||||||
unset($postalInfo['id']);
|
|
||||||
$postalInfo['contact_id'] = $newContactId;
|
|
||||||
$columns = array_keys($postalInfo);
|
|
||||||
$stmt = $dbh->prepare('INSERT INTO contact_postalInfo (' . implode(', ', $columns) . ') VALUES (:' . implode(', :', $columns) . ')');
|
|
||||||
foreach ($postalInfo as $key => $value) {
|
|
||||||
$stmt->bindValue(':' . $key, $value);
|
$stmt->bindValue(':' . $key, $value);
|
||||||
}
|
}
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
$newContactId = $dbh->lastInsertId();
|
||||||
|
$newContactIds[$contact['contact_id']] = $newContactId;
|
||||||
|
|
||||||
$new_authinfo = generateAuthInfo();
|
// Repeat postal info and auth info/status insertion for each new contact
|
||||||
$dbh->prepare('INSERT INTO contact_authInfo (contact_id, authtype, authinfo) VALUES (?, ?, ?)')->execute([$newContactId, 'pw', $new_authinfo]);
|
$stmt = $dbh->prepare('SELECT * FROM contact_postalInfo WHERE contact_id = ?');
|
||||||
$dbh->prepare('INSERT INTO contact_status (contact_id, status) VALUES (?, ?)')->execute([$newContactId, 'ok']);
|
$stmt->execute([$contact['contact_id']]);
|
||||||
|
$postalInfos = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
foreach ($postalInfos as $postalInfo) {
|
||||||
|
unset($postalInfo['id']);
|
||||||
|
$postalInfo['contact_id'] = $newContactId;
|
||||||
|
$columns = array_keys($postalInfo);
|
||||||
|
$stmt = $dbh->prepare('INSERT INTO contact_postalInfo (' . implode(', ', $columns) . ') VALUES (:' . implode(', :', $columns) . ')');
|
||||||
|
foreach ($postalInfo as $key => $value) {
|
||||||
|
$stmt->bindValue(':' . $key, $value);
|
||||||
|
}
|
||||||
|
$stmt->execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
$new_authinfo = generateAuthInfo();
|
||||||
|
$dbh->prepare('INSERT INTO contact_authInfo (contact_id, authtype, authinfo) VALUES (?, ?, ?)')->execute([$newContactId, 'pw', $new_authinfo]);
|
||||||
|
$dbh->prepare('INSERT INTO contact_status (contact_id, status) VALUES (?, ?)')->execute([$newContactId, 'ok']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,21 +159,23 @@ try {
|
||||||
$stmt_update_auth = $dbh->prepare("UPDATE domain_authInfo SET authinfo = '$new_authinfo' WHERE domain_id = '$domain_id'");
|
$stmt_update_auth = $dbh->prepare("UPDATE domain_authInfo SET authinfo = '$new_authinfo' WHERE domain_id = '$domain_id'");
|
||||||
$stmt_update_auth->execute();
|
$stmt_update_auth->execute();
|
||||||
|
|
||||||
foreach ($contactMap as $contact) {
|
if (!$minimum_data) {
|
||||||
// Construct the SQL update query
|
foreach ($contactMap as $contact) {
|
||||||
$sql = "UPDATE domain_contact_map SET contact_id = :new_contact_id WHERE domain_id = :domain_id AND type = :type AND contact_id = :contact_id";
|
// 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";
|
||||||
|
|
||||||
// Prepare the SQL statement
|
// Prepare the SQL statement
|
||||||
$stmt = $dbh->prepare($sql);
|
$stmt = $dbh->prepare($sql);
|
||||||
|
|
||||||
// Bind the values to the placeholders
|
// Bind the values to the placeholders
|
||||||
$stmt->bindValue(':new_contact_id', $newContactIds[$contact['contact_id']]);
|
$stmt->bindValue(':new_contact_id', $newContactIds[$contact['contact_id']]);
|
||||||
$stmt->bindValue(':domain_id', $domain_id);
|
$stmt->bindValue(':domain_id', $domain_id);
|
||||||
$stmt->bindValue(':type', $contact['type']);
|
$stmt->bindValue(':type', $contact['type']);
|
||||||
$stmt->bindValue(':contact_id', $contact['contact_id']);
|
$stmt->bindValue(':contact_id', $contact['contact_id']);
|
||||||
|
|
||||||
// Execute the update statement
|
// Execute the update statement
|
||||||
$stmt->execute();
|
$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 = $dbh->prepare("UPDATE host SET clid = '$reid', upid = NULL, lastupdate = CURRENT_TIMESTAMP, trdate = CURRENT_TIMESTAMP WHERE domain_id = '$domain_id'");
|
||||||
|
|
|
@ -19,6 +19,7 @@ try {
|
||||||
try {
|
try {
|
||||||
// Auto-Renew Grace Period
|
// Auto-Renew Grace Period
|
||||||
$auto_renew = 0;
|
$auto_renew = 0;
|
||||||
|
$minimum_data = $c['minimum_data'];
|
||||||
|
|
||||||
if ($auto_renew) {
|
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 = $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'");
|
$dbh->exec("DELETE FROM domain_host_map WHERE host_id = '$host_id'");
|
||||||
}
|
}
|
||||||
|
|
||||||
$dbh->exec("DELETE FROM domain_contact_map WHERE domain_id = '$domain_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_host_map WHERE domain_id = '$domain_id'");
|
||||||
$dbh->exec("DELETE FROM domain_authInfo 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 domain_status WHERE domain_id = '$domain_id'");
|
||||||
|
|
|
@ -75,4 +75,7 @@ return [
|
||||||
// LORDN Configuration
|
// LORDN Configuration
|
||||||
'lordn_user' => 'your_username',
|
'lordn_user' => 'your_username',
|
||||||
'lordn_pass' => 'your_password',
|
'lordn_pass' => 'your_password',
|
||||||
|
|
||||||
|
// Minimum Data Set
|
||||||
|
'minimum_data' => false,
|
||||||
];
|
];
|
Loading…
Add table
Add a link
Reference in a new issue