Skip to content

Commit

Permalink
Added ability to have bulk contact check
Browse files Browse the repository at this point in the history
  • Loading branch information
getpinga committed Dec 11, 2024
1 parent 0942990 commit 8b3df41
Show file tree
Hide file tree
Showing 16 changed files with 147 additions and 79 deletions.
13 changes: 10 additions & 3 deletions examples/ContactCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ([email protected])
*
* @license MIT
Expand All @@ -17,7 +17,7 @@
$epp = connectEpp('generic');

$params = array(
'contact' => 'tembo007'
'contact' => array('tembo007', 'tembo009')
);
$contactCheck = $epp->contactCheck($params);

Expand All @@ -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++;
}
Expand Down
14 changes: 9 additions & 5 deletions src/Epp.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 .= '<contact:id>' . htmlspecialchars($id) . '</contact:id>' . "\n";
}
$from[] = '/{{ ids }}/';
$to[] = $text;
$from[] = '/{{ clTRID }}/';
$microtime = str_replace('.', '', round(microtime(1), 3));
$to[] = htmlspecialchars($this->prefix . '-contact-check-' . $microtime);
Expand All @@ -682,7 +685,7 @@ public function contactCheck($params = array())
<contact:check
xmlns:contact="urn:ietf:params:xml:ns:contact-1.0"
xsi:schemaLocation="urn:ietf:params:xml:ns:contact-1.0 contact-1.0.xsd">
<contact:id>{{ id }}</contact:id>
{{ ids }}
</contact:check>
</check>
<clTRID>{{ clTRID }}</clTRID>
Expand All @@ -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;
}

Expand Down
14 changes: 9 additions & 5 deletions src/Registries/FiEpp.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 .= '<contact:id>' . htmlspecialchars($id) . '</contact:id>' . "\n";
}
$from[] = '/{{ ids }}/';
$to[] = $text;
$from[] = '/{{ clTRID }}/';
$microtime = str_replace('.', '', round(microtime(1), 3));
$to[] = htmlspecialchars($this->prefix . '-contact-check-' . $microtime);
Expand All @@ -682,7 +685,7 @@ public function contactCheck($params = array())
<contact:check
xmlns:contact="urn:ietf:params:xml:ns:contact-1.0"
xsi:schemaLocation="urn:ietf:params:xml:ns:contact-1.0 contact-1.0.xsd">
<contact:id>{{ id }}</contact:id>
{{ ids }}
</contact:check>
</check>
<clTRID>{{ clTRID }}</clTRID>
Expand All @@ -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;
}

Expand Down
14 changes: 9 additions & 5 deletions src/Registries/FrEpp.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 .= '<contact:id>' . htmlspecialchars($id) . '</contact:id>' . "\n";
}
$from[] = '/{{ ids }}/';
$to[] = $text;
$from[] = '/{{ clTRID }}/';
$microtime = str_replace('.', '', round(microtime(1), 3));
$to[] = htmlspecialchars($this->prefix . '-contact-check-' . $microtime);
Expand All @@ -676,7 +679,7 @@ public function contactCheck($params = array())
<contact:check
xmlns:contact="urn:ietf:params:xml:ns:contact-1.0"
xsi:schemaLocation="urn:ietf:params:xml:ns:contact-1.0 contact-1.0.xsd">
<contact:id>{{ id }}</contact:id>
{{ ids }}
</contact:check>
</check>
<clTRID>{{ clTRID }}</clTRID>
Expand All @@ -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;
}

Expand Down
14 changes: 9 additions & 5 deletions src/Registries/FredEpp.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 .= '<contact:id>' . htmlspecialchars($id) . '</contact:id>' . "\n";
}
$from[] = '/{{ ids }}/';
$to[] = $text;
$from[] = '/{{ clTRID }}/';
$microtime = str_replace('.', '', round(microtime(1), 3));
$to[] = htmlspecialchars($this->prefix . '-contact-check-' . $microtime);
Expand All @@ -700,7 +703,7 @@ public function contactCheck($params = array())
<check>
<contact:check xmlns:contact="http://www.nic.cz/xml/epp/contact-1.6"
xsi:schemaLocation="http://www.nic.cz/xml/epp/contact-1.6 contact-1.6.2.xsd">
<contact:id>{{ id }}</contact:id>
{{ ids }}
</contact:check>
</check>
<clTRID>{{ clTRID }}</clTRID>
Expand All @@ -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;
}

Expand Down
14 changes: 9 additions & 5 deletions src/Registries/GrEpp.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 .= '<contact:id>' . htmlspecialchars($id) . '</contact:id>' . "\n";
}
$from[] = '/{{ ids }}/';
$to[] = $text;
$from[] = '/{{ clTRID }}/';
$microtime = str_replace('.', '', round(microtime(1), 3));
$to[] = htmlspecialchars($this->prefix . '-contact-check-' . $microtime);
Expand All @@ -666,7 +669,7 @@ public function contactCheck($params = array())
<contact:check
xmlns:contact="urn:ietf:params:xml:ns:contact-1.0"
xsi:schemaLocation="urn:ietf:params:xml:ns:contact-1.0 contact-1.0.xsd">
<contact:id>{{ id }}</contact:id>
{{ ids }}
</contact:check>
</check>
<clTRID>{{ clTRID }}</clTRID>
Expand All @@ -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;
}

Expand Down
14 changes: 9 additions & 5 deletions src/Registries/HkEpp.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 .= '<contact:id>' . htmlspecialchars($id) . '</contact:id>' . "\n";
}
$from[] = '/{{ ids }}/';
$to[] = $text;
$from[] = '/{{ clTRID }}/';
$microtime = str_replace('.', '', round(microtime(1), 3));
$to[] = htmlspecialchars($this->prefix . '-contact-check-' . $microtime);
Expand All @@ -673,7 +676,7 @@ public function contactCheck($params = array())
<contact:check
xmlns:contact="urn:ietf:params:xml:ns:contact-1.0"
xsi:schemaLocation="urn:ietf:params:xml:ns:contact-1.0 contact-1.0.xsd">
<contact:id>{{ id }}</contact:id>
{{ ids }}
</contact:check>
</check>
<clTRID>{{ clTRID }}</clTRID>
Expand All @@ -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;
}

Expand Down
14 changes: 9 additions & 5 deletions src/Registries/HrEpp.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 .= '<contact:id>' . htmlspecialchars($id) . '</contact:id>' . "\n";
}
$from[] = '/{{ ids }}/';
$to[] = $text;
$from[] = '/{{ clTRID }}/';
$microtime = str_replace('.', '', round(microtime(1), 3));
$to[] = htmlspecialchars($this->prefix . '-contact-check-' . $microtime);
Expand All @@ -428,7 +431,7 @@ public function contactCheck($params = array())
<contact:check
xmlns:contact="urn:ietf:params:xml:ns:contact-1.0"
xsi:schemaLocation="urn:ietf:params:xml:ns:contact-1.0 contact-1.0.xsd">
<contact:id>{{ id }}</contact:id>
{{ ids }}
</contact:check>
</check>
<clTRID>{{ clTRID }}</clTRID>
Expand All @@ -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;
}

Expand Down
16 changes: 10 additions & 6 deletions src/Registries/ItEpp.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 .= '<contact:id>' . htmlspecialchars($id) . '</contact:id>' . "\n";
}
$from[] = '/{{ ids }}/';
$to[] = $text;
$from[] = '/{{ clTRID }}/';
$microtime = str_replace('.', '', round(microtime(1), 3));
$to[] = htmlspecialchars($this->prefix . '-contact-check-' . $microtime);
Expand All @@ -423,7 +426,7 @@ public function contactCheck($params = array())
<contact:check
xmlns:contact="urn:ietf:params:xml:ns:contact-1.0"
xsi:schemaLocation="urn:ietf:params:xml:ns:contact-1.0 contact-1.0.xsd">
<contact:id>{{ id }}</contact:id>
{{ ids }}
</contact:check>
</check>
<clTRID>{{ clTRID }}</clTRID>
Expand All @@ -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;
}

Expand Down Expand Up @@ -653,7 +657,7 @@ public function contactCreate($params = array())
<contact:fax>{{ fax }}</contact:fax>
<contact:email>{{ email }}</contact:email>
<contact:authInfo>
<contact:pw></contact:pw>
<contact:pw>{{ authInfo }}</contact:pw>
</contact:authInfo>
</contact:create>
</create>
Expand Down
14 changes: 9 additions & 5 deletions src/Registries/LvEpp.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 .= '<contact:id>' . htmlspecialchars($id) . '</contact:id>' . "\n";
}
$from[] = '/{{ ids }}/';
$to[] = $text;
$from[] = '/{{ clTRID }}/';
$microtime = str_replace('.', '', round(microtime(1), 3));
$to[] = htmlspecialchars($this->prefix . '-contact-check-' . $microtime);
Expand All @@ -673,7 +676,7 @@ public function contactCheck($params = array())
<contact:check
xmlns:contact="urn:ietf:params:xml:ns:contact-1.0"
xsi:schemaLocation="urn:ietf:params:xml:ns:contact-1.0 contact-1.0.xsd">
<contact:id>{{ id }}</contact:id>
{{ ids }}
</contact:check>
</check>
<clTRID>{{ clTRID }}</clTRID>
Expand All @@ -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;
}

Expand Down
14 changes: 9 additions & 5 deletions src/Registries/MxEpp.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 .= '<contact:id>' . htmlspecialchars($id) . '</contact:id>' . "\n";
}
$from[] = '/{{ ids }}/';
$to[] = $text;
$from[] = '/{{ clTRID }}/';
$microtime = str_replace('.', '', round(microtime(1), 3));
$to[] = htmlspecialchars($this->prefix . '-contact-check-' . $microtime);
Expand All @@ -674,7 +677,7 @@ public function contactCheck($params = array())
<contact:check
xmlns:contact="urn:ietf:params:xml:ns:contact-1.0"
xsi:schemaLocation="urn:ietf:params:xml:ns:contact-1.0 contact-1.0.xsd">
<contact:id>{{ id }}</contact:id>
{{ ids }}
</contact:check>
</check>
<clTRID>{{ clTRID }}</clTRID>
Expand All @@ -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;
}

Expand Down
Loading

0 comments on commit 8b3df41

Please sign in to comment.