mirror of
https://github.com/getnamingo/registry.git
synced 2025-07-21 10:06:05 +02:00
Update epp-update.php
This commit is contained in:
parent
c9982bbcc0
commit
c42213b513
1 changed files with 26 additions and 33 deletions
|
@ -917,43 +917,36 @@ function processHostUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
|
||||||
$hostRow = $stmt->fetch(PDO::FETCH_ASSOC);
|
$hostRow = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
if ($hostRow) {
|
$domain_id = $hostRow['domain_id'];
|
||||||
$domain_id = $hostRow['domain_id'];
|
$host_id = $hostRow['id'];
|
||||||
$host_id = $hostRow['id'];
|
|
||||||
|
|
||||||
// Subordinate host
|
if ($domain_id !== null) {
|
||||||
if ($domain_id) {
|
$tlds_scan = $db->query("SELECT tld FROM domain_tld")->fetchAll(PDO::FETCH_COLUMN);
|
||||||
$stmt = $db->prepare("SELECT name FROM domain WHERE id = ? LIMIT 1");
|
$chg_domain = extractDomainFromHost($chg_name, $tlds_scan);
|
||||||
$stmt->execute([$domain_id]);
|
|
||||||
$domain_name = $stmt->fetchColumn();
|
|
||||||
$stmt->closeCursor();
|
|
||||||
|
|
||||||
if (!preg_match('/\.' . preg_quote($domain_name, '/') . '$/i', strtolower($chg_name))) {
|
$stmt = $db->prepare("SELECT clid FROM domain WHERE name = ? LIMIT 1");
|
||||||
// Renaming to another domain → not allowed
|
$stmt->execute([$chg_domain]);
|
||||||
sendEppError($conn, $db, 2304, 'Out-of-bailiwick renaming is not allowed for subordinate hosts', $clTRID, $trans);
|
$chg_clid = $stmt->fetchColumn();
|
||||||
return;
|
$stmt->closeCursor();
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// External host
|
|
||||||
$tlds = $db->query("SELECT tld FROM domain_tld")->fetchAll(PDO::FETCH_COLUMN);
|
|
||||||
$internal_host = false;
|
|
||||||
foreach ($tlds as $tld) {
|
|
||||||
if (str_ends_with(strtolower($chg_name), strtolower($tld))) {
|
|
||||||
$internal_host = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($internal_host) {
|
if ($chg_clid === false) {
|
||||||
sendEppError($conn, $db, 2005, 'Out-of-bailiwick change not allowed: host must be external to registry-managed domains', $clTRID, $trans);
|
sendEppError($conn, $db, 2303, 'Superordinate domain does not exist: ' . $chg_domain, $clTRID, $trans);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// External + new name is also external → delete IPs if not explicitly removed
|
if ($chg_clid !== false && $chg_clid !== $clid) {
|
||||||
if (!isset($hostRem)) {
|
sendEppError($conn, $db, 2304, 'Host rename denied: domain owned by another registrar', $clTRID, $trans);
|
||||||
$stmt = $db->prepare("DELETE FROM host_addr WHERE host_id = ?");
|
return;
|
||||||
$stmt->execute([$host_id]);
|
}
|
||||||
}
|
|
||||||
|
$stmt = $db->prepare("SELECT name FROM domain WHERE id = ? LIMIT 1");
|
||||||
|
$stmt->execute([$domain_id]);
|
||||||
|
$domain_name = $stmt->fetchColumn();
|
||||||
|
$stmt->closeCursor();
|
||||||
|
|
||||||
|
if (!preg_match('/\.' . preg_quote($domain_name, '/') . '$/i', strtolower($chg_name))) {
|
||||||
|
$stmt = $db->prepare("DELETE FROM host_addr WHERE host_id = ?");
|
||||||
|
$stmt->execute([$host_id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue