From b2ba26d8b8bbdc4ffa78d099b856f12c968c4585 Mon Sep 17 00:00:00 2001 From: Pinga <121483313+getpinga@users.noreply.github.com> Date: Fri, 2 May 2025 22:18:54 +0300 Subject: [PATCH] Contact update status fix --- epp/src/epp-update.php | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/epp/src/epp-update.php b/epp/src/epp-update.php index c2f5fad..f39e16f 100644 --- a/epp/src/epp-update.php +++ b/epp/src/epp-update.php @@ -439,24 +439,36 @@ function processContactUpdate($conn, $db, $xml, $clid, $database_type, $trans) { } } - if ($contactRem && $xml->xpath("./*[name()='$contactRem']")) { - $status_list = $xml->xpath("contact:status/@s"); + if (!empty($contactRem)) { + $status_list = $xml->xpath('//contact:rem/contact:status/@s'); foreach ($status_list as $node) { - $status = (string)$node[0]; + $status = (string)$node; $sth = $db->prepare("DELETE FROM contact_status WHERE contact_id = ? AND status = ?"); $sth->execute([$contact_id, $status]); } + + $sth = $db->prepare("SELECT COUNT(*) FROM contact_status WHERE contact_id = ?"); + $sth->execute([$contact_id]); + $remaining = $sth->fetchColumn(); + + if ((int)$remaining === 0) { + $sth = $db->prepare("INSERT INTO contact_status (contact_id, status) VALUES (?, 'ok')"); + $sth->execute([$contact_id]); + } } - if ($contactAdd && $xml->xpath("./*[name()='$contactAdd']")) { - $status_list = $xml->xpath("contact:status/@s"); + if (!empty($contactAdd)) { + $status_list = $xml->xpath('//contact:add/contact:status/@s'); foreach ($status_list as $node) { - $status = (string)$node[0]; - $sth = $db->prepare("INSERT INTO contact_status (contact_id,status) VALUES(?,?)"); + $status = (string)$node; + $sth = $db->prepare("INSERT INTO contact_status (contact_id, status) VALUES (?, ?)"); $sth->execute([$contact_id, $status]); } + + $sth = $db->prepare("DELETE FROM contact_status WHERE contact_id = ? AND status = 'ok'"); + $sth->execute([$contact_id]); } if ($contactChg) {