From 2cfa794e723a17523934b2549e7f81cba1fa99ad Mon Sep 17 00:00:00 2001 From: Pinga Date: Mon, 5 May 2025 22:32:33 +0300 Subject: [PATCH] Update epp-update.php --- epp/src/epp-update.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/epp/src/epp-update.php b/epp/src/epp-update.php index bc490c8..5044a63 100644 --- a/epp/src/epp-update.php +++ b/epp/src/epp-update.php @@ -979,6 +979,18 @@ function processHostUpdate($conn, $db, $xml, $clid, $database_type, $trans) { $addr_list = $xml->xpath('//host:rem/host:addr'); $status_list = $xml->xpath('//host:rem/host:status/@s'); + $removingCount = count($addr_list); + + $stmt = $db->prepare("SELECT COUNT(*) FROM host_addr WHERE host_id = ?"); + $stmt->execute([$hostId]); + $currentCount = $stmt->fetchColumn(); + $stmt->closeCursor(); + + if ($currentCount - $removingCount <= 0) { + sendEppError($conn, $db, 2306, 'Host must have at least one IP address', $clTRID, $trans); + return; + } + foreach ($addr_list as $node) { $addr = (string) $node; $addr_type = $node->attributes()['ip'] ? (string) $node->attributes()['ip'] : 'v4'; @@ -1007,15 +1019,6 @@ function processHostUpdate($conn, $db, $xml, $clid, $database_type, $trans) { $stmt->execute([$hostId, $status]); } - $stmt = $db->prepare("SELECT COUNT(*) FROM host_addr WHERE host_id = ?"); - $stmt->execute([$hostId]); - $remainingAddrs = $stmt->fetchColumn(); - $stmt->closeCursor(); - - if ($remainingAddrs == 0) { - sendEppError($conn, $db, 2306, 'Host must have at least one IP address', $clTRID, $trans); - return; - } } if (isset($hostAdd)) {