Added EPP transaction log for all successful commands

Fixed #13
This commit is contained in:
Pinga 2023-08-25 17:28:03 +03:00
parent c6ab5572ca
commit 5c0ffbe60f
7 changed files with 95 additions and 55 deletions

View file

@ -1,6 +1,6 @@
<?php <?php
function processContactCreate($conn, $db, $xml, $clid, $database_type) { function processContactCreate($conn, $db, $xml, $clid, $database_type, $trans) {
$contactID = (string) $xml->command->create->children('urn:ietf:params:xml:ns:contact-1.0')->create->{'id'}; $contactID = (string) $xml->command->create->children('urn:ietf:params:xml:ns:contact-1.0')->create->{'id'};
$clTRID = (string) $xml->command->clTRID; $clTRID = (string) $xml->command->clTRID;
@ -374,6 +374,7 @@ function processContactCreate($conn, $db, $xml, $clid, $database_type) {
return; return;
} }
$svTRID = generateSvTRID();
$response = [ $response = [
'command' => 'create_contact', 'command' => 'create_contact',
'resultCode' => 1000, 'resultCode' => 1000,
@ -382,15 +383,16 @@ function processContactCreate($conn, $db, $xml, $clid, $database_type) {
'id' => $identifier, 'id' => $identifier,
'crDate' => $crdate, 'crDate' => $crdate,
'clTRID' => $clTRID, 'clTRID' => $clTRID,
'svTRID' => generateSvTRID(), 'svTRID' => $svTRID,
]; ];
$epp = new EPP\EppWriter(); $epp = new EPP\EppWriter();
$xml = $epp->epp_writer($response); $xml = $epp->epp_writer($response);
updateTransaction($db, 'create', 'contact', $identifier, 1000, 'Command completed successfully', $svTRID, $xml, $trans);
sendEppResponse($conn, $xml); sendEppResponse($conn, $xml);
} }
function processHostCreate($conn, $db, $xml, $clid, $database_type) { function processHostCreate($conn, $db, $xml, $clid, $database_type, $trans) {
$hostName = $xml->command->create->children('urn:ietf:params:xml:ns:host-1.0')->create->name; $hostName = $xml->command->create->children('urn:ietf:params:xml:ns:host-1.0')->create->name;
$clTRID = (string) $xml->command->clTRID; $clTRID = (string) $xml->command->clTRID;
@ -515,6 +517,7 @@ function processHostCreate($conn, $db, $xml, $clid, $database_type) {
$stmt->execute([$hostName]); $stmt->execute([$hostName]);
$crdate = $stmt->fetchColumn(); $crdate = $stmt->fetchColumn();
$svTRID = generateSvTRID();
$response = [ $response = [
'command' => 'create_host', 'command' => 'create_host',
'resultCode' => 1000, 'resultCode' => 1000,
@ -523,15 +526,15 @@ function processHostCreate($conn, $db, $xml, $clid, $database_type) {
'name' => $hostName, 'name' => $hostName,
'crDate' => $crdate, 'crDate' => $crdate,
'clTRID' => $clTRID, 'clTRID' => $clTRID,
'svTRID' => generateSvTRID(), 'svTRID' => $svTRID,
]; ];
$epp = new EPP\EppWriter(); $epp = new EPP\EppWriter();
$xml = $epp->epp_writer($response); $xml = $epp->epp_writer($response);
updateTransaction($db, 'create', 'host', $hostName, 1000, 'Command completed successfully', $svTRID, $xml, $trans);
sendEppResponse($conn, $xml); sendEppResponse($conn, $xml);
} else { } else {
$stmt = $db->prepare("INSERT INTO host (name,clid,crid,crdate) VALUES(?,?,?,CURRENT_TIMESTAMP)"); $stmt = $db->prepare("INSERT INTO host (name,clid,crid,crdate) VALUES(?,?,?,CURRENT_TIMESTAMP)");
$stmt->execute([$hostName, $clid, $clid]); $stmt->execute([$hostName, $clid, $clid]);
@ -541,6 +544,7 @@ function processHostCreate($conn, $db, $xml, $clid, $database_type) {
$stmt->execute([$hostName]); $stmt->execute([$hostName]);
$crdate = $stmt->fetchColumn(); $crdate = $stmt->fetchColumn();
$svTRID = generateSvTRID();
$response = [ $response = [
'command' => 'create_host', 'command' => 'create_host',
'resultCode' => 1000, 'resultCode' => 1000,
@ -549,17 +553,18 @@ function processHostCreate($conn, $db, $xml, $clid, $database_type) {
'name' => $hostName, 'name' => $hostName,
'crDate' => $crdate, 'crDate' => $crdate,
'clTRID' => $clTRID, 'clTRID' => $clTRID,
'svTRID' => generateSvTRID(), 'svTRID' => $svTRID,
]; ];
$epp = new EPP\EppWriter(); $epp = new EPP\EppWriter();
$xml = $epp->epp_writer($response); $xml = $epp->epp_writer($response);
updateTransaction($db, 'create', 'host', $hostName, 1000, 'Command completed successfully', $svTRID, $xml, $trans);
sendEppResponse($conn, $xml); sendEppResponse($conn, $xml);
} }
} }
function processDomainCreate($conn, $db, $xml, $clid, $database_type) { function processDomainCreate($conn, $db, $xml, $clid, $database_type, $trans) {
$domainName = $xml->command->create->children('urn:ietf:params:xml:ns:domain-1.0')->create->name; $domainName = $xml->command->create->children('urn:ietf:params:xml:ns:domain-1.0')->create->name;
$clTRID = (string) $xml->command->clTRID; $clTRID = (string) $xml->command->clTRID;
@ -1190,6 +1195,7 @@ function processDomainCreate($conn, $db, $xml, $clid, $database_type) {
} }
$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()");
$svTRID = generateSvTRID();
$response = [ $response = [
'command' => 'create_domain', 'command' => 'create_domain',
'resultCode' => 1000, 'resultCode' => 1000,
@ -1199,10 +1205,11 @@ function processDomainCreate($conn, $db, $xml, $clid, $database_type) {
'crDate' => $crdate, 'crDate' => $crdate,
'exDate' => $exdate, 'exDate' => $exdate,
'clTRID' => $clTRID, 'clTRID' => $clTRID,
'svTRID' => generateSvTRID(), 'svTRID' => $svTRID,
]; ];
$epp = new EPP\EppWriter(); $epp = new EPP\EppWriter();
$xml = $epp->epp_writer($response); $xml = $epp->epp_writer($response);
updateTransaction($db, 'create', 'domain', $domainName, 1000, 'Command completed successfully', $svTRID, $xml, $trans);
sendEppResponse($conn, $xml); sendEppResponse($conn, $xml);
} }

View file

@ -1,6 +1,6 @@
<?php <?php
function processContactDelete($conn, $db, $xml, $clid, $database_type) { function processContactDelete($conn, $db, $xml, $clid, $database_type, $trans) {
$contactID = (string) $xml->command->delete->children('urn:ietf:params:xml:ns:contact-1.0')->delete->{'id'}; $contactID = (string) $xml->command->delete->children('urn:ietf:params:xml:ns:contact-1.0')->delete->{'id'};
$clTRID = (string) $xml->command->clTRID; $clTRID = (string) $xml->command->clTRID;
@ -73,21 +73,23 @@ function processContactDelete($conn, $db, $xml, $clid, $database_type) {
return; return;
} }
$svTRID = generateSvTRID();
$response = [ $response = [
'command' => 'delete_contact', 'command' => 'delete_contact',
'resultCode' => 1000, 'resultCode' => 1000,
'lang' => 'en-US', 'lang' => 'en-US',
'message' => 'Command completed successfully', 'message' => 'Command completed successfully',
'clTRID' => $clTRID, 'clTRID' => $clTRID,
'svTRID' => generateSvTRID(), 'svTRID' => $svTRID,
]; ];
$epp = new EPP\EppWriter(); $epp = new EPP\EppWriter();
$xml = $epp->epp_writer($response); $xml = $epp->epp_writer($response);
updateTransaction($db, 'delete', 'contact', $contact_id, 1000, 'Command completed successfully', $svTRID, $xml, $trans);
sendEppResponse($conn, $xml); sendEppResponse($conn, $xml);
} }
function processHostDelete($conn, $db, $xml, $clid, $database_type) { function processHostDelete($conn, $db, $xml, $clid, $database_type, $trans) {
$hostName = $xml->command->delete->children('urn:ietf:params:xml:ns:host-1.0')->delete->name; $hostName = $xml->command->delete->children('urn:ietf:params:xml:ns:host-1.0')->delete->name;
$clTRID = (string) $xml->command->clTRID; $clTRID = (string) $xml->command->clTRID;
@ -147,21 +149,23 @@ function processHostDelete($conn, $db, $xml, $clid, $database_type) {
return; return;
} }
$svTRID = generateSvTRID();
$response = [ $response = [
'command' => 'delete_host', 'command' => 'delete_host',
'resultCode' => 1000, 'resultCode' => 1000,
'lang' => 'en-US', 'lang' => 'en-US',
'message' => 'Command completed successfully', 'message' => 'Command completed successfully',
'clTRID' => $clTRID, 'clTRID' => $clTRID,
'svTRID' => generateSvTRID(), 'svTRID' => $svTRID,
]; ];
$epp = new EPP\EppWriter(); $epp = new EPP\EppWriter();
$xml = $epp->epp_writer($response); $xml = $epp->epp_writer($response);
updateTransaction($db, 'delete', 'host', $host_id, 1000, 'Command completed successfully', $svTRID, $xml, $trans);
sendEppResponse($conn, $xml); sendEppResponse($conn, $xml);
} }
function processDomainDelete($conn, $db, $xml, $clid, $database_type) { function processDomainDelete($conn, $db, $xml, $clid, $database_type, $trans) {
$domainName = $xml->command->delete->children('urn:ietf:params:xml:ns:domain-1.0')->delete->name; $domainName = $xml->command->delete->children('urn:ietf:params:xml:ns:domain-1.0')->delete->name;
$clTRID = (string) $xml->command->clTRID; $clTRID = (string) $xml->command->clTRID;
@ -378,16 +382,18 @@ function processDomainDelete($conn, $db, $xml, $clid, $database_type) {
} }
} }
$svTRID = generateSvTRID();
$response = [ $response = [
'command' => 'delete_domain', 'command' => 'delete_domain',
'resultCode' => 1001, 'resultCode' => 1001,
'lang' => 'en-US', 'lang' => 'en-US',
'message' => 'Command completed successfully; action pending', 'message' => 'Command completed successfully; action pending',
'clTRID' => $clTRID, 'clTRID' => $clTRID,
'svTRID' => generateSvTRID(), 'svTRID' => $svTRID,
]; ];
$epp = new EPP\EppWriter(); $epp = new EPP\EppWriter();
$xml = $epp->epp_writer($response); $xml = $epp->epp_writer($response);
updateTransaction($db, 'delete', 'domain', $domainName, 1000, 'Command completed successfully', $svTRID, $xml, $trans);
sendEppResponse($conn, $xml); sendEppResponse($conn, $xml);
} }

