From 8b3df413183ddd6365bb4b9ec5dd8a4f2c50c6e9 Mon Sep 17 00:00:00 2001 From: Pinga <121483313+getpinga@users.noreply.github.com> Date: Wed, 11 Dec 2024 13:25:09 +0200 Subject: [PATCH] Added ability to have bulk contact check --- examples/ContactCheck.php | 13 ++++++++++--- src/Epp.php | 14 +++++++++----- src/Registries/FiEpp.php | 14 +++++++++----- src/Registries/FrEpp.php | 14 +++++++++----- src/Registries/FredEpp.php | 14 +++++++++----- src/Registries/GrEpp.php | 14 +++++++++----- src/Registries/HkEpp.php | 14 +++++++++----- src/Registries/HrEpp.php | 14 +++++++++----- src/Registries/ItEpp.php | 16 ++++++++++------ src/Registries/LvEpp.php | 14 +++++++++----- src/Registries/MxEpp.php | 14 +++++++++----- src/Registries/NoEpp.php | 15 ++++++++++----- src/Registries/PlEpp.php | 14 +++++++++----- src/Registries/PtEpp.php | 14 +++++++++----- src/Registries/SeEpp.php | 14 +++++++++----- src/Registries/UaEpp.php | 14 +++++++++----- 16 files changed, 147 insertions(+), 79 deletions(-) diff --git a/examples/ContactCheck.php b/examples/ContactCheck.php index eb15dea..7d34585 100644 --- a/examples/ContactCheck.php +++ b/examples/ContactCheck.php @@ -2,7 +2,7 @@ /** * Tembo EPP client test file * - * Written in 2023 by Taras Kondratyuk (https://getpinga.com) + * Written in 2024 by Taras Kondratyuk (https://getpinga.com) * Based on xpanel/epp-bundle written in 2019 by Lilian Rudenco (info@xpanel.com) * * @license MIT @@ -17,7 +17,7 @@ $epp = connectEpp('generic'); $params = array( - 'contact' => 'tembo007' + 'contact' => array('tembo007', 'tembo009') ); $contactCheck = $epp->contactCheck($params); @@ -37,7 +37,14 @@ } else { - echo "Contact ".$x.": ID " . $contact['id'] . " is not available because: " . $contact['reason'] . PHP_EOL; + if (!empty($contact['reason'])) + { + echo "Contact " . $x . ": ID " . $contact['id'] . " is not available because: " . $contact['reason'] . PHP_EOL; + } + else + { + echo "Contact " . $x . ": ID " . $contact['id'] . " is not available" . PHP_EOL; + } } $x++; } diff --git a/src/Epp.php b/src/Epp.php index ad3a9cd..26fb315 100644 --- a/src/Epp.php +++ b/src/Epp.php @@ -665,9 +665,12 @@ public function contactCheck($params = array()) $return = array(); try { $from = $to = array(); - $from[] = '/{{ id }}/'; - $id = $params['contact']; - $to[] = htmlspecialchars($id); + $text = ''; + foreach ($params['contact'] as $id) { + $text .= '' . htmlspecialchars($id) . '' . "\n"; + } + $from[] = '/{{ ids }}/'; + $to[] = $text; $from[] = '/{{ clTRID }}/'; $microtime = str_replace('.', '', round(microtime(1), 3)); $to[] = htmlspecialchars($this->prefix . '-contact-check-' . $microtime); @@ -682,7 +685,7 @@ public function contactCheck($params = array()) - {{ id }} + {{ ids }} {{ clTRID }} @@ -697,7 +700,8 @@ public function contactCheck($params = array()) foreach ($r->cd as $cd) { $i++; $contacts[$i]['id'] = (string)$cd->id; - $contacts[$i]['avail'] = (int)$cd->id->attributes()->avail; + $availStr = (string)$cd->id->attributes()->avail; + $contacts[$i]['avail'] = ($availStr === 'true' || $availStr === '1') ? true : false; $contacts[$i]['reason'] = (string)$cd->reason; } diff --git a/src/Registries/FiEpp.php b/src/Registries/FiEpp.php index a3e1b77..5709a80 100644 --- a/src/Registries/FiEpp.php +++ b/src/Registries/FiEpp.php @@ -665,9 +665,12 @@ public function contactCheck($params = array()) $return = array(); try { $from = $to = array(); - $from[] = '/{{ id }}/'; - $id = $params['contact']; - $to[] = htmlspecialchars($id); + $text = ''; + foreach ($params['contact'] as $id) { + $text .= '' . htmlspecialchars($id) . '' . "\n"; + } + $from[] = '/{{ ids }}/'; + $to[] = $text; $from[] = '/{{ clTRID }}/'; $microtime = str_replace('.', '', round(microtime(1), 3)); $to[] = htmlspecialchars($this->prefix . '-contact-check-' . $microtime); @@ -682,7 +685,7 @@ public function contactCheck($params = array()) - {{ id }} + {{ ids }} {{ clTRID }} @@ -697,7 +700,8 @@ public function contactCheck($params = array()) foreach ($r->cd as $cd) { $i++; $contacts[$i]['id'] = (string)$cd->id; - $contacts[$i]['avail'] = (int)$cd->id->attributes()->avail; + $availStr = (string)$cd->id->attributes()->avail; + $contacts[$i]['avail'] = ($availStr === 'true' || $availStr === '1') ? true : false; $contacts[$i]['reason'] = (string)$cd->reason; } diff --git a/src/Registries/FrEpp.php b/src/Registries/FrEpp.php index fe09b80..f66bde3 100644 --- a/src/Registries/FrEpp.php +++ b/src/Registries/FrEpp.php @@ -659,9 +659,12 @@ public function contactCheck($params = array()) $return = array(); try { $from = $to = array(); - $from[] = '/{{ id }}/'; - $id = $params['contact']; - $to[] = htmlspecialchars($id); + $text = ''; + foreach ($params['contact'] as $id) { + $text .= '' . htmlspecialchars($id) . '' . "\n"; + } + $from[] = '/{{ ids }}/'; + $to[] = $text; $from[] = '/{{ clTRID }}/'; $microtime = str_replace('.', '', round(microtime(1), 3)); $to[] = htmlspecialchars($this->prefix . '-contact-check-' . $microtime); @@ -676,7 +679,7 @@ public function contactCheck($params = array()) - {{ id }} + {{ ids }} {{ clTRID }} @@ -691,7 +694,8 @@ public function contactCheck($params = array()) foreach ($r->cd as $cd) { $i++; $contacts[$i]['id'] = (string)$cd->id; - $contacts[$i]['avail'] = (int)$cd->id->attributes()->avail; + $availStr = (string)$cd->id->attributes()->avail; + $contacts[$i]['avail'] = ($availStr === 'true' || $availStr === '1') ? true : false; $contacts[$i]['reason'] = (string)$cd->reason; } diff --git a/src/Registries/FredEpp.php b/src/Registries/FredEpp.php index 6014d15..8b06dd8 100644 --- a/src/Registries/FredEpp.php +++ b/src/Registries/FredEpp.php @@ -684,9 +684,12 @@ public function contactCheck($params = array()) $return = array(); try { $from = $to = array(); - $from[] = '/{{ id }}/'; - $id = $params['contact']; - $to[] = htmlspecialchars($id); + $text = ''; + foreach ($params['contact'] as $id) { + $text .= '' . htmlspecialchars($id) . '' . "\n"; + } + $from[] = '/{{ ids }}/'; + $to[] = $text; $from[] = '/{{ clTRID }}/'; $microtime = str_replace('.', '', round(microtime(1), 3)); $to[] = htmlspecialchars($this->prefix . '-contact-check-' . $microtime); @@ -700,7 +703,7 @@ public function contactCheck($params = array()) - {{ id }} + {{ ids }} {{ clTRID }} @@ -714,7 +717,8 @@ public function contactCheck($params = array()) foreach ($r->cd as $cd) { $i++; $contacts[$i]['id'] = (string)$cd->id; - $contacts[$i]['avail'] = (int)$cd->id->attributes()->avail; + $availStr = (string)$cd->id->attributes()->avail; + $contacts[$i]['avail'] = ($availStr === 'true' || $availStr === '1') ? true : false; $contacts[$i]['reason'] = (string)$cd->reason; } diff --git a/src/Registries/GrEpp.php b/src/Registries/GrEpp.php index 3eb8e79..6efbd2c 100644 --- a/src/Registries/GrEpp.php +++ b/src/Registries/GrEpp.php @@ -649,9 +649,12 @@ public function contactCheck($params = array()) $return = array(); try { $from = $to = array(); - $from[] = '/{{ id }}/'; - $id = $params['contact']; - $to[] = htmlspecialchars($id); + $text = ''; + foreach ($params['contact'] as $id) { + $text .= '' . htmlspecialchars($id) . '' . "\n"; + } + $from[] = '/{{ ids }}/'; + $to[] = $text; $from[] = '/{{ clTRID }}/'; $microtime = str_replace('.', '', round(microtime(1), 3)); $to[] = htmlspecialchars($this->prefix . '-contact-check-' . $microtime); @@ -666,7 +669,7 @@ public function contactCheck($params = array()) - {{ id }} + {{ ids }} {{ clTRID }} @@ -681,7 +684,8 @@ public function contactCheck($params = array()) foreach ($r->cd as $cd) { $i++; $contacts[$i]['id'] = (string)$cd->id; - $contacts[$i]['avail'] = (int)$cd->id->attributes()->avail; + $availStr = (string)$cd->id->attributes()->avail; + $contacts[$i]['avail'] = ($availStr === 'true' || $availStr === '1') ? true : false; $contacts[$i]['reason'] = (string)$cd->reason; } diff --git a/src/Registries/HkEpp.php b/src/Registries/HkEpp.php index c357262..6c5218e 100644 --- a/src/Registries/HkEpp.php +++ b/src/Registries/HkEpp.php @@ -656,9 +656,12 @@ public function contactCheck($params = array()) $return = array(); try { $from = $to = array(); - $from[] = '/{{ id }}/'; - $id = $params['contact']; - $to[] = htmlspecialchars($id); + $text = ''; + foreach ($params['contact'] as $id) { + $text .= '' . htmlspecialchars($id) . '' . "\n"; + } + $from[] = '/{{ ids }}/'; + $to[] = $text; $from[] = '/{{ clTRID }}/'; $microtime = str_replace('.', '', round(microtime(1), 3)); $to[] = htmlspecialchars($this->prefix . '-contact-check-' . $microtime); @@ -673,7 +676,7 @@ public function contactCheck($params = array()) - {{ id }} + {{ ids }} {{ clTRID }} @@ -688,7 +691,8 @@ public function contactCheck($params = array()) foreach ($r->cd as $cd) { $i++; $contacts[$i]['id'] = (string)$cd->id; - $contacts[$i]['avail'] = (int)$cd->id->attributes()->avail; + $availStr = (string)$cd->id->attributes()->avail; + $contacts[$i]['avail'] = ($availStr === 'true' || $availStr === '1') ? true : false; $contacts[$i]['reason'] = (string)$cd->reason; } diff --git a/src/Registries/HrEpp.php b/src/Registries/HrEpp.php index 447e09c..d39303d 100644 --- a/src/Registries/HrEpp.php +++ b/src/Registries/HrEpp.php @@ -411,9 +411,12 @@ public function contactCheck($params = array()) $return = array(); try { $from = $to = array(); - $from[] = '/{{ id }}/'; - $id = $params['contact']; - $to[] = htmlspecialchars($id); + $text = ''; + foreach ($params['contact'] as $id) { + $text .= '' . htmlspecialchars($id) . '' . "\n"; + } + $from[] = '/{{ ids }}/'; + $to[] = $text; $from[] = '/{{ clTRID }}/'; $microtime = str_replace('.', '', round(microtime(1), 3)); $to[] = htmlspecialchars($this->prefix . '-contact-check-' . $microtime); @@ -428,7 +431,7 @@ public function contactCheck($params = array()) - {{ id }} + {{ ids }} {{ clTRID }} @@ -443,7 +446,8 @@ public function contactCheck($params = array()) foreach ($r->cd as $cd) { $i++; $contacts[$i]['id'] = (string)$cd->id; - $contacts[$i]['avail'] = (int)$cd->id->attributes()->avail; + $availStr = (string)$cd->id->attributes()->avail; + $contacts[$i]['avail'] = ($availStr === 'true' || $availStr === '1') ? true : false; $contacts[$i]['reason'] = (string)$cd->reason; } diff --git a/src/Registries/ItEpp.php b/src/Registries/ItEpp.php index 13a9b73..30c2f50 100644 --- a/src/Registries/ItEpp.php +++ b/src/Registries/ItEpp.php @@ -406,9 +406,12 @@ public function contactCheck($params = array()) $return = array(); try { $from = $to = array(); - $from[] = '/{{ id }}/'; - $id = $params['contact']; - $to[] = htmlspecialchars($id); + $text = ''; + foreach ($params['contact'] as $id) { + $text .= '' . htmlspecialchars($id) . '' . "\n"; + } + $from[] = '/{{ ids }}/'; + $to[] = $text; $from[] = '/{{ clTRID }}/'; $microtime = str_replace('.', '', round(microtime(1), 3)); $to[] = htmlspecialchars($this->prefix . '-contact-check-' . $microtime); @@ -423,7 +426,7 @@ public function contactCheck($params = array()) - {{ id }} + {{ ids }} {{ clTRID }} @@ -438,7 +441,8 @@ public function contactCheck($params = array()) foreach ($r->cd as $cd) { $i++; $contacts[$i]['id'] = (string)$cd->id; - $contacts[$i]['avail'] = (int)$cd->id->attributes()->avail; + $availStr = (string)$cd->id->attributes()->avail; + $contacts[$i]['avail'] = ($availStr === 'true' || $availStr === '1') ? true : false; $contacts[$i]['reason'] = (string)$cd->reason; } @@ -653,7 +657,7 @@ public function contactCreate($params = array()) {{ fax }} {{ email }} - + {{ authInfo }} diff --git a/src/Registries/LvEpp.php b/src/Registries/LvEpp.php index 6978ccc..4cc3df1 100644 --- a/src/Registries/LvEpp.php +++ b/src/Registries/LvEpp.php @@ -656,9 +656,12 @@ public function contactCheck($params = array()) $return = array(); try { $from = $to = array(); - $from[] = '/{{ id }}/'; - $id = $params['contact']; - $to[] = htmlspecialchars($id); + $text = ''; + foreach ($params['contact'] as $id) { + $text .= '' . htmlspecialchars($id) . '' . "\n"; + } + $from[] = '/{{ ids }}/'; + $to[] = $text; $from[] = '/{{ clTRID }}/'; $microtime = str_replace('.', '', round(microtime(1), 3)); $to[] = htmlspecialchars($this->prefix . '-contact-check-' . $microtime); @@ -673,7 +676,7 @@ public function contactCheck($params = array()) - {{ id }} + {{ ids }} {{ clTRID }} @@ -688,7 +691,8 @@ public function contactCheck($params = array()) foreach ($r->cd as $cd) { $i++; $contacts[$i]['id'] = (string)$cd->id; - $contacts[$i]['avail'] = (int)$cd->id->attributes()->avail; + $availStr = (string)$cd->id->attributes()->avail; + $contacts[$i]['avail'] = ($availStr === 'true' || $availStr === '1') ? true : false; $contacts[$i]['reason'] = (string)$cd->reason; } diff --git a/src/Registries/MxEpp.php b/src/Registries/MxEpp.php index 97b7ebe..4c0db0f 100644 --- a/src/Registries/MxEpp.php +++ b/src/Registries/MxEpp.php @@ -657,9 +657,12 @@ public function contactCheck($params = array()) $return = array(); try { $from = $to = array(); - $from[] = '/{{ id }}/'; - $id = $params['contact']; - $to[] = htmlspecialchars($id); + $text = ''; + foreach ($params['contact'] as $id) { + $text .= '' . htmlspecialchars($id) . '' . "\n"; + } + $from[] = '/{{ ids }}/'; + $to[] = $text; $from[] = '/{{ clTRID }}/'; $microtime = str_replace('.', '', round(microtime(1), 3)); $to[] = htmlspecialchars($this->prefix . '-contact-check-' . $microtime); @@ -674,7 +677,7 @@ public function contactCheck($params = array()) - {{ id }} + {{ ids }} {{ clTRID }} @@ -689,7 +692,8 @@ public function contactCheck($params = array()) foreach ($r->cd as $cd) { $i++; $contacts[$i]['id'] = (string)$cd->id; - $contacts[$i]['avail'] = (int)$cd->id->attributes()->avail; + $availStr = (string)$cd->id->attributes()->avail; + $contacts[$i]['avail'] = ($availStr === 'true' || $availStr === '1') ? true : false; $contacts[$i]['reason'] = (string)$cd->reason; } diff --git a/src/Registries/NoEpp.php b/src/Registries/NoEpp.php index 230e140..0ca7511 100644 --- a/src/Registries/NoEpp.php +++ b/src/Registries/NoEpp.php @@ -660,9 +660,12 @@ public function contactCheck($params = array()) $return = array(); try { $from = $to = array(); - $from[] = '/{{ id }}/'; - $id = $params['contact']; - $to[] = htmlspecialchars($id); + $text = ''; + foreach ($params['contact'] as $id) { + $text .= '' . htmlspecialchars($id) . '' . "\n"; + } + $from[] = '/{{ ids }}/'; + $to[] = $text; $from[] = '/{{ clTRID }}/'; $microtime = str_replace('.', '', round(microtime(1), 3)); $to[] = htmlspecialchars($this->prefix . '-contact-check-' . $microtime); @@ -677,7 +680,7 @@ public function contactCheck($params = array()) - {{ id }} + {{ ids }} {{ clTRID }} @@ -687,11 +690,13 @@ public function contactCheck($params = array()) $code = (int)$r->response->result->attributes()->code; $msg = (string)$r->response->result->msg; $r = $r->response->resData->children('urn:ietf:params:xml:ns:contact-1.0')->chkData; + $i = 0; foreach ($r->cd as $cd) { $i++; $contacts[$i]['id'] = (string)$cd->id; - $contacts[$i]['avail'] = (int)$cd->id->attributes()->avail; + $availStr = (string)$cd->id->attributes()->avail; + $contacts[$i]['avail'] = ($availStr === 'true' || $availStr === '1') ? true : false; $contacts[$i]['reason'] = (string)$cd->reason; } diff --git a/src/Registries/PlEpp.php b/src/Registries/PlEpp.php index 059c693..f6434bf 100644 --- a/src/Registries/PlEpp.php +++ b/src/Registries/PlEpp.php @@ -664,9 +664,12 @@ public function contactCheck($params = array()) $return = array(); try { $from = $to = array(); - $from[] = '/{{ id }}/'; - $id = $params['contact']; - $to[] = htmlspecialchars($id); + $text = ''; + foreach ($params['contact'] as $id) { + $text .= '' . htmlspecialchars($id) . '' . "\n"; + } + $from[] = '/{{ ids }}/'; + $to[] = $text; $from[] = '/{{ clTRID }}/'; $microtime = str_replace('.', '', round(microtime(1), 3)); $to[] = htmlspecialchars($this->prefix . '-contact-check-' . $microtime); @@ -683,7 +686,7 @@ public function contactCheck($params = array()) xmlns:contact="http://www.dns.pl/nask-epp-schema/contact-2.1" xsi:schemaLocation="http://www.dns.pl/nask-epp-schema/contact-2.1 contact-2.1.xsd"> - {{ id }} + {{ ids }} {{ clTRID }} @@ -698,7 +701,8 @@ public function contactCheck($params = array()) foreach ($r->cd as $cd) { $i++; $contacts[$i]['id'] = (string)$cd->id; - $contacts[$i]['avail'] = (int)$cd->id->attributes()->avail; + $availStr = (string)$cd->id->attributes()->avail; + $contacts[$i]['avail'] = ($availStr === 'true' || $availStr === '1') ? true : false; $contacts[$i]['reason'] = (string)$cd->reason; } diff --git a/src/Registries/PtEpp.php b/src/Registries/PtEpp.php index b89d600..925f3f1 100644 --- a/src/Registries/PtEpp.php +++ b/src/Registries/PtEpp.php @@ -662,9 +662,12 @@ public function contactCheck($params = array()) $return = array(); try { $from = $to = array(); - $from[] = '/{{ id }}/'; - $id = $params['contact']; - $to[] = htmlspecialchars($id); + $text = ''; + foreach ($params['contact'] as $id) { + $text .= '' . htmlspecialchars($id) . '' . "\n"; + } + $from[] = '/{{ ids }}/'; + $to[] = $text; $from[] = '/{{ clTRID }}/'; $microtime = str_replace('.', '', round(microtime(1), 3)); $to[] = htmlspecialchars($this->prefix . '-contact-check-' . $microtime); @@ -679,7 +682,7 @@ public function contactCheck($params = array()) - {{ id }} + {{ ids }} {{ clTRID }} @@ -694,7 +697,8 @@ public function contactCheck($params = array()) foreach ($r->cd as $cd) { $i++; $contacts[$i]['id'] = (string)$cd->id; - $contacts[$i]['avail'] = (int)$cd->id->attributes()->avail; + $availStr = (string)$cd->id->attributes()->avail; + $contacts[$i]['avail'] = ($availStr === 'true' || $availStr === '1') ? true : false; $contacts[$i]['reason'] = (string)$cd->reason; } diff --git a/src/Registries/SeEpp.php b/src/Registries/SeEpp.php index 35ffdf1..c2ea41a 100644 --- a/src/Registries/SeEpp.php +++ b/src/Registries/SeEpp.php @@ -650,9 +650,12 @@ public function contactCheck($params = array()) $return = array(); try { $from = $to = array(); - $from[] = '/{{ id }}/'; - $id = $params['contact']; - $to[] = htmlspecialchars($id); + $text = ''; + foreach ($params['contact'] as $id) { + $text .= '' . htmlspecialchars($id) . '' . "\n"; + } + $from[] = '/{{ ids }}/'; + $to[] = $text; $from[] = '/{{ clTRID }}/'; $microtime = str_replace('.', '', round(microtime(1), 3)); $to[] = htmlspecialchars($this->prefix . '-contact-check-' . $microtime); @@ -667,7 +670,7 @@ public function contactCheck($params = array()) - {{ id }} + {{ ids }} {{ clTRID }} @@ -681,7 +684,8 @@ public function contactCheck($params = array()) foreach ($r->cd as $cd) { $i++; $contacts[$i]['id'] = (string)$cd->id; - $contacts[$i]['avail'] = (int)$cd->id->attributes()->avail; + $availStr = (string)$cd->id->attributes()->avail; + $contacts[$i]['avail'] = ($availStr === 'true' || $availStr === '1') ? true : false; $contacts[$i]['reason'] = (string)$cd->reason; } diff --git a/src/Registries/UaEpp.php b/src/Registries/UaEpp.php index 2baccc5..9454360 100644 --- a/src/Registries/UaEpp.php +++ b/src/Registries/UaEpp.php @@ -654,9 +654,12 @@ public function contactCheck($params = array()) $return = array(); try { $from = $to = array(); - $from[] = '/{{ id }}/'; - $id = $params['contact']; - $to[] = htmlspecialchars($id); + $text = ''; + foreach ($params['contact'] as $id) { + $text .= '' . htmlspecialchars($id) . '' . "\n"; + } + $from[] = '/{{ ids }}/'; + $to[] = $text; $from[] = '/{{ clTRID }}/'; $microtime = str_replace('.', '', round(microtime(1), 3)); $to[] = htmlspecialchars($this->prefix . '-contact-check-' . $microtime); @@ -670,7 +673,7 @@ public function contactCheck($params = array()) - {{ id }} + {{ ids }} {{ clTRID }} @@ -685,7 +688,8 @@ public function contactCheck($params = array()) foreach ($r->cd as $cd) { $i++; $contacts[$i]['id'] = (string)$cd->id; - $contacts[$i]['avail'] = (int)$cd->id->attributes()->avail; + $availStr = (string)$cd->id->attributes()->avail; + $contacts[$i]['avail'] = ($availStr === 'true' || $availStr === '1') ? true : false; $contacts[$i]['reason'] = (string)$cd->reason; }