RST improvement

This commit is contained in:
Pinga 2025-05-05 22:24:11 +03:00
parent 6528ad6530
commit 446655226f

View file

@ -905,7 +905,7 @@ function processHostUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
} }
if (isset($hostChg)) { if (isset($hostChg)) {
$chg_name = $xml->xpath('//host:name[1]')[0]; $chg_name = (string) $xml->xpath('//host:chg/host:name')[0];
if (!validateHostName($chg_name)) { if (!validateHostName($chg_name)) {
sendEppError($conn, $db, 2005, 'Invalid host:name', $clTRID, $trans); sendEppError($conn, $db, 2005, 'Invalid host:name', $clTRID, $trans);
@ -971,9 +971,7 @@ function processHostUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
} }
if (isset($hostRem)) { if (isset($hostRem)) {
$rem_name = $xml->xpath('//host:name[1]')[0]; if (!validateHostName($name)) {
if (!validateHostName($rem_name)) {
sendEppError($conn, $db, 2005, 'Invalid host:name', $clTRID, $trans); sendEppError($conn, $db, 2005, 'Invalid host:name', $clTRID, $trans);
return; return;
} }
@ -1008,6 +1006,16 @@ function processHostUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
$stmt = $db->prepare("DELETE FROM host_status WHERE host_id = ? AND status = ?"); $stmt = $db->prepare("DELETE FROM host_status WHERE host_id = ? AND status = ?");
$stmt->execute([$hostId, $status]); $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)) { if (isset($hostAdd)) {