View file

@ -1,6 +1,6 @@
<?php <?php
function processPoll($conn, $db, $xml, $clid) { function processPoll($conn, $db, $xml, $clid, $trans) {
$clTRID = (string) $xml->command->clTRID; $clTRID = (string) $xml->command->clTRID;
$node = $xml->command->poll; $node = $xml->command->poll;
$op = (string) $node['op']; $op = (string) $node['op'];
@ -28,16 +28,18 @@ function processPoll($conn, $db, $xml, $clid) {
} }
if ((int) $response['resultCode'] === 1300) { if ((int) $response['resultCode'] === 1300) {
$svTRID = generateSvTRID();
$response = [ $response = [
'command' => 'poll', 'command' => 'poll',
'clTRID' => $clTRID, 'clTRID' => $clTRID,
'svTRID' => generateSvTRID(), 'svTRID' => $svTRID,
'resultCode' => $response['resultCode'], 'resultCode' => $response['resultCode'],
'msg' => 'Command completed successfully; no messages', 'msg' => 'Command completed successfully; no messages',
]; ];
$epp = new EPP\EppWriter(); $epp = new EPP\EppWriter();
$xml = $epp->epp_writer($response); $xml = $epp->epp_writer($response);
updateTransaction($db, 'poll', null, null, $response['resultCode'], 'Command completed successfully', $svTRID, $xml, $trans);
sendEppResponse($conn, $xml); sendEppResponse($conn, $xml);
return; return;
} }
@ -90,5 +92,6 @@ function processPoll($conn, $db, $xml, $clid) {
$epp = new EPP\EppWriter(); $epp = new EPP\EppWriter();
$xml = $epp->epp_writer($response); $xml = $epp->epp_writer($response);
updateTransaction($db, 'poll', null, $response['id'], $response['resultCode'], 'Command completed successfully', $response['svTRID'], $xml, $trans);
sendEppResponse($conn, $xml); sendEppResponse($conn, $xml);
} }

