Skip to content

Commit df84e14

Browse files
committed
Fixed #20
1 parent 50d8780 commit df84e14

2 files changed

Lines changed: 16 additions & 13 deletions

File tree

rdap/config.php.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ return [
99
'db_password' => 'your_password',
1010
'registry_url' => 'https://example.com/rdap-terms',
1111
'rdap_url' => 'https://rdap.example.com',
12+
'privacy' => true,
1213
'rately' => false,
1314
'limit' => 1000,
1415
'period' => 60,

rdap/helpers.php

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ function setupLogger($logFilePath, $channelName = 'app') {
4242
}
4343

4444
function mapContactToVCard($contactDetails, $role, $c) {
45+
$redacted = 'REDACTED FOR PRIVACY';
46+
4547
return [
4648
'objectClassName' => 'entity',
4749
'handle' => [$contactDetails['registrant_contact_id']],
@@ -50,21 +52,21 @@ function mapContactToVCard($contactDetails, $role, $c) {
5052
"vcard",
5153
[
5254
['version', new stdClass(), 'text', '4.0'],
53-
["fn", new stdClass(), 'text', $contactDetails['contact_first_name'].' '.$contactDetails['contact_last_name']],
54-
["org", $contactDetails['contact_company']],
55-
["adr", [
55+
["fn", new stdClass(), 'text', $c['privacy'] ? $redacted : $contactDetails['contact_first_name'] . ' ' . $contactDetails['contact_last_name']],
56+
["org", new stdClass(), 'text', $c['privacy'] ? $redacted : $contactDetails['contact_company']],
57+
["adr", new stdClass(), 'text', [
5658
"", // Post office box
57-
$contactDetails['contact_address1'], // Extended address
58-
$contactDetails['contact_address2'], // Street address
59-
$contactDetails['contact_city'], // Locality
60-
$contactDetails['contact_state'], // Region
61-
$contactDetails['contact_postcode'], // Postal code
62-
$contactDetails['contact_country'] // Country name
59+
$c['privacy'] ? $redacted : $contactDetails['contact_address1'], // Extended address
60+
$c['privacy'] ? $redacted : $contactDetails['contact_address2'], // Street address
61+
$c['privacy'] ? $redacted : $contactDetails['contact_city'], // Locality
62+
$c['privacy'] ? $redacted : $contactDetails['contact_state'], // Region
63+
$c['privacy'] ? $redacted : $contactDetails['contact_postcode'], // Postal code
64+
$c['privacy'] ? $redacted : strtoupper($contactDetails['contact_country']) // Country name
6365
]],
64-
["tel", $contactDetails['contact_phone_cc'].'.'.$contactDetails['contact_phone'], ["type" => "voice"]],
65-
["tel", $contactDetails['fax'], ["type" => "fax"]],
66-
["email", $contactDetails['contact_email']],
66+
["tel", new stdClass(), 'text', $c['privacy'] ? $redacted : $contactDetails['contact_phone_cc'] . '.' . $contactDetails['contact_phone'], ["type" => "voice"]],
67+
["tel", new stdClass(), 'text', $c['privacy'] ? $redacted : $contactDetails['fax'], ["type" => "fax"]],
68+
["email", new stdClass(), 'text', $c['privacy'] ? $redacted : $contactDetails['contact_email']]
6769
]
6870
],
6971
];
70-
}
72+
}

0 commit comments

Comments
 (0)