feat: add payment method support for domain registration

Extended the EPP registrar module to include payment method fields `card_id` and `card_cvc`, allowing for direct payment processing during domain registration and renewal processes. This update enables more streamlined transactions by incorporating payment details directly within the domain provisioning workflow, addressing previous limitations that required separate payment handling.

This change introduces new configuration options for storing payment method details securely and modifies the domain registration and renewal XML requests to include these details as per the updated EPP standard. Ensure proper handling and storage of these sensitive details in compliance with applicable security standards.
This commit is contained in:
Kumi 2024-05-19 18:40:15 +02:00
parent 66c0c8e0e6
commit 0047b66f53
Signed by: kumi
GPG key ID: ECBCC9082395383F

606
ISNIC.php
View file

@ -1,4 +1,5 @@
<?php
/**
* Indera EPP registrar module for FOSSBilling (https://fossbilling.org/)
*
@ -10,119 +11,146 @@
*/
class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
{
public $config = array();
public $socket;
public $isLogined;
public $config = array();
public $socket;
public $isLogined;
public function __construct($options)
{
if(isset($options['username'])) {
$this->config['username'] = $options['username'];
}
if(isset($options['password'])) {
$this->config['password'] = $options['password'];
}
if(isset($options['host'])) {
$this->config['host'] = $options['host'];
}
if(isset($options['port'])) {
$this->config['port'] = $options['port'];
}
if(isset($options['registrarprefix'])) {
$this->config['registrarprefix'] = $options['registrarprefix'];
}
if(isset($options['ssl_cert'])) {
$this->config['ssl_cert'] = $options['ssl_cert'];
}
if(isset($options['ssl_key'])) {
$this->config['ssl_key'] = $options['ssl_key'];
}
if(isset($options['ssl_ca'])) {
$this->config['ssl_ca'] = $options['ssl_ca'];
}
if(isset($options['use_tls_12'])) {
$this->config['use_tls_12'] = (bool)$options['use_tls_12'];
} else {
$this->config['use_tls_12'] = false;
}
}
public function __construct($options)
{
if (isset($options['username'])) {
$this->config['username'] = $options['username'];
}
if (isset($options['password'])) {
$this->config['password'] = $options['password'];
}
if (isset($options['host'])) {
$this->config['host'] = $options['host'];
}
if (isset($options['port'])) {
$this->config['port'] = $options['port'];
}
if (isset($options['registrarprefix'])) {
$this->config['registrarprefix'] = $options['registrarprefix'];
}
if (isset($options['ssl_cert'])) {
$this->config['ssl_cert'] = $options['ssl_cert'];
}
if (isset($options['ssl_key'])) {
$this->config['ssl_key'] = $options['ssl_key'];
}
if (isset($options['ssl_ca'])) {
$this->config['ssl_ca'] = $options['ssl_ca'];
}
if (isset($options['use_tls_12'])) {
$this->config['use_tls_12'] = (bool)$options['use_tls_12'];
} else {
$this->config['use_tls_12'] = false;
}
if (isset($options['card_id'])) {
$this->config['card_id'] = $options['card_id'];
}
if (isset($options['card_cvc'])) {
$this->config['card_cvc'] = $options['card_cvc'];
}
}
public function getTlds()
{
return array();
}
public static function getConfig()
{
return array(
'label' => 'An EPP registry module allows registrars to manage and register domain names using the Extensible Provisioning Protocol (EPP). All details below are typically provided by the domain registry and are used to authenticate your account when connecting to the EPP server.',
'form' => array(
'username' => array('text', array(
'label' => 'EPP Server Username',
'required' => true,
),
),
'password' => array('password', array(
'label' => 'EPP Server Password',
'required' => true,
'renderPassword' => true,
),
),
'host' => array('text', array(
'label' => 'EPP Server Host',
'required' => true,
),
),
'port' => array('text', array(
'label' => 'EPP Server Port',
'required' => true,
),
),
'registrarprefix' => array('text', array(
'label' => 'Registrar Prefix',
'required' => true,
),
),
'ssl_cert' => array('text', array(
'label' => 'SSL Certificate Path',
'required' => true,
),
),
'ssl_key' => array('text', array(
'label' => 'SSL Key Path',
'required' => true,
),
),
'ssl_ca' => array('text', array(
'label' => 'SSL CA Path',
'required' => false,
),
),
'use_tls_12' => array('radio', array(
'multiOptions' => array('1'=>'Yes', '0'=>'No'),
'label' => 'Use TLS 1.2 instead of 1.3',
),
),
),
);
}
public function isDomaincanBeTransferred(Registrar_Domain $domain)
{
$this->getLog()->debug('Checking if domain can be transferred: ' . $domain->getName());
return true;
}
public function getTlds()
{
return array();
}
public function isDomainAvailable(Registrar_Domain $domain)
{
$this->getLog()->debug('Checking domain availability: ' . $domain->getName());
public static function getConfig()
{
return array(
'label' => 'An EPP registry module allows registrars to manage and register domain names using the Extensible Provisioning Protocol (EPP). All details below are typically provided by the domain registry and are used to authenticate your account when connecting to the EPP server.',
'form' => array(
'username' => array(
'text', array(
'label' => 'EPP Server Username',
'required' => true,
),
),
'password' => array(
'password', array(
'label' => 'EPP Server Password',
'required' => true,
'renderPassword' => true,
),
),
'host' => array(
'text', array(
'label' => 'EPP Server Host',
'required' => true,
),
),
'port' => array(
'text', array(
'label' => 'EPP Server Port',
'required' => true,
),
),
'registrarprefix' => array(
'text', array(
'label' => 'Registrar Prefix',
'required' => true,
),
),
'ssl_cert' => array(
'text', array(
'label' => 'SSL Certificate Path',
'required' => true,
),
),
'ssl_key' => array(
'text', array(
'label' => 'SSL Key Path',
'required' => true,
),
),
'ssl_ca' => array(
'text', array(
'label' => 'SSL CA Path',
'required' => false,
),
),
'use_tls_12' => array(
'radio', array(
'multiOptions' => array('1' => 'Yes', '0' => 'No'),
'label' => 'Use TLS 1.2 instead of 1.3',
),
),
'card_id' => array(
'text', array(
'label' => 'Card ID of the payment method',
'required' => true,
),
),
'card_cvc' => array(
'text', array(
'label' => 'Card CVC',
'required' => true,
),
),
),
);
}
public function isDomaincanBeTransferred(Registrar_Domain $domain)
{
$this->getLog()->debug('Checking if domain can be transferred: ' . $domain->getName());
return true;
}
public function isDomainAvailable(Registrar_Domain $domain)
{
$this->getLog()->debug('Checking domain availability: ' . $domain->getName());
$s = $this->connect();
$this->login();
$from = $to = array();
$from[] = '/{{ name }}/';
$to[] = htmlspecialchars($domain->getName());
$from[] = '/{{ clTRID }}/';
$clTRID = str_replace('.', '', round(microtime(1) , 3));
$clTRID = str_replace('.', '', round(microtime(1), 3));
$to[] = htmlspecialchars($this->config['registrarprefix'] . '-domain-check-' . $clTRID);
$xml = preg_replace($from, $to, '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0"
@ -144,27 +172,25 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
$r = $r->response->resData->children('urn:ietf:params:xml:ns:domain-1.0')->chkData;
$reason = (string)$r->cd[0]->reason;
if ($reason)
{
if ($reason) {
return false;
} else {
return true;
}
if (!empty($s))
{
if (!empty($s)) {
$this->logout();
}
return true;
}
return true;
}
public function modifyNs(Registrar_Domain $domain)
{
$this->getLog()->debug('Modifying nameservers: ' . $domain->getName());
$this->getLog()->debug('Ns1: ' . $domain->getNs1());
$this->getLog()->debug('Ns2: ' . $domain->getNs2());
$this->getLog()->debug('Ns3: ' . $domain->getNs3());
$this->getLog()->debug('Ns4: ' . $domain->getNs4());
public function modifyNs(Registrar_Domain $domain)
{
$this->getLog()->debug('Modifying nameservers: ' . $domain->getName());
$this->getLog()->debug('Ns1: ' . $domain->getNs1());
$this->getLog()->debug('Ns2: ' . $domain->getNs2());
$this->getLog()->debug('Ns3: ' . $domain->getNs3());
$this->getLog()->debug('Ns4: ' . $domain->getNs4());
$return = array();
try {
$s = $this->connect();
@ -194,7 +220,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
$r = $r->response->resData->children('urn:ietf:params:xml:ns:domain-1.0')->infData;
$add = $rem = array();
$i = 0;
foreach($r->ns->hostObj as $ns) {
foreach ($r->ns->hostObj as $ns) {
$i++;
$ns = (string)$ns;
if (!$ns) {
@ -205,31 +231,31 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
}
foreach (range(1, 4) as $i) {
$k = "getNs$i";
$v = $domain->{$k}();
if (!$v) {
continue;
}
$k = "getNs$i";
$v = $domain->{$k}();
if (!$v) {
continue;
}
if ($k0 = array_search($v, $rem)) {
unset($rem[$k0]);
} else {
$add["ns$i"] = $v;
}
if ($k0 = array_search($v, $rem)) {
unset($rem[$k0]);
} else {
$add["ns$i"] = $v;
}
}
if (!empty($add) || !empty($rem)) {
$from = $to = array();
$text = '';
foreach($add as $k => $v) {
$text.= '<domain:hostObj>' . $v . '</domain:hostObj>' . "\n";
foreach ($add as $k => $v) {
$text .= '<domain:hostObj>' . $v . '</domain:hostObj>' . "\n";
}
$from[] = '/{{ add }}/';
$to[] = (empty($text) ? '' : "<domain:add><domain:ns>\n{$text}</domain:ns></domain:add>\n");
$text = '';
foreach($rem as $k => $v) {
$text.= '<domain:hostObj>' . $v . '</domain:hostObj>' . "\n";
foreach ($rem as $k => $v) {
$text .= '<domain:hostObj>' . $v . '</domain:hostObj>' . "\n";
}
$from[] = '/{{ rem }}/';
@ -258,9 +284,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
</epp>');
$r = $this->write($xml, __FUNCTION__);
}
}
catch(exception $e) {
} catch (exception $e) {
$return = array(
'error' => $e->getMessage()
);
@ -271,12 +295,12 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
}
return $return;
}
}
public function transferDomain(Registrar_Domain $domain)
{
$this->getLog()->debug('Transfering domain: ' . $domain->getName());
$this->getLog()->debug('Epp code: ' . $domain->getEpp());
public function transferDomain(Registrar_Domain $domain)
{
$this->getLog()->debug('Transfering domain: ' . $domain->getName());
$this->getLog()->debug('Epp code: ' . $domain->getEpp());
$return = array();
try {
$s = $this->connect();
@ -309,9 +333,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
</epp>');
$r = $this->write($xml, __FUNCTION__);
$r = $r->response->resData->children('urn:ietf:params:xml:ns:domain-1.0')->trnData;
}
catch(exception $e) {
} catch (exception $e) {
$return = array(
'error' => $e->getMessage()
);
@ -322,11 +344,11 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
}
return $return;
}
}
public function getDomainDetails(Registrar_Domain $domain)
{
$this->getLog()->debug('Getting domain details: ' . $domain->getName());
public function getDomainDetails(Registrar_Domain $domain)
{
$this->getLog()->debug('Getting domain details: ' . $domain->getName());
try {
$s = $this->connect();
$this->login();
@ -360,16 +382,16 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
$status = array();
$i = 0;
foreach ($r->status as $e) {
$i++;
$status[$i] = (string)$e->attributes()->s;
$i++;
$status[$i] = (string)$e->attributes()->s;
}
$ns = array();
$i = 0;
foreach ($r->ns->hostObj as $hostObj) {
$i++;
$ns[$i] = (string)$hostObj;
$i++;
$ns[$i] = (string)$hostObj;
}
$crDate = strtotime($crDate);
$exDate = strtotime($exDate);
@ -381,9 +403,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
$domain->setNs2(isset($ns[1]) ? $ns[1] : '');
$domain->setNs3(isset($ns[2]) ? $ns[2] : '');
$domain->setNs4(isset($ns[3]) ? $ns[3] : '');
}
catch(exception $e) {
} catch (exception $e) {
$domain = array(
'error' => $e->getMessage()
);
@ -394,11 +414,11 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
}
return $domain;
}
}
public function deleteDomain(Registrar_Domain $domain)
{
$this->getLog()->debug('Removing domain: ' . $domain->getName());
public function deleteDomain(Registrar_Domain $domain)
{
$this->getLog()->debug('Removing domain: ' . $domain->getName());
$return = array();
try {
$s = $this->connect();
@ -424,9 +444,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
</command>
</epp>');
$r = $this->write($xml, __FUNCTION__);
}
catch(exception $e) {
} catch (exception $e) {
$return = array(
'error' => $e->getMessage()
);
@ -437,11 +455,11 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
}
return $return;
}
}
public function registerDomain(Registrar_Domain $domain)
{
$this->getLog()->debug('Registering domain: ' . $domain->getName(). ' for '.$domain->getRegistrationPeriod(). ' years');
public function registerDomain(Registrar_Domain $domain)
{
$this->getLog()->debug('Registering domain: ' . $domain->getName() . ' for ' . $domain->getRegistrationPeriod() . ' years');
$client = $domain->getContactRegistrar();
$return = array();
@ -479,7 +497,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
if (0 == (int)$r->cd[0]->name->attributes()->avail) {
throw new exception($r->cd[0]->name . ' ' . $reason);
}
// contact:create
$from = $to = array();
$from[] = '/{{ id }}/';
@ -500,7 +518,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
$from[] = '/{{ country }}/';
$to[] = htmlspecialchars($client->getCountry());
$from[] = '/{{ phonenumber }}/';
$to[] = htmlspecialchars('+'.$client->getTelCc().'.'.$client->getTel());
$to[] = htmlspecialchars('+' . $client->getTelCc() . '.' . $client->getTel());
$from[] = '/{{ email }}/';
$to[] = htmlspecialchars($client->getEmail());
$from[] = '/{{ authInfo }}/';
@ -605,33 +623,33 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
$to[] = htmlspecialchars($domain->getName());
$from[] = '/{{ period }}/';
$to[] = htmlspecialchars($domain->getRegistrationPeriod());
if($domain->getNs1()) {
$from[] = '/{{ ns1 }}/';
$to[] = htmlspecialchars($domain->getNs1());
if ($domain->getNs1()) {
$from[] = '/{{ ns1 }}/';
$to[] = htmlspecialchars($domain->getNs1());
} else {
$from[] = '/{{ ns1 }}/';
$to[] = '';
$from[] = '/{{ ns1 }}/';
$to[] = '';
}
if($domain->getNs2()) {
$from[] = '/{{ ns2 }}/';
$to[] = htmlspecialchars($domain->getNs2());
if ($domain->getNs2()) {
$from[] = '/{{ ns2 }}/';
$to[] = htmlspecialchars($domain->getNs2());
} else {
$from[] = '/{{ ns2 }}/';
$to[] = '';
$from[] = '/{{ ns2 }}/';
$to[] = '';
}
if($domain->getNs3()) {
$from[] = '/{{ ns3 }}/';
$to[] = htmlspecialchars($domain->getNs3());
if ($domain->getNs3()) {
$from[] = '/{{ ns3 }}/';
$to[] = htmlspecialchars($domain->getNs3());
} else {
$from[] = '/{{ ns3 }}/';
$to[] = '';
$from[] = '/{{ ns3 }}/';
$to[] = '';
}
if($domain->getNs4()) {
$from[] = '/{{ ns4 }}/';
$to[] = htmlspecialchars($domain->getNs4());
if ($domain->getNs4()) {
$from[] = '/{{ ns4 }}/';
$to[] = htmlspecialchars($domain->getNs4());
} else {
$from[] = '/{{ ns4 }}/';
$to[] = '';
$from[] = '/{{ ns4 }}/';
$to[] = '';
}
$from[] = '/{{ cID_1 }}/';
$to[] = htmlspecialchars($contacts);
@ -673,13 +691,17 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
</domain:authInfo>
</domain:create>
</create>
<extension>
<is-ext-domain:create>
<is-ext-domain:cardID>{{ card_id }}</is-ext-domain:cardID>
<is-ext-domain:cardCVC>{{ card_cvc }}</is-ext-domain:cardCVC>
</is-ext-domain:create>
</extension>
<clTRID>{{ clTRID }}</clTRID>
</command>
</epp>');
$r = $this->write($xml, __FUNCTION__);
}
catch(exception $e) {
} catch (exception $e) {
$return = array(
'error' => $e->getMessage()
);
@ -690,11 +712,11 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
}
return $return;
}
}
public function renewDomain(Registrar_Domain $domain)
{
$this->getLog()->debug('Renewing domain: ' . $domain->getName());
public function renewDomain(Registrar_Domain $domain)
{
$this->getLog()->debug('Renewing domain: ' . $domain->getName());
$return = array();
try {
$s = $this->connect();
@ -745,13 +767,17 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
<domain:period unit="y">1</domain:period>
</domain:renew>
</renew>
<extension>
<is-ext-domain:renew>
<is-ext-domain:cardID>{{ card_id }}</is-ext-domain:cardID>
<is-ext-domain:cardCVC>{{ card_cvc }}</is-ext-domain:cardCVC>
</is-ext-domain:renew>
</extension>
<clTRID>{{ clTRID }}</clTRID>
</command>
</epp>');
$r = $this->write($xml, __FUNCTION__);
}
catch(exception $e) {
} catch (exception $e) {
$return = array(
'error' => $e->getMessage()
);
@ -762,11 +788,11 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
}
return $return;
}
}
public function modifyContact(Registrar_Domain $domain)
{
$this->getLog()->debug('Updating contact info: ' . $domain->getName());
public function modifyContact(Registrar_Domain $domain)
{
$this->getLog()->debug('Updating contact info: ' . $domain->getName());
$client = $domain->getContactRegistrar();
$return = array();
try {
@ -816,7 +842,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
$from[] = '/{{ country }}/';
$to[] = htmlspecialchars($client->getCountry());
$from[] = '/{{ phonenumber }}/';
$to[] = htmlspecialchars('+'.$client->getTelCc().'.'.$client->getTel());
$to[] = htmlspecialchars('+' . $client->getTelCc() . '.' . $client->getTel());
$from[] = '/{{ email }}/';
$to[] = htmlspecialchars($client->getEmail());
$from[] = '/{{ clTRID }}/';
@ -853,9 +879,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
</command>
</epp>');
$r = $this->write($xml, __FUNCTION__);
}
catch(exception $e) {
} catch (exception $e) {
$return = array(
'error' => $e->getMessage()
);
@ -866,11 +890,11 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
}
return $return;
}
public function enablePrivacyProtection(Registrar_Domain $domain)
{
$this->getLog()->debug('Enabling Privacy protection: ' . $domain->getName());
}
public function enablePrivacyProtection(Registrar_Domain $domain)
{
$this->getLog()->debug('Enabling Privacy protection: ' . $domain->getName());
$return = array();
try {
$s = $this->connect();
@ -900,13 +924,13 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
$r = $r->response->resData->children('urn:ietf:params:xml:ns:domain-1.0')->infData;
$dcontact = array();
$dcontact['registrant'] = (string)$r->registrant;
foreach($r->contact as $e) {
foreach ($r->contact as $e) {
$type = (string)$e->attributes()->type;
$dcontact[$type] = (string)$e;
}
$contact = array();
foreach($dcontact as $id) {
foreach ($dcontact as $id) {
if (isset($contact[$id])) {
continue;
}
@ -916,7 +940,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
$from[] = '/{{ flag }}/';
$to[] = 1;
$from[] = '/{{ clTRID }}/';
$clTRID = str_replace('.', '', round(microtime(1) , 3));
$clTRID = str_replace('.', '', round(microtime(1), 3));
$to[] = htmlspecialchars($this->config['registrarprefix'] . '-contact-update-' . $clTRID);
$xml = preg_replace($from, $to, '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0"
@ -943,9 +967,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
</epp>');
$r = $this->write($xml, __FUNCTION__);
}
}
catch(exception $e) {
} catch (exception $e) {
$return = array(
'error' => $e->getMessage()
);
@ -956,11 +978,11 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
}
return $return;
}
public function disablePrivacyProtection(Registrar_Domain $domain)
{
$this->getLog()->debug('Disabling Privacy protection: ' . $domain->getName());
}
public function disablePrivacyProtection(Registrar_Domain $domain)
{
$this->getLog()->debug('Disabling Privacy protection: ' . $domain->getName());
$return = array();
try {
$s = $this->connect();
@ -990,13 +1012,13 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
$r = $r->response->resData->children('urn:ietf:params:xml:ns:domain-1.0')->infData;
$dcontact = array();
$dcontact['registrant'] = (string)$r->registrant;
foreach($r->contact as $e) {
foreach ($r->contact as $e) {
$type = (string)$e->attributes()->type;
$dcontact[$type] = (string)$e;
}
$contact = array();
foreach($dcontact as $id) {
foreach ($dcontact as $id) {
if (isset($contact[$id])) {
continue;
}
@ -1006,7 +1028,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
$from[] = '/{{ flag }}/';
$to[] = 0;
$from[] = '/{{ clTRID }}/';
$clTRID = str_replace('.', '', round(microtime(1) , 3));
$clTRID = str_replace('.', '', round(microtime(1), 3));
$to[] = htmlspecialchars($this->config['registrarprefix'] . '-contact-update-' . $clTRID);
$xml = preg_replace($from, $to, '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0"
@ -1033,9 +1055,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
</epp>');
$r = $this->write($xml, __FUNCTION__);
}
}
catch(exception $e) {
} catch (exception $e) {
$return = array(
'error' => $e->getMessage()
);
@ -1046,11 +1066,11 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
}
return $return;
}
}
public function getEpp(Registrar_Domain $domain)
{
$this->getLog()->debug('Retrieving domain transfer code: ' . $domain->getName());
public function getEpp(Registrar_Domain $domain)
{
$this->getLog()->debug('Retrieving domain transfer code: ' . $domain->getName());
$return = array();
try {
$s = $this->connect();
@ -1081,12 +1101,10 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
$eppcode = (string)$r->authInfo->pw;
if (!empty($s)) {
$this->logout();
}
$this->logout();
}
return $eppcode;
}
catch(exception $e) {
} catch (exception $e) {
$return = array(
'error' => $e->getMessage()
);
@ -1097,11 +1115,11 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
}
return $return;
}
}
public function lock(Registrar_Domain $domain)
{
$this->getLog()->debug('Locking domain: ' . $domain->getName());
public function lock(Registrar_Domain $domain)
{
$this->getLog()->debug('Locking domain: ' . $domain->getName());
$return = array();
try {
$s = $this->connect();
@ -1130,7 +1148,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
$r = $this->write($xml, __FUNCTION__);
$r = $r->response->resData->children('urn:ietf:params:xml:ns:domain-1.0')->infData;
$status = array();
foreach($r->status as $e) {
foreach ($r->status as $e) {
$st = (string)$e->attributes()->s;
if (!preg_match("/^client.+Prohibited$/i", $st)) {
continue;
@ -1140,7 +1158,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
}
$add = array();
foreach(array(
foreach (array(
'clientUpdateProhibited',
'clientDeleteProhibited',
'clientTransferProhibited'
@ -1152,8 +1170,8 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
if (!empty($add)) {
$text = '';
foreach($add as $st) {
$text.= '<domain:status s="' . $st . '" lang="en"></domain:status>' . "\n";
foreach ($add as $st) {
$text .= '<domain:status s="' . $st . '" lang="en"></domain:status>' . "\n";
}
$from[] = '/{{ add }}/';
$to[] = (empty($text) ? '' : "<domain:add>\n{$text}</domain:add>\n");
@ -1180,9 +1198,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
</epp>');
$r = $this->write($xml, __FUNCTION__);
}
}
catch(exception $e) {
} catch (exception $e) {
$return = array(
'error' => $e->getMessage()
);
@ -1193,11 +1209,11 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
}
return $return;
}
}
public function unlock(Registrar_Domain $domain)
{
$this->getLog()->debug('Unlocking: ' . $domain->getName());
public function unlock(Registrar_Domain $domain)
{
$this->getLog()->debug('Unlocking: ' . $domain->getName());
$return = array();
try {
$s = $this->connect();
@ -1226,7 +1242,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
$r = $this->write($xml, __FUNCTION__);
$r = $r->response->resData->children('urn:ietf:params:xml:ns:domain-1.0')->infData;
$status = array();
foreach($r->status as $e) {
foreach ($r->status as $e) {
$st = (string)$e->attributes()->s;
if (!preg_match("/^client.+Prohibited$/i", $st)) {
continue;
@ -1236,7 +1252,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
}
$rem = array();
foreach(array(
foreach (array(
'clientUpdateProhibited',
'clientDeleteProhibited',
'clientTransferProhibited'
@ -1248,8 +1264,8 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
if (!empty($rem)) {
$text = '';
foreach($rem as $st) {
$text.= '<domain:status s="' . $st . '" lang="en"></domain:status>' . "\n";
foreach ($rem as $st) {
$text .= '<domain:status s="' . $st . '" lang="en"></domain:status>' . "\n";
}
$from[] = '/{{ rem }}/';
$to[] = (empty($text) ? '' : "<domain:rem>\n{$text}</domain:rem>\n");
@ -1276,9 +1292,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
</epp>');
$r = $this->write($xml, __FUNCTION__);
}
}
catch(exception $e) {
} catch (exception $e) {
$return = array(
'error' => $e->getMessage()
);
@ -1289,14 +1303,14 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
}
return $return;
}
}
public function connect()
{
$host = $this->config['host'];
$port = $this->config['port'];
$timeout = 30;
$opts = array(
'ssl' => array(
'verify_peer' => false,
@ -1309,11 +1323,11 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
);
$context = stream_context_create($opts);
if ($this->config['use_tls_12'] === true) {
$tls = 'tlsv1.2';
$tls = 'tlsv1.2';
} else {
$tls = 'tlsv1.3';
$tls = 'tlsv1.3';
}
$this->socket = stream_socket_client($tls."://{$host}:{$port}", $errno, $errmsg, $timeout, STREAM_CLIENT_CONNECT, $context);
$this->socket = stream_socket_client($tls . "://{$host}:{$port}", $errno, $errmsg, $timeout, STREAM_CLIENT_CONNECT, $context);
if (!$this->socket) {
throw new exception("Cannot connect to server '{$host}': {$errmsg}");
@ -1387,40 +1401,40 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
public function read()
{
$hdr = stream_get_contents($this->socket, 4);
if ($hdr === false) {
throw new exception('Connection appears to have closed.');
}
if (strlen($hdr) < 4) {
throw new exception('Failed to read header from the connection.');
}
$unpacked = unpack('N', $hdr);
$xml = fread($this->socket, ($unpacked[1] - 4));
$xml = preg_replace('/></', ">\n<", $xml);
return $xml;
$hdr = stream_get_contents($this->socket, 4);
if ($hdr === false) {
throw new exception('Connection appears to have closed.');
}
if (strlen($hdr) < 4) {
throw new exception('Failed to read header from the connection.');
}
$unpacked = unpack('N', $hdr);
$xml = fread($this->socket, ($unpacked[1] - 4));
$xml = preg_replace('/></', ">\n<", $xml);
return $xml;
}
public function write($xml)
{
if (fwrite($this->socket, pack('N', (strlen($xml) + 4)) . $xml) === false) {
throw new exception('Error writing to the connection.');
}
$xml_string = $this->read();
libxml_use_internal_errors(true);
$r = simplexml_load_string($xml_string, 'SimpleXMLElement', LIBXML_DTDLOAD | LIBXML_NOENT);
if ($r instanceof SimpleXMLElement) {
$r->registerXPathNamespace('e', 'urn:ietf:params:xml:ns:epp-1.0');
$r->registerXPathNamespace('xsi', 'http://www.w3.org/2001/XMLSchema-instance');
$r->registerXPathNamespace('domain', 'urn:ietf:params:xml:ns:domain-1.0');
$r->registerXPathNamespace('contact', 'urn:ietf:params:xml:ns:contact-1.0');
$r->registerXPathNamespace('host', 'urn:ietf:params:xml:ns:host-1.0');
$r->registerXPathNamespace('rgp', 'urn:ietf:params:xml:ns:rgp-1.0');
}
if (fwrite($this->socket, pack('N', (strlen($xml) + 4)) . $xml) === false) {
throw new exception('Error writing to the connection.');
}
$xml_string = $this->read();
libxml_use_internal_errors(true);
if (isset($r->response) && $r->response->result->attributes()->code >= 2000) {
throw new exception($r->response->result->msg);
}
$r = simplexml_load_string($xml_string, 'SimpleXMLElement', LIBXML_DTDLOAD | LIBXML_NOENT);
if ($r instanceof SimpleXMLElement) {
$r->registerXPathNamespace('e', 'urn:ietf:params:xml:ns:epp-1.0');
$r->registerXPathNamespace('xsi', 'http://www.w3.org/2001/XMLSchema-instance');
$r->registerXPathNamespace('domain', 'urn:ietf:params:xml:ns:domain-1.0');
$r->registerXPathNamespace('contact', 'urn:ietf:params:xml:ns:contact-1.0');
$r->registerXPathNamespace('host', 'urn:ietf:params:xml:ns:host-1.0');
$r->registerXPathNamespace('rgp', 'urn:ietf:params:xml:ns:rgp-1.0');
}
if (isset($r->response) && $r->response->result->attributes()->code >= 2000) {
throw new exception($r->response->result->msg);
}
return $r;
}
@ -1429,7 +1443,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
{
$result = fclose($this->socket);
if (!$result) {
throw new exception('Error closing the connection.');
throw new exception('Error closing the connection.');
}
$this->socket = null;
return $result;
@ -1460,8 +1474,8 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
return 'aA1' . $result;
}
public function generateRandomString()
public function generateRandomString()
{
$characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$randomString = '';