PgSql update

This commit is contained in:
Pinga 2023-12-13 06:59:56 +02:00
parent f0e3fd8f8c
commit 9db59109f7
15 changed files with 251 additions and 271 deletions

View file

@ -17,7 +17,7 @@ try {
}
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'";
$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->execute();
@ -58,10 +58,10 @@ try {
$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 = $dbh->prepare("UPDATE domain SET exdate = DATE_ADD(exdate, INTERVAL $date_add MONTH), lastupdate = 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 = $dbh->prepare("UPDATE host SET clid = '$reid', upid = NULL, lastupdate = CURRENT_TIMESTAMP, trdate = CURRENT_TIMESTAMP WHERE domain_id = '$domain_id'");
$stmt_update_host->execute();
if ($stmt_update->errorCode() != "00000") {
@ -76,18 +76,18 @@ try {
$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 = $dbh->prepare("SELECT id,registrant,crdate,exdate,lastupdate,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 = $dbh->prepare("INSERT INTO domain_auto_approve_transfer (name,registrant,crdate,exdate,lastupdate,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 = $dbh->prepare("SELECT id, crid, crdate, upid, lastupdate, 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)) {
@ -95,18 +95,18 @@ try {
$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 = $dbh->prepare("UPDATE contact SET lastupdate = 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 = $dbh->prepare("SELECT identifier, crid, crdate, upid, lastupdate, 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 = $dbh->prepare("INSERT INTO contact_auto_approve_transfer (identifier, crid, crdate, upid, lastupdate, trdate, trstatus, reid, redate, acid, acdate) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
$stmt_auto_approve_transfer->execute(array_values($contact_selected_data));
}
}

View file

@ -285,7 +285,7 @@ try {
$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']);
$upDate = DateTime::createFromFormat('Y-m-d H:i:s.v', $contact['lastupdate']);
$xml->writeElement('rdeContact:upDate', $upDate->format("Y-m-d\\TH:i:s.v\\Z"));
}
$xml->endElement(); // Closing rdeContact:contact

View file

@ -876,7 +876,7 @@ class ContactsController extends Controller
'nin' => $nin ?? null,
'nin_type' => $nin_type ?? null,
'upid' => $clid,
'update' => $update,
'lastupdate' => $update,
'disclose_voice' => $disclose_voice,
'disclose_fax' => $disclose_fax,
'disclose_email' => $disclose_email

View file

@ -387,7 +387,7 @@ class DomainsController extends Controller
'registrant' => $registrant_id,
'crdate' => $crdate,
'exdate' => $exdate,
'update' => null,
'lastupdate' => null,
'clid' => $clid,
'crid' => $clid,
'upid' => null,
@ -759,7 +759,7 @@ class DomainsController extends Controller
$uri = $request->getUri()->getPath();
if ($args) {
$domain = $db->selectRow('SELECT id, name, registrant, crdate, exdate, `update`, clid, idnlang, rgpstatus FROM domain WHERE name = ?',
$domain = $db->selectRow('SELECT id, name, registrant, crdate, exdate, lastupdate, clid, idnlang, rgpstatus FROM domain WHERE name = ?',
[ $args ]);
if ($domain) {
@ -837,7 +837,7 @@ class DomainsController extends Controller
$uri = $request->getUri()->getPath();
if ($args) {
$domain = $db->selectRow('SELECT id, name, registrant, crdate, exdate, `update`, clid, idnlang, rgpstatus FROM domain WHERE name = ?',
$domain = $db->selectRow('SELECT id, name, registrant, crdate, exdate, lastupdate, clid, idnlang, rgpstatus FROM domain WHERE name = ?',
[ $args ]);
if ($domain) {
@ -1053,7 +1053,7 @@ class DomainsController extends Controller
$db->update('domain', [
'registrant' => $registrant_id,
'update' => $update,
'lastupdate' => $update,
'upid' => $clid
],
[
@ -1466,7 +1466,7 @@ class DomainsController extends Controller
$uri = $request->getUri()->getPath();
if ($args) {
$domain = $db->selectRow('SELECT id, name, registrant, crdate, exdate, `update`, clid, idnlang, rgpstatus FROM domain WHERE name = ?',
$domain = $db->selectRow('SELECT id, name, registrant, crdate, exdate, lastupdate, clid, idnlang, rgpstatus FROM domain WHERE name = ?',
[ $args ]);
if ($domain) {
@ -1968,13 +1968,13 @@ class DomainsController extends Controller
return $response->withHeader('Location', '/transfer/request')->withStatus(302);
}
$domain = $db->selectRow('SELECT id, registrant, crdate, exdate, clid, crid, upid, trdate, trstatus, reid, redate, acid, acdate FROM domain WHERE name = ? LIMIT 1',
$domain = $db->selectRow('SELECT id, registrant, crdate, exdate, lastupdate, clid, crid, upid, trdate, trstatus, reid, redate, acid, acdate FROM domain WHERE name = ? LIMIT 1',
[ $domainName ]);
$registrant = $domain['registrant'];
$crdate = $domain['crdate'];
$exdate = $domain['exdate'];
$update = $domain['update'];
$update = $domain['lastupdate'];
$crid = $domain['crid'];
$upid = $domain['upid'];
$trdate = $domain['trdate'];
@ -2242,12 +2242,12 @@ class DomainsController extends Controller
$from = $row['exdate'];
$db->exec(
'UPDATE domain SET exdate = DATE_ADD(exdate, INTERVAL ? MONTH), `update` = CURRENT_TIMESTAMP(3), clid = ?, upid = ?, trdate = CURRENT_TIMESTAMP(3), trstatus = ?, acdate = CURRENT_TIMESTAMP(3), transfer_exdate = NULL, rgpstatus = ?, transferPeriod = ? WHERE id = ?',
'UPDATE domain SET exdate = DATE_ADD(exdate, INTERVAL ? MONTH), lastupdate = CURRENT_TIMESTAMP(3), clid = ?, upid = ?, trdate = CURRENT_TIMESTAMP(3), trstatus = ?, acdate = CURRENT_TIMESTAMP(3), transfer_exdate = NULL, rgpstatus = ?, transferPeriod = ? WHERE id = ?',
[$date_add, $reid, $clid, 'clientApproved', 'transferPeriod', $date_add, $domain_id]
);
$db->exec(
'UPDATE host SET clid = ?, upid = ?, `update` = CURRENT_TIMESTAMP(3), trdate = CURRENT_TIMESTAMP(3) WHERE domain_id = ?',
'UPDATE host SET clid = ?, upid = ?, lastupdate = CURRENT_TIMESTAMP(3), trdate = CURRENT_TIMESTAMP(3) WHERE domain_id = ?',
[$reid, $clid, $domain_id]
);
@ -2451,7 +2451,7 @@ class DomainsController extends Controller
);
$temp_id_status = $db->selectValue(
'SELECT COUNT(id) AS ids FROM domain_status WHERE status = ? AND `domain_id` = ? LIMIT 1',
'SELECT COUNT(id) AS ids FROM domain_status WHERE status = ? AND domain_id = ? LIMIT 1',
['pendingDelete', $domain_id]
);
@ -2472,7 +2472,7 @@ class DomainsController extends Controller
$db->update('domain', [
'rgpstatus' => 'pendingRestore',
'resTime' => $date,
'update' => $date
'lastupdate' => $date
],
[
'id' => $domain_id
@ -2554,7 +2554,7 @@ class DomainsController extends Controller
$db->beginTransaction();
$db->exec(
'UPDATE domain SET exdate = DATE_ADD(exdate, INTERVAL 12 MONTH), rgpstatus = NULL, rgpresTime = CURRENT_TIMESTAMP(3), `update` = CURRENT_TIMESTAMP(3) WHERE name = ?',
'UPDATE domain SET exdate = DATE_ADD(exdate, INTERVAL 12 MONTH), rgpstatus = NULL, rgpresTime = CURRENT_TIMESTAMP(3), lastupdate = CURRENT_TIMESTAMP(3) WHERE name = ?',
[
$domainName
]

View file

@ -513,7 +513,7 @@ class HostsController extends Controller
$update = $currentDateTime->format('Y-m-d H:i:s.v'); // Current timestamp
$db->update('host', [
'update' => $update,
'lastupdate' => $update,
'upid' => $clid
],
[

View file

@ -141,7 +141,7 @@ class RegistrarsController extends Controller
'thresholdType' => $data['thresholdType'],
'currency' => $currency,
'crdate' => $crdate,
'update' => $crdate
'lastupdate' => $crdate
]
);
$registrar_id = $db->getLastInsertId();
@ -518,7 +518,7 @@ class RegistrarsController extends Controller
'creditLimit' => $data['creditLimit'],
'creditThreshold' => $data['creditThreshold'],
'currency' => $currency,
'update' => $crdate
'lastupdate' => $crdate
];
if (!empty($data['eppPassword'])) {

View file

@ -82,7 +82,7 @@ CREATE TABLE IF NOT EXISTS `registry`.`registrar` (
`thresholdType` enum('fixed','percent') NOT NULL default 'fixed',
`currency` varchar(5) NOT NULL default 'USD',
`crdate` datetime(3) NOT NULL,
`update` TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP,
`lastupdate` TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `clid` (`clid`),
UNIQUE KEY `prefix` (`prefix`),
@ -205,7 +205,7 @@ CREATE TABLE IF NOT EXISTS `registry`.`contact` (
`crid` int(10) unsigned NOT NULL,
`crdate` datetime(3) NOT NULL,
`upid` int(10) unsigned default NULL,
`update` datetime(3) default NULL,
`lastupdate` datetime(3) default NULL,
`trdate` datetime(3) default NULL,
`trstatus` enum('clientApproved','clientCancelled','clientRejected','pending','serverApproved','serverCancelled') default NULL,
`reid` int(10) unsigned default NULL,
@ -272,7 +272,7 @@ CREATE TABLE IF NOT EXISTS `registry`.`domain` (
`registrant` int(10) unsigned default NULL,
`crdate` datetime(3) NOT NULL,
`exdate` datetime(3) NOT NULL,
`update` datetime(3) default NULL,
`lastupdate` datetime(3) default NULL,
`clid` int(10) unsigned NOT NULL,
`crid` int(10) unsigned NOT NULL,
`upid` int(10) unsigned default NULL,
@ -371,7 +371,7 @@ CREATE TABLE IF NOT EXISTS `registry`.`host` (
`crid` int(10) unsigned NOT NULL,
`crdate` datetime(3) NOT NULL,
`upid` int(10) unsigned default NULL,
`update` datetime(3) default NULL,
`lastupdate` datetime(3) default NULL,
`trdate` datetime(3) default NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`),
@ -416,7 +416,7 @@ CREATE TABLE IF NOT EXISTS `registry`.`domain_auto_approve_transfer` (
`registrant` int(10) unsigned default NULL,
`crdate` datetime(3) NOT NULL,
`exdate` datetime(3) NOT NULL,
`update` datetime(3) default NULL,
`lastupdate` datetime(3) default NULL,
`clid` int(10) unsigned NOT NULL,
`crid` int(10) unsigned NOT NULL,
`upid` int(10) unsigned default NULL,
@ -444,7 +444,7 @@ CREATE TABLE IF NOT EXISTS `registry`.`contact_auto_approve_transfer` (
`crid` int(10) unsigned NOT NULL,
`crdate` datetime(3) NOT NULL,
`upid` int(10) unsigned default NULL,
`update` datetime(3) default NULL,
`lastupdate` datetime(3) default NULL,
`trdate` datetime(3) default NULL,
`trstatus` enum('clientApproved','clientCancelled','clientRejected','pending','serverApproved','serverCancelled') default NULL,
`reid` int(10) unsigned default NULL,
@ -672,8 +672,8 @@ INSERT INTO `registry`.`domain_price` VALUES('6','2','transfer','0.00','5.00','1
INSERT INTO `registry`.`domain_restore_price` VALUES('1','1','50.00');
INSERT INTO `registry`.`domain_restore_price` VALUES('2','2','50.00');
INSERT INTO `registry`.`registrar` (`name`,`clid`,`pw`,`prefix`,`email`,`whois_server`,`rdap_server`,`url`,`abuse_email`,`abuse_phone`,`accountBalance`,`creditLimit`,`creditThreshold`,`thresholdType`,`crdate`,`update`) VALUES('LeoNet LLC','leonet','$argon2id$v=19$m=131072,t=6,p=4$M0ViOHhzTWFtQW5YSGZ2MA$g2pKb+PEYtfs4QwLmf2iUtPM4+7evuqYQFp6yqGZmQg','LN','info@leonet.test','whois.leonet.test','rdap.leonet.test','https://www.leonet.test','abuse@leonet.test','+380.325050','100000.00','100000.00','500.00','fixed',CURRENT_TIMESTAMP,CURRENT_TIMESTAMP);
INSERT INTO `registry`.`registrar` (`name`,`clid`,`pw`,`prefix`,`email`,`whois_server`,`rdap_server`,`url`,`abuse_email`,`abuse_phone`,`accountBalance`,`creditLimit`,`creditThreshold`,`thresholdType`,`crdate`,`update`) VALUES('Nord Registrar AB','nordregistrar','$argon2id$v=19$m=131072,t=6,p=4$MU9Eei5UMjA0M2cxYjd3bg$2yBHTWVVY4xQlMGhnhol9MRbVyVQg8qkcZ6cpdeID1U','NR','info@nordregistrar.test','whois.nordregistrar.test','rdap.nordregistrar.test','https://www.nordregistrar.test','abuse@nordregistrar.test','+46.80203','100000.00','100000.00','500.00','fixed',CURRENT_TIMESTAMP,CURRENT_TIMESTAMP);
INSERT INTO `registry`.`registrar` (`name`,`clid`,`pw`,`prefix`,`email`,`whois_server`,`rdap_server`,`url`,`abuse_email`,`abuse_phone`,`accountBalance`,`creditLimit`,`creditThreshold`,`thresholdType`,`crdate`,`lastupdate`) VALUES('LeoNet LLC','leonet','$argon2id$v=19$m=131072,t=6,p=4$M0ViOHhzTWFtQW5YSGZ2MA$g2pKb+PEYtfs4QwLmf2iUtPM4+7evuqYQFp6yqGZmQg','LN','info@leonet.test','whois.leonet.test','rdap.leonet.test','https://www.leonet.test','abuse@leonet.test','+380.325050','100000.00','100000.00','500.00','fixed',CURRENT_TIMESTAMP,CURRENT_TIMESTAMP);
INSERT INTO `registry`.`registrar` (`name`,`clid`,`pw`,`prefix`,`email`,`whois_server`,`rdap_server`,`url`,`abuse_email`,`abuse_phone`,`accountBalance`,`creditLimit`,`creditThreshold`,`thresholdType`,`crdate`,`lastupdate`) VALUES('Nord Registrar AB','nordregistrar','$argon2id$v=19$m=131072,t=6,p=4$MU9Eei5UMjA0M2cxYjd3bg$2yBHTWVVY4xQlMGhnhol9MRbVyVQg8qkcZ6cpdeID1U','NR','info@nordregistrar.test','whois.nordregistrar.test','rdap.nordregistrar.test','https://www.nordregistrar.test','abuse@nordregistrar.test','+46.80203','100000.00','100000.00','500.00','fixed',CURRENT_TIMESTAMP,CURRENT_TIMESTAMP);
INSERT INTO `registry`.`ticket_categories` (name, description) VALUES
('Domain Transfer', 'Issues related to domain transfers between registrars'),

View file

@ -81,7 +81,7 @@ CREATE TABLE registry.registrar (
"thresholdtype" varchar CHECK ("thresholdtype" IN ( 'fixed','percent' )) NOT NULL default 'fixed',
"currency" varchar(5) NOT NULL default 'USD',
"crdate" timestamp(3) without time zone NOT NULL,
"update" timestamp(3),
"lastupdate" timestamp(3),
primary key ("id"),
unique ("clid") ,
unique ("prefix") ,
@ -90,7 +90,7 @@ CREATE TABLE registry.registrar (
CREATE OR REPLACE FUNCTION update_registrar() RETURNS trigger AS '
BEGIN
NEW.update := CURRENT_TIMESTAMP;
NEW.lastupdate := CURRENT_TIMESTAMP;
RETURN NEW;
END;
' LANGUAGE 'plpgsql';
@ -210,7 +210,7 @@ CREATE TABLE registry.contact (
"crid" int CHECK ("crid" >= 0) NOT NULL,
"crdate" timestamp(3) without time zone NOT NULL,
"upid" int CHECK ("upid" >= 0) default NULL,
"update" timestamp(3) without time zone default NULL,
"lastupdate" timestamp(3) without time zone default NULL,
"trdate" timestamp(3) without time zone default NULL,
"trstatus" varchar CHECK ("trstatus" IN ( 'clientApproved','clientCancelled','clientRejected','pending','serverApproved','serverCancelled' )) default NULL,
"reid" int CHECK ("reid" >= 0) default NULL,
@ -271,7 +271,7 @@ CREATE TABLE registry.domain (
"registrant" int CHECK ("registrant" >= 0) default NULL,
"crdate" timestamp(3) without time zone NOT NULL,
"exdate" timestamp(3) without time zone NOT NULL,
"update" timestamp(3) without time zone default NULL,
"lastupdate" timestamp(3) without time zone default NULL,
"clid" int CHECK ("clid" >= 0) NOT NULL,
"crid" int CHECK ("crid" >= 0) NOT NULL,
"upid" int CHECK ("upid" >= 0) default NULL,
@ -358,7 +358,7 @@ CREATE TABLE registry.host (
"crid" int CHECK ("crid" >= 0) NOT NULL,
"crdate" timestamp(3) without time zone NOT NULL,
"upid" int CHECK ("upid" >= 0) default NULL,
"update" timestamp(3) without time zone default NULL,
"lastupdate" timestamp(3) without time zone default NULL,
"trdate" timestamp(3) without time zone default NULL,
primary key ("id"),
unique ("name")
@ -395,7 +395,7 @@ CREATE TABLE registry.domain_auto_approve_transfer (
"registrant" int CHECK ("registrant" >= 0) default NULL,
"crdate" timestamp(3) without time zone NOT NULL,
"exdate" timestamp(3) without time zone NOT NULL,
"update" timestamp(3) without time zone default NULL,
"lastupdate" timestamp(3) without time zone default NULL,
"clid" int CHECK ("clid" >= 0) NOT NULL,
"crid" int CHECK ("crid" >= 0) NOT NULL,
"upid" int CHECK ("upid" >= 0) default NULL,
@ -423,7 +423,7 @@ CREATE TABLE registry.contact_auto_approve_transfer (
"crid" int CHECK ("crid" >= 0) NOT NULL,
"crdate" timestamp(3) without time zone NOT NULL,
"upid" int CHECK ("upid" >= 0) default NULL,
"update" timestamp(3) without time zone default NULL,
"lastupdate" timestamp(3) without time zone default NULL,
"trdate" timestamp(3) without time zone default NULL,
"trstatus" varchar CHECK ("trstatus" IN ( 'clientApproved','clientCancelled','clientRejected','pending','serverApproved','serverCancelled' )) default NULL,
"reid" int CHECK ("reid" >= 0) default NULL,
@ -649,8 +649,8 @@ INSERT INTO registry.domain_price VALUES (E'6',E'2',E'transfer',E'0.00',E'5.00',
INSERT INTO registry.domain_restore_price VALUES (E'1',E'1',E'50.00');
INSERT INTO registry.domain_restore_price VALUES (E'2',E'2',E'50.00');
INSERT INTO registry.registrar ("name", "clid", "pw", "prefix", "email", "whois_server", "rdap_server", "url", "abuse_email", "abuse_phone", "accountbalance", "creditlimit", "creditthreshold", "thresholdtype", "crdate", "update") VALUES (E'LeoNet LLC',E'leonet',E'$argon2id$v=19$m=131072,t=6,p=4$M0ViOHhzTWFtQW5YSGZ2MA$g2pKb+PEYtfs4QwLmf2iUtPM4+7evuqYQFp6yqGZmQg',E'LN',E'info@leonet.test',E'whois.leonet.test',E'rdap.leonet.test',E'https://www.leonet.test',E'abuse@leonet.test',E'+380.325050',E'100000.00',E'100000.00',E'500.00',E'fixed',CURRENT_TIMESTAMP,CURRENT_TIMESTAMP);
INSERT INTO registry.registrar ("name", "clid", "pw", "prefix", "email", "whois_server", "rdap_server", "url", "abuse_email", "abuse_phone", "accountbalance", "creditlimit", "creditthreshold", "thresholdtype", "crdate", "update") VALUES (E'Nord Registrar AB',E'nordregistrar',E'$argon2id$v=19$m=131072,t=6,p=4$MU9Eei5UMjA0M2cxYjd3bg$2yBHTWVVY4xQlMGhnhol9MRbVyVQg8qkcZ6cpdeID1U',E'NR',E'info@nordregistrar.test',E'whois.nordregistrar.test',E'rdap.nordregistrar.test',E'https://www.nordregistrar.test',E'abuse@nordregistrar.test',E'+46.80203',E'100000.00',E'100000.00',E'500.00',E'fixed',CURRENT_TIMESTAMP,CURRENT_TIMESTAMP);
INSERT INTO registry.registrar ("name", "clid", "pw", "prefix", "email", "whois_server", "rdap_server", "url", "abuse_email", "abuse_phone", "accountbalance", "creditlimit", "creditthreshold", "thresholdtype", "crdate", "lastupdate") VALUES (E'LeoNet LLC',E'leonet',E'$argon2id$v=19$m=131072,t=6,p=4$M0ViOHhzTWFtQW5YSGZ2MA$g2pKb+PEYtfs4QwLmf2iUtPM4+7evuqYQFp6yqGZmQg',E'LN',E'info@leonet.test',E'whois.leonet.test',E'rdap.leonet.test',E'https://www.leonet.test',E'abuse@leonet.test',E'+380.325050',E'100000.00',E'100000.00',E'500.00',E'fixed',CURRENT_TIMESTAMP,CURRENT_TIMESTAMP);
INSERT INTO registry.registrar ("name", "clid", "pw", "prefix", "email", "whois_server", "rdap_server", "url", "abuse_email", "abuse_phone", "accountbalance", "creditlimit", "creditthreshold", "thresholdtype", "crdate", "lastupdate") VALUES (E'Nord Registrar AB',E'nordregistrar',E'$argon2id$v=19$m=131072,t=6,p=4$MU9Eei5UMjA0M2cxYjd3bg$2yBHTWVVY4xQlMGhnhol9MRbVyVQg8qkcZ6cpdeID1U',E'NR',E'info@nordregistrar.test',E'whois.nordregistrar.test',E'rdap.nordregistrar.test',E'https://www.nordregistrar.test',E'abuse@nordregistrar.test',E'+46.80203',E'100000.00',E'100000.00',E'500.00',E'fixed',CURRENT_TIMESTAMP,CURRENT_TIMESTAMP);
INSERT INTO registry.ticket_categories (name, description) VALUES
('Domain Transfer', 'Issues related to domain transfers between registrars'),

View file

@ -321,11 +321,7 @@ function processContactCreate($conn, $db, $xml, $clid, $database_type, $trans) {
}
try {
if ($database_type === 'mysql') {
$stmt = $db->prepare("INSERT INTO contact (identifier,voice,voice_x,fax,fax_x,email,nin,nin_type,clid,crid,crdate,upid,`update`,trdate,trstatus,reid,redate,acid,acdate,disclose_voice,disclose_fax,disclose_email) VALUES(?,?,?,?,?,?,?,?,?,?,CURRENT_TIMESTAMP(3),NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,?,?,?)");
} elseif ($database_type === 'pgsql') {
$stmt = $db->prepare("INSERT INTO \"contact\" (\"identifier\",\"voice\",\"voice_x\",\"fax\",\"fax_x\",\"email\",\"nin\",\"nin_type\",\"clid\",\"crid\",\"crdate\",\"upid\",\"update\",\"trdate\",\"trstatus\",\"reid\",\"redate\",\"acid\",\"acdate\",\"disclose_voice\",\"disclose_fax\",\"disclose_email\") VALUES(?,?,?,?,?,?,?,?,?,?,CURRENT_TIMESTAMP(3),NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,?,?,?)");
}
$stmt = $db->prepare("INSERT INTO contact (identifier,voice,voice_x,fax,fax_x,email,nin,nin_type,clid,crid,crdate,upid,lastupdate,trdate,trstatus,reid,redate,acid,acdate,disclose_voice,disclose_fax,disclose_email) VALUES(?,?,?,?,?,?,?,?,?,?,CURRENT_TIMESTAMP(3),NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,?,?,?)");
$stmt->execute([
$contactID,
@ -660,7 +656,7 @@ function processDomainCreate($conn, $db, $xml, $clid, $database_type, $trans) {
$clid = $stmt->fetch(PDO::FETCH_ASSOC);
$clid = $clid['id'];
$stmt = $db->prepare("SELECT `accountBalance`, `creditLimit` FROM `registrar` WHERE `id` = :registrar_id LIMIT 1");
$stmt = $db->prepare("SELECT accountBalance, creditLimit FROM registrar WHERE id = :registrar_id LIMIT 1");
$stmt->bindParam(':registrar_id', $clid, PDO::PARAM_INT);
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
@ -668,7 +664,7 @@ function processDomainCreate($conn, $db, $xml, $clid, $database_type, $trans) {
$creditLimit = $result['creditLimit'];
$priceColumn = "m" . $date_add;
$stmt = $db->prepare("SELECT `$priceColumn` FROM `domain_price` WHERE `tldid` = :tld_id AND `command` = 'create' LIMIT 1");
$stmt = $db->prepare("SELECT $priceColumn FROM domain_price WHERE tldid = :tld_id AND command = 'create' LIMIT 1");
$stmt->bindParam(':tld_id', $tld_id, PDO::PARAM_INT);
$stmt->execute();
$price = $stmt->fetchColumn();
@ -740,7 +736,7 @@ function processDomainCreate($conn, $db, $xml, $clid, $database_type, $trans) {
if (preg_match("/^([A-Z0-9]([A-Z0-9-]{0,61}[A-Z0-9]){0,1}\.){1,125}[A-Z0-9]([A-Z0-9-]{0,61}[A-Z0-9])$/", $hostObj) && strlen($hostObj) < 254) {
// A host object MUST be known to the server before the host object can be associated with a domain object.
$stmt = $db->prepare("SELECT `id` FROM `host` WHERE `name` = :hostObj LIMIT 1");
$stmt = $db->prepare("SELECT id FROM host WHERE name = :hostObj LIMIT 1");
$stmt->bindParam(':hostObj', $hostObj);
$stmt->execute();
@ -768,7 +764,7 @@ function processDomainCreate($conn, $db, $xml, $clid, $database_type, $trans) {
// Check if the host is internal or external
$internal_host = false;
$stmt = $db->prepare("SELECT `tld` FROM `domain_tld`");
$stmt = $db->prepare("SELECT tld FROM domain_tld");
$stmt->execute();
while ($tld = $stmt->fetchColumn()) {
$tld = strtoupper($tld);
@ -846,7 +842,7 @@ function processDomainCreate($conn, $db, $xml, $clid, $database_type, $trans) {
$clid_domain = 0;
// Prepare statement
$stmt = $db->prepare("SELECT `clid`, `name` FROM `domain`");
$stmt = $db->prepare("SELECT clid, name FROM domain");
$stmt->execute();
// Fetch results
@ -959,7 +955,7 @@ function processDomainCreate($conn, $db, $xml, $clid, $database_type, $trans) {
if ($registrant) {
$validRegistrant = validate_identifier($registrant_id);
$stmt = $db->prepare("SELECT `id`, `clid` FROM `contact` WHERE `identifier` = :registrant LIMIT 1");
$stmt = $db->prepare("SELECT id, clid FROM contact WHERE identifier = :registrant LIMIT 1");
$stmt->bindParam(':registrant', $registrant_id);
$stmt->execute();
@ -990,7 +986,7 @@ function processDomainCreate($conn, $db, $xml, $clid, $database_type, $trans) {
$contactValue = (string)$node;
$validContact = validate_identifier($contactValue);
$stmt = $db->prepare("SELECT `id`, `clid` FROM `contact` WHERE `identifier` = :contact LIMIT 1");
$stmt = $db->prepare("SELECT id, clid FROM contact WHERE identifier = :contact LIMIT 1");
$stmt->bindParam(':contact', $contactValue);
$stmt->execute();
@ -1029,14 +1025,14 @@ function processDomainCreate($conn, $db, $xml, $clid, $database_type, $trans) {
return;
}
$registrantStmt = $db->prepare("SELECT `id` FROM `contact` WHERE `identifier` = :registrant LIMIT 1");
$registrantStmt = $db->prepare("SELECT id FROM contact WHERE identifier = :registrant LIMIT 1");
$registrantStmt->execute([':registrant' => $registrant_id]);
$registrant_id = $registrantStmt->fetchColumn();
try {
$db->beginTransaction();
$domainSql = "INSERT INTO `domain` (`name`,`tldid`,`registrant`,`crdate`,`exdate`,`update`,`clid`,`crid`,`upid`,`trdate`,`trstatus`,`reid`,`redate`,`acid`,`acdate`,`rgpstatus`,`addPeriod`)
$domainSql = "INSERT INTO domain (name,tldid,registrant,crdate,exdate,lastupdate,clid,crid,upid,trdate,trstatus,reid,redate,acid,acdate,rgpstatus,addPeriod)
VALUES(:name, :tld_id, :registrant_id, CURRENT_TIMESTAMP(3), DATE_ADD(CURRENT_TIMESTAMP(3), INTERVAL :date_add MONTH), NULL, :registrar_id, :registrar_id, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'addPeriod', :date_add2)";
$domainStmt = $db->prepare($domainSql);
@ -1050,7 +1046,7 @@ function processDomainCreate($conn, $db, $xml, $clid, $database_type, $trans) {
]);
$domain_id = $db->lastInsertId();
$authInfoStmt = $db->prepare("INSERT INTO `domain_authInfo` (`domain_id`,`authtype`,`authinfo`) VALUES(:domain_id,'pw',:authInfo_pw)");
$authInfoStmt = $db->prepare("INSERT INTO domain_authInfo (domain_id,authtype,authinfo) VALUES(:domain_id,'pw',:authInfo_pw)");
$authInfoStmt->execute([
':domain_id' => $domain_id,
':authInfo_pw' => $authInfo_pw
@ -1143,7 +1139,7 @@ function processDomainCreate($conn, $db, $xml, $clid, $database_type, $trans) {
}
}
$stmt = $db->prepare("INSERT INTO `secdns` (`domain_id`, `maxsiglife`, `interface`, `keytag`, `alg`, `digesttype`, `digest`, `flags`, `protocol`, `keydata_alg`, `pubkey`) VALUES (:domain_id, :maxsiglife, :interface, :keytag, :alg, :digesttype, :digest, :flags, :protocol, :keydata_alg, :pubkey)");
$stmt = $db->prepare("INSERT INTO secdns (domain_id, maxsiglife, interface, keytag, alg, digesttype, digest, flags, protocol, keydata_alg, pubkey) VALUES (:domain_id, :maxsiglife, :interface, :keytag, :alg, :digesttype, :digest, :flags, :protocol, :keydata_alg, :pubkey)");
$stmt->execute([
':domain_id' => $domain_id,
@ -1161,24 +1157,24 @@ function processDomainCreate($conn, $db, $xml, $clid, $database_type, $trans) {
}
}
$updateRegistrarStmt = $db->prepare("UPDATE `registrar` SET `accountBalance` = (`accountBalance` - :price) WHERE `id` = :registrar_id");
$updateRegistrarStmt = $db->prepare("UPDATE registrar SET accountBalance = (accountBalance - :price) WHERE id = :registrar_id");
$updateRegistrarStmt->execute([
':price' => $price,
':registrar_id' => $clid
]);
$paymentHistoryStmt = $db->prepare("INSERT INTO `payment_history` (`registrar_id`,`date`,`description`,`amount`) VALUES(:registrar_id,CURRENT_TIMESTAMP(3),:description,:amount)");
$paymentHistoryStmt = $db->prepare("INSERT INTO payment_history (registrar_id,date,description,amount) VALUES(:registrar_id,CURRENT_TIMESTAMP(3),:description,:amount)");
$paymentHistoryStmt->execute([
':registrar_id' => $clid,
':description' => "create domain $domainName for period $date_add MONTH",
':amount' => "-$price"
]);
$selectDomainDatesStmt = $db->prepare("SELECT `crdate`,`exdate` FROM `domain` WHERE `name` = :name LIMIT 1");
$selectDomainDatesStmt = $db->prepare("SELECT crdate,exdate FROM domain WHERE name = :name LIMIT 1");
$selectDomainDatesStmt->execute([':name' => $domainName]);
[$from, $to] = $selectDomainDatesStmt->fetch(PDO::FETCH_NUM);
$statementStmt = $db->prepare("INSERT INTO `statement` (`registrar_id`,`date`,`command`,`domain_name`,`length_in_months`,`from`,`to`,`amount`) VALUES(:registrar_id,CURRENT_TIMESTAMP(3),:cmd,:name,:date_add,:from,:to,:price)");
$statementStmt = $db->prepare("INSERT INTO statement (registrar_id,date,command,domain_name,length_in_months,from,to,amount) VALUES(:registrar_id,CURRENT_TIMESTAMP(3),:cmd,:name,:date_add,:from,:to,:price)");
$statementStmt->execute([
':registrar_id' => $clid,
':cmd' => 'create',
@ -1193,25 +1189,25 @@ function processDomainCreate($conn, $db, $xml, $clid, $database_type, $trans) {
foreach ($hostObj_list as $node) {
$hostObj = strtoupper((string)$node);
$hostExistStmt = $db->prepare("SELECT `id` FROM `host` WHERE `name` = :hostObj LIMIT 1");
$hostExistStmt = $db->prepare("SELECT id FROM host WHERE name = :hostObj LIMIT 1");
$hostExistStmt->execute([':hostObj' => $hostObj]);
$hostObj_already_exist = $hostExistStmt->fetchColumn();
if ($hostObj_already_exist) {
$domainHostMapStmt = $db->prepare("SELECT `domain_id` FROM `domain_host_map` WHERE `domain_id` = :domain_id AND `host_id` = :host_id LIMIT 1");
$domainHostMapStmt = $db->prepare("SELECT domain_id FROM domain_host_map WHERE domain_id = :domain_id AND host_id = :host_id LIMIT 1");
$domainHostMapStmt->execute([':domain_id' => $domain_id, ':host_id' => $hostObj_already_exist]);
$domain_host_map_id = $domainHostMapStmt->fetchColumn();
if (!$domain_host_map_id) {
$insertDomainHostMapStmt = $db->prepare("INSERT INTO `domain_host_map` (`domain_id`,`host_id`) VALUES(:domain_id,:host_id)");
$insertDomainHostMapStmt = $db->prepare("INSERT INTO domain_host_map (domain_id,host_id) VALUES(:domain_id,:host_id)");
$insertDomainHostMapStmt->execute([':domain_id' => $domain_id, ':host_id' => $hostObj_already_exist]);
} else {
$errorLogStmt = $db->prepare("INSERT INTO `error_log` (`registrar_id`,`log`,`date`) VALUES(:registrar_id,:log,CURRENT_TIMESTAMP(3))");
$errorLogStmt = $db->prepare("INSERT INTO error_log (registrar_id,log,date) VALUES(:registrar_id,:log,CURRENT_TIMESTAMP(3))");
$errorLogStmt->execute([':registrar_id' => $clid, ':log' => "Domain : $domainName ; hostObj : $hostObj - se dubleaza"]);
}
} else {
$internal_host = false;
$stmt = $db->prepare("SELECT `tld` FROM `domain_tld`");
$stmt = $db->prepare("SELECT tld FROM domain_tld");
$stmt->execute();
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
@ -1226,19 +1222,19 @@ function processDomainCreate($conn, $db, $xml, $clid, $database_type, $trans) {
if ($internal_host) {
if (preg_match("/\.$domainName$/i", $hostObj)) {
$stmt = $db->prepare("INSERT INTO `host` (`name`,`domain_id`,`clid`,`crid`,`crdate`) VALUES(?, ?, ?, ?, CURRENT_TIMESTAMP(3))");
$stmt = $db->prepare("INSERT INTO host (name,domain_id,clid,crid,crdate) VALUES(?, ?, ?, ?, CURRENT_TIMESTAMP(3))");
$stmt->execute([$hostObj, $domain_id, $clid, $clid]);
$host_id = $db->lastInsertId();
$stmt = $db->prepare("INSERT INTO `domain_host_map` (`domain_id`,`host_id`) VALUES(?, ?)");
$stmt = $db->prepare("INSERT INTO domain_host_map (domain_id,host_id) VALUES(?, ?)");
$stmt->execute([$domain_id, $host_id]);
}
} else {
$stmt = $db->prepare("INSERT INTO `host` (`name`,`clid`,`crid`,`crdate`) VALUES(?, ?, ?, CURRENT_TIMESTAMP(3))");
$stmt = $db->prepare("INSERT INTO host (name,clid,crid,crdate) VALUES(?, ?, ?, CURRENT_TIMESTAMP(3))");
$stmt->execute([$hostObj, $clid, $clid]);
$host_id = $db->lastInsertId();
$stmt = $db->prepare("INSERT INTO `domain_host_map` (`domain_id`,`host_id`) VALUES(?, ?)");
$stmt = $db->prepare("INSERT INTO domain_host_map (domain_id,host_id) VALUES(?, ?)");
$stmt->execute([$domain_id, $host_id]);
}
@ -1250,28 +1246,28 @@ function processDomainCreate($conn, $db, $xml, $clid, $database_type, $trans) {
foreach ($hostAttr_list as $element) {
foreach ($element->children() as $node) {
$hostName = strtoupper($node->xpath('//domain:hostName')[0]);
$stmt = $db->prepare("SELECT `id` FROM `host` WHERE `name` = ? LIMIT 1");
$stmt = $db->prepare("SELECT id FROM host WHERE name = ? LIMIT 1");
$stmt->execute([$hostName]);
$hostName_already_exist = $stmt->fetchColumn();
if ($hostName_already_exist) {
$stmt = $db->prepare("SELECT `domain_id` FROM `domain_host_map` WHERE `domain_id` = ? AND `host_id` = ? LIMIT 1");
$stmt = $db->prepare("SELECT domain_id FROM domain_host_map WHERE domain_id = ? AND host_id = ? LIMIT 1");
$stmt->execute([$domain_id, $hostName_already_exist]);
$domain_host_map_id = $stmt->fetchColumn();
if (!$domain_host_map_id) {
$stmt = $db->prepare("INSERT INTO `domain_host_map` (`domain_id`,`host_id`) VALUES(?,?)");
$stmt = $db->prepare("INSERT INTO domain_host_map (domain_id,host_id) VALUES(?,?)");
$stmt->execute([$domain_id, $hostName_already_exist]);
} else {
$stmt = $db->prepare("INSERT INTO `error_log` (`registrar_id`,`log`,`date`) VALUES(?, ?, CURRENT_TIMESTAMP(3))");
$stmt = $db->prepare("INSERT INTO error_log (registrar_id,log,date) VALUES(?, ?, CURRENT_TIMESTAMP(3))");
$stmt->execute([$clid, "Domain : $domainName ; hostName : $hostName - se dubleaza"]);
}
} else {
$stmt = $db->prepare("INSERT INTO `host` (`name`,`domain_id`,`clid`,`crid`,`crdate`) VALUES(?, ?, ?, ?, CURRENT_TIMESTAMP(3))");
$stmt = $db->prepare("INSERT INTO host (name,domain_id,clid,crid,crdate) VALUES(?, ?, ?, ?, CURRENT_TIMESTAMP(3))");
$stmt->execute([$hostName, $domain_id, $clid, $clid]);
$host_id = $db->lastInsertId();
$stmt = $db->prepare("INSERT INTO `domain_host_map` (`domain_id`,`host_id`) VALUES(?,?)");
$stmt = $db->prepare("INSERT INTO domain_host_map (domain_id,host_id) VALUES(?,?)");
$stmt->execute([$domain_id, $host_id]);
foreach ($node->xpath('//domain:hostAddr') as $nodeAddr) {
@ -1284,7 +1280,7 @@ function processDomainCreate($conn, $db, $xml, $clid, $database_type, $trans) {
$hostAddr = normalize_v4_address($hostAddr);
}
$stmt = $db->prepare("INSERT INTO `host_addr` (`host_id`,`addr`,`ip`) VALUES(?,?,?)");
$stmt = $db->prepare("INSERT INTO host_addr (host_id,addr,ip) VALUES(?,?,?)");
$stmt->execute([$host_id, $hostAddr, $addr_type]);
}
}
@ -1305,28 +1301,28 @@ function processDomainCreate($conn, $db, $xml, $clid, $database_type, $trans) {
foreach ($contactTypes as $type => $contact_list) {
foreach ($contact_list as $element) {
$contact = (string)$element;
$stmt = $db->prepare("SELECT `id` FROM `contact` WHERE `identifier` = ? LIMIT 1");
$stmt = $db->prepare("SELECT id FROM contact WHERE identifier = ? LIMIT 1");
$stmt->execute([$contact]);
$contact_id = $stmt->fetchColumn();
$stmt = $db->prepare("INSERT INTO `domain_contact_map` (`domain_id`,`contact_id`,`type`) VALUES(?,?,?)");
$stmt = $db->prepare("INSERT INTO domain_contact_map (domain_id,contact_id,type) VALUES(?,?,?)");
$stmt->execute([$domain_id, $contact_id, $type]);
}
}
$stmt = $db->prepare("SELECT `crdate`,`exdate` FROM `domain` WHERE `name` = ? LIMIT 1");
$stmt = $db->prepare("SELECT crdate,exdate FROM domain WHERE name = ? LIMIT 1");
$stmt->execute([$domainName]);
[$crdate, $exdate] = $stmt->fetch(PDO::FETCH_NUM);
$stmt = $db->prepare("SELECT `id` FROM `statistics` WHERE `date` = CURDATE()");
$stmt = $db->prepare("SELECT id FROM statistics WHERE date = CURDATE()");
$stmt->execute();
$curdate_id = $stmt->fetchColumn();
if (!$curdate_id) {
$stmt = $db->prepare("INSERT IGNORE INTO `statistics` (`date`) VALUES(CURDATE())");
$stmt = $db->prepare("INSERT IGNORE INTO statistics (date) VALUES(CURDATE())");
$stmt->execute();
}
$db->exec("UPDATE `statistics` SET `created_domains` = `created_domains` + 1 WHERE `date` = CURDATE()");
$db->exec("UPDATE statistics SET created_domains = created_domains + 1 WHERE date = CURDATE()");
$db->commit();
} catch (Exception $e) {

View file

@ -227,7 +227,7 @@ function processDomainDelete($conn, $db, $xml, $clid, $database_type, $trans) {
$grace_period = 30;
// DELETE FROM `domain_status`
// DELETE FROM domain_status
$stmt = $db->prepare("DELETE FROM domain_status WHERE domain_id = ?");
$stmt->execute([$domain_id]);

View file

@ -74,7 +74,7 @@ function processContactInfo($conn, $db, $xml, $trans) {
'crID' => getRegistrarClid($db, $contact['crid']),
'crDate' => $contact['crdate'],
'upID' => getRegistrarClid($db, $contact['upid']),
'upDate' => $contact['update'],
'upDate' => $contact['lastupdate'],
'authInfo' => 'valid',
'authInfo_type' => $authInfo['authtype'],
'authInfo_val' => $authInfo['authinfo']
@ -155,7 +155,7 @@ function processHostInfo($conn, $db, $xml, $trans) {
'crID' => getRegistrarClid($db, $host['crid']),
'crDate' => $host['crdate'],
'upID' => getRegistrarClid($db, $host['upid']),
'upDate' => $host['update'],
'upDate' => $host['lastupdate'],
'trDate' => $host['trdate']
];
@ -299,8 +299,8 @@ function processDomainInfo($conn, $db, $xml, $trans) {
if (isset($domain['upid']) && $domain['upid']) {
$response['upID'] = getRegistrarClid($db, $domain['upid']);
}
if (isset($domain['update']) && $domain['update']) {
$response['upDate'] = $domain['update'];
if (isset($domain['lastupdate']) && $domain['lastupdate']) {
$response['upDate'] = $domain['lastupdate'];
}
if (isset($domain['trdate']) && $domain['trdate']) {
$response['trDate'] = $domain['trdate'];

View file

@ -158,7 +158,7 @@ function processDomainRenew($conn, $db, $xml, $clid, $database_type, $trans) {
$stmt->bindParam(':amount', $negative_price, PDO::PARAM_INT);
$stmt->execute();
// Fetch `exdate`:
// Fetch exdate:
$stmt = $db->prepare("SELECT exdate FROM domain WHERE id = :domain_id LIMIT 1");
$stmt->bindParam(':domain_id', $domainData['id'], PDO::PARAM_INT);
$stmt->execute();
@ -166,7 +166,7 @@ function processDomainRenew($conn, $db, $xml, $clid, $database_type, $trans) {
// Insert into statement:
if ($database_type === "mysql") {
$stmt = $db->prepare("INSERT INTO statement (registrar_id, date, command, domain_name, length_in_months, `from`, `to`, amount) VALUES (?, CURRENT_TIMESTAMP(3), ?, ?, ?, ?, ?, ?)");
$stmt = $db->prepare("INSERT INTO statement (registrar_id, date, command, domain_name, length_in_months, from, to, amount) VALUES (?, CURRENT_TIMESTAMP(3), ?, ?, ?, ?, ?, ?)");
} elseif ($database_type === "pgsql") {
$stmt = $db->prepare('INSERT INTO statement (registrar_id, date, command, domain_name, length_in_months, "from", "to", amount) VALUES (?, CURRENT_TIMESTAMP(3), ?, ?, ?, ?, ?, ?)');
} else {
@ -182,7 +182,7 @@ function processDomainRenew($conn, $db, $xml, $clid, $database_type, $trans) {
$stmt->execute();
$exdateUpdated = $stmt->fetchColumn();
// Check for an existing entry in `statistics` for the current date
// Check for an existing entry in statistics for the current date
$stmt = $db->prepare("SELECT id FROM statistics WHERE date = CURDATE()");
$stmt->execute();
$curdate_id = $stmt->fetchColumn();
@ -193,7 +193,7 @@ function processDomainRenew($conn, $db, $xml, $clid, $database_type, $trans) {
$stmt->execute();
}
// Update the `renewed_domains` count for the current date
// Update the renewed_domains count for the current date
$stmt = $db->prepare("UPDATE statistics SET renewed_domains = renewed_domains + 1 WHERE date = CURDATE()");
$stmt->execute();

View file

@ -17,7 +17,7 @@ function processContactTranfer($conn, $db, $xml, $clid, $database_type, $trans)
}
$identifier = strtoupper($contactID);
$stmt = $db->prepare("SELECT `id`, `clid` FROM `contact` WHERE `identifier` = :identifier LIMIT 1");
$stmt = $db->prepare("SELECT id, clid FROM contact WHERE identifier = :identifier LIMIT 1");
$stmt->execute([':identifier' => $identifier]);
$result = $stmt->fetch(PDO::FETCH_ASSOC);
$contact_id = $result['id'] ?? null;
@ -41,7 +41,7 @@ function processContactTranfer($conn, $db, $xml, $clid, $database_type, $trans)
}
if ($authInfo_pw) {
$stmt = $db->prepare("SELECT `id` FROM `contact_authInfo` WHERE `contact_id` = :contact_id AND `authtype` = 'pw' AND `authinfo` = :authInfo_pw LIMIT 1");
$stmt = $db->prepare("SELECT id FROM contact_authInfo WHERE contact_id = :contact_id AND authtype = 'pw' AND authinfo = :authInfo_pw LIMIT 1");
$stmt->execute([
':contact_id' => $contact_id,
':authInfo_pw' => $authInfo_pw
@ -54,13 +54,13 @@ function processContactTranfer($conn, $db, $xml, $clid, $database_type, $trans)
}
}
$stmt = $db->prepare("SELECT `crid`, `crdate`, `upid`, `update`, `trdate`, `trstatus`, `reid`, `redate`, `acid`, `acdate` FROM `contact` WHERE `id` = :contact_id LIMIT 1");
$stmt = $db->prepare("SELECT crid, crdate, upid, lastupdate, trdate, trstatus, reid, redate, acid, acdate FROM contact WHERE id = :contact_id LIMIT 1");
$stmt->execute([':contact_id' => $contact_id]);
$contactInfo = $stmt->fetch(PDO::FETCH_ASSOC);
$trstatus = $contactInfo['trstatus'] ?? '';
if ($trstatus === 'pending') {
$stmt = $db->prepare("UPDATE `contact` SET `update` = CURRENT_TIMESTAMP(3), `clid` = :reid, `upid` = :upid, `trdate` = CURRENT_TIMESTAMP(3), `trstatus` = 'clientApproved', `acdate` = CURRENT_TIMESTAMP(3) WHERE `id` = :contact_id");
$stmt = $db->prepare("UPDATE contact SET lastupdate = CURRENT_TIMESTAMP(3), clid = :reid, upid = :upid, trdate = CURRENT_TIMESTAMP(3), trstatus = 'clientApproved', acdate = CURRENT_TIMESTAMP(3) WHERE id = :contact_id");
$stmt->execute([
':reid' => $contactInfo['reid'],
':upid' => $clid,
@ -74,11 +74,11 @@ function processContactTranfer($conn, $db, $xml, $clid, $database_type, $trans)
$stmt->execute([':contact_id' => $contact_id]);
$updatedContactInfo = $stmt->fetch(PDO::FETCH_ASSOC);
$reid_identifier_stmt = $db->prepare("SELECT `clid` FROM `registrar` WHERE `id` = :reid LIMIT 1");
$reid_identifier_stmt = $db->prepare("SELECT clid FROM registrar WHERE id = :reid LIMIT 1");
$reid_identifier_stmt->execute([':reid' => $updatedContactInfo['reid']]);
$reid_identifier = $reid_identifier_stmt->fetchColumn();
$acid_identifier_stmt = $db->prepare("SELECT `clid` FROM `registrar` WHERE `id` = :acid LIMIT 1");
$acid_identifier_stmt = $db->prepare("SELECT clid FROM registrar WHERE id = :acid LIMIT 1");
$acid_identifier_stmt->execute([':acid' => $updatedContactInfo['acid']]);
$acid_identifier = $acid_identifier_stmt->fetchColumn();
@ -116,7 +116,7 @@ function processContactTranfer($conn, $db, $xml, $clid, $database_type, $trans)
// A <contact:authInfo> element that contains authorization information associated with the contact object.
if ($authInfo_pw) {
$stmt = $db->prepare("SELECT `id` FROM `contact_authInfo` WHERE `contact_id` = :contact_id AND `authtype` = 'pw' AND `authinfo` = :authInfo_pw LIMIT 1");
$stmt = $db->prepare("SELECT id FROM contact_authInfo WHERE contact_id = :contact_id AND authtype = 'pw' AND authinfo = :authInfo_pw LIMIT 1");
$stmt->execute([':contact_id' => $contact_id, ':authInfo_pw' => $authInfo_pw]);
$contact_authinfo_id = $stmt->fetchColumn();
if (!$contact_authinfo_id) {
@ -125,13 +125,13 @@ function processContactTranfer($conn, $db, $xml, $clid, $database_type, $trans)
}
}
$stmt = $db->prepare("SELECT `crid`, `crdate`, `upid`, `update`, `trdate`, `trstatus`, `reid`, `redate`, `acid`, `acdate` FROM `contact` WHERE `id` = :contact_id LIMIT 1");
$stmt = $db->prepare("SELECT crid, crdate, upid, lastupdate, trdate, trstatus, reid, redate, acid, acdate FROM contact WHERE id = :contact_id LIMIT 1");
$stmt->execute([':contact_id' => $contact_id]);
$contactInfo = $stmt->fetch(PDO::FETCH_ASSOC);
$trstatus = $contactInfo['trstatus'] ?? '';
if ($trstatus === 'pending') {
$stmt = $db->prepare("UPDATE `contact` SET `trstatus` = 'clientCancelled' WHERE `id` = :contact_id");
$stmt = $db->prepare("UPDATE contact SET trstatus = 'clientCancelled' WHERE id = :contact_id");
$stmt->execute([':contact_id' => $contact_id]);
if ($stmt->errorCode() != 0) {
@ -141,11 +141,11 @@ function processContactTranfer($conn, $db, $xml, $clid, $database_type, $trans)
$stmt->execute([':contact_id' => $contact_id]);
$updatedContactInfo = $stmt->fetch(PDO::FETCH_ASSOC);
$reid_identifier_stmt = $db->prepare("SELECT `clid` FROM `registrar` WHERE `id` = :reid LIMIT 1");
$reid_identifier_stmt = $db->prepare("SELECT clid FROM registrar WHERE id = :reid LIMIT 1");
$reid_identifier_stmt->execute([':reid' => $updatedContactInfo['reid']]);
$reid_identifier = $reid_identifier_stmt->fetchColumn();
$acid_identifier_stmt = $db->prepare("SELECT `clid` FROM `registrar` WHERE `id` = :acid LIMIT 1");
$acid_identifier_stmt = $db->prepare("SELECT clid FROM registrar WHERE id = :acid LIMIT 1");
$acid_identifier_stmt->execute([':acid' => $updatedContactInfo['acid']]);
$acid_identifier = $acid_identifier_stmt->fetchColumn();
@ -175,17 +175,17 @@ function processContactTranfer($conn, $db, $xml, $clid, $database_type, $trans)
return;
}
} elseif ($op === 'query') {
$stmt = $db->prepare("SELECT `crid`, `crdate`, `upid`, `update`, `trdate`, `trstatus`, `reid`, `redate`, `acid`, `acdate` FROM `contact` WHERE `id` = :contact_id LIMIT 1");
$stmt = $db->prepare("SELECT crid, crdate, upid, lastupdate, trdate, trstatus, reid, redate, acid, acdate FROM contact WHERE id = :contact_id LIMIT 1");
$stmt->execute([':contact_id' => $contact_id]);
$contactInfo = $stmt->fetch(PDO::FETCH_ASSOC);
$trstatus = $contactInfo['trstatus'] ?? '';
if ($trstatus === 'pending') {
$reid_identifier_stmt = $db->prepare("SELECT `clid` FROM `registrar` WHERE `id` = :reid LIMIT 1");
$reid_identifier_stmt = $db->prepare("SELECT clid FROM registrar WHERE id = :reid LIMIT 1");
$reid_identifier_stmt->execute([':reid' => $contactInfo['reid']]);
$reid_identifier = $reid_identifier_stmt->fetchColumn();
$acid_identifier_stmt = $db->prepare("SELECT `clid` FROM `registrar` WHERE `id` = :acid LIMIT 1");
$acid_identifier_stmt = $db->prepare("SELECT clid FROM registrar WHERE id = :acid LIMIT 1");
$acid_identifier_stmt->execute([':acid' => $contactInfo['acid']]);
$acid_identifier = $acid_identifier_stmt->fetchColumn();
@ -222,7 +222,7 @@ function processContactTranfer($conn, $db, $xml, $clid, $database_type, $trans)
// A <contact:authInfo> element that contains authorization information associated with the contact object.
if ($authInfo_pw) {
$stmt = $db->prepare("SELECT `id` FROM `contact_authInfo` WHERE `contact_id` = :contact_id AND `authtype` = 'pw' AND `authinfo` = :authInfo_pw LIMIT 1");
$stmt = $db->prepare("SELECT id FROM contact_authInfo WHERE contact_id = :contact_id AND authtype = 'pw' AND authinfo = :authInfo_pw LIMIT 1");
$stmt->execute([':contact_id' => $contact_id, ':authInfo_pw' => $authInfo_pw]);
$contact_authinfo_id = $stmt->fetchColumn();
@ -232,29 +232,29 @@ function processContactTranfer($conn, $db, $xml, $clid, $database_type, $trans)
}
}
$stmt = $db->prepare("SELECT `crid`, `crdate`, `upid`, `update`, `trdate`, `trstatus`, `reid`, `redate`, `acid`, `acdate` FROM `contact` WHERE `id` = :contact_id LIMIT 1");
$stmt = $db->prepare("SELECT crid, crdate, upid, lastupdate, trdate, trstatus, reid, redate, acid, acdate FROM contact WHERE id = :contact_id LIMIT 1");
$stmt->execute([':contact_id' => $contact_id]);
$contactInfo = $stmt->fetch(PDO::FETCH_ASSOC);
if ($contactInfo['trstatus'] === 'pending') {
// The losing registrar has five days once the contact is pending to respond.
$updateStmt = $db->prepare("UPDATE `contact` SET `trstatus` = 'clientRejected' WHERE `id` = :contact_id");
$updateStmt = $db->prepare("UPDATE contact SET trstatus = 'clientRejected' WHERE id = :contact_id");
$updateStmt->execute([':contact_id' => $contact_id]);
if ($updateStmt->errorCode() !== '00000') {
sendEppError($conn, $db, 2400, 'The transfer was not successfully rejected, something is wrong', $clTRID, $trans);
return;
} else {
$stmt = $db->prepare("SELECT `crid`, `crdate`, `upid`, `update`, `trdate`, `trstatus`, `reid`, `redate`, `acid`, `acdate` FROM `contact` WHERE `id` = :contact_id LIMIT 1");
$stmt = $db->prepare("SELECT crid, crdate, upid, lastupdate, trdate, trstatus, reid, redate, acid, acdate FROM contact WHERE id = :contact_id LIMIT 1");
$stmt->execute([':contact_id' => $contact_id]);
$contactInfo = $stmt->fetch(PDO::FETCH_ASSOC);
// Fetch registrar identifiers
$reidStmt = $db->prepare("SELECT `clid` FROM `registrar` WHERE `id` = :reid LIMIT 1");
$reidStmt = $db->prepare("SELECT clid FROM registrar WHERE id = :reid LIMIT 1");
$reidStmt->execute([':reid' => $contactInfo['reid']]);
$reid_identifier = $reidStmt->fetchColumn();
$acidStmt = $db->prepare("SELECT `clid` FROM `registrar` WHERE `id` = :acid LIMIT 1");
$acidStmt = $db->prepare("SELECT clid FROM registrar WHERE id = :acid LIMIT 1");
$acidStmt->execute([':acid' => $contactInfo['acid']]);
$acid_identifier = $acidStmt->fetchColumn();
@ -285,7 +285,7 @@ function processContactTranfer($conn, $db, $xml, $clid, $database_type, $trans)
}
} elseif ($op == 'request') {
// Check if contact is within 60 days of its initial registration
$stmt = $db->prepare("SELECT DATEDIFF(CURRENT_TIMESTAMP(3),`crdate`) FROM `contact` WHERE `id` = :contact_id LIMIT 1");
$stmt = $db->prepare("SELECT DATEDIFF(CURRENT_TIMESTAMP(3),crdate) FROM contact WHERE id = :contact_id LIMIT 1");
$stmt->execute([':contact_id' => $contact_id]);
$days_from_registration = $stmt->fetchColumn();
@ -295,7 +295,7 @@ function processContactTranfer($conn, $db, $xml, $clid, $database_type, $trans)
}
// Check if contact is within 60 days of its last transfer
$stmt = $db->prepare("SELECT `trdate`, DATEDIFF(CURRENT_TIMESTAMP(3),`trdate`) AS `intval` FROM `contact` WHERE `id` = :contact_id LIMIT 1");
$stmt = $db->prepare("SELECT trdate, DATEDIFF(CURRENT_TIMESTAMP(3),trdate) AS intval FROM contact WHERE id = :contact_id LIMIT 1");
$stmt->execute([':contact_id' => $contact_id]);
$result = $stmt->fetch(PDO::FETCH_ASSOC);
$last_trdate = $result['trdate'];
@ -307,7 +307,7 @@ function processContactTranfer($conn, $db, $xml, $clid, $database_type, $trans)
}
// Check the <contact:authInfo> element
$stmt = $db->prepare("SELECT `id` FROM `contact_authInfo` WHERE `contact_id` = :contact_id AND `authtype` = 'pw' AND `authinfo` = :authInfo_pw LIMIT 1");
$stmt = $db->prepare("SELECT id FROM contact_authInfo WHERE contact_id = :contact_id AND authtype = 'pw' AND authinfo = :authInfo_pw LIMIT 1");
$stmt->execute([':contact_id' => $contact_id, ':authInfo_pw' => $authInfo_pw]);
$contact_authinfo_id = $stmt->fetchColumn();
@ -317,7 +317,7 @@ function processContactTranfer($conn, $db, $xml, $clid, $database_type, $trans)
}
// Check if the contact name is subject to any special locks or holds
$stmt = $db->prepare("SELECT `status` FROM `contact_status` WHERE `contact_id` = :contact_id");
$stmt = $db->prepare("SELECT status FROM contact_status WHERE contact_id = :contact_id");
$stmt->execute([':contact_id' => $contact_id]);
while ($status = $stmt->fetchColumn()) {
@ -332,14 +332,14 @@ function processContactTranfer($conn, $db, $xml, $clid, $database_type, $trans)
return;
}
$stmt = $db->prepare("SELECT `crid`,`crdate`,`upid`,`update`,`trdate`,`trstatus`,`reid`,`redate`,`acid`,`acdate` FROM `contact` WHERE `id` = :contact_id LIMIT 1");
$stmt = $db->prepare("SELECT crid,crdate,upid,lastupdate,trdate,trstatus,reid,redate,acid,acdate FROM contact WHERE id = :contact_id LIMIT 1");
$stmt->execute([':contact_id' => $contact_id]);
$result = $stmt->fetch(PDO::FETCH_ASSOC);
$trstatus = $result['trstatus'];
if (!$trstatus || $trstatus != 'pending') {
$waiting_period = 5; // days
$stmt = $db->prepare("UPDATE `contact` SET `trstatus` = 'pending', `reid` = :registrar_id, `redate` = CURRENT_TIMESTAMP(3), `acid` = :registrar_id_contact, `acdate` = DATE_ADD(CURRENT_TIMESTAMP(3), INTERVAL $waiting_period DAY) WHERE `id` = :contact_id");
$stmt = $db->prepare("UPDATE contact SET trstatus = 'pending', reid = :registrar_id, redate = CURRENT_TIMESTAMP(3), acid = :registrar_id_contact, acdate = DATE_ADD(CURRENT_TIMESTAMP(3), INTERVAL $waiting_period DAY) WHERE id = :contact_id");
$stmt->execute([
':registrar_id' => $clid,
':registrar_id_contact' => $registrar_id_contact,
@ -350,14 +350,14 @@ function processContactTranfer($conn, $db, $xml, $clid, $database_type, $trans)
sendEppError($conn, $db, 2400, 'The transfer was not initiated successfully, something is wrong', $clTRID, $trans);
return;
} else {
$stmt = $db->prepare("SELECT `crid`,`crdate`,`upid`,`update`,`trdate`,`trstatus`,`reid`,`redate`,`acid`,`acdate` FROM `contact` WHERE `id` = :contact_id LIMIT 1");
$stmt = $db->prepare("SELECT crid,crdate,upid,lastupdate,trdate,trstatus,reid,redate,acid,acdate FROM contact WHERE id = :contact_id LIMIT 1");
$stmt->execute([':contact_id' => $contact_id]);
$result = $stmt->fetch(PDO::FETCH_ASSOC);
$reid_identifier = $db->query("SELECT `clid` FROM `registrar` WHERE `id` = '{$result['reid']}' LIMIT 1")->fetchColumn();
$acid_identifier = $db->query("SELECT `clid` FROM `registrar` WHERE `id` = '{$result['acid']}' LIMIT 1")->fetchColumn();
$reid_identifier = $db->query("SELECT clid FROM registrar WHERE id = '{$result['reid']}' LIMIT 1")->fetchColumn();
$acid_identifier = $db->query("SELECT clid FROM registrar WHERE id = '{$result['acid']}' LIMIT 1")->fetchColumn();
$db->prepare("INSERT INTO `poll` (`registrar_id`,`qdate`,`msg`,`msg_type`,`obj_name_or_id`,`obj_trStatus`,`obj_reID`,`obj_reDate`,`obj_acID`,`obj_acDate`,`obj_exDate`) VALUES(:registrar_id_contact, CURRENT_TIMESTAMP(3), 'Transfer requested.', 'contactTransfer', :identifier, 'pending', :reid_identifier, :redate, :acid_identifier, :acdate, NULL)")
$db->prepare("INSERT INTO poll (registrar_id,qdate,msg,msg_type,obj_name_or_id,obj_trStatus,obj_reID,obj_reDate,obj_acID,obj_acDate,obj_exDate) VALUES(:registrar_id_contact, CURRENT_TIMESTAMP(3), 'Transfer requested.', 'contactTransfer', :identifier, 'pending', :reid_identifier, :redate, :acid_identifier, :acdate, NULL)")
->execute([
':registrar_id_contact' => $registrar_id_contact,
':identifier' => $identifier,
@ -412,7 +412,7 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type, $trans)
return;
}
$stmt = $db->prepare("SELECT `id`,`tldid`,`clid` FROM `domain` WHERE `name` = :name LIMIT 1");
$stmt = $db->prepare("SELECT id,tldid,clid FROM domain WHERE name = :name LIMIT 1");
$stmt->bindParam(':name', $domainName, PDO::PARAM_STR);
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC);
@ -439,7 +439,7 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type, $trans)
}
if ($authInfo_pw) {
$stmt = $db->prepare("SELECT `id` FROM `domain_authInfo` WHERE `domain_id` = ? AND `authtype` = 'pw' AND `authinfo` = ? LIMIT 1");
$stmt = $db->prepare("SELECT id FROM domain_authInfo WHERE domain_id = ? AND authtype = 'pw' AND authinfo = ? LIMIT 1");
$stmt->execute([$domain_id, $authInfo_pw]);
$domain_authinfo_id = $stmt->fetchColumn();
@ -449,7 +449,7 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type, $trans)
}
}
$stmt = $db->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 = $db->prepare("SELECT id,registrant,crdate,exdate,lastupdate,clid,crid,upid,trdate,trstatus,reid,redate,acid,acdate,transfer_exdate FROM domain WHERE name = ? LIMIT 1");
$stmt->execute([$domainName]);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
@ -457,16 +457,16 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type, $trans)
$date_add = 0;
$price = 0;
$stmt = $db->prepare("SELECT `accountBalance`,`creditLimit` FROM `registrar` WHERE `id` = ? LIMIT 1");
$stmt = $db->prepare("SELECT accountBalance,creditLimit FROM registrar WHERE id = ? LIMIT 1");
$stmt->execute([$row["reid"]]);
list($registrar_balance, $creditLimit) = $stmt->fetch(PDO::FETCH_NUM);
if ($row["transfer_exdate"]) {
$stmt = $db->prepare("SELECT PERIOD_DIFF(DATE_FORMAT(`transfer_exdate`, '%Y%m'), DATE_FORMAT(`exdate`, '%Y%m')) AS `intval` FROM `domain` WHERE `name` = ? LIMIT 1");
$stmt = $db->prepare("SELECT PERIOD_DIFF(DATE_FORMAT(transfer_exdate, '%Y%m'), DATE_FORMAT(exdate, '%Y%m')) AS intval FROM domain WHERE name = ? LIMIT 1");
$stmt->execute([$domainName]);
$date_add = $stmt->fetchColumn();
$stmt = $db->prepare("SELECT `m$date_add` FROM `domain_price` WHERE `tldid` = ? AND `command` = 'transfer' LIMIT 1");
$stmt = $db->prepare("SELECT m$date_add FROM domain_price WHERE tldid = ? AND command = 'transfer' LIMIT 1");
$stmt->execute([$tldid]);
$price = $stmt->fetchColumn();
@ -476,57 +476,57 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type, $trans)
}
}
$stmt = $db->prepare("SELECT `exdate` FROM `domain` WHERE `id` = :domain_id LIMIT 1");
$stmt = $db->prepare("SELECT exdate FROM domain WHERE id = :domain_id LIMIT 1");
$stmt->execute(['domain_id' => $domain_id]);
$from = $stmt->fetchColumn();
$stmt = $db->prepare("UPDATE `domain` SET `exdate` = DATE_ADD(`exdate`, INTERVAL ? MONTH), `update` = CURRENT_TIMESTAMP(3), `clid` = ?, `upid` = ?, `trdate` = CURRENT_TIMESTAMP(3), `trstatus` = 'clientApproved', `acdate` = CURRENT_TIMESTAMP(3), `transfer_exdate` = NULL, `rgpstatus` = 'transferPeriod', `transferPeriod` = ? WHERE `id` = ?");
$stmt = $db->prepare("UPDATE domain SET exdate = DATE_ADD(exdate, INTERVAL ? MONTH), lastupdate = CURRENT_TIMESTAMP(3), clid = ?, upid = ?, trdate = CURRENT_TIMESTAMP(3), trstatus = 'clientApproved', acdate = CURRENT_TIMESTAMP(3), transfer_exdate = NULL, rgpstatus = 'transferPeriod', transferPeriod = ? WHERE id = ?");
$stmt->execute([$date_add, $row["reid"], $clid, $date_add, $domain_id]);
$stmt = $db->prepare("UPDATE `host` SET `clid` = ?, `upid` = ?, `update` = CURRENT_TIMESTAMP(3), `trdate` = CURRENT_TIMESTAMP(3) WHERE `domain_id` = ?");
$stmt = $db->prepare("UPDATE host SET clid = ?, upid = ?, lastupdate = CURRENT_TIMESTAMP(3), trdate = CURRENT_TIMESTAMP(3) WHERE domain_id = ?");
$stmt->execute([$row["reid"], $clid, $domain_id]);
if ($stmt->errorCode() !== PDO::ERR_NONE) {
sendEppError($conn, $db, 2400, 'The transfer was not successful, something is wrong', $clTRID, $trans);
return;
} else {
$stmt = $db->prepare("UPDATE `registrar` SET `accountBalance` = (`accountBalance` - :price) WHERE `id` = :reid");
$stmt = $db->prepare("UPDATE registrar SET accountBalance = (accountBalance - :price) WHERE id = :reid");
$stmt->execute(['price' => $price, 'reid' => $reid]);
$stmt = $db->prepare("INSERT INTO `payment_history` (`registrar_id`,`date`,`description`,`amount`) VALUES(:reid, CURRENT_TIMESTAMP(3), :description, :amount)");
$stmt = $db->prepare("INSERT INTO payment_history (registrar_id,date,description,amount) VALUES(:reid, CURRENT_TIMESTAMP(3), :description, :amount)");
$description = "transfer domain $domainName for period $date_add MONTH";
$stmt->execute(['reid' => $reid, 'description' => $description, 'amount' => -$price]);
$stmt = $db->prepare("SELECT `exdate` FROM `domain` WHERE `id` = :domain_id LIMIT 1");
$stmt = $db->prepare("SELECT exdate FROM domain WHERE id = :domain_id LIMIT 1");
$stmt->execute(['domain_id' => $domain_id]);
$to = $stmt->fetchColumn();
$stmt = $db->prepare("INSERT INTO `statement` (`registrar_id`,`date`,`command`,`domain_name`,`length_in_months`,`from`,`to`,`amount`) VALUES(:registrar_id, CURRENT_TIMESTAMP(3), :command, :domain_name, :length_in_months, :from, :to, :amount)");
$stmt = $db->prepare("INSERT INTO statement (registrar_id,date,command,domain_name,length_in_months,from,to,amount) VALUES(:registrar_id, CURRENT_TIMESTAMP(3), :command, :domain_name, :length_in_months, :from, :to, :amount)");
$stmt->execute(['registrar_id' => $reid, 'command' => 'transfer', 'domain_name' => $domainName, 'length_in_months' => $date_add, 'from' => $from, 'to' => $to, 'amount' => $price]);
$stmt = $db->prepare("SELECT `id`,`registrant`,`crdate`,`exdate`,`update`,`clid`,`crid`,`upid`,`trdate`,`trstatus`,`reid`,`redate`,`acid`,`acdate`,`transfer_exdate` FROM `domain` WHERE `name` = :name LIMIT 1");
$stmt = $db->prepare("SELECT id,registrant,crdate,exdate,lastupdate,clid,crid,upid,trdate,trstatus,reid,redate,acid,acdate,transfer_exdate FROM domain WHERE name = :name LIMIT 1");
$stmt->execute(['name' => $domainName]);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
extract($row);
$stmt = $db->prepare("SELECT `clid` FROM `registrar` WHERE `id` = :reid LIMIT 1");
$stmt = $db->prepare("SELECT clid FROM registrar WHERE id = :reid LIMIT 1");
$stmt->execute(['reid' => $reid]);
$reid_identifier = $stmt->fetchColumn();
$stmt = $db->prepare("SELECT `clid` FROM `registrar` WHERE `id` = :acid LIMIT 1");
$stmt = $db->prepare("SELECT clid FROM registrar WHERE id = :acid LIMIT 1");
$stmt->execute(['acid' => $acid]);
$acid_identifier = $stmt->fetchColumn();
$stmt = $db->prepare("SELECT `id` FROM `statistics` WHERE `date` = CURDATE()");
$stmt = $db->prepare("SELECT id FROM statistics WHERE date = CURDATE()");
$stmt->execute();
$curdate_id = $stmt->fetchColumn();
if (!$curdate_id) {
$stmt = $db->prepare("INSERT IGNORE INTO `statistics` (`date`) VALUES(CURDATE())");
$stmt = $db->prepare("INSERT IGNORE INTO statistics (date) VALUES(CURDATE())");
$stmt->execute();
}
$stmt = $db->prepare("UPDATE `statistics` SET `transfered_domains` = `transfered_domains` + 1 WHERE `date` = CURDATE()");
$stmt = $db->prepare("UPDATE statistics SET transfered_domains = transfered_domains + 1 WHERE date = CURDATE()");
$stmt->execute();
$svTRID = generateSvTRID();
@ -567,7 +567,7 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type, $trans)
}
if ($authInfo_pw) {
$stmt = $db->prepare("SELECT `id` FROM `domain_authInfo` WHERE `domain_id` = :domain_id AND `authtype` = 'pw' AND `authinfo` = :authInfo_pw LIMIT 1");
$stmt = $db->prepare("SELECT id FROM domain_authInfo WHERE domain_id = :domain_id AND authtype = 'pw' AND authinfo = :authInfo_pw LIMIT 1");
$stmt->execute(['domain_id' => $domain_id, 'authInfo_pw' => $authInfo_pw]);
$domain_authinfo_id = $stmt->fetchColumn();
@ -577,29 +577,29 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type, $trans)
}
}
$stmt = $db->prepare("SELECT `id`, `registrant`, `crdate`, `exdate`, `update`, `clid`, `crid`, `upid`, `trdate`, `trstatus`, `reid`, `redate`, `acid`, `acdate`, `transfer_exdate` FROM `domain` WHERE `name` = :name LIMIT 1");
$stmt = $db->prepare("SELECT id, registrant, crdate, exdate, lastupdate, clid, crid, upid, trdate, trstatus, reid, redate, acid, acdate, transfer_exdate FROM domain WHERE name = :name LIMIT 1");
$stmt->execute(['name' => $domainName]);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
extract($row);
if ($trstatus === 'pending') {
$stmt = $db->prepare("UPDATE `domain` SET `trstatus` = 'clientCancelled' WHERE `id` = :domain_id");
$stmt = $db->prepare("UPDATE domain SET trstatus = 'clientCancelled' WHERE id = :domain_id");
$stmt->execute(['domain_id' => $domain_id]);
if ($stmt->errorCode() !== '00000') {
sendEppError($conn, $db, 2400, 'The transfer was not canceled successfully, something is wrong', $clTRID, $trans);
return;
} else {
$stmt = $db->prepare("SELECT `id`, `registrant`, `crdate`, `exdate`, `update`, `clid`, `crid`, `upid`, `trdate`, `trstatus`, `reid`, `redate`, `acid`, `acdate`, `transfer_exdate` FROM `domain` WHERE `name` = :name LIMIT 1");
$stmt = $db->prepare("SELECT id, registrant, crdate, exdate, lastupdate, clid, crid, upid, trdate, trstatus, reid, redate, acid, acdate, transfer_exdate FROM domain WHERE name = :name LIMIT 1");
$stmt->execute(['name' => $domainName]);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
extract($row);
$stmt = $db->prepare("SELECT `clid` FROM `registrar` WHERE `id` = :reid LIMIT 1");
$stmt = $db->prepare("SELECT clid FROM registrar WHERE id = :reid LIMIT 1");
$stmt->execute(['reid' => $reid]);
$reid_identifier = $stmt->fetchColumn();
$stmt = $db->prepare("SELECT `clid` FROM `registrar` WHERE `id` = :acid LIMIT 1");
$stmt = $db->prepare("SELECT clid FROM registrar WHERE id = :acid LIMIT 1");
$stmt->execute(['acid' => $acid]);
$acid_identifier = $stmt->fetchColumn();
@ -636,18 +636,18 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type, $trans)
elseif ($op === 'query') {
$stmt = $db->prepare("SELECT `id`, `registrant`, `crdate`, `exdate`, `update`, `clid`, `crid`, `upid`, `trdate`, `trstatus`, `reid`, `redate`, `acid`, `acdate`, `transfer_exdate` FROM `domain` WHERE `name` = :name LIMIT 1");
$stmt = $db->prepare("SELECT id, registrant, crdate, exdate, lastupdate, clid, crid, upid, trdate, trstatus, reid, redate, acid, acdate, transfer_exdate FROM domain WHERE name = :name LIMIT 1");
$stmt->execute(['name' => $domainName]);
$result = $stmt->fetch(PDO::FETCH_ASSOC);
extract($result);
if ($trstatus === 'pending') {
$stmtReID = $db->prepare("SELECT `clid` FROM `registrar` WHERE `id` = :reid LIMIT 1");
$stmtReID = $db->prepare("SELECT clid FROM registrar WHERE id = :reid LIMIT 1");
$stmtReID->execute(['reid' => $reid]);
$reid_identifier = $stmtReID->fetchColumn();
$stmtAcID = $db->prepare("SELECT `clid` FROM `registrar` WHERE `id` = :acid LIMIT 1");
$stmtAcID = $db->prepare("SELECT clid FROM registrar WHERE id = :acid LIMIT 1");
$stmtAcID->execute(['acid' => $acid]);
$acid_identifier = $stmtAcID->fetchColumn();
@ -688,7 +688,7 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type, $trans)
}
if ($authInfo_pw) {
$stmtAuthInfo = $db->prepare("SELECT `id` FROM `domain_authInfo` WHERE `domain_id` = :domain_id AND `authtype` = 'pw' AND `authinfo` = :authInfo_pw LIMIT 1");
$stmtAuthInfo = $db->prepare("SELECT id FROM domain_authInfo WHERE domain_id = :domain_id AND authtype = 'pw' AND authinfo = :authInfo_pw LIMIT 1");
$stmtAuthInfo->execute(['domain_id' => $domain_id, 'authInfo_pw' => $authInfo_pw]);
$domain_authinfo_id = $stmtAuthInfo->fetchColumn();
@ -698,24 +698,24 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type, $trans)
}
}
$stmt = $db->prepare("SELECT `id`, `registrant`, `crdate`, `exdate`, `update`, `clid`, `crid`, `upid`, `trdate`, `trstatus`, `reid`, `redate`, `acid`, `acdate`, `transfer_exdate` FROM `domain` WHERE `name` = :name LIMIT 1");
$stmt = $db->prepare("SELECT id, registrant, crdate, exdate, lastupdate, clid, crid, upid, trdate, trstatus, reid, redate, acid, acdate, transfer_exdate FROM domain WHERE name = :name LIMIT 1");
$stmt->execute(['name' => $domainName]);
$result = $stmt->fetch(PDO::FETCH_ASSOC);
extract($result);
if ($trstatus === 'pending') {
$stmtUpdate = $db->prepare("UPDATE `domain` SET `trstatus` = 'clientRejected' WHERE `id` = :domain_id");
$stmtUpdate = $db->prepare("UPDATE domain SET trstatus = 'clientRejected' WHERE id = :domain_id");
$success = $stmtUpdate->execute(['domain_id' => $domain_id]);
if (!$success || $stmtUpdate->errorCode() !== '00000') {
sendEppError($conn, $db, 2400, 'The transfer was not successfully rejected, something is wrong', $clTRID, $trans);
return;
} else {
$stmtReID = $db->prepare("SELECT `clid` FROM `registrar` WHERE `id` = :reid LIMIT 1");
$stmtReID = $db->prepare("SELECT clid FROM registrar WHERE id = :reid LIMIT 1");
$stmtReID->execute(['reid' => $reid]);
$reid_identifier = $stmtReID->fetchColumn();
$stmtAcID = $db->prepare("SELECT `clid` FROM `registrar` WHERE `id` = :acid LIMIT 1");
$stmtAcID = $db->prepare("SELECT clid FROM registrar WHERE id = :acid LIMIT 1");
$stmtAcID->execute(['acid' => $acid]);
$acid_identifier = $stmtAcID->fetchColumn();
@ -752,7 +752,7 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type, $trans)
elseif ($op === 'request') {
// Check days from registration
$stmt = $db->prepare("SELECT DATEDIFF(CURRENT_TIMESTAMP(3), `crdate`) FROM `domain` WHERE `id` = :domain_id LIMIT 1");
$stmt = $db->prepare("SELECT DATEDIFF(CURRENT_TIMESTAMP(3), crdate) FROM domain WHERE id = :domain_id LIMIT 1");
$stmt->execute(['domain_id' => $domain_id]);
$days_from_registration = $stmt->fetchColumn();
@ -762,7 +762,7 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type, $trans)
}
// Check days from last transfer
$stmt = $db->prepare("SELECT `trdate`, DATEDIFF(CURRENT_TIMESTAMP(3),`trdate`) AS `intval` FROM `domain` WHERE `id` = :domain_id LIMIT 1");
$stmt = $db->prepare("SELECT trdate, DATEDIFF(CURRENT_TIMESTAMP(3),trdate) AS intval FROM domain WHERE id = :domain_id LIMIT 1");
$stmt->execute(['domain_id' => $domain_id]);
$result = $stmt->fetch();
$last_trdate = $result["trdate"];
@ -774,7 +774,7 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type, $trans)
}
// Check days from expiry date
$stmt = $db->prepare("SELECT DATEDIFF(CURRENT_TIMESTAMP(3),`exdate`) FROM `domain` WHERE `id` = :domain_id LIMIT 1");
$stmt = $db->prepare("SELECT DATEDIFF(CURRENT_TIMESTAMP(3),exdate) FROM domain WHERE id = :domain_id LIMIT 1");
$stmt->execute(['domain_id' => $domain_id]);
$days_from_expiry_date = $stmt->fetchColumn();
@ -784,7 +784,7 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type, $trans)
}
// Auth info
$stmt = $db->prepare("SELECT `id` FROM `domain_authInfo` WHERE `domain_id` = :domain_id AND `authtype` = 'pw' AND `authinfo` = :authInfo_pw LIMIT 1");
$stmt = $db->prepare("SELECT id FROM domain_authInfo WHERE domain_id = :domain_id AND authtype = 'pw' AND authinfo = :authInfo_pw LIMIT 1");
$stmt->execute(['domain_id' => $domain_id, 'authInfo_pw' => $authInfo_pw]);
$domain_authinfo_id = $stmt->fetchColumn();
@ -794,7 +794,7 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type, $trans)
}
// Check domain status
$stmt = $db->prepare("SELECT `status` FROM `domain_status` WHERE `domain_id` = :domain_id");
$stmt = $db->prepare("SELECT status FROM domain_status WHERE domain_id = :domain_id");
$stmt->execute(['domain_id' => $domain_id]);
while ($status = $stmt->fetchColumn()) {
if (preg_match('/.*(TransferProhibited)$/', $status) || preg_match('/^pending/', $status)) {
@ -808,7 +808,7 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type, $trans)
return;
}
$stmt = $db->prepare("SELECT `id`, `registrant`, `crdate`, `exdate`, `update`, `clid`, `crid`, `upid`, `trdate`, `trstatus`, `reid`, `redate`, `acid`, `acdate` FROM `domain` WHERE `name` = ? LIMIT 1");
$stmt = $db->prepare("SELECT id, registrant, crdate, exdate, lastupdate, clid, crid, upid, trdate, trstatus, reid, redate, acid, acdate FROM domain WHERE name = ? LIMIT 1");
$stmt->execute([$domainName]);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
@ -816,7 +816,7 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type, $trans)
$registrant = $row['registrant'];
$crdate = $row['crdate'];
$exdate = $row['exdate'];
$update = $row['update'];
$update = $row['lastupdate'];
$registrar_id_domain = $row['clid'];
$crid = $row['crid'];
$upid = $row['upid'];
@ -860,13 +860,13 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type, $trans)
return;
}
$stmt = $db->prepare("SELECT `accountBalance`, `creditLimit` FROM `registrar` WHERE `id` = :registrar_id LIMIT 1");
$stmt = $db->prepare("SELECT accountBalance, creditLimit FROM registrar WHERE id = :registrar_id LIMIT 1");
$stmt->execute([':registrar_id' => $clid]);
$result = $stmt->fetch(PDO::FETCH_ASSOC);
$registrar_balance = $result["accountBalance"];
$creditLimit = $result["creditLimit"];
$stmt = $db->prepare("SELECT `m$date_add` FROM `domain_price` WHERE `tldid` = :tldid AND `command` = 'transfer' LIMIT 1");
$stmt = $db->prepare("SELECT m$date_add FROM domain_price WHERE tldid = :tldid AND command = 'transfer' LIMIT 1");
$stmt->execute([':tldid' => $tldid]);
$result = $stmt->fetch(PDO::FETCH_ASSOC);
$price = $result["m$date_add"];
@ -877,7 +877,7 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type, $trans)
}
$waiting_period = 5;
$stmt = $db->prepare("UPDATE `domain` SET `trstatus` = 'pending', `reid` = :registrar_id, `redate` = CURRENT_TIMESTAMP(3), `acid` = :registrar_id_domain, `acdate` = DATE_ADD(CURRENT_TIMESTAMP(3), INTERVAL $waiting_period DAY), `transfer_exdate` = DATE_ADD(`exdate`, INTERVAL $date_add MONTH) WHERE `id` = :domain_id");
$stmt = $db->prepare("UPDATE domain SET trstatus = 'pending', reid = :registrar_id, redate = CURRENT_TIMESTAMP(3), acid = :registrar_id_domain, acdate = DATE_ADD(CURRENT_TIMESTAMP(3), INTERVAL $waiting_period DAY), transfer_exdate = DATE_ADD(exdate, INTERVAL $date_add MONTH) WHERE id = :domain_id");
$stmt->execute([':registrar_id' => $clid, ':registrar_id_domain' => $registrar_id_domain, ':domain_id' => $domain_id]);
if ($stmt->errorCode() !== '00000') {
@ -885,22 +885,22 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type, $trans)
return;
} else {
// Get the domain details
$stmt = $db->prepare("SELECT `id`, `registrant`, `crdate`, `exdate`, `update`, `clid`, `crid`, `upid`, `trdate`, `trstatus`, `reid`, `redate`, `acid`, `acdate`, `transfer_exdate` FROM `domain` WHERE `name` = :name LIMIT 1");
$stmt = $db->prepare("SELECT id, registrant, crdate, exdate, lastupdate, clid, crid, upid, trdate, trstatus, reid, redate, acid, acdate, transfer_exdate FROM domain WHERE name = :name LIMIT 1");
$stmt->execute([':name' => $domainName]);
$result = $stmt->fetch(PDO::FETCH_ASSOC);
list($domain_id, $registrant, $crdate, $exdate, $update, $registrar_id_domain, $crid, $upid, $trdate, $trstatus, $reid, $redate, $acid, $acdate, $transfer_exdate) = array_values($result);
list($domain_id, $registrant, $crdate, $exdate, $lastupdate, $registrar_id_domain, $crid, $upid, $trdate, $trstatus, $reid, $redate, $acid, $acdate, $transfer_exdate) = array_values($result);
$stmt = $db->prepare("SELECT `clid` FROM `registrar` WHERE `id` = :reid LIMIT 1");
$stmt = $db->prepare("SELECT clid FROM registrar WHERE id = :reid LIMIT 1");
$stmt->execute([':reid' => $reid]);
$reid_identifier = $stmt->fetchColumn();
$stmt = $db->prepare("SELECT `clid` FROM `registrar` WHERE `id` = :acid LIMIT 1");
$stmt = $db->prepare("SELECT clid FROM registrar WHERE id = :acid LIMIT 1");
$stmt->execute([':acid' => $acid]);
$acid_identifier = $stmt->fetchColumn();
// The current sponsoring registrar will receive a notification of a pending transfer
$stmt = $db->prepare("INSERT INTO `poll` (`registrar_id`,`qdate`,`msg`,`msg_type`,`obj_name_or_id`,`obj_trStatus`,`obj_reID`,`obj_reDate`,`obj_acID`,`obj_acDate`,`obj_exDate`) VALUES(:registrar_id_domain, CURRENT_TIMESTAMP(3), 'Transfer requested.', 'domainTransfer', :name, 'pending', :reid_identifier, :redate, :acid_identifier, :acdate, :transfer_exdate)");
$stmt = $db->prepare("INSERT INTO poll (registrar_id,qdate,msg,msg_type,obj_name_or_id,obj_trStatus,obj_reID,obj_reDate,obj_acID,obj_acDate,obj_exDate) VALUES(:registrar_id_domain, CURRENT_TIMESTAMP(3), 'Transfer requested.', 'domainTransfer', :name, 'pending', :reid_identifier, :redate, :acid_identifier, :acdate, :transfer_exdate)");
$stmt->execute([
':registrar_id_domain' => $registrar_id_domain,
':name' => $domainName,
@ -940,7 +940,7 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type, $trans)
// No expiration date is inserted after the transfer procedure
$waiting_period = 5; // days
$stmt = $db->prepare("UPDATE `domain` SET `trstatus` = 'pending', `reid` = :registrar_id, `redate` = CURRENT_TIMESTAMP(3), `acid` = :registrar_id_domain, `acdate` = DATE_ADD(CURRENT_TIMESTAMP(3), INTERVAL :waiting_period DAY), `transfer_exdate` = NULL WHERE `id` = :domain_id");
$stmt = $db->prepare("UPDATE domain SET trstatus = 'pending', reid = :registrar_id, redate = CURRENT_TIMESTAMP(3), acid = :registrar_id_domain, acdate = DATE_ADD(CURRENT_TIMESTAMP(3), INTERVAL :waiting_period DAY), transfer_exdate = NULL WHERE id = :domain_id");
$stmt->execute([
':registrar_id' => $clid,
':registrar_id_domain' => $registrar_id_domain,
@ -953,22 +953,22 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type, $trans)
return;
} else {
// Get the domain details
$stmt = $db->prepare("SELECT `id`, `registrant`, `crdate`, `exdate`, `update`, `clid`, `crid`, `upid`, `trdate`, `trstatus`, `reid`, `redate`, `acid`, `acdate`, `transfer_exdate` FROM `domain` WHERE `name` = :name LIMIT 1");
$stmt = $db->prepare("SELECT id, registrant, crdate, exdate, lastupdate, clid, crid, upid, trdate, trstatus, reid, redate, acid, acdate, transfer_exdate FROM domain WHERE name = :name LIMIT 1");
$stmt->execute([':name' => $domainName]);
$result = $stmt->fetch(PDO::FETCH_ASSOC);
list($domain_id, $registrant, $crdate, $exdate, $update, $registrar_id_domain, $crid, $upid, $trdate, $trstatus, $reid, $redate, $acid, $acdate, $transfer_exdate) = array_values($result);
list($domain_id, $registrant, $crdate, $exdate, $lastupdate, $registrar_id_domain, $crid, $upid, $trdate, $trstatus, $reid, $redate, $acid, $acdate, $transfer_exdate) = array_values($result);
$stmt = $db->prepare("SELECT `clid` FROM `registrar` WHERE `id` = :reid LIMIT 1");
$stmt = $db->prepare("SELECT clid FROM registrar WHERE id = :reid LIMIT 1");
$stmt->execute([':reid' => $reid]);
$reid_identifier = $stmt->fetchColumn();
$stmt = $db->prepare("SELECT `clid` FROM `registrar` WHERE `id` = :acid LIMIT 1");
$stmt = $db->prepare("SELECT clid FROM registrar WHERE id = :acid LIMIT 1");
$stmt->execute([':acid' => $acid]);
$acid_identifier = $stmt->fetchColumn();
// Notify the current sponsoring registrar of the pending transfer
$stmt = $db->prepare("INSERT INTO `poll` (`registrar_id`, `qdate`, `msg`, `msg_type`, `obj_name_or_id`, `obj_trStatus`, `obj_reID`, `obj_reDate`, `obj_acID`, `obj_acDate`, `obj_exDate`) VALUES(:registrar_id_domain, CURRENT_TIMESTAMP(3), 'Transfer requested.', 'domainTransfer', :name, 'pending', :reid_identifier, :redate, :acid_identifier, :acdate, NULL)");
$stmt = $db->prepare("INSERT INTO poll (registrar_id, qdate, msg, msg_type, obj_name_or_id, obj_trStatus, obj_reID, obj_reDate, obj_acID, obj_acDate, obj_exDate) VALUES(:registrar_id_domain, CURRENT_TIMESTAMP(3), 'Transfer requested.', 'domainTransfer', :name, 'pending', :reid_identifier, :redate, :acid_identifier, :acdate, NULL)");
$stmt->execute([
':registrar_id_domain' => $registrar_id_domain,
':name' => $domainName,

View file

@ -427,18 +427,14 @@ function processContactUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
}
if ($contactChg) {
if ($database_type == 'mysql') {
$stmt = $db->prepare("SELECT `voice`, `voice_x`, `fax`, `fax_x`, `email`, `clid`, `crid`, `crdate`, `upid`, `update`, `trdate`, `trstatus`, `reid`, `redate`, `acid`, `acdate`, `disclose_voice`, `disclose_fax`, `disclose_email` FROM `contact` WHERE `id` = :contact_id LIMIT 1");
} else if ($database_type == 'pgsql') {
$stmt = $db->prepare("SELECT \"voice\", \"voice_x\", \"fax\", \"fax_x\", \"email\", \"clid\", \"crid\", \"crdate\", \"upid\", \"update\", \"trdate\", \"trstatus\", \"reid\", \"redate\", \"acid\", \"acdate\", \"disclose_voice\", \"disclose_fax\", \"disclose_email\" FROM \"contact\" WHERE \"id\" = :contact_id LIMIT 1");
}
$stmt = $db->prepare("SELECT voice, voice_x, fax, fax_x, email, clid, crid, crdate, upid, lastupdate, trdate, trstatus, reid, redate, acid, acdate, disclose_voice, disclose_fax, disclose_email FROM contact WHERE id = :contact_id LIMIT 1");
$stmt->bindParam(':contact_id', $contact_id, PDO::PARAM_INT);
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC);
extract($row);
/* if ($postalInfoInt) {
// For `contact_postalInfo` table with `type` = 'int'
// For contact_postalInfo table with type = 'int'
$stmt_int = $db->prepare("SELECT name,org,street1,street2,street3,city,sp,pc,cc,disclose_name_int,disclose_org_int,disclose_addr_int FROM contact_postalInfo WHERE contact_id = :contact_id AND type = 'int' LIMIT 1");
$stmt_int->bindParam(':contact_id', $contact_id, PDO::PARAM_INT);
$stmt_int->execute();
@ -447,7 +443,7 @@ function processContactUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
}
if ($postalInfoLoc) {
// For `contact_postalInfo` table with `type` = 'loc'
// For contact_postalInfo table with type = 'loc'
$stmt_loc = $db->prepare("SELECT name,org,street1,street2,street3,city,sp,pc,cc,disclose_name_loc,disclose_org_loc,disclose_addr_loc FROM contact_postalInfo WHERE contact_id = :contact_id AND type = 'loc' LIMIT 1");
$stmt_loc->bindParam(':contact_id', $contact_id, PDO::PARAM_INT);
$stmt_loc->execute();
@ -455,13 +451,13 @@ function processContactUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
extract($row_loc);
} */
// For `contact_authInfo` table with `authtype` = 'pw'
// For contact_authInfo table with authtype = 'pw'
$stmt_pw = $db->prepare("SELECT authinfo FROM contact_authInfo WHERE contact_id = :contact_id AND authtype = 'pw' LIMIT 1");
$stmt_pw->bindParam(':contact_id', $contact_id, PDO::PARAM_INT);
$stmt_pw->execute();
$e_authInfo_pw = $stmt_pw->fetchColumn();
// For `contact_authInfo` table with `authtype` = 'ext'
// For contact_authInfo table with authtype = 'ext'
$stmt_ext = $db->prepare("SELECT authinfo FROM contact_authInfo WHERE contact_id = :contact_id AND authtype = 'ext' LIMIT 1");
$stmt_ext->bindParam(':contact_id', $contact_id, PDO::PARAM_INT);
$stmt_ext->execute();
@ -508,11 +504,7 @@ function processContactUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
$e_authInfo_ext = (string)($xml->xpath("//contact:authInfo/contact:ext")[0] ?? "");
// Update contact
if ($database_type == 'mysql') {
$query = "UPDATE `contact` SET `voice` = ?, `voice_x` = ?, `fax` = ?, `fax_x` = ?, `email` = ?, `update` = CURRENT_TIMESTAMP(3) WHERE `id` = ?";
} else if ($database_type == 'pgsql') {
$query = "UPDATE \"contact\" SET \"voice\" = ?, \"voice_x\" = ?, \"fax\" = ?, \"fax_x\" = ?, \"email\" = ?, \"update\" = timestamp 'now' WHERE \"id\" = ?";
}
$query = "UPDATE contact SET voice = ?, voice_x = ?, fax = ?, fax_x = ?, email = ?, lastupdate = CURRENT_TIMESTAMP(3) WHERE id = ?";
$stmt = $db->prepare($query);
$stmt->execute([
$e_voice ?: null,
@ -581,11 +573,7 @@ function processContactUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
}
if ($identica_update) {
if ($database_type == 'mysql') {
$query = "UPDATE `contact` SET `nin` = ?, `nin_type` = ?, `update` = CURRENT_TIMESTAMP(3) WHERE `id` = ?";
} else if ($database_type == 'pgsql') {
$query = "UPDATE \"contact\" SET \"nin\" = ?, \"nin_type\" = ?, \"update\" = timestamp 'now' WHERE \"id\" = ?";
}
$query = "UPDATE contact SET nin = ?, nin_type = ?, lastupdate = CURRENT_TIMESTAMP(3) WHERE id = ?";
$stmt = $db->prepare($query);
if (!$stmt) {
@ -908,11 +896,7 @@ function processHostUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
if (isset($hostChg)) {
$chg_name = strtoupper($xml->xpath('//host:name[1]')[0]);
if ($database_type == 'mysql') {
$query = "UPDATE `host` SET `name` = ?, `update` = CURRENT_TIMESTAMP(3) WHERE `name` = ?";
} else if ($database_type == 'pgsql') {
$query = "UPDATE \"host\" SET \"name\" = ?, \"update\" = timestamp 'now' WHERE \"name\" = ?";
}
$query = "UPDATE host SET name = ?, lastupdate = CURRENT_TIMESTAMP(3) WHERE name = ?";
$stmt = $db->prepare($query);
$stmt->execute([$chg_name, $name]);
@ -957,7 +941,7 @@ function processDomainUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
return;
}
$stmt = $db->prepare("SELECT `id`,`tldid`,`exdate`,`clid` FROM `domain` WHERE `name` = ? LIMIT 1");
$stmt = $db->prepare("SELECT id,tldid,exdate,clid FROM domain WHERE name = ? LIMIT 1");
$stmt->execute([$domainName]);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
@ -979,7 +963,7 @@ function processDomainUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
$domain_id = $row['id'];
$stmt = $db->prepare("SELECT `status` FROM `domain_status` WHERE `domain_id` = ?");
$stmt = $db->prepare("SELECT status FROM domain_status WHERE domain_id = ?");
$stmt->execute([$row['id']]);
while ($status = $stmt->fetchColumn()) {
if (strpos($status, 'serverUpdateProhibited') !== false || strpos($status, 'pendingTransfer') !== false) {
@ -989,7 +973,7 @@ function processDomainUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
}
$clientUpdateProhibited = 0;
$stmt = $db->prepare("SELECT `id` FROM `domain_status` WHERE `domain_id` = ? AND `status` = 'clientUpdateProhibited' LIMIT 1");
$stmt = $db->prepare("SELECT id FROM domain_status WHERE domain_id = ? AND status = 'clientUpdateProhibited' LIMIT 1");
$stmt->execute([$row['id']]);
$clientUpdateProhibited = $stmt->fetchColumn();
@ -1051,7 +1035,7 @@ function processDomainUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
$matchingNodes = $xml->xpath('domain:status[@s="' . $status . '"]');
if (!$matchingNodes || count($matchingNodes) == 0) {
$stmt = $db->prepare("SELECT `id` FROM `domain_status` WHERE `domain_id` = ? AND `status` = ? LIMIT 1");
$stmt = $db->prepare("SELECT id FROM domain_status WHERE domain_id = ? AND status = ? LIMIT 1");
$stmt->execute([$row['id'], $status]);
$domainStatusId = $stmt->fetchColumn();
@ -1118,7 +1102,7 @@ function processDomainUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
// Additional checks related to domain TLDs and existing records
if (preg_match('/^([A-Z0-9]([A-Z0-9-]{0,61}[A-Z0-9]){0,1}\.){1,125}[A-Z0-9]([A-Z0-9-]{0,61}[A-Z0-9])$/i', $hostObj) && strlen($hostObj) < 254) {
$stmt = $db->prepare("SELECT `tld` FROM `domain_tld`");
$stmt = $db->prepare("SELECT tld FROM domain_tld");
$stmt->execute();
$tlds = $stmt->fetchAll(PDO::FETCH_COLUMN);
$host_from_this_registry = 0;
@ -1134,7 +1118,7 @@ function processDomainUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
if (preg_match("/\.$domainName$/i", $hostObj)) {
$superordinate_domain = 1;
} else {
$stmt = $db->prepare("SELECT `id` FROM `host` WHERE `name` = :hostObj LIMIT 1");
$stmt = $db->prepare("SELECT id FROM host WHERE name = :hostObj LIMIT 1");
$stmt->bindParam(':hostObj', $hostObj);
$stmt->execute();
$host_id_already_exist = $stmt->fetchColumn();
@ -1208,7 +1192,7 @@ function processDomainUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
$contact_type = (string)$contactAttributes['type'];
$contact = strtoupper($contact);
$stmt = $db->prepare("SELECT `id` FROM `contact` WHERE `identifier` = ? LIMIT 1");
$stmt = $db->prepare("SELECT id FROM contact WHERE identifier = ? LIMIT 1");
$stmt->execute([$contact]);
$contact_id = $stmt->fetchColumn();
@ -1217,7 +1201,7 @@ function processDomainUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
return;
}
$stmt2 = $db->prepare("SELECT `id` FROM `domain_contact_map` WHERE `domain_id` = ? AND `contact_id` = ? AND `type` = ? LIMIT 1");
$stmt2 = $db->prepare("SELECT id FROM domain_contact_map WHERE domain_id = ? AND contact_id = ? AND type = ? LIMIT 1");
$stmt2->execute([$row['id'], $contact_id, $contact_type]);
$domain_contact_map_id = $stmt2->fetchColumn();
@ -1235,7 +1219,7 @@ function processDomainUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
}
if (isset($registrant)) {
$stmt3 = $db->prepare("SELECT `id` FROM `contact` WHERE `identifier` = ? LIMIT 1");
$stmt3 = $db->prepare("SELECT id FROM contact WHERE identifier = ? LIMIT 1");
$stmt3->execute([$registrant]);
$registrant_id = $stmt3->fetchColumn();
@ -1245,7 +1229,7 @@ function processDomainUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
}
}
$stmt4 = $db->prepare("SELECT `status` FROM `domain_status` WHERE `domain_id` = ?");
$stmt4 = $db->prepare("SELECT status FROM domain_status WHERE domain_id = ?");
$stmt4->execute([$row['id']]);
while ($status = $stmt4->fetchColumn()) {
if (preg_match('/.*(serverUpdateProhibited)$/', $status) || preg_match('/^pendingTransfer/', $status)) {
@ -1281,7 +1265,7 @@ function processDomainUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
$op_attribute = (string) $xml->xpath('//rgp:restore/@op[1]')[0];
if ($op_attribute === 'request') {
$stmt = $db->prepare("SELECT COUNT(`id`) AS `ids` FROM `domain` WHERE `rgpstatus` = 'redemptionPeriod' AND `id` = :domain_id LIMIT 1");
$stmt = $db->prepare("SELECT COUNT(id) AS ids FROM domain WHERE rgpstatus = 'redemptionPeriod' AND id = :domain_id LIMIT 1");
$stmt->bindParam(':domain_id', $domain_id, PDO::PARAM_INT);
$stmt->execute();
$temp_id_rgpstatus = $stmt->fetchColumn();
@ -1291,7 +1275,7 @@ function processDomainUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
return;
}
$stmt = $db->prepare("SELECT COUNT(`id`) AS `ids` FROM `domain_status` WHERE `status` = 'pendingDelete' AND `domain_id` = :domain_id LIMIT 1");
$stmt = $db->prepare("SELECT COUNT(id) AS ids FROM domain_status WHERE status = 'pendingDelete' AND domain_id = :domain_id LIMIT 1");
$stmt->bindParam(':domain_id', $domain_id, PDO::PARAM_INT);
$stmt->execute();
$temp_id_status = $stmt->fetchColumn();
@ -1301,7 +1285,7 @@ function processDomainUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
return;
}
} elseif ($op_attribute === 'report') {
$stmt = $db->prepare("SELECT COUNT(`id`) AS `ids` FROM `domain` WHERE `rgpstatus` = 'pendingRestore' AND `id` = :domain_id LIMIT 1");
$stmt = $db->prepare("SELECT COUNT(id) AS ids FROM domain WHERE rgpstatus = 'pendingRestore' AND id = :domain_id LIMIT 1");
$stmt->bindParam(':domain_id', $domain_id, PDO::PARAM_INT);
$stmt->execute();
$temp_id = $stmt->fetchColumn();
@ -1325,13 +1309,13 @@ function processDomainUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
foreach ($hostObj_list as $node) {
$hostObj = (string) $node;
$stmt = $db->prepare("SELECT `id` FROM `host` WHERE `name` = :hostObj LIMIT 1");
$stmt = $db->prepare("SELECT id FROM host WHERE name = :hostObj LIMIT 1");
$stmt->bindParam(':hostObj', $hostObj, PDO::PARAM_STR);
$stmt->execute();
$host_id = $stmt->fetchColumn();
if ($host_id) {
$stmt = $db->prepare("DELETE FROM `domain_host_map` WHERE `domain_id` = :domain_id AND `host_id` = :host_id");
$stmt = $db->prepare("DELETE FROM domain_host_map WHERE domain_id = :domain_id AND host_id = :host_id");
$stmt->bindParam(':domain_id', $domain_id, PDO::PARAM_INT);
$stmt->bindParam(':host_id', $host_id, PDO::PARAM_INT);
$stmt->execute();
@ -1344,22 +1328,22 @@ function processDomainUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
if ($hostNameNodes && isset($hostNameNodes[0])) {
$hostName = (string) $hostNameNodes[0];
$stmt = $db->prepare("SELECT `id` FROM `host` WHERE `name` = :hostName LIMIT 1");
$stmt = $db->prepare("SELECT id FROM host WHERE name = :hostName LIMIT 1");
$stmt->bindParam(':hostName', $hostName, PDO::PARAM_STR);
$stmt->execute();
$host_id = $stmt->fetchColumn();
if ($host_id) {
$stmt = $db->prepare("DELETE FROM `domain_host_map` WHERE `domain_id` = :domain_id AND `host_id` = :host_id");
$stmt = $db->prepare("DELETE FROM domain_host_map WHERE domain_id = :domain_id AND host_id = :host_id");
$stmt->bindParam(':domain_id', $domain_id, PDO::PARAM_INT);
$stmt->bindParam(':host_id', $host_id, PDO::PARAM_INT);
$stmt->execute();
$stmt = $db->prepare("DELETE FROM `host_addr` WHERE `host_id` = :host_id");
$stmt = $db->prepare("DELETE FROM host_addr WHERE host_id = :host_id");
$stmt->bindParam(':host_id', $host_id, PDO::PARAM_INT);
$stmt->execute();
$stmt = $db->prepare("DELETE FROM `host` WHERE `id` = :host_id");
$stmt = $db->prepare("DELETE FROM host WHERE id = :host_id");
$stmt->bindParam(':host_id', $host_id, PDO::PARAM_INT);
$stmt->execute();
}
@ -1370,13 +1354,13 @@ function processDomainUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
$contact = (string) $node;
$contact_type = (string) $node->attributes()->type;
$stmt = $db->prepare("SELECT `id` FROM `contact` WHERE `identifier` = :contact LIMIT 1");
$stmt = $db->prepare("SELECT id FROM contact WHERE identifier = :contact LIMIT 1");
$stmt->bindParam(':contact', $contact, PDO::PARAM_STR);
$stmt->execute();
$contact_id = $stmt->fetchColumn();
if ($contact_id) {
$stmt = $db->prepare("DELETE FROM `domain_contact_map` WHERE `domain_id` = :domain_id AND `contact_id` = :contact_id AND `type` = :contact_type");
$stmt = $db->prepare("DELETE FROM domain_contact_map WHERE domain_id = :domain_id AND contact_id = :contact_id AND type = :contact_type");
$stmt->bindParam(':domain_id', $domain_id, PDO::PARAM_INT);
$stmt->bindParam(':contact_id', $contact_id, PDO::PARAM_INT);
$stmt->bindParam(':contact_type', $contact_type, PDO::PARAM_STR);
@ -1387,7 +1371,7 @@ function processDomainUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
foreach ($status_list as $node) {
$status = (string) $node;
$stmt = $db->prepare("DELETE FROM `domain_status` WHERE `domain_id` = :domain_id AND `status` = :status");
$stmt = $db->prepare("DELETE FROM domain_status WHERE domain_id = :domain_id AND status = :status");
$stmt->bindParam(':domain_id', $domain_id, PDO::PARAM_INT);
$stmt->bindParam(':status', $status, PDO::PARAM_STR);
$stmt->execute();
@ -1405,25 +1389,25 @@ function processDomainUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
$hostObj = (string) $node;
// Check if hostObj exists in the database
$stmt = $db->prepare("SELECT `id` FROM `host` WHERE `name` = :hostObj LIMIT 1");
$stmt = $db->prepare("SELECT id FROM host WHERE name = :hostObj LIMIT 1");
$stmt->bindParam(':hostObj', $hostObj, PDO::PARAM_STR);
$stmt->execute();
$hostObj_already_exist = $stmt->fetchColumn();
if ($hostObj_already_exist) {
$stmt = $db->prepare("SELECT `domain_id` FROM `domain_host_map` WHERE `domain_id` = :domain_id AND `host_id` = :hostObj_already_exist LIMIT 1");
$stmt = $db->prepare("SELECT domain_id FROM domain_host_map WHERE domain_id = :domain_id AND host_id = :hostObj_already_exist LIMIT 1");
$stmt->bindParam(':domain_id', $domain_id, PDO::PARAM_INT);
$stmt->bindParam(':hostObj_already_exist', $hostObj_already_exist, PDO::PARAM_INT);
$stmt->execute();
$domain_host_map_id = $stmt->fetchColumn();
if (!$domain_host_map_id) {
$stmt = $db->prepare("INSERT INTO `domain_host_map` (`domain_id`,`host_id`) VALUES(:domain_id, :hostObj_already_exist)");
$stmt = $db->prepare("INSERT INTO domain_host_map (domain_id,host_id) VALUES(:domain_id, :hostObj_already_exist)");
$stmt->bindParam(':domain_id', $domain_id, PDO::PARAM_INT);
$stmt->bindParam(':hostObj_already_exist', $hostObj_already_exist, PDO::PARAM_INT);
$stmt->execute();
} else {
$stmt = $db->prepare("INSERT INTO `error_log` (`registrar_id`,`log`,`date`) VALUES(:registrar_id, :log, CURRENT_TIMESTAMP(3))");
$stmt = $db->prepare("INSERT INTO error_log (registrar_id,log,date) VALUES(:registrar_id, :log, CURRENT_TIMESTAMP(3))");
$log = "Domain : $domainName ; hostObj : $hostObj - se dubleaza";
$stmt->bindParam(':registrar_id', $clid, PDO::PARAM_INT);
$stmt->bindParam(':log', $log, PDO::PARAM_STR);
@ -1432,7 +1416,7 @@ function processDomainUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
} else {
$host_from_this_registry = 0;
$sth = $db->prepare("SELECT `tld` FROM `domain_tld`");
$sth = $db->prepare("SELECT tld FROM domain_tld");
if (!$sth->execute()) {
sendEppError($conn, $db, 2400, 'Database error', $clTRID, $trans);
return;
@ -1449,28 +1433,28 @@ function processDomainUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
if ($host_from_this_registry) {
if (preg_match("/\.$domainName$/i", $hostObj)) {
$sth = $db->prepare("INSERT INTO `host` (`name`,`domain_id`,`clid`,`crid`,`crdate`) VALUES(?, ?, ?, ?, CURRENT_TIMESTAMP(3))");
$sth = $db->prepare("INSERT INTO host (name,domain_id,clid,crid,crdate) VALUES(?, ?, ?, ?, CURRENT_TIMESTAMP(3))");
if (!$sth->execute([$hostObj, $domain_id, $clid, $clid])) {
sendEppError($conn, $db, 2400, 'Database error', $clTRID, $trans);
return;
}
$host_id = $db->lastInsertId();
$sth = $db->prepare("INSERT INTO `domain_host_map` (`domain_id`,`host_id`) VALUES(?, ?)");
$sth = $db->prepare("INSERT INTO domain_host_map (domain_id,host_id) VALUES(?, ?)");
if (!$sth->execute([$domain_id, $host_id])) {
sendEppError($conn, $db, 2400, 'Database error', $clTRID, $trans);
return;
}
}
} else {
$sth = $db->prepare("INSERT INTO `host` (`name`,`clid`,`crid`,`crdate`) VALUES(?, ?, ?, CURRENT_TIMESTAMP(3))");
$sth = $db->prepare("INSERT INTO host (name,clid,crid,crdate) VALUES(?, ?, ?, CURRENT_TIMESTAMP(3))");
if (!$sth->execute([$hostObj, $clid, $clid])) {
sendEppError($conn, $db, 2400, 'Database error', $clTRID, $trans);
return;
}
$host_id = $db->lastInsertId();
$sth = $db->prepare("INSERT INTO `domain_host_map` (`domain_id`,`host_id`) VALUES(?, ?)");
$sth = $db->prepare("INSERT INTO domain_host_map (domain_id,host_id) VALUES(?, ?)");
if (!$sth->execute([$domain_id, $host_id])) {
sendEppError($conn, $db, 2400, 'Database error', $clTRID, $trans);
return;
@ -1484,25 +1468,25 @@ function processDomainUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
$hostName = isset($hostNames[0]) ? (string)$hostNames[0] : null;
if ($hostName) {
$stmt = $db->prepare("SELECT `id` FROM `host` WHERE `name` = :hostName LIMIT 1");
$stmt = $db->prepare("SELECT id FROM host WHERE name = :hostName LIMIT 1");
$stmt->bindParam(':hostName', $hostName, PDO::PARAM_STR);
$stmt->execute();
$hostName_already_exist = $stmt->fetchColumn();
if ($hostName_already_exist) {
$sth = $db->prepare("SELECT `domain_id` FROM `domain_host_map` WHERE `domain_id` = ? AND `host_id` = ? LIMIT 1");
$sth = $db->prepare("SELECT domain_id FROM domain_host_map WHERE domain_id = ? AND host_id = ? LIMIT 1");
$sth->execute([$domain_id, $hostName_already_exist]);
$domain_host_map_id = $sth->fetchColumn();
if (!$domain_host_map_id) {
$sth = $db->prepare("INSERT INTO `domain_host_map` (`domain_id`,`host_id`) VALUES(?, ?)");
$sth = $db->prepare("INSERT INTO domain_host_map (domain_id,host_id) VALUES(?, ?)");
if (!$sth->execute([$domain_id, $hostName_already_exist])) {
sendEppError($conn, $db, 2400, 'Database error', $clTRID, $trans);
return;
}
} else {
$logMessage = "Domain : $domainName ; hostName : $hostName - se dubleaza";
$sth = $db->prepare("INSERT INTO `error_log` (`registrar_id`,`log`,`date`) VALUES(?, ?, CURRENT_TIMESTAMP(3))");
$sth = $db->prepare("INSERT INTO error_log (registrar_id,log,date) VALUES(?, ?, CURRENT_TIMESTAMP(3))");
if (!$sth->execute([$clid, $logMessage])) {
sendEppError($conn, $db, 2400, 'Database error', $clTRID, $trans);
return;
@ -1510,13 +1494,13 @@ function processDomainUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
}
} else {
// Insert into the host table
$sth = $db->prepare("INSERT INTO `host` (`name`,`domain_id`,`clid`,`crid`,`crdate`) VALUES(?, ?, ?, ?, CURRENT_TIMESTAMP(3))");
$sth = $db->prepare("INSERT INTO host (name,domain_id,clid,crid,crdate) VALUES(?, ?, ?, ?, CURRENT_TIMESTAMP(3))");
$sth->execute([$hostName, $domain_id, $clid, $clid]) or die($sth->errorInfo()[2]);
$host_id = $db->lastInsertId();
// Insert into the domain_host_map table
$sth = $db->prepare("INSERT INTO `domain_host_map` (`domain_id`,`host_id`) VALUES(?, ?)");
$sth = $db->prepare("INSERT INTO domain_host_map (domain_id,host_id) VALUES(?, ?)");
$sth->execute([$domain_id, $host_id]) or die($sth->errorInfo()[2]);
// Iterate over the hostAddr_list
@ -1533,7 +1517,7 @@ function processDomainUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
}
// Insert into the host_addr table
$sth = $db->prepare("INSERT INTO `host_addr` (`host_id`,`addr`,`ip`) VALUES(?, ?, ?)");
$sth = $db->prepare("INSERT INTO host_addr (host_id,addr,ip) VALUES(?, ?, ?)");
$sth->execute([$host_id, $hostAddr, $addr_type]) or die($sth->errorInfo()[2]);
}
}
@ -1544,13 +1528,13 @@ function processDomainUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
$contact = (string) $node;
$contact_type = (string) $node->attributes()->type;
$stmt = $db->prepare("SELECT `id` FROM `contact` WHERE `identifier` = :contact LIMIT 1");
$stmt = $db->prepare("SELECT id FROM contact WHERE identifier = :contact LIMIT 1");
$stmt->bindParam(':contact', $contact, PDO::PARAM_STR);
$stmt->execute();
$contact_id = $stmt->fetchColumn();
try {
$stmt = $db->prepare("INSERT INTO `domain_contact_map` (`domain_id`,`contact_id`,`type`) VALUES(:domain_id, :contact_id, :contact_type)");
$stmt = $db->prepare("INSERT INTO domain_contact_map (domain_id,contact_id,type) VALUES(:domain_id, :contact_id, :contact_type)");
$stmt->bindParam(':domain_id', $domain_id, PDO::PARAM_INT);
$stmt->bindParam(':contact_id', $contact_id, PDO::PARAM_INT);
$stmt->bindParam(':contact_type', $contact_type, PDO::PARAM_STR);
@ -1568,7 +1552,7 @@ function processDomainUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
$status = (string) $node;
try {
$stmt = $db->prepare("INSERT INTO `domain_status` (`domain_id`,`status`) VALUES(:domain_id, :status)");
$stmt = $db->prepare("INSERT INTO domain_status (domain_id,status) VALUES(:domain_id, :status)");
$stmt->bindParam(':domain_id', $domain_id, PDO::PARAM_INT);
$stmt->bindParam(':status', $status, PDO::PARAM_STR);
$stmt->execute();
@ -1589,17 +1573,17 @@ function processDomainUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
$registrant = strtoupper((string)$registrant_nodes[0]);
if ($registrant) {
$sth = $db->prepare("SELECT `id` FROM `contact` WHERE `identifier` = ? LIMIT 1");
$sth = $db->prepare("SELECT id FROM contact WHERE identifier = ? LIMIT 1");
$sth->execute([$registrant]);
$registrant_id = $sth->fetchColumn();
$sth = $db->prepare("UPDATE `domain` SET `registrant` = ?, `update` = CURRENT_TIMESTAMP(3) WHERE `id` = ?");
$sth = $db->prepare("UPDATE domain SET registrant = ?, update = CURRENT_TIMESTAMP(3) WHERE id = ?");
if (!$sth->execute([$registrant_id, $domain_id])) {
sendEppError($conn, $db, 2400, 'Database error', $clTRID, $trans);
return;
}
} else {
$sth = $db->prepare("UPDATE `domain` SET `registrant` = NULL, `update` = CURRENT_TIMESTAMP(3) WHERE `id` = ?");
$sth = $db->prepare("UPDATE domain SET registrant = NULL, update = CURRENT_TIMESTAMP(3) WHERE id = ?");
if (!$sth->execute([$domain_id])) {
sendEppError($conn, $db, 2400, 'Database error', $clTRID, $trans);
return;
@ -1611,7 +1595,7 @@ function processDomainUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
$authInfo_pw = (!empty($authInfoNodes)) ? (string)$xml->xpath('//domain:pw[1]')[0] : null;
if ($authInfo_pw) {
$sth = $db->prepare("UPDATE `domain_authInfo` SET `authinfo` = ? WHERE `domain_id` = ? AND `authtype` = ?");
$sth = $db->prepare("UPDATE domain_authInfo SET authinfo = ? WHERE domain_id = ? AND authtype = ?");
if (!$sth->execute([$authInfo_pw, $domain_id, 'pw'])) {
sendEppError($conn, $db, 2400, 'Database error', $clTRID, $trans);
return;
@ -1622,7 +1606,7 @@ function processDomainUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
$authInfo_ext = (!empty($authInfoExtNodes)) ? (string)$authInfoExtNodes[0] : null;
if (isset($authInfo_ext)) {
$sth = $db->prepare("UPDATE `domain_authInfo` SET `authinfo` = ? WHERE `domain_id` = ? AND `authtype` = ?");
$sth = $db->prepare("UPDATE domain_authInfo SET authinfo = ? WHERE domain_id = ? AND authtype = ?");
if (!$sth->execute([$authInfo_ext, $domain_id, 'ext'])) {
sendEppError($conn, $db, 2400, 'Database error', $clTRID, $trans);
return;
@ -1633,7 +1617,7 @@ function processDomainUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
$authInfo_null = (!empty($authInfoNullNodes)) ? (string)$authInfoNullNodes[0] : null;
if (isset($authInfo_null)) {
$sth = $db->prepare("DELETE FROM `domain_authInfo` WHERE `domain_id` = ?");
$sth = $db->prepare("DELETE FROM domain_authInfo WHERE domain_id = ?");
if (!$sth->execute([$domain_id])) {
sendEppError($conn, $db, 2400, 'Database error', $clTRID, $trans);
return;
@ -1645,12 +1629,12 @@ function processDomainUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
$op_attribute = (string) $xml->xpath('//rgp:restore/@op[1]')[0];
if ($op_attribute == 'request') {
$sth = $db->prepare("SELECT COUNT(`id`) AS `ids` FROM `domain` WHERE `rgpstatus` = 'redemptionPeriod' AND `id` = ?");
$sth = $db->prepare("SELECT COUNT(id) AS ids FROM domain WHERE rgpstatus = 'redemptionPeriod' AND id = ?");
$sth->execute([$domain_id]);
$temp_id = $sth->fetchColumn();
if ($temp_id == 1) {
$sth = $db->prepare("UPDATE `domain` SET `rgpstatus` = 'pendingRestore', `resTime` = CURRENT_TIMESTAMP(3), `update` = CURRENT_TIMESTAMP(3) WHERE `id` = ?");
$sth = $db->prepare("UPDATE domain SET rgpstatus = 'pendingRestore', resTime = CURRENT_TIMESTAMP(3), lastupdate = CURRENT_TIMESTAMP(3) WHERE id = ?");
if (!$sth->execute([$domain_id])) {
sendEppError($conn, $db, 2400, 'Database error', $clTRID, $trans);
return;
@ -1660,20 +1644,20 @@ function processDomainUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
return;
}
} elseif ($op_attribute == 'report') {
$sth = $db->prepare("SELECT COUNT(`id`) AS `ids` FROM `domain` WHERE `rgpstatus` = 'pendingRestore' AND `id` = ?");
$sth = $db->prepare("SELECT COUNT(id) AS ids FROM domain WHERE rgpstatus = 'pendingRestore' AND id = ?");
$sth->execute([$domain_id]);
$temp_id = $sth->fetchColumn();
if ($temp_id == 1) {
$sth = $db->prepare("SELECT `accountBalance`,`creditLimit` FROM `registrar` WHERE `id` = ?");
$sth = $db->prepare("SELECT accountBalance,creditLimit FROM registrar WHERE id = ?");
$sth->execute([$clid]);
list($registrar_balance, $creditLimit) = $sth->fetch();
$sth = $db->prepare("SELECT `m12` FROM `domain_price` WHERE `tldid` = ? AND `command` = 'renew' LIMIT 1");
$sth = $db->prepare("SELECT m12 FROM domain_price WHERE tldid = ? AND command = 'renew' LIMIT 1");
$sth->execute([$row['tldid']]);
$renew_price = $sth->fetchColumn();
$sth = $db->prepare("SELECT `price` FROM `domain_restore_price` WHERE `tldid` = ? LIMIT 1");
$sth = $db->prepare("SELECT price FROM domain_restore_price WHERE tldid = ? LIMIT 1");
$sth->execute([$row['tldid']]);
$restore_price = $sth->fetchColumn();
@ -1682,50 +1666,50 @@ function processDomainUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
return;
}
$sth = $db->prepare("SELECT `exdate` FROM `domain` WHERE `id` = ?");
$sth = $db->prepare("SELECT exdate FROM domain WHERE id = ?");
$sth->execute([$domain_id]);
$from = $sth->fetchColumn();
$sth = $db->prepare("UPDATE `domain` SET `exdate` = DATE_ADD(`exdate`, INTERVAL 12 MONTH), `rgpstatus` = NULL, `rgpresTime` = CURRENT_TIMESTAMP(3), `update` = CURRENT_TIMESTAMP(3) WHERE `id` = ?");
$sth = $db->prepare("UPDATE domain SET exdate = DATE_ADD(exdate, INTERVAL 12 MONTH), rgpstatus = NULL, rgpresTime = CURRENT_TIMESTAMP(3), lastupdate = CURRENT_TIMESTAMP(3) WHERE id = ?");
if (!$sth->execute([$domain_id])) {
sendEppError($conn, $db, 2400, 'It was not renewed successfully, something is wrong', $clTRID, $trans);
return;
} else {
$sth = $db->prepare("DELETE FROM `domain_status` WHERE `domain_id` = ? AND `status` = ?");
$sth = $db->prepare("DELETE FROM domain_status WHERE domain_id = ? AND status = ?");
$sth->execute([$domain_id, 'pendingDelete']);
$db->prepare("UPDATE `registrar` SET `accountBalance` = (`accountBalance` - ? - ?) WHERE `id` = ?")
$db->prepare("UPDATE registrar SET accountBalance = (accountBalance - ? - ?) WHERE id = ?")
->execute([$renew_price, $restore_price, $clid]);
$db->prepare("INSERT INTO `payment_history` (`registrar_id`,`date`,`description`,`amount`) VALUES(?,CURRENT_TIMESTAMP(3),'restore domain $domainName',?)")
$db->prepare("INSERT INTO payment_history (registrar_id,date,description,amount) VALUES(?,CURRENT_TIMESTAMP(3),'restore domain $domainName',?)")
->execute([$clid, -$restore_price]);
$db->prepare("INSERT INTO `payment_history` (`registrar_id`,`date`,`description`,`amount`) VALUES(?,CURRENT_TIMESTAMP(3),'renew domain $domainName for period 12 MONTH',?)")
$db->prepare("INSERT INTO payment_history (registrar_id,date,description,amount) VALUES(?,CURRENT_TIMESTAMP(3),'renew domain $domainName for period 12 MONTH',?)")
->execute([$clid, -$renew_price]);
$stmt = $db->prepare("SELECT `exdate` FROM `domain` WHERE `id` = ?");
$stmt = $db->prepare("SELECT exdate FROM domain WHERE id = ?");
$stmt->execute([$domain_id]);
$to = $stmt->fetchColumn();
$sth = $db->prepare("INSERT INTO `statement` (`registrar_id`,`date`,`command`,`domain_name`,`length_in_months`,`from`,`to`,`amount`) VALUES(?,CURRENT_TIMESTAMP(3),?,?,?,?,?,?)");
$sth = $db->prepare("INSERT INTO statement (registrar_id,date,command,domain_name,length_in_months,from,to,amount) VALUES(?,CURRENT_TIMESTAMP(3),?,?,?,?,?,?)");
$sth->execute([$clid, 'restore', $domainName, 0, $from, $from, $restore_price]);
$sth->execute([$clid, 'renew', $domainName, 12, $from, $to, $renew_price]);
$stmt = $db->prepare("SELECT `id` FROM `statistics` WHERE `date` = CURDATE()");
$stmt = $db->prepare("SELECT id FROM statistics WHERE date = CURDATE()");
$stmt->execute();
$curdate_id = $stmt->fetchColumn();
if (!$curdate_id) {
$db->prepare("INSERT IGNORE INTO `statistics` (`date`) VALUES(CURDATE())")
$db->prepare("INSERT IGNORE INTO statistics (date) VALUES(CURDATE())")
->execute();
}
$db->prepare("UPDATE `statistics` SET `restored_domains` = `restored_domains` + 1 WHERE `date` = CURDATE()")
$db->prepare("UPDATE statistics SET restored_domains = restored_domains + 1 WHERE date = CURDATE()")
->execute();
$db->prepare("UPDATE `statistics` SET `renewed_domains` = `renewed_domains` + 1 WHERE `date` = CURDATE()")
$db->prepare("UPDATE statistics SET renewed_domains = renewed_domains + 1 WHERE date = CURDATE()")
->execute();
}
} else {
@ -1946,7 +1930,7 @@ function processDomainUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
}
try {
$stmt = $db->prepare("INSERT INTO `secdns` (`domain_id`, `maxsiglife`, `interface`, `keytag`, `alg`, `digesttype`, `digest`, `flags`, `protocol`, `keydata_alg`, `pubkey`) VALUES (:domain_id, :maxsiglife, :interface, :keytag, :alg, :digesttype, :digest, :flags, :protocol, :keydata_alg, :pubkey)");
$stmt = $db->prepare("INSERT INTO secdns (domain_id, maxsiglife, interface, keytag, alg, digesttype, digest, flags, protocol, keydata_alg, pubkey) VALUES (:domain_id, :maxsiglife, :interface, :keytag, :alg, :digesttype, :digest, :flags, :protocol, :keydata_alg, :pubkey)");
$stmt->execute([
':domain_id' => $domain_id,
@ -2010,7 +1994,7 @@ function processDomainUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
$dsres = dnssec_key2ds($domainName.'.', $flags, $protocol, $algKeyData, $pubKey);
try {
$stmt = $db->prepare("INSERT INTO `secdns` (`domain_id`, `maxsiglife`, `interface`, `keytag`, `alg`, `digesttype`, `digest`, `flags`, `protocol`, `keydata_alg`, `pubkey`) VALUES (:domain_id, :maxsiglife, :interface, :keytag, :alg, :digesttype, :digest, :flags, :protocol, :keydata_alg, :pubkey)");
$stmt = $db->prepare("INSERT INTO secdns (domain_id, maxsiglife, interface, keytag, alg, digesttype, digest, flags, protocol, keydata_alg, pubkey) VALUES (:domain_id, :maxsiglife, :interface, :keytag, :alg, :digesttype, :digest, :flags, :protocol, :keydata_alg, :pubkey)");
$stmt->execute([
':domain_id' => $domain_id,

View file

@ -263,7 +263,7 @@ function normalize_v6_address($v6) {
function createTransaction($db, $clid, $clTRID, $clTRIDframe) {
// Prepare the statement for insertion
$stmt = $db->prepare("INSERT INTO `registryTransaction`.`transaction_identifier` (`registrar_id`,`clTRID`,`clTRIDframe`,`cldate`,`clmicrosecond`) VALUES(?,?,?,?,?)");
$stmt = $db->prepare("INSERT INTO registryTransaction.transaction_identifier (registrar_id,clTRID,clTRIDframe,cldate,clmicrosecond) VALUES(?,?,?,?,?)");
// Get date and microsecond for cl transaction
$currentDateTime = new DateTime("now", new DateTimeZone("UTC"));
@ -293,7 +293,7 @@ function createTransaction($db, $clid, $clTRID, $clTRIDframe) {
function updateTransaction($db, $cmd, $obj_type, $obj_id, $code, $msg, $svTRID, $svTRIDframe, $transaction_id) {
// Prepare the statement
$stmt = $db->prepare("UPDATE `registryTransaction`.`transaction_identifier` SET `cmd` = ?, `obj_type` = ?, `obj_id` = ?, `code` = ?, `msg` = ?, `svTRID` = ?, `svTRIDframe` = ?, `svdate` = ?, `svmicrosecond` = ? WHERE `id` = ?");
$stmt = $db->prepare("UPDATE registryTransaction.transaction_identifier SET cmd = ?, obj_type = ?, obj_id = ?, code = ?, msg = ?, svTRID = ?, svTRIDframe = ?, svdate = ?, svmicrosecond = ? WHERE id = ?");
// Get date and microsecond for sv transaction
$currentDateTime = new DateTime("now", new DateTimeZone("UTC"));