Added epp log for check and info

This commit is contained in:
Pinga 2023-08-25 15:56:31 +03:00
parent 5674434894
commit c6ab5572ca
3 changed files with 45 additions and 22 deletions

View file

@ -1,6 +1,6 @@
<?php <?php
function processContactCheck($conn, $db, $xml) { function processContactCheck($conn, $db, $xml, $trans) {
$contactIDs = $xml->command->check->children('urn:ietf:params:xml:ns:contact-1.0')->check->{'id'}; $contactIDs = $xml->command->check->children('urn:ietf:params:xml:ns:contact-1.0')->check->{'id'};
$clTRID = (string) $xml->command->clTRID; $clTRID = (string) $xml->command->clTRID;
@ -35,6 +35,7 @@ function processContactCheck($conn, $db, $xml) {
$ids[] = $entry; $ids[] = $entry;
} }
$svTRID = generateSvTRID();
$response = [ $response = [
'command' => 'check_contact', 'command' => 'check_contact',
'resultCode' => 1000, 'resultCode' => 1000,
@ -42,15 +43,19 @@ function processContactCheck($conn, $db, $xml) {
'message' => 'Command completed successfully', 'message' => 'Command completed successfully',
'ids' => $ids, 'ids' => $ids,
'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);
if (is_array($ids)) {
$ids = implode(',', array_column($ids, 0));
}
updateTransaction($db, 'check', 'contact', $ids, 1000, 'Command completed successfully', $svTRID, $xml, $trans);
sendEppResponse($conn, $xml); sendEppResponse($conn, $xml);
} }
function processHostCheck($conn, $db, $xml) { function processHostCheck($conn, $db, $xml, $trans) {
$hosts = $xml->command->check->children('urn:ietf:params:xml:ns:host-1.0')->check->{'name'}; $hosts = $xml->command->check->children('urn:ietf:params:xml:ns:host-1.0')->check->{'name'};
$clTRID = (string) $xml->command->clTRID; $clTRID = (string) $xml->command->clTRID;
@ -80,6 +85,7 @@ function processHostCheck($conn, $db, $xml) {
$names[] = $entry; $names[] = $entry;
} }
$svTRID = generateSvTRID();
$response = [ $response = [
'command' => 'check_host', 'command' => 'check_host',
'resultCode' => 1000, 'resultCode' => 1000,
@ -87,15 +93,19 @@ function processHostCheck($conn, $db, $xml) {
'message' => 'Command completed successfully', 'message' => 'Command completed successfully',
'names' => $names, 'names' => $names,
'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);
if (is_array($names)) {
$names = implode(',', array_column($names, 0));
}
updateTransaction($db, 'check', 'host', $names, 1000, 'Command completed successfully', $svTRID, $xml, $trans);
sendEppResponse($conn, $xml); sendEppResponse($conn, $xml);
} }
function processDomainCheck($conn, $db, $xml) { function processDomainCheck($conn, $db, $xml, $trans) {
$domains = $xml->command->check->children('urn:ietf:params:xml:ns:domain-1.0')->check->name; $domains = $xml->command->check->children('urn:ietf:params:xml:ns:domain-1.0')->check->name;
$clTRID = (string) $xml->command->clTRID; $clTRID = (string) $xml->command->clTRID;
@ -132,6 +142,7 @@ function processDomainCheck($conn, $db, $xml) {
$names[] = $domainEntry; $names[] = $domainEntry;
} }
$svTRID = generateSvTRID();
$response = [ $response = [
'command' => 'check_domain', 'command' => 'check_domain',
'resultCode' => 1000, 'resultCode' => 1000,
@ -139,10 +150,14 @@ function processDomainCheck($conn, $db, $xml) {
'message' => 'Command completed successfully', 'message' => 'Command completed successfully',
'names' => $names, 'names' => $names,
'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);
if (is_array($names)) {
$names = implode(',', array_column($names, 0));
}
updateTransaction($db, 'check', 'domain', $names, 1000, 'Command completed successfully', $svTRID, $xml, $trans);
sendEppResponse($conn, $xml); sendEppResponse($conn, $xml);
} }

View file

@ -1,6 +1,6 @@
<?php <?php
function processContactInfo($conn, $db, $xml) { function processContactInfo($conn, $db, $xml, $trans) {
$contactID = (string) $xml->command->info->children('urn:ietf:params:xml:ns:contact-1.0')->info->{'id'}; $contactID = (string) $xml->command->info->children('urn:ietf:params:xml:ns:contact-1.0')->info->{'id'};
$clTRID = (string) $xml->command->clTRID; $clTRID = (string) $xml->command->clTRID;
@ -56,10 +56,11 @@ function processContactInfo($conn, $db, $xml) {
]; ];
} }
$svTRID = generateSvTRID();
$response = [ $response = [
'command' => 'info_contact', 'command' => 'info_contact',
'clTRID' => $clTRID, 'clTRID' => $clTRID,
'svTRID' => generateSvTRID(), 'svTRID' => $svTRID,
'resultCode' => 1000, 'resultCode' => 1000,
'msg' => 'Command completed successfully', 'msg' => 'Command completed successfully',
'id' => $contact['id'], 'id' => $contact['id'],
@ -81,6 +82,7 @@ function processContactInfo($conn, $db, $xml) {
$epp = new EPP\EppWriter(); $epp = new EPP\EppWriter();
$xml = $epp->epp_writer($response); $xml = $epp->epp_writer($response);
updateTransaction($db, 'info', 'contact', 'C_'.$contact['identifier'], 1000, 'Command completed successfully', $svTRID, $xml, $trans);
sendEppResponse($conn, $xml); sendEppResponse($conn, $xml);
} catch (PDOException $e) { } catch (PDOException $e) {
@ -88,7 +90,7 @@ function processContactInfo($conn, $db, $xml) {
} }
} }
function processHostInfo($conn, $db, $xml) { function processHostInfo($conn, $db, $xml, $trans) {
$hostName = $xml->command->info->children('urn:ietf:params:xml:ns:host-1.0')->info->name; $hostName = $xml->command->info->children('urn:ietf:params:xml:ns:host-1.0')->info->name;
$clTRID = (string) $xml->command->clTRID; $clTRID = (string) $xml->command->clTRID;
@ -138,10 +140,11 @@ function processHostInfo($conn, $db, $xml) {
$statusArray[] = ['linked']; $statusArray[] = ['linked'];
} }
$svTRID = generateSvTRID();
$response = [ $response = [
'command' => 'info_host', 'command' => 'info_host',
'clTRID' => $clTRID, 'clTRID' => $clTRID,
'svTRID' => generateSvTRID(), 'svTRID' => $svTRID,
'resultCode' => 1000, 'resultCode' => 1000,
'msg' => 'Command completed successfully', 'msg' => 'Command completed successfully',
'name' => $host['name'], 'name' => $host['name'],
@ -158,13 +161,14 @@ function processHostInfo($conn, $db, $xml) {
$epp = new EPP\EppWriter(); $epp = new EPP\EppWriter();
$xml = $epp->epp_writer($response); $xml = $epp->epp_writer($response);
updateTransaction($db, 'info', 'host', 'H_'.$host['id'], 1000, 'Command completed successfully', $svTRID, $xml, $trans);
sendEppResponse($conn, $xml); sendEppResponse($conn, $xml);
} catch (PDOException $e) { } catch (PDOException $e) {
sendEppError($conn, 2400, 'Database error', $clTRID); sendEppError($conn, 2400, 'Database error', $clTRID);
} }
} }
function processDomainInfo($conn, $db, $xml) { function processDomainInfo($conn, $db, $xml, $trans) {
$domainName = $xml->command->info->children('urn:ietf:params:xml:ns:domain-1.0')->info->name; $domainName = $xml->command->info->children('urn:ietf:params:xml:ns:domain-1.0')->info->name;
$clTRID = (string) $xml->command->clTRID; $clTRID = (string) $xml->command->clTRID;
@ -226,10 +230,11 @@ function processDomainInfo($conn, $db, $xml) {
$statusArray[] = [$status['status']]; $statusArray[] = [$status['status']];
} }
$svTRID = generateSvTRID();
$response = [ $response = [
'command' => 'info_domain', 'command' => 'info_domain',
'clTRID' => $clTRID, 'clTRID' => $clTRID,
'svTRID' => generateSvTRID(), 'svTRID' => $svTRID,
'resultCode' => 1000, 'resultCode' => 1000,
'msg' => 'Command completed successfully', 'msg' => 'Command completed successfully',
'name' => $domain['name'], 'name' => $domain['name'],
@ -252,13 +257,14 @@ function processDomainInfo($conn, $db, $xml) {
$epp = new EPP\EppWriter(); $epp = new EPP\EppWriter();
$xml = $epp->epp_writer($response); $xml = $epp->epp_writer($response);
updateTransaction($db, 'info', 'domain', 'D_'.$domain['id'], 1000, 'Command completed successfully', $svTRID, $xml, $trans);
sendEppResponse($conn, $xml); sendEppResponse($conn, $xml);
} catch (PDOException $e) { } catch (PDOException $e) {
sendEppError($conn, 2400, 'Database error', $clTRID); sendEppError($conn, 2400, 'Database error', $clTRID);
} }
} }
function processFundsInfo($conn, $db, $xml, $clid) { function processFundsInfo($conn, $db, $xml, $clid, $trans) {
$clTRID = (string) $xml->command->clTRID; $clTRID = (string) $xml->command->clTRID;
try { try {
@ -276,10 +282,11 @@ function processFundsInfo($conn, $db, $xml, $clid) {
return; return;
} }
$svTRID = generateSvTRID();
$response = [ $response = [
'command' => 'info_funds', 'command' => 'info_funds',
'clTRID' => $clTRID, 'clTRID' => $clTRID,
'svTRID' => generateSvTRID(), 'svTRID' => $svTRID,
'resultCode' => 1000, 'resultCode' => 1000,
'msg' => 'Command completed successfully', 'msg' => 'Command completed successfully',
'funds' => $funds['accountBalance'], 'funds' => $funds['accountBalance'],
@ -292,6 +299,7 @@ function processFundsInfo($conn, $db, $xml, $clid) {
$epp = new EPP\EppWriter(); $epp = new EPP\EppWriter();
$xml = $epp->epp_writer($response); $xml = $epp->epp_writer($response);
updateTransaction($db, 'info', null, $funds['accountBalance'], 1000, 'Command completed successfully', $svTRID, $xml, $trans);
sendEppResponse($conn, $xml); sendEppResponse($conn, $xml);
} catch (PDOException $e) { } catch (PDOException $e) {

View file

@ -173,7 +173,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();
} }
processContactCheck($conn, $db, $xml); processContactCheck($conn, $db, $xml, $trans);
break; break;
} }
@ -203,7 +203,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();
} }
processContactInfo($conn, $db, $xml); processContactInfo($conn, $db, $xml, $trans);
break; break;
} }
@ -263,7 +263,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();
} }
processDomainCheck($conn, $db, $xml); processDomainCheck($conn, $db, $xml, $trans);
break; break;
} }
@ -278,7 +278,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();
} }
processDomainInfo($conn, $db, $xml); processDomainInfo($conn, $db, $xml, $trans);
break; break;
} }
@ -353,7 +353,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();
} }
processHostCheck($conn, $db, $xml); processHostCheck($conn, $db, $xml, $trans);
break; break;
} }
@ -383,7 +383,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();
} }
processHostInfo($conn, $db, $xml); processHostInfo($conn, $db, $xml, $trans);
break; break;
} }
@ -428,7 +428,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();
} }
processFundsInfo($conn, $db, $xml, $data['clid']); processFundsInfo($conn, $db, $xml, $data['clid'], $trans);
break; break;
} }