EPP whois disclose fix

This commit is contained in:
Pinga 2024-09-05 12:26:32 +03:00
parent bcb4d50fcd
commit 9ca1c7f6c9

View file

@ -339,45 +339,47 @@ function processContactUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
}
$contact_disclose = $xml->xpath('//contact:disclose');
$disclose_voice = 1;
$disclose_fax = 1;
$disclose_email = 1;
$disclose_name_int = 1;
$disclose_name_loc = 1;
$disclose_org_int = 1;
$disclose_org_loc = 1;
$disclose_addr_int = 1;
$disclose_addr_loc = 1;
$disclose = [
'voice' => 1,
'fax' => 1,
'email' => 1,
'name_int' => 1,
'name_loc' => 1,
'org_int' => 1,
'org_loc' => 1,
'addr_int' => 1,
'addr_loc' => 1,
];
foreach ($contact_disclose as $node_disclose) {
foreach ($xml->xpath('//contact:disclose') as $node_disclose) {
$flag = (string)$node_disclose['flag'];
if ($node_disclose->xpath('contact:voice')) {
$disclose_voice = $flag;
$disclose['voice'] = $flag;
}
if ($node_disclose->xpath('contact:fax')) {
$disclose_fax = $flag;
$disclose['fax'] = $flag;
}
if ($node_disclose->xpath('contact:email')) {
$disclose_email = $flag;
$disclose['email'] = $flag;
}
if ($node_disclose->xpath('contact:name[@type="int"]')) {
$disclose_name_int = $flag;
$disclose['name_int'] = $flag;
}
if ($node_disclose->xpath('contact:name[@type="loc"]')) {
$disclose_name_loc = $flag;
$disclose['name_loc'] = $flag;
}
if ($node_disclose->xpath('contact:org[@type="int"]')) {
$disclose_org_int = $flag;
$disclose['org_int'] = $flag;
}
if ($node_disclose->xpath('contact:org[@type="loc"]')) {
$disclose_org_loc = $flag;
$disclose['org_loc'] = $flag;
}
if ($node_disclose->xpath('contact:addr[@type="int"]')) {
$disclose_addr_int = $flag;
$disclose['addr_int'] = $flag;
}
if ($node_disclose->xpath('contact:addr[@type="loc"]')) {
$disclose_addr_loc = $flag;
$disclose['addr_loc'] = $flag;
}
}
@ -433,7 +435,7 @@ function processContactUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
$row = $stmt->fetch(PDO::FETCH_ASSOC);
extract($row);
/* if ($postalInfoInt) {
if ($postalInfoInt) {
// 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);
@ -449,7 +451,7 @@ function processContactUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
$stmt_loc->execute();
$row_loc = $stmt_loc->fetch(PDO::FETCH_ASSOC);
extract($row_loc);
} */
}
// 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");
@ -507,6 +509,7 @@ function processContactUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
// Update contact
$query = "UPDATE contact SET voice = ?, voice_x = ?, fax = ?, fax_x = ?, email = ?, upid = ?, lastupdate = CURRENT_TIMESTAMP(3) WHERE id = ?";
$stmt = $db->prepare($query);
$stmt->execute([
$e_voice ?: null,
$e_voice_x ?: null,
@ -518,10 +521,26 @@ function processContactUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
]);
}
if (isset($disclose['voice']) || isset($disclose['fax']) || isset($disclose['email'])) {
// Update contact
$query = "UPDATE contact SET disclose_voice = ?, disclose_fax = ?, disclose_email = ?, upid = ?, lastupdate = CURRENT_TIMESTAMP(3) WHERE id = ?";
$stmt = $db->prepare($query);
$stmt->execute([
isset($disclose['voice']) ? $disclose['voice'] : $disclose_voice, // Check if $disclose['voice'] is set, otherwise use $disclose_voice
isset($disclose['fax']) ? $disclose['fax'] : $disclose_fax, // Same logic for fax
isset($disclose['email']) ? $disclose['email'] : $disclose_email, // Same logic for email
$clid,
$contact_id
]);
}
if ($postalInfoInt) {
// Update contact_postalInfo for 'int'
$query = "UPDATE contact_postalInfo SET name = ?, org = ?, street1 = ?, street2 = ?, street3 = ?, city = ?, sp = ?, pc = ?, cc = ? WHERE contact_id = ? AND type = ?";
$stmt = $db->prepare($query);
// Use the disclose array if set, otherwise fall back to the extracted values
$stmt->execute([
$int_name,
$int_org,
@ -535,12 +554,28 @@ function processContactUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
$contact_id,
'int'
]);
if (isset($disclose['name_int']) || isset($disclose['org_int']) || isset($disclose['addr_int'])) {
$query = "UPDATE contact_postalInfo SET disclose_name_int = ?, disclose_org_int = ?, disclose_addr_int = ? WHERE contact_id = ? AND type = ?";
$stmt = $db->prepare($query);
// Use the disclose array if set, otherwise fall back to the extracted values
$stmt->execute([
isset($disclose['name_int']) ? $disclose['name_int'] : $disclose_name_int, // Use disclose array if set, otherwise use the extracted value
isset($disclose['org_int']) ? $disclose['org_int'] : $disclose_org_int, // Same logic for org
isset($disclose['addr_int']) ? $disclose['addr_int'] : $disclose_addr_int, // Same logic for address
$contact_id,
'int'
]);
}
}
if ($postalInfoLoc) {
// Update contact_postalInfo for 'loc'
$query = "UPDATE contact_postalInfo SET name = ?, org = ?, street1 = ?, street2 = ?, street3 = ?, city = ?, sp = ?, pc = ?, cc = ? WHERE contact_id = ? AND type = ?";
$stmt = $db->prepare($query);
// Use the disclose array if set, otherwise fall back to the extracted values
$stmt->execute([
$loc_name,
$loc_org,
@ -554,6 +589,20 @@ function processContactUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
$contact_id,
'loc'
]);
if (isset($disclose['name_loc']) || isset($disclose['org_loc']) || isset($disclose['addr_loc'])) {
$query = "UPDATE contact_postalInfo SET disclose_name_loc = ?, disclose_org_loc = ?, disclose_addr_loc = ? WHERE contact_id = ? AND type = ?";
$stmt = $db->prepare($query);
// Use the disclose array if set, otherwise fall back to the extracted values
$stmt->execute([
isset($disclose['name_loc']) ? $disclose['name_loc'] : $disclose_name_loc, // Use disclose array if set, otherwise use the extracted value
isset($disclose['org_loc']) ? $disclose['org_loc'] : $disclose_org_loc, // Same logic for org
isset($disclose['addr_loc']) ? $disclose['addr_loc'] : $disclose_addr_loc, // Same logic for address
$contact_id,
'int'
]);
}
}
// Update contact_authInfo for 'pw'