View file

@ -1,6 +1,6 @@
<?php <?php
function processDomainRenew($conn, $db, $xml, $clid, $database_type) { function processDomainRenew($conn, $db, $xml, $clid, $database_type, $trans) {
$domainName = (string) $xml->command->renew->children('urn:ietf:params:xml:ns:domain-1.0')->renew->name; $domainName = (string) $xml->command->renew->children('urn:ietf:params:xml:ns:domain-1.0')->renew->name;
$curExpDate = (string) $xml->command->renew->children('urn:ietf:params:xml:ns:domain-1.0')->renew->curExpDate; $curExpDate = (string) $xml->command->renew->children('urn:ietf:params:xml:ns:domain-1.0')->renew->curExpDate;
$periodElements = $xml->xpath("//domain:renew/domain:period"); $periodElements = $xml->xpath("//domain:renew/domain:period");
@ -187,6 +187,7 @@ function processDomainRenew($conn, $db, $xml, $clid, $database_type) {
$stmt = $db->prepare("UPDATE statistics SET renewed_domains = renewed_domains + 1 WHERE date = CURDATE()"); $stmt = $db->prepare("UPDATE statistics SET renewed_domains = renewed_domains + 1 WHERE date = CURDATE()");
$stmt->execute(); $stmt->execute();
$svTRID = generateSvTRID();
$response = [ $response = [
'command' => 'renew_domain', 'command' => 'renew_domain',
'resultCode' => 1000, 'resultCode' => 1000,
@ -195,10 +196,11 @@ function processDomainRenew($conn, $db, $xml, $clid, $database_type) {
'name' => $domainName, 'name' => $domainName,
'exDate' => $exdateUpdated, 'exDate' => $exdateUpdated,
'clTRID' => $clTRID, 'clTRID' => $clTRID,
'svTRID' => generateSvTRID(), 'svTRID' => $svTRID,
]; ];
$epp = new EPP\EppWriter(); $epp = new EPP\EppWriter();
$xml = $epp->epp_writer($response); $xml = $epp->epp_writer($response);
updateTransaction($db, 'renew', 'domain', $domainName, 1000, 'Command completed successfully', $svTRID, $xml, $trans);
sendEppResponse($conn, $xml); sendEppResponse($conn, $xml);
} }

View file

@ -1,6 +1,6 @@
<?php <?php
function processContactTranfer($conn, $db, $xml, $clid, $database_type) { function processContactTranfer($conn, $db, $xml, $clid, $database_type, $trans) {
$contactID = (string) $xml->command->transfer->children('urn:ietf:params:xml:ns:contact-1.0')->transfer->{'id'}; $contactID = (string) $xml->command->transfer->children('urn:ietf:params:xml:ns:contact-1.0')->transfer->{'id'};
$clTRID = (string) $xml->command->clTRID; $clTRID = (string) $xml->command->clTRID;
$op = (string) $xml->xpath('//@op')[0] ?? null; $op = (string) $xml->xpath('//@op')[0] ?? null;
@ -82,6 +82,7 @@ function processContactTranfer($conn, $db, $xml, $clid, $database_type) {
$acid_identifier_stmt->execute([':acid' => $updatedContactInfo['acid']]); $acid_identifier_stmt->execute([':acid' => $updatedContactInfo['acid']]);
$acid_identifier = $acid_identifier_stmt->fetchColumn(); $acid_identifier = $acid_identifier_stmt->fetchColumn();
$svTRID = generateSvTRID();
$response = [ $response = [
'command' => 'transfer_contact', 'command' => 'transfer_contact',
'resultCode' => 1000, 'resultCode' => 1000,
@ -94,11 +95,12 @@ function processContactTranfer($conn, $db, $xml, $clid, $database_type) {
'acID' => $acid_identifier, 'acID' => $acid_identifier,
'acDate' => $updatedContactInfo['acdate'], 'acDate' => $updatedContactInfo['acdate'],
'clTRID' => $clTRID, 'clTRID' => $clTRID,
'svTRID' => generateSvTRID(), 'svTRID' => $svTRID,
]; ];
$epp = new EPP\EppWriter(); $epp = new EPP\EppWriter();
$xml = $epp->epp_writer($response); $xml = $epp->epp_writer($response);
updateTransaction($db, 'transfer', 'contact', $identifier, 1000, 'Command completed successfully', $svTRID, $xml, $trans);
sendEppResponse($conn, $xml); sendEppResponse($conn, $xml);
} }
} else { } else {
@ -147,6 +149,7 @@ function processContactTranfer($conn, $db, $xml, $clid, $database_type) {
$acid_identifier_stmt->execute([':acid' => $updatedContactInfo['acid']]); $acid_identifier_stmt->execute([':acid' => $updatedContactInfo['acid']]);
$acid_identifier = $acid_identifier_stmt->fetchColumn(); $acid_identifier = $acid_identifier_stmt->fetchColumn();
$svTRID = generateSvTRID();
$response = [ $response = [
'command' => 'transfer_contact', 'command' => 'transfer_contact',
'resultCode' => 1000, 'resultCode' => 1000,
@ -159,11 +162,12 @@ function processContactTranfer($conn, $db, $xml, $clid, $database_type) {
'acID' => $acid_identifier, 'acID' => $acid_identifier,
'acDate' => $updatedContactInfo['acdate'], 'acDate' => $updatedContactInfo['acdate'],
'clTRID' => $clTRID, 'clTRID' => $clTRID,
'svTRID' => generateSvTRID(), 'svTRID' => $svTRID,
]; ];
$epp = new EPP\EppWriter(); $epp = new EPP\EppWriter();
$xml = $epp->epp_writer($response); $xml = $epp->epp_writer($response);
updateTransaction($db, 'transfer', 'contact', $identifier, 1000, 'Command completed successfully', $svTRID, $xml, $trans);
sendEppResponse($conn, $xml); sendEppResponse($conn, $xml);
} }
} else { } else {
@ -185,6 +189,7 @@ function processContactTranfer($conn, $db, $xml, $clid, $database_type) {
$acid_identifier_stmt->execute([':acid' => $contactInfo['acid']]); $acid_identifier_stmt->execute([':acid' => $contactInfo['acid']]);
$acid_identifier = $acid_identifier_stmt->fetchColumn(); $acid_identifier = $acid_identifier_stmt->fetchColumn();
$svTRID = generateSvTRID();
$response = [ $response = [
'command' => 'transfer_contact', 'command' => 'transfer_contact',
'resultCode' => 1000, 'resultCode' => 1000,
@ -197,11 +202,12 @@ function processContactTranfer($conn, $db, $xml, $clid, $database_type) {
'acID' => $acid_identifier, 'acID' => $acid_identifier,
'acDate' => $contactInfo['acdate'], 'acDate' => $contactInfo['acdate'],
'clTRID' => $clTRID, 'clTRID' => $clTRID,
'svTRID' => generateSvTRID(), 'svTRID' => $svTRID,
]; ];
$epp = new EPP\EppWriter(); $epp = new EPP\EppWriter();
$xml = $epp->epp_writer($response); $xml = $epp->epp_writer($response);
updateTransaction($db, 'transfer', 'contact', $identifier, 1000, 'Command completed successfully', $svTRID, $xml, $trans);
sendEppResponse($conn, $xml); sendEppResponse($conn, $xml);
} else { } else {
sendEppError($conn, 2301, 'Command failed because the contact is NOT pending transfer', $clTRID); sendEppError($conn, 2301, 'Command failed because the contact is NOT pending transfer', $clTRID);
@ -252,6 +258,7 @@ function processContactTranfer($conn, $db, $xml, $clid, $database_type) {
$acidStmt->execute([':acid' => $contactInfo['acid']]); $acidStmt->execute([':acid' => $contactInfo['acid']]);
$acid_identifier = $acidStmt->fetchColumn(); $acid_identifier = $acidStmt->fetchColumn();
$svTRID = generateSvTRID();
$response = [ $response = [
'command' => 'transfer_contact', 'command' => 'transfer_contact',
'resultCode' => 1000, 'resultCode' => 1000,
@ -264,11 +271,12 @@ function processContactTranfer($conn, $db, $xml, $clid, $database_type) {
'acID' => $acid_identifier, 'acID' => $acid_identifier,
'acDate' => $contactInfo['acdate'], 'acDate' => $contactInfo['acdate'],
'clTRID' => $clTRID, 'clTRID' => $clTRID,
'svTRID' => generateSvTRID(), 'svTRID' => $svTRID,
]; ];
$epp = new EPP\EppWriter(); $epp = new EPP\EppWriter();
$xml = $epp->epp_writer($response); $xml = $epp->epp_writer($response);
updateTransaction($db, 'transfer', 'contact', $identifier, 1000, 'Command completed successfully', $svTRID, $xml, $trans);
sendEppResponse($conn, $xml); sendEppResponse($conn, $xml);
} }
} else { } else {
@ -359,6 +367,7 @@ function processContactTranfer($conn, $db, $xml, $clid, $database_type) {
':acdate' => str_replace(" ", "T", $result['acdate']) . '.0Z' ':acdate' => str_replace(" ", "T", $result['acdate']) . '.0Z'
]); ]);
$svTRID = generateSvTRID();
$response = [ $response = [
'command' => 'transfer_contact', 'command' => 'transfer_contact',
'resultCode' => 1000, 'resultCode' => 1000,
@ -371,11 +380,12 @@ function processContactTranfer($conn, $db, $xml, $clid, $database_type) {
'acID' => $acid_identifier, 'acID' => $acid_identifier,
'acDate' => $result['acdate'], 'acDate' => $result['acdate'],
'clTRID' => $clTRID, 'clTRID' => $clTRID,
'svTRID' => generateSvTRID(), 'svTRID' => $svTRID,
]; ];
$epp = new EPP\EppWriter(); $epp = new EPP\EppWriter();
$xml = $epp->epp_writer($response); $xml = $epp->epp_writer($response);
updateTransaction($db, 'transfer', 'contact', $identifier, 1000, 'Command completed successfully', $svTRID, $xml, $trans);
sendEppResponse($conn, $xml); sendEppResponse($conn, $xml);
} }
} elseif ($op == 'pending') { } elseif ($op == 'pending') {
@ -389,7 +399,7 @@ function processContactTranfer($conn, $db, $xml, $clid, $database_type) {
} }
} }
function processDomainTransfer($conn, $db, $xml, $clid, $database_type) { function processDomainTransfer($conn, $db, $xml, $clid, $database_type, $trans) {
$domainName = (string) $xml->command->transfer->children('urn:ietf:params:xml:ns:domain-1.0')->transfer->name; $domainName = (string) $xml->command->transfer->children('urn:ietf:params:xml:ns:domain-1.0')->transfer->name;
$clTRID = (string) $xml->command->clTRID; $clTRID = (string) $xml->command->clTRID;
$op = (string) $xml->xpath('//@op')[0] ?? null; $op = (string) $xml->xpath('//@op')[0] ?? null;
@ -488,7 +498,7 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type) {
$to = $stmt->fetchColumn(); $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, :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, :command, :domain_name, :length_in_months, :from, :to, :amount)");
$stmt->execute(['registrar_id' => $reid, 'command' => $blob["cmd"], 'domain_name' => $domainName, 'length_in_months' => $date_add, 'from' => $from, 'to' => $to, 'amount' => $price]); $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`,`update`,`clid`,`crid`,`upid`,`trdate`,`trstatus`,`reid`,`redate`,`acid`,`acdate`,`transfer_exdate` FROM `domain` WHERE `name` = :name LIMIT 1");
$stmt->execute(['name' => $domainName]); $stmt->execute(['name' => $domainName]);
@ -515,6 +525,7 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type) {
$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(); $stmt->execute();
$svTRID = generateSvTRID();
$response = [ $response = [
'command' => 'transfer_domain', 'command' => 'transfer_domain',
'resultCode' => 1000, 'resultCode' => 1000,
@ -527,7 +538,7 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type) {
'acID' => $acid_identifier, 'acID' => $acid_identifier,
'acDate' => $acdate, 'acDate' => $acdate,
'clTRID' => $clTRID, 'clTRID' => $clTRID,
'svTRID' => generateSvTRID(), 'svTRID' => $svTRID,
]; ];
if ($transfer_exdate) { if ($transfer_exdate) {
@ -536,6 +547,7 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type) {
$epp = new EPP\EppWriter(); $epp = new EPP\EppWriter();
$xml = $epp->epp_writer($response); $xml = $epp->epp_writer($response);
updateTransaction($db, 'transfer', 'domain', $domainName, 1000, 'Command completed successfully', $svTRID, $xml, $trans);
sendEppResponse($conn, $xml); sendEppResponse($conn, $xml);
} }
} else { } else {
@ -587,6 +599,7 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type) {
$stmt->execute(['acid' => $acid]); $stmt->execute(['acid' => $acid]);
$acid_identifier = $stmt->fetchColumn(); $acid_identifier = $stmt->fetchColumn();
$svTRID = generateSvTRID();
$response = [ $response = [
'command' => 'transfer_domain', 'command' => 'transfer_domain',
'resultCode' => 1000, 'resultCode' => 1000,
@ -599,7 +612,7 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type) {
'acID' => $acid_identifier, 'acID' => $acid_identifier,
'acDate' => $acdate, 'acDate' => $acdate,
'clTRID' => $clTRID, 'clTRID' => $clTRID,
'svTRID' => generateSvTRID(), 'svTRID' => $svTRID,
]; ];
if ($transfer_exdate) { if ($transfer_exdate) {
@ -608,6 +621,7 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type) {
$epp = new EPP\EppWriter(); $epp = new EPP\EppWriter();
$xml = $epp->epp_writer($response); $xml = $epp->epp_writer($response);
updateTransaction($db, 'transfer', 'domain', $domainName, 1000, 'Command completed successfully', $svTRID, $xml, $trans);
sendEppResponse($conn, $xml); sendEppResponse($conn, $xml);
} }
} else { } else {
@ -633,6 +647,7 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type) {
$stmtAcID->execute(['acid' => $acid]); $stmtAcID->execute(['acid' => $acid]);
$acid_identifier = $stmtAcID->fetchColumn(); $acid_identifier = $stmtAcID->fetchColumn();
$svTRID = generateSvTRID();
$response = [ $response = [
'command' => 'transfer_domain', 'command' => 'transfer_domain',
'resultCode' => 1000, 'resultCode' => 1000,
@ -645,7 +660,7 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type) {
'acID' => $acid_identifier, 'acID' => $acid_identifier,
'acDate' => $acdate, 'acDate' => $acdate,
'clTRID' => $clTRID, 'clTRID' => $clTRID,
'svTRID' => generateSvTRID(), 'svTRID' => $svTRID,
]; ];
if ($transfer_exdate) { if ($transfer_exdate) {
@ -654,16 +669,12 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type) {
$epp = new EPP\EppWriter(); $epp = new EPP\EppWriter();
$xml = $epp->epp_writer($response); $xml = $epp->epp_writer($response);
updateTransaction($db, 'transfer', 'domain', $domainName, 1000, 'Command completed successfully', $svTRID, $xml, $trans);
sendEppResponse($conn, $xml); sendEppResponse($conn, $xml);
} else { } else {
sendEppError($conn, 2301, 'The domain is NOT pending transfer', $clTRID); sendEppError($conn, 2301, 'The domain is NOT pending transfer', $clTRID);
return; return;
} }
$msg = epp_writer($blob);
echo $msg;
$uptr = update_transaction($msg);
exit;
} }
elseif ($op === 'reject') { elseif ($op === 'reject') {
@ -704,6 +715,7 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type) {
$stmtAcID->execute(['acid' => $acid]); $stmtAcID->execute(['acid' => $acid]);
$acid_identifier = $stmtAcID->fetchColumn(); $acid_identifier = $stmtAcID->fetchColumn();
$svTRID = generateSvTRID();
$response = [ $response = [
'command' => 'transfer_domain', 'command' => 'transfer_domain',
'resultCode' => 1000, 'resultCode' => 1000,
@ -716,7 +728,7 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type) {
'acID' => $acid_identifier, 'acID' => $acid_identifier,
'acDate' => $acdate, 'acDate' => $acdate,
'clTRID' => $clTRID, 'clTRID' => $clTRID,
'svTRID' => generateSvTRID(), 'svTRID' => $svTRID,
]; ];
if ($transfer_exdate) { if ($transfer_exdate) {
@ -725,6 +737,7 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type) {
$epp = new EPP\EppWriter(); $epp = new EPP\EppWriter();
$xml = $epp->epp_writer($response); $xml = $epp->epp_writer($response);
updateTransaction($db, 'transfer', 'domain', $domainName, 1000, 'Command completed successfully', $svTRID, $xml, $trans);
sendEppResponse($conn, $xml); sendEppResponse($conn, $xml);
} }
} else { } else {
@ -893,6 +906,7 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type) {
':transfer_exdate' => $transfer_exdate ':transfer_exdate' => $transfer_exdate
]); ]);
$svTRID = generateSvTRID();
$response = [ $response = [
'command' => 'transfer_domain', 'command' => 'transfer_domain',
'resultCode' => 1001, 'resultCode' => 1001,
@ -905,7 +919,7 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type) {
'acID' => $acid_identifier, 'acID' => $acid_identifier,
'acDate' => $acdate, 'acDate' => $acdate,
'clTRID' => $clTRID, 'clTRID' => $clTRID,
'svTRID' => generateSvTRID(), 'svTRID' => $svTRID,
]; ];
if ($transfer_exdate) { if ($transfer_exdate) {
@ -914,6 +928,7 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type) {
$epp = new EPP\EppWriter(); $epp = new EPP\EppWriter();
$xml = $epp->epp_writer($response); $xml = $epp->epp_writer($response);
updateTransaction($db, 'transfer', 'domain', $domainName, 1000, 'Command completed successfully', $svTRID, $xml, $trans);
sendEppResponse($conn, $xml); sendEppResponse($conn, $xml);
} }
} else { } else {
@ -979,6 +994,7 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type) {
$epp = new EPP\EppWriter(); $epp = new EPP\EppWriter();
$xml = $epp->epp_writer($response); $xml = $epp->epp_writer($response);
updateTransaction($db, 'transfer', 'domain', $domainName, 1000, 'Command completed successfully', $svTRID, $xml, $trans);
sendEppResponse($conn, $xml); sendEppResponse($conn, $xml);
} }
} }

View file

@ -1,6 +1,6 @@
<?php <?php
function processContactUpdate($conn, $db, $xml, $clid, $database_type) { function processContactUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
$contactID = (string) $xml->command->update->children('urn:ietf:params:xml:ns:contact-1.0')->update->{'id'}; $contactID = (string) $xml->command->update->children('urn:ietf:params:xml:ns:contact-1.0')->update->{'id'};
$clTRID = (string) $xml->command->clTRID; $clTRID = (string) $xml->command->clTRID;
@ -604,21 +604,23 @@ function processContactUpdate($conn, $db, $xml, $clid, $database_type) {
} }
} }
$svTRID = generateSvTRID();
$response = [ $response = [
'command' => 'update_contact', 'command' => 'update_contact',
'resultCode' => 1000, 'resultCode' => 1000,
'lang' => 'en-US', 'lang' => 'en-US',
'message' => 'Command completed successfully', 'message' => 'Command completed successfully',
'clTRID' => $clTRID, 'clTRID' => $clTRID,
'svTRID' => generateSvTRID(), 'svTRID' => $svTRID,
]; ];
$epp = new EPP\EppWriter(); $epp = new EPP\EppWriter();
$xml = $epp->epp_writer($response); $xml = $epp->epp_writer($response);
updateTransaction($db, 'update', 'contact', $contact_id, 1000, 'Command completed successfully', $svTRID, $xml, $trans);
sendEppResponse($conn, $xml); sendEppResponse($conn, $xml);
} }
function processHostUpdate($conn, $db, $xml, $clid, $database_type) { function processHostUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
$name = (string) $xml->command->update->children('urn:ietf:params:xml:ns:host-1.0')->update->name; $name = (string) $xml->command->update->children('urn:ietf:params:xml:ns:host-1.0')->update->name;
$clTRID = (string) $xml->command->clTRID; $clTRID = (string) $xml->command->clTRID;
@ -915,21 +917,23 @@ function processHostUpdate($conn, $db, $xml, $clid, $database_type) {
$stmt->execute([$chg_name, $name]); $stmt->execute([$chg_name, $name]);
} }
$svTRID = generateSvTRID();
$response = [ $response = [
'command' => 'update_host', 'command' => 'update_host',
'resultCode' => 1000, 'resultCode' => 1000,
'lang' => 'en-US', 'lang' => 'en-US',
'message' => 'Command completed successfully', 'message' => 'Command completed successfully',
'clTRID' => $clTRID, 'clTRID' => $clTRID,
'svTRID' => generateSvTRID(), 'svTRID' => $svTRID,
]; ];
$epp = new EPP\EppWriter(); $epp = new EPP\EppWriter();
$xml = $epp->epp_writer($response); $xml = $epp->epp_writer($response);
updateTransaction($db, 'update', 'host', $hostId, 1000, 'Command completed successfully', $svTRID, $xml, $trans);
sendEppResponse($conn, $xml); sendEppResponse($conn, $xml);
} }
function processDomainUpdate($conn, $db, $xml, $clid, $database_type) { function processDomainUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
$domainName = (string) $xml->command->update->children('urn:ietf:params:xml:ns:domain-1.0')->update->name; $domainName = (string) $xml->command->update->children('urn:ietf:params:xml:ns:domain-1.0')->update->name;
$clTRID = (string) $xml->command->clTRID; $clTRID = (string) $xml->command->clTRID;
@ -1726,17 +1730,19 @@ function processDomainUpdate($conn, $db, $xml, $clid, $database_type) {
} }
} }
$svTRID = generateSvTRID();
$response = [ $response = [
'command' => 'update_domain', 'command' => 'update_domain',
'resultCode' => 1000, 'resultCode' => 1000,
'lang' => 'en-US', 'lang' => 'en-US',
'message' => 'Command completed successfully', 'message' => 'Command completed successfully',
'clTRID' => $clTRID, 'clTRID' => $clTRID,
'svTRID' => generateSvTRID(), 'svTRID' => $svTRID,
]; ];
$epp = new EPP\EppWriter(); $epp = new EPP\EppWriter();
$xml = $epp->epp_writer($response); $xml = $epp->epp_writer($response);
updateTransaction($db, 'update', 'domain', $domainName, 1000, 'Command completed successfully', $svTRID, $xml, $trans);
sendEppResponse($conn, $xml); sendEppResponse($conn, $xml);
} }

View file

@ -158,7 +158,7 @@ $server->handle(function (Connection $conn) use ($table, $db, $c) {
sendEppError($conn, 2202, 'Authorization error', $clTRID); sendEppError($conn, 2202, 'Authorization error', $clTRID);
$conn->close(); $conn->close();
} }
processPoll($conn, $db, $xml, $data['clid']); processPoll($conn, $db, $xml, $data['clid'], $trans);
break; break;
} }
@ -188,7 +188,7 @@ $server->handle(function (Connection $conn) use ($table, $db, $c) {
sendEppError($conn, 2202, 'Authorization error', $clTRID); sendEppError($conn, 2202, 'Authorization error', $clTRID);
$conn->close(); $conn->close();
} }
processContactCreate($conn, $db, $xml, $data['clid'], $c['db_type']); processContactCreate($conn, $db, $xml, $data['clid'], $c['db_type'], $trans);
break; break;
} }
@ -218,7 +218,7 @@ $server->handle(function (Connection $conn) use ($table, $db, $c) {
sendEppError($conn, 2202, 'Authorization error', $clTRID); sendEppError($conn, 2202, 'Authorization error', $clTRID);
$conn->close(); $conn->close();
} }
processContactUpdate($conn, $db, $xml, $data['clid'], $c['db_type']); processContactUpdate($conn, $db, $xml, $data['clid'], $c['db_type'], $trans);
break; break;
} }
@ -233,7 +233,7 @@ $server->handle(function (Connection $conn) use ($table, $db, $c) {
sendEppError($conn, 2202, 'Authorization error', $clTRID); sendEppError($conn, 2202, 'Authorization error', $clTRID);
$conn->close(); $conn->close();
} }
processContactDelete($conn, $db, $xml, $data['clid'], $c['db_type']); processContactDelete($conn, $db, $xml, $data['clid'], $c['db_type'], $trans);
break; break;
} }
@ -248,7 +248,7 @@ $server->handle(function (Connection $conn) use ($table, $db, $c) {
sendEppError($conn, 2202, 'Authorization error', $clTRID); sendEppError($conn, 2202, 'Authorization error', $clTRID);
$conn->close(); $conn->close();
} }
processContactTransfer($conn, $db, $xml, $data['clid'], $c['db_type']); processContactTransfer($conn, $db, $xml, $data['clid'], $c['db_type'], $trans);
break; break;
} }
@ -293,7 +293,7 @@ $server->handle(function (Connection $conn) use ($table, $db, $c) {
sendEppError($conn, 2202, 'Authorization error', $clTRID); sendEppError($conn, 2202, 'Authorization error', $clTRID);
$conn->close(); $conn->close();
} }
processDomainUpdate($conn, $db, $xml, $data['clid'], $c['db_type']); processDomainUpdate($conn, $db, $xml, $data['clid'], $c['db_type'], $trans);
break; break;
} }
@ -308,7 +308,7 @@ $server->handle(function (Connection $conn) use ($table, $db, $c) {
sendEppError($conn, 2202, 'Authorization error', $clTRID); sendEppError($conn, 2202, 'Authorization error', $clTRID);
$conn->close(); $conn->close();
} }
processDomainCreate($conn, $db, $xml, $data['clid'], $c['db_type']); processDomainCreate($conn, $db, $xml, $data['clid'], $c['db_type'], $trans);
break; break;
} }
@ -323,7 +323,7 @@ $server->handle(function (Connection $conn) use ($table, $db, $c) {
sendEppError($conn, 2202, 'Authorization error', $clTRID); sendEppError($conn, 2202, 'Authorization error', $clTRID);
$conn->close(); $conn->close();
} }
processDomainDelete($conn, $db, $xml, $data['clid'], $c['db_type']); processDomainDelete($conn, $db, $xml, $data['clid'], $c['db_type'], $trans);
break; break;
} }
@ -338,7 +338,7 @@ $server->handle(function (Connection $conn) use ($table, $db, $c) {
sendEppError($conn, 2202, 'Authorization error', $clTRID); sendEppError($conn, 2202, 'Authorization error', $clTRID);
$conn->close(); $conn->close();
} }
processDomainTransfer($conn, $db, $xml, $data['clid'], $c['db_type']); processDomainTransfer($conn, $db, $xml, $data['clid'], $c['db_type'], $trans);
break; break;
} }
@ -368,7 +368,7 @@ $server->handle(function (Connection $conn) use ($table, $db, $c) {
sendEppError($conn, 2202, 'Authorization error', $clTRID); sendEppError($conn, 2202, 'Authorization error', $clTRID);
$conn->close(); $conn->close();
} }
processHostCreate($conn, $db, $xml, $data['clid'], $c['db_type']); processHostCreate($conn, $db, $xml, $data['clid'], $c['db_type'], $trans);
break; break;
} }
@ -398,7 +398,7 @@ $server->handle(function (Connection $conn) use ($table, $db, $c) {
sendEppError($conn, 2202, 'Authorization error', $clTRID); sendEppError($conn, 2202, 'Authorization error', $clTRID);
$conn->close(); $conn->close();
} }
processHostUpdate($conn, $db, $xml, $data['clid'], $c['db_type']); processHostUpdate($conn, $db, $xml, $data['clid'], $c['db_type'], $trans);
break; break;
} }
@ -413,7 +413,7 @@ $server->handle(function (Connection $conn) use ($table, $db, $c) {
sendEppError($conn, 2202, 'Authorization error', $clTRID); sendEppError($conn, 2202, 'Authorization error', $clTRID);
$conn->close(); $conn->close();
} }
processHostDelete($conn, $db, $xml, $data['clid'], $c['db_type']); processHostDelete($conn, $db, $xml, $data['clid'], $c['db_type'], $trans);
break; break;
} }
@ -443,7 +443,7 @@ $server->handle(function (Connection $conn) use ($table, $db, $c) {
sendEppError($conn, 2202, 'Authorization error', $clTRID); sendEppError($conn, 2202, 'Authorization error', $clTRID);
$conn->close(); $conn->close();
} }
processDomainRenew($conn, $db, $xml, $data['clid'], $c['db_type']); processDomainRenew($conn, $db, $xml, $data['clid'], $c['db_type'], $trans);
break; break;
} }