mirror of
https://github.com/getnamingo/registry.git
synced 2025-07-12 13:58:12 +02:00
RST related EPP server fixes
This commit is contained in:
parent
daf8e630bf
commit
8d3493bb7a
6 changed files with 63 additions and 40 deletions
|
@ -225,6 +225,9 @@ function validate_label($domain, $db) {
|
||||||
if (strpos($domain, '.') === false) {
|
if (strpos($domain, '.') === false) {
|
||||||
return 'Invalid domain name format: must contain at least one dot (.)';
|
return 'Invalid domain name format: must contain at least one dot (.)';
|
||||||
}
|
}
|
||||||
|
if ($domain[0] === '.' || substr($domain, -1) === '.') {
|
||||||
|
return 'Invalid domain name format: cannot start or end with a dot (.)';
|
||||||
|
}
|
||||||
|
|
||||||
// Split domain into labels (subdomains, SLD, TLD)
|
// Split domain into labels (subdomains, SLD, TLD)
|
||||||
$labels = explode('.', $domain);
|
$labels = explode('.', $domain);
|
||||||
|
|
|
@ -590,7 +590,10 @@ class EppWriter {
|
||||||
$writer->writeAttribute('flag', $resp['disclose']['flag']); // 1 = disclose, 0 = restrict
|
$writer->writeAttribute('flag', $resp['disclose']['flag']); // 1 = disclose, 0 = restrict
|
||||||
|
|
||||||
foreach ($resp['disclose']['fields'] as $field) {
|
foreach ($resp['disclose']['fields'] as $field) {
|
||||||
$writer->startElement('contact:' . $field);
|
$writer->startElement('contact:' . $field['name']);
|
||||||
|
if (isset($field['type'])) {
|
||||||
|
$writer->writeAttribute('type', $field['type']);
|
||||||
|
}
|
||||||
$writer->endElement();
|
$writer->endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -910,11 +913,6 @@ class EppWriter {
|
||||||
$crDateFormatted = $crDate->format('Y-m-d\TH:i:s.v\Z');
|
$crDateFormatted = $crDate->format('Y-m-d\TH:i:s.v\Z');
|
||||||
$writer->writeElement('domain:crDate', $crDateFormatted);
|
$writer->writeElement('domain:crDate', $crDateFormatted);
|
||||||
}
|
}
|
||||||
if (isset($resp['exDate'])) {
|
|
||||||
$exDate = new \DateTime($resp['exDate']);
|
|
||||||
$exDateFormatted = $exDate->format('Y-m-d\TH:i:s.v\Z');
|
|
||||||
$writer->writeElement('domain:exDate', $exDateFormatted);
|
|
||||||
}
|
|
||||||
if (isset($resp['upID'])) {
|
if (isset($resp['upID'])) {
|
||||||
$writer->writeElement('domain:upID', $resp['upID']);
|
$writer->writeElement('domain:upID', $resp['upID']);
|
||||||
}
|
}
|
||||||
|
@ -923,6 +921,11 @@ class EppWriter {
|
||||||
$upDateFormatted = $upDate->format('Y-m-d\TH:i:s.v\Z');
|
$upDateFormatted = $upDate->format('Y-m-d\TH:i:s.v\Z');
|
||||||
$writer->writeElement('domain:upDate', $upDateFormatted);
|
$writer->writeElement('domain:upDate', $upDateFormatted);
|
||||||
}
|
}
|
||||||
|
if (isset($resp['exDate'])) {
|
||||||
|
$exDate = new \DateTime($resp['exDate']);
|
||||||
|
$exDateFormatted = $exDate->format('Y-m-d\TH:i:s.v\Z');
|
||||||
|
$writer->writeElement('domain:exDate', $exDateFormatted);
|
||||||
|
}
|
||||||
if (isset($resp['trDate'])) {
|
if (isset($resp['trDate'])) {
|
||||||
$trDate = new \DateTime($resp['trDate']);
|
$trDate = new \DateTime($resp['trDate']);
|
||||||
$trDateFormatted = $trDate->format('Y-m-d\TH:i:s.v\Z');
|
$trDateFormatted = $trDate->format('Y-m-d\TH:i:s.v\Z');
|
||||||
|
|
|
@ -10,30 +10,25 @@ function processContactCheck($conn, $db, $xml, $trans) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$results = [];
|
$ids = [];
|
||||||
|
|
||||||
foreach ($contactIDs as $contactID) {
|
foreach ($contactIDs as $contactID) {
|
||||||
$contactID = (string)$contactID;
|
$contactID = (string)$contactID;
|
||||||
|
$entry = [$contactID];
|
||||||
|
|
||||||
$stmt = $db->prepare("SELECT 1 FROM contact WHERE identifier = :id");
|
|
||||||
$stmt->execute(['id' => $contactID]);
|
|
||||||
|
|
||||||
$results[$contactID] = $stmt->fetch() ? '0' : '1'; // 0 if exists, 1 if not
|
|
||||||
$stmt->closeCursor();
|
|
||||||
}
|
|
||||||
|
|
||||||
$ids = [];
|
|
||||||
foreach ($results as $id => $available) {
|
|
||||||
$invalid_identifier = validate_identifier($contactID);
|
$invalid_identifier = validate_identifier($contactID);
|
||||||
$entry = [$id];
|
|
||||||
|
|
||||||
// Check if the contact ID is Invalid
|
|
||||||
if ($invalid_identifier) {
|
if ($invalid_identifier) {
|
||||||
$entry[] = 0; // Set status to unavailable
|
$entry[] = 0;
|
||||||
$entry[] = $invalid_identifier;
|
$entry[] = $invalid_identifier;
|
||||||
} else {
|
} else {
|
||||||
|
$stmt = $db->prepare("SELECT 1 FROM contact WHERE identifier = :id");
|
||||||
|
$stmt->execute(['id' => $contactID]);
|
||||||
|
$available = $stmt->fetch() ? '0' : '1';
|
||||||
|
$stmt->closeCursor();
|
||||||
|
|
||||||
$entry[] = $available;
|
$entry[] = $available;
|
||||||
|
|
||||||
// Check if the contact is unavailable
|
|
||||||
if (!$available) {
|
if (!$available) {
|
||||||
$entry[] = "In use";
|
$entry[] = "In use";
|
||||||
}
|
}
|
||||||
|
@ -55,9 +50,11 @@ function processContactCheck($conn, $db, $xml, $trans) {
|
||||||
|
|
||||||
$epp = new EPP\EppWriter();
|
$epp = new EPP\EppWriter();
|
||||||
$xml = $epp->epp_writer($response);
|
$xml = $epp->epp_writer($response);
|
||||||
|
|
||||||
if (is_array($ids)) {
|
if (is_array($ids)) {
|
||||||
$ids = implode(',', array_column($ids, 0));
|
$ids = implode(',', array_column($ids, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTransaction($db, 'check', 'contact', $ids, 1000, 'Command completed successfully', $svTRID, $xml, $trans);
|
updateTransaction($db, 'check', 'contact', $ids, 1000, 'Command completed successfully', $svTRID, $xml, $trans);
|
||||||
sendEppResponse($conn, $xml);
|
sendEppResponse($conn, $xml);
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,18 +72,35 @@ function processContactInfo($conn, $db, $xml, $clid, $trans) {
|
||||||
$statusArray = array_map(fn($status) => [$status], $statuses);
|
$statusArray = array_map(fn($status) => [$status], $statuses);
|
||||||
|
|
||||||
// Handle Disclose Fields (Only Show When Set to `1`)
|
// Handle Disclose Fields (Only Show When Set to `1`)
|
||||||
$disclose_fields = [
|
$disclose_fields = [];
|
||||||
'voice' => $contactRow['disclose_voice'],
|
|
||||||
'fax' => $contactRow['disclose_fax'],
|
if ($contactRow['disclose_voice'] === '1') {
|
||||||
'email' => $contactRow['disclose_email'],
|
$disclose_fields[] = ['name' => 'voice'];
|
||||||
'name_int' => $contactRow['disclose_name_int'],
|
}
|
||||||
'name_loc' => $contactRow['disclose_name_loc'],
|
if ($contactRow['disclose_fax'] === '1') {
|
||||||
'org_int' => $contactRow['disclose_org_int'],
|
$disclose_fields[] = ['name' => 'fax'];
|
||||||
'org_loc' => $contactRow['disclose_org_loc'],
|
}
|
||||||
'addr_int' => $contactRow['disclose_addr_int'],
|
if ($contactRow['disclose_email'] === '1') {
|
||||||
'addr_loc' => $contactRow['disclose_addr_loc']
|
$disclose_fields[] = ['name' => 'email'];
|
||||||
];
|
}
|
||||||
$disclose_required = array_filter($disclose_fields, fn($value) => $value === '1');
|
if ($contactRow['disclose_name_int'] === '1') {
|
||||||
|
$disclose_fields[] = ['name' => 'name', 'type' => 'int'];
|
||||||
|
}
|
||||||
|
if ($contactRow['disclose_name_loc'] === '1') {
|
||||||
|
$disclose_fields[] = ['name' => 'name', 'type' => 'loc'];
|
||||||
|
}
|
||||||
|
if ($contactRow['disclose_org_int'] === '1') {
|
||||||
|
$disclose_fields[] = ['name' => 'org', 'type' => 'int'];
|
||||||
|
}
|
||||||
|
if ($contactRow['disclose_org_loc'] === '1') {
|
||||||
|
$disclose_fields[] = ['name' => 'org', 'type' => 'loc'];
|
||||||
|
}
|
||||||
|
if ($contactRow['disclose_addr_int'] === '1') {
|
||||||
|
$disclose_fields[] = ['name' => 'addr', 'type' => 'int'];
|
||||||
|
}
|
||||||
|
if ($contactRow['disclose_addr_loc'] === '1') {
|
||||||
|
$disclose_fields[] = ['name' => 'addr', 'type' => 'loc'];
|
||||||
|
}
|
||||||
|
|
||||||
$stmt = $db->query("SELECT value FROM settings WHERE name = 'handle'");
|
$stmt = $db->query("SELECT value FROM settings WHERE name = 'handle'");
|
||||||
$roid = $stmt->fetchColumn();
|
$roid = $stmt->fetchColumn();
|
||||||
|
@ -113,10 +130,10 @@ function processContactInfo($conn, $db, $xml, $clid, $trans) {
|
||||||
'authInfo_val' => $contactRow['authinfo']
|
'authInfo_val' => $contactRow['authinfo']
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!empty($disclose_required)) {
|
if (!empty($disclose_fields)) {
|
||||||
$response['disclose'] = [
|
$response['disclose'] = [
|
||||||
'flag' => '1', // Show when disclosure is enabled
|
'flag' => '1',
|
||||||
'fields' => array_keys($disclose_required)
|
'fields' => $disclose_fields
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,9 @@ function processContactUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
|
||||||
$contactRem = $xml->xpath('//contact:rem') ?? null;
|
$contactRem = $xml->xpath('//contact:rem') ?? null;
|
||||||
$contactAdd = $xml->xpath('//contact:add') ?? null;
|
$contactAdd = $xml->xpath('//contact:add') ?? null;
|
||||||
$contactChg = $xml->xpath('//contact:chg') ?? null;
|
$contactChg = $xml->xpath('//contact:chg') ?? null;
|
||||||
$identicaUpdate = $xml->xpath('//identica:update') ?? null;
|
$identicaUpdate = $xml->xpath('//identica:update');
|
||||||
|
|
||||||
if (!$contactRem && !$contactAdd && !$contactChg && !$identicaUpdate) {
|
if (!$contactRem && !$contactAdd && !$contactChg && empty($identicaUpdate)) {
|
||||||
sendEppError($conn, $db, 2003, 'At least one contact:rem || contact:add || contact:chg', $clTRID, $trans);
|
sendEppError($conn, $db, 2003, 'At least one contact:rem || contact:add || contact:chg', $clTRID, $trans);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -420,7 +420,7 @@ function processContactUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($identicaUpdate)) {
|
if (!empty($identicaUpdate)) {
|
||||||
$nin = (string) ($xml->xpath('//identica:nin[1]')[0] ?? null);
|
$nin = (string) ($xml->xpath('//identica:nin[1]')[0] ?? null);
|
||||||
$nin_type = (string) ($xml->xpath('//identica:nin/@type[1]')[0] ?? null);
|
$nin_type = (string) ($xml->xpath('//identica:nin/@type[1]')[0] ?? null);
|
||||||
$validation = (string) ($xml->xpath('//identica:status[1]')[0] ?? null);
|
$validation = (string) ($xml->xpath('//identica:status[1]')[0] ?? null);
|
||||||
|
|
|
@ -230,6 +230,9 @@ function validate_label($domain, $pdo) {
|
||||||
if (strpos($domain, '.') === false) {
|
if (strpos($domain, '.') === false) {
|
||||||
return 'Invalid domain name format: must contain at least one dot (.)';
|
return 'Invalid domain name format: must contain at least one dot (.)';
|
||||||
}
|
}
|
||||||
|
if ($domain[0] === '.' || substr($domain, -1) === '.') {
|
||||||
|
return 'Invalid domain name format: cannot start or end with a dot (.)';
|
||||||
|
}
|
||||||
|
|
||||||
// Split domain into labels (subdomains, SLD, TLD)
|
// Split domain into labels (subdomains, SLD, TLD)
|
||||||
$labels = explode('.', $domain);
|
$labels = explode('.', $domain);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue