This commit is contained in:
Pinga 2023-12-19 20:59:05 +02:00
parent 1f7bdb8c64
commit 40e2b1ab54

View file

@ -172,6 +172,13 @@ function processDomainInfo($conn, $db, $xml, $trans) {
$domainName = $xml->command->info->children('urn:ietf:params:xml:ns:domain-1.0')->info->name;
$clTRID = (string) $xml->command->clTRID;
$result = $xml->xpath('//domain:authInfo/domain:pw[1]');
if (!empty($result)) {
$authInfo_pw = (string)$result[0];
} else {
$authInfo_pw = null;
}
// Validation for domain name
$invalid_label = validate_label($domainName, $db);
if ($invalid_label) {
@ -195,6 +202,17 @@ function processDomainInfo($conn, $db, $xml, $trans) {
return;
}
if ($authInfo_pw) {
$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();
if (!$domain_authinfo_id) {
sendEppError($conn, $db, 2202, 'authInfo pw is not correct', $clTRID, $trans);
return;
}
}
// Fetch contacts
$stmt = $db->prepare("SELECT * FROM domain_contact_map WHERE domain_id = :id");
$stmt->execute(['id' => $domain['id']]);
@ -241,6 +259,11 @@ function processDomainInfo($conn, $db, $xml, $trans) {
$stmt->execute(['id' => $domain['id']]);
$secDnsRecords = $stmt->fetchAll(PDO::FETCH_ASSOC);
// Fetch registrant identifier
$stmt = $db->prepare("SELECT identifier FROM contact WHERE id = :id");
$stmt->execute(['id' => $domain['registrant']]);
$registrant_id = $stmt->fetch(PDO::FETCH_COLUMN);
$transformedSecDnsRecords = [];
if ($secDnsRecords) {
foreach ($secDnsRecords as $record) {
@ -285,15 +308,12 @@ function processDomainInfo($conn, $db, $xml, $trans) {
'name' => $domain['name'],
'roid' => 'D' . $domain['id'],
'status' => $statusArray,
'registrant' => $domain['registrant'],
'registrant' => $registrant_id,
'contact' => $transformedContacts,
'clID' => getRegistrarClid($db, $domain['clid']),
'crID' => getRegistrarClid($db, $domain['crid']),
'crDate' => $domain['crdate'],
'exDate' => $domain['exdate'],
'authInfo' => 'valid',
'authInfo_type' => $authInfo['authtype'],
'authInfo_val' => $authInfo['authinfo']
'exDate' => $domain['exdate']
];
// Conditionally add upID, upDate, and trDate to the response
if (isset($domain['upid']) && $domain['upid']) {
@ -305,6 +325,13 @@ function processDomainInfo($conn, $db, $xml, $trans) {
if (isset($domain['trdate']) && $domain['trdate']) {
$response['trDate'] = $domain['trdate'];
}
if (isset($domain_authinfo_id) && $domain_authinfo_id) {
$response['authInfo'] = 'valid';
$response['authInfo_type'] = $authInfo['authtype'];
$response['authInfo_val'] = $authInfo['authinfo'];
} else {
$response['authInfo'] = 'invalid';
}
// Conditionally add hostObj if hosts are available from domain_host_map
if (!empty($transformedHosts)) {
@ -346,7 +373,7 @@ function processFundsInfo($conn, $db, $xml, $clid, $trans) {
$creditBalance = ($funds['accountBalance'] < 0) ? -$funds['accountBalance'] : 0;
$availableCredit = $funds['creditLimit'] - $creditBalance;
$availableCredit = number_format($availableCredit, 2, '.', '');
$availableCredit = number_format($availableCredit, 2, '.', '');
if (!$funds) {
sendEppError($conn, $db, 2303, 'Registrar does not exist', $clTRID, $trans);