refactor: improve code structure and readability

- Standardized the formatting across ISNICSync.php and eppClient.php for better consistency and readability, making future maintenance and debugging efforts more efficient.
- Adjusted the use of whitespace and alignment in both files to follow best coding practices, enhancing code clarity and developer experience.
- Simplified control structures for improved logic flow and reduced complexity in error handling and network communication processes.
- Ensured that all modified functions and error messages remain functional with clearer, more standardized error handling to minimize runtime errors and facilitate easier error tracking.

This refactor does not introduce any new features or significantly alter existing functionality but sets a solid foundation for more reliable and maintainable codebase.
This commit is contained in:
Kumi 2024-05-19 20:13:58 +02:00
parent 0047b66f53
commit 6e18fa423d
Signed by: kumi
GPG key ID: ECBCC9082395383F
2 changed files with 259 additions and 271 deletions

View file

@ -2,13 +2,13 @@
require_once "eppClient.php";
use Pinga\Tembo\eppClient;
$config = include "config.php";
$c = $config["db"];
$registrar = "ISNIC";
try
{
try {
// Establish the PDO connection
$dsn = $c["type"] . ":host=" . $c["host"] . ";port=" . $c["port"] . ";dbname=" . $c["name"];
$pdo = new PDO($dsn, $c["user"], $c["password"]);
@ -27,52 +27,42 @@ try
$config = [];
foreach ($rows as $row)
{
foreach ($rows as $row) {
$config = json_decode($row["config"], true);
$registrar_id = $row["id"];
}
if (empty($config))
{
if (empty($config)) {
throw new Exception("Database cannot be accessed right now.");
}
}
catch(PDOException $e)
{
} catch (PDOException $e) {
echo "Database error: " . $e->getMessage();
}
catch(Exception $e)
{
} catch (Exception $e) {
echo "General error: " . $e->getMessage();
}
function connectEpp(string $registry, $config)
{
try
{
try {
$epp = new eppClient();
$info = [
"host" => $config["host"],
"port" => $config["port"], "timeout" => 30, "tls" => "1.3", "bind" => false, "bindip" => "1.2.3.4:0", "verify_peer" => false, "verify_peer_name" => false,
"verify_host" => false, "cafile" => "", "local_cert" => $config["ssl_cert"], "local_pk" => $config["ssl_key"], "passphrase" => "", "allow_self_signed" => true, ];
"host" => $config["host"],
"port" => $config["port"], "timeout" => 30, "tls" => "1.3", "bind" => false, "bindip" => "1.2.3.4:0", "verify_peer" => false, "verify_peer_name" => false,
"verify_host" => false, "cafile" => "", "local_cert" => $config["ssl_cert"], "local_pk" => $config["ssl_key"], "passphrase" => "", "allow_self_signed" => true,
];
$epp->connect($info);
$login = $epp->login(["clID" => $config["username"], "pw" => $config["password"],
"prefix" => "tembo", ]);
if (array_key_exists("error", $login))
{
$login = $epp->login([
"clID" => $config["username"], "pw" => $config["password"],
"prefix" => "tembo",
]);
if (array_key_exists("error", $login)) {
echo "Login Error: " . $login["error"] . PHP_EOL;
exit();
}
else
{
} else {
echo "Login Result: " . $login["code"] . ": " . $login["msg"][0] . PHP_EOL;
}
return $epp;
}
catch(EppException $e)
{
} catch (EppException $e) {
return "Error : " . $e->getMessage();
}
}
@ -83,7 +73,7 @@ try {
$stmt->bindValue(':registrar', $registrar_id);
$stmt->execute();
$domains = $stmt->fetchAll(PDO::FETCH_ASSOC);
$epp = connectEpp("generic", $config);
foreach ($domains as $domainRow) {
@ -97,18 +87,18 @@ try {
echo "DomainInfo Error: " . $domainInfo["error"] . " (" . $domain . ")" . PHP_EOL;
continue;
}
$ns = $domainInfo['ns'];
$ns1 = isset($ns[1]) ? $ns[1] : null;
$ns2 = isset($ns[2]) ? $ns[2] : null;
$ns3 = isset($ns[3]) ? $ns[3] : null;
$ns4 = isset($ns[4]) ? $ns[4] : null;
$exDate = $domainInfo['exDate'];
$datetime = new DateTime($exDate);
$formattedExDate = $datetime->format('Y-m-d H:i:s');
$statuses = $domainInfo['status'];
$clientStatuses = ['clientDeleteProhibited', 'clientTransferProhibited', 'clientUpdateProhibited'];
@ -121,9 +111,9 @@ try {
$serverProhibited = count(array_intersect($serverStatuses, $statuses)) === count($serverStatuses);
if ($clientProhibited || $serverProhibited) {
$locked = 1;
$locked = 1;
} else {
$locked = 0;
$locked = 0;
}
// Prepare the UPDATE statement
@ -142,7 +132,7 @@ try {
// Execute the statement
$stmt->execute();
echo "Update successful for domain: " . $domain . PHP_EOL;
}
@ -150,6 +140,6 @@ try {
echo "Logout Result: " . $logout["code"] . ": " . $logout["msg"][0] . PHP_EOL;
} catch (PDOException $e) {
echo "Database error: " . $e->getMessage();
} catch(EppException $e) {
} catch (EppException $e) {
echo "Error: ", $e->getMessage();
}

View file

@ -1,4 +1,5 @@
<?php
/**
* Tembo EPP client library
*
@ -42,15 +43,15 @@ class eppClient
}
$opts = array(
'ssl' => array(
'verify_peer' => (bool)$params['verify_peer'],
'verify_peer_name' => (bool)$params['verify_peer_name'],
'verify_host' => (bool)$params['verify_host'],
'cafile' => (string)$params['cafile'],
'local_cert' => (string)$params['local_cert'],
'local_pk' => (string)$params['local_pk'],
'passphrase' => (string)$params['passphrase'],
'allow_self_signed' => (bool)$params['allow_self_signed'],
'min_tls_version' => $tls
'verify_peer' => (bool)$params['verify_peer'],
'verify_peer_name' => (bool)$params['verify_peer_name'],
'verify_host' => (bool)$params['verify_host'],
'cafile' => (string)$params['cafile'],
'local_cert' => (string)$params['local_cert'],
'local_pk' => (string)$params['local_pk'],
'passphrase' => (string)$params['passphrase'],
'allow_self_signed' => (bool)$params['allow_self_signed'],
'min_tls_version' => $tls
)
);
if ($bind) {
@ -93,18 +94,18 @@ class eppClient
if (fwrite($this->resource, pack('N', (strlen($xml) + 4)) . $xml) === false) {
throw new exception('Error writing to the connection.');
}
$xml_string = $this->readResponse();
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');
}
$xml_string = $this->readResponse();
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 (isset($r->response) && $r->response->result->attributes()->code >= 2000) {
throw new \exception($r->response->result->msg);
}
@ -123,8 +124,8 @@ class eppClient
}
/**
* wrapper for functions
*/
* wrapper for functions
*/
public function __call($func, $args)
{
if (!function_exists($func)) {
@ -168,13 +169,13 @@ class eppClient
$from[] = '/{{ clID }}/';
$to[] = htmlspecialchars($params['clID']);
$from[] = '/{{ pwd }}/';
$to[] = htmlspecialchars($params['pw']);
$to[] = htmlspecialchars($params['pw']);
if (isset($params['newpw']) && !empty($params['newpw'])) {
$from[] = '/{{ newpw }}/';
$to[] = PHP_EOL . ' <newPW>' . htmlspecialchars($params['newpw']) . '</newPW>';
$from[] = '/{{ newpw }}/';
$to[] = PHP_EOL . ' <newPW>' . htmlspecialchars($params['newpw']) . '</newPW>';
} else {
$from[] = '/{{ newpw }}/';
$to[] = '';
$from[] = '/{{ newpw }}/';
$to[] = '';
}
$from[] = '/{{ clTRID }}/';
$microtime = str_replace('.', '', round(microtime(1), 3));
@ -460,10 +461,10 @@ class eppClient
$from = $to = array();
$from[] = '/{{ name }}/';
$to[] = htmlspecialchars($params['hostname']);
$from[] = '/{{ ip }}/';
$to[] = htmlspecialchars($params['ipaddress']);
$from[] = '/{{ v }}/';
$to[] = (preg_match('/:/', $params['ipaddress']) ? 'v6' : 'v4');
$from[] = '/{{ ip }}/';
$to[] = htmlspecialchars($params['ipaddress']);
$from[] = '/{{ v }}/';
$to[] = (preg_match('/:/', $params['ipaddress']) ? 'v6' : 'v4');
$from[] = '/{{ clTRID }}/';
$clTRID = str_replace('.', '', round(microtime(1), 3));
$to[] = htmlspecialchars($this->prefix . '-host-create-' . $clTRID);
@ -503,7 +504,7 @@ class eppClient
return $return;
}
/**
* hostUpdate
*/
@ -519,16 +520,16 @@ class eppClient
$return = array();
try {
$from = $to = array();
$from[] = '/{{ name }}/';
$to[] = htmlspecialchars($params['hostname']);
$from[] = '/{{ ip1 }}/';
$to[] = htmlspecialchars($params['currentipaddress']);
$from[] = '/{{ v1 }}/';
$to[] = (preg_match('/:/', $params['currentipaddress']) ? 'v6' : 'v4');
$from[] = '/{{ ip2 }}/';
$to[] = htmlspecialchars($params['newipaddress']);
$from[] = '/{{ v2 }}/';
$to[] = (preg_match('/:/', $params['newipaddress']) ? 'v6' : 'v4');
$from[] = '/{{ name }}/';
$to[] = htmlspecialchars($params['hostname']);
$from[] = '/{{ ip1 }}/';
$to[] = htmlspecialchars($params['currentipaddress']);
$from[] = '/{{ v1 }}/';
$to[] = (preg_match('/:/', $params['currentipaddress']) ? 'v6' : 'v4');
$from[] = '/{{ ip2 }}/';
$to[] = htmlspecialchars($params['newipaddress']);
$from[] = '/{{ v2 }}/';
$to[] = (preg_match('/:/', $params['newipaddress']) ? 'v6' : 'v4');
$from[] = '/{{ clTRID }}/';
$clTRID = str_replace('.', '', round(microtime(1), 3));
$to[] = htmlspecialchars($this->prefix . '-host-update-' . $clTRID);
@ -1110,7 +1111,7 @@ class eppClient
return $return;
}
/**
* domainCheckClaims
*/
@ -1359,14 +1360,14 @@ class eppClient
$from = $to = array();
$text = '';
foreach ($add as $k => $v) {
$text.= '<domain:hostObj>' . $v . '</domain:hostObj>' . "\n";
$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";
$text .= '<domain:hostObj>' . $v . '</domain:hostObj>' . "\n";
}
$from[] = '/{{ rem }}/';
@ -1428,21 +1429,21 @@ class eppClient
$from = $to = array();
$from[] = '/{{ name }}/';
$to[] = htmlspecialchars($params['domainname']);
if ($params['contacttype'] === 'registrant') {
$from[] = '/{{ add }}/';
$to[] = "";
$from[] = '/{{ rem }}/';
$to[] = "";
$from[] = '/{{ chg }}/';
$to[] = "<domain:chg><domain:registrant>".htmlspecialchars($params['new_contactid'])."</domain:registrant></domain:chg>\n";
} else {
$from[] = '/{{ add }}/';
$to[] = "<domain:add><domain:contact type=\"".htmlspecialchars($params['contacttype'])."\">".htmlspecialchars($params['new_contactid'])."</domain:contact></domain:add>\n";
$from[] = '/{{ rem }}/';
$to[] = "<domain:rem><domain:contact type=\"".htmlspecialchars($params['contacttype'])."\">".htmlspecialchars($params['old_contactid'])."</domain:contact></domain:rem>\n";
$from[] = '/{{ chg }}/';
$to[] = "";
}
if ($params['contacttype'] === 'registrant') {
$from[] = '/{{ add }}/';
$to[] = "";
$from[] = '/{{ rem }}/';
$to[] = "";
$from[] = '/{{ chg }}/';
$to[] = "<domain:chg><domain:registrant>" . htmlspecialchars($params['new_contactid']) . "</domain:registrant></domain:chg>\n";
} else {
$from[] = '/{{ add }}/';
$to[] = "<domain:add><domain:contact type=\"" . htmlspecialchars($params['contacttype']) . "\">" . htmlspecialchars($params['new_contactid']) . "</domain:contact></domain:add>\n";
$from[] = '/{{ rem }}/';
$to[] = "<domain:rem><domain:contact type=\"" . htmlspecialchars($params['contacttype']) . "\">" . htmlspecialchars($params['old_contactid']) . "</domain:contact></domain:rem>\n";
$from[] = '/{{ chg }}/';
$to[] = "";
}
$from[] = '/{{ clTRID }}/';
$clTRID = str_replace('.', '', round(microtime(1), 3));
$to[] = htmlspecialchars($this->prefix . '-domain-updateContact-' . $clTRID);
@ -1482,7 +1483,7 @@ class eppClient
return $return;
}
/**
* domainUpdateStatus
*/
@ -1500,17 +1501,17 @@ class eppClient
$from = $to = array();
$from[] = '/{{ name }}/';
$to[] = htmlspecialchars($params['domainname']);
if ($params['command'] === 'add') {
$from[] = '/{{ add }}/';
$to[] = "<domain:add><domain:status s=\"".htmlspecialchars($params['status'])."\"/></domain:add>\n";
$from[] = '/{{ rem }}/';
$to[] = "";
} else if ($params['command'] === 'rem') {
$from[] = '/{{ add }}/';
$to[] = "";
$from[] = '/{{ rem }}/';
$to[] = "<domain:rem><domain:status s=\"".htmlspecialchars($params['status'])."\"/></domain:rem>\n";
}
if ($params['command'] === 'add') {
$from[] = '/{{ add }}/';
$to[] = "<domain:add><domain:status s=\"" . htmlspecialchars($params['status']) . "\"/></domain:add>\n";
$from[] = '/{{ rem }}/';
$to[] = "";
} else if ($params['command'] === 'rem') {
$from[] = '/{{ add }}/';
$to[] = "";
$from[] = '/{{ rem }}/';
$to[] = "<domain:rem><domain:status s=\"" . htmlspecialchars($params['status']) . "\"/></domain:rem>\n";
}
$from[] = '/{{ clTRID }}/';
$clTRID = str_replace('.', '', round(microtime(1), 3));
$to[] = htmlspecialchars($this->prefix . '-domain-updateStatus-' . $clTRID);
@ -1549,7 +1550,7 @@ class eppClient
return $return;
}
/**
* domainUpdateAuthinfo
*/
@ -1610,7 +1611,7 @@ class eppClient
return $return;
}
/**
* domainUpdateDNSSEC
*/
@ -1628,57 +1629,57 @@ class eppClient
$from = $to = array();
$from[] = '/{{ name }}/';
$to[] = htmlspecialchars($params['domainname']);
if ($params['command'] == 'add') {
$from[] = '/{{ add }}/';
$to[] = "<secDNS:add>
if ($params['command'] == 'add') {
$from[] = '/{{ add }}/';
$to[] = "<secDNS:add>
<secDNS:dsData>
<secDNS:keyTag>".htmlspecialchars($params['keyTag_1'])."</secDNS:keyTag>
<secDNS:alg>".htmlspecialchars($params['alg_1'])."</secDNS:alg>
<secDNS:digestType>".htmlspecialchars($params['digestType_1'])."</secDNS:digestType>
<secDNS:digest>".htmlspecialchars($params['digest_1'])."</secDNS:digest>
<secDNS:keyTag>" . htmlspecialchars($params['keyTag_1']) . "</secDNS:keyTag>
<secDNS:alg>" . htmlspecialchars($params['alg_1']) . "</secDNS:alg>
<secDNS:digestType>" . htmlspecialchars($params['digestType_1']) . "</secDNS:digestType>
<secDNS:digest>" . htmlspecialchars($params['digest_1']) . "</secDNS:digest>
</secDNS:dsData>
</secDNS:add>";
$from[] = '/{{ rem }}/';
$to[] = "";
$from[] = '/{{ addrem }}/';
$to[] = "";
} else if ($params['command'] == 'rem') {
$from[] = '/{{ add }}/';
$to[] = "";
$from[] = '/{{ rem }}/';
$to[] = "<secDNS:rem>
$from[] = '/{{ rem }}/';
$to[] = "";
$from[] = '/{{ addrem }}/';
$to[] = "";
} else if ($params['command'] == 'rem') {
$from[] = '/{{ add }}/';
$to[] = "";
$from[] = '/{{ rem }}/';
$to[] = "<secDNS:rem>
<secDNS:dsData>
<secDNS:keyTag>".htmlspecialchars($params['keyTag_1'])."</secDNS:keyTag>
<secDNS:alg>".htmlspecialchars($params['alg_1'])."</secDNS:alg>
<secDNS:digestType>".htmlspecialchars($params['digestType_1'])."</secDNS:digestType>
<secDNS:digest>".htmlspecialchars($params['digest_1'])."</secDNS:digest>
<secDNS:keyTag>" . htmlspecialchars($params['keyTag_1']) . "</secDNS:keyTag>
<secDNS:alg>" . htmlspecialchars($params['alg_1']) . "</secDNS:alg>
<secDNS:digestType>" . htmlspecialchars($params['digestType_1']) . "</secDNS:digestType>
<secDNS:digest>" . htmlspecialchars($params['digest_1']) . "</secDNS:digest>
</secDNS:dsData>
</secDNS:rem>";
$from[] = '/{{ addrem }}/';
$to[] = "";
} else if ($params['command'] == 'addrem') {
$from[] = '/{{ add }}/';
$to[] = "";
$from[] = '/{{ rem }}/';
$to[] = "";
$from[] = '/{{ addrem }}/';
$to[] = "<secDNS:rem>
$from[] = '/{{ addrem }}/';
$to[] = "";
} else if ($params['command'] == 'addrem') {
$from[] = '/{{ add }}/';
$to[] = "";
$from[] = '/{{ rem }}/';
$to[] = "";
$from[] = '/{{ addrem }}/';
$to[] = "<secDNS:rem>
<secDNS:dsData>
<secDNS:keyTag>".htmlspecialchars($params['keyTag_1'])."</secDNS:keyTag>
<secDNS:alg>".htmlspecialchars($params['alg_1'])."</secDNS:alg>
<secDNS:digestType>".htmlspecialchars($params['digestType_1'])."</secDNS:digestType>
<secDNS:digest>".htmlspecialchars($params['digest_1'])."</secDNS:digest>
<secDNS:keyTag>" . htmlspecialchars($params['keyTag_1']) . "</secDNS:keyTag>
<secDNS:alg>" . htmlspecialchars($params['alg_1']) . "</secDNS:alg>
<secDNS:digestType>" . htmlspecialchars($params['digestType_1']) . "</secDNS:digestType>
<secDNS:digest>" . htmlspecialchars($params['digest_1']) . "</secDNS:digest>
</secDNS:dsData>
</secDNS:rem>
<secDNS:add>
<secDNS:dsData>
<secDNS:keyTag>".htmlspecialchars($params['keyTag_2'])."</secDNS:keyTag>
<secDNS:alg>".htmlspecialchars($params['alg_2'])."</secDNS:alg>
<secDNS:digestType>".htmlspecialchars($params['digestType_2'])."</secDNS:digestType>
<secDNS:digest>".htmlspecialchars($params['digest_2'])."</secDNS:digest>
<secDNS:keyTag>" . htmlspecialchars($params['keyTag_2']) . "</secDNS:keyTag>
<secDNS:alg>" . htmlspecialchars($params['alg_2']) . "</secDNS:alg>
<secDNS:digestType>" . htmlspecialchars($params['digestType_2']) . "</secDNS:digestType>
<secDNS:digest>" . htmlspecialchars($params['digest_2']) . "</secDNS:digest>
</secDNS:dsData>
</secDNS:add>";
}
}
$from[] = '/{{ clTRID }}/';
$clTRID = str_replace('.', '', round(microtime(1), 3));
$to[] = htmlspecialchars($this->prefix . '-domain-updateDNSSEC-' . $clTRID);
@ -1742,43 +1743,43 @@ class eppClient
$from = $to = array();
$from[] = '/{{ name }}/';
$to[] = htmlspecialchars($params['domainname']);
switch (htmlspecialchars($params['op'])) {
case 'request':
$from[] = '/{{ years }}/';
$to[] = (int)($params['years']);
$from[] = '/{{ authInfoPw }}/';
$to[] = htmlspecialchars($params['authInfoPw']);
$xmltype = 'req';
break;
case 'query':
$from[] = '/{{ type }}/';
$to[] = 'query';
$xmltype = 'oth';
break;
case 'cancel':
$from[] = '/{{ type }}/';
$to[] = 'cancel';
$xmltype = 'oth';
break;
case 'reject':
$from[] = '/{{ type }}/';
$to[] = 'reject';
$xmltype = 'oth';
break;
case 'approve':
$xmltype = 'apr';
break;
default:
throw new EppException('Invalid value for transfer:op specified.');
break;
}
switch (htmlspecialchars($params['op'])) {
case 'request':
$from[] = '/{{ years }}/';
$to[] = (int)($params['years']);
$from[] = '/{{ authInfoPw }}/';
$to[] = htmlspecialchars($params['authInfoPw']);
$xmltype = 'req';
break;
case 'query':
$from[] = '/{{ type }}/';
$to[] = 'query';
$xmltype = 'oth';
break;
case 'cancel':
$from[] = '/{{ type }}/';
$to[] = 'cancel';
$xmltype = 'oth';
break;
case 'reject':
$from[] = '/{{ type }}/';
$to[] = 'reject';
$xmltype = 'oth';
break;
case 'approve':
$xmltype = 'apr';
break;
default:
throw new EppException('Invalid value for transfer:op specified.');
break;
}
$from[] = '/{{ clTRID }}/';
$clTRID = str_replace('.', '', round(microtime(1), 3));
$to[] = htmlspecialchars($this->prefix . '-domain-transfer-' . $clTRID);
$from[] = "/<\w+:\w+>\s*<\/\w+:\w+>\s+/ims";
$to[] = '';
if ($xmltype === 'req') {
$xml = preg_replace($from, $to, '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
if ($xmltype === 'req') {
$xml = preg_replace($from, $to, '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
@ -1796,33 +1797,32 @@ class eppClient
<clTRID>{{ clTRID }}</clTRID>
</command>
</epp>');
$r = $this->writeRequest($xml);
$code = (int)$r->response->result->attributes()->code;
$msg = (string)$r->response->result->msg;
$r = $r->response->resData->children('urn:ietf:params:xml:ns:domain-1.0')->trnData;
$name = (string)$r->name;
$trStatus = (string)$r->trStatus;
$reID = (string)$r->reID;
$reDate = (string)$r->reDate;
$acID = (string)$r->acID;
$acDate = (string)$r->acDate;
$exDate = (string)$r->exDate;
$return = array(
'code' => $code,
'msg' => $msg,
'name' => $name,
'trStatus' => $trStatus,
'reID' => $reID,
'reDate' => $reDate,
'acID' => $acID,
'acDate' => $acDate,
'exDate' => $exDate
);
} else if ($xmltype === 'apr') {
$xml = preg_replace($from, $to, '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
$r = $this->writeRequest($xml);
$code = (int)$r->response->result->attributes()->code;
$msg = (string)$r->response->result->msg;
$r = $r->response->resData->children('urn:ietf:params:xml:ns:domain-1.0')->trnData;
$name = (string)$r->name;
$trStatus = (string)$r->trStatus;
$reID = (string)$r->reID;
$reDate = (string)$r->reDate;
$acID = (string)$r->acID;
$acDate = (string)$r->acDate;
$exDate = (string)$r->exDate;
$return = array(
'code' => $code,
'msg' => $msg,
'name' => $name,
'trStatus' => $trStatus,
'reID' => $reID,
'reDate' => $reDate,
'acID' => $acID,
'acDate' => $acDate,
'exDate' => $exDate
);
} else if ($xmltype === 'apr') {
$xml = preg_replace($from, $to, '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
@ -1836,27 +1836,26 @@ class eppClient
<clTRID>{{ clTRID }}</clTRID>
</command>
</epp>');
$r = $this->writeRequest($xml);
$code = (int)$r->response->result->attributes()->code;
$msg = (string)$r->response->result->msg;
$r = $r->response->resData->children('urn:ietf:params:xml:ns:domain-1.0')->Data;
$name = (string)$r->name;
$trStatus = (string)$r->trStatus;
$reID = (string)$r->reID;
$reDate = (string)$r->reDate;
$return = array(
'code' => $code,
'msg' => $msg,
'name' => $name,
'trStatus' => $trStatus,
'reID' => $reID,
'reDate' => $reDate
);
} else if ($xmltype === 'oth') {
$xml = preg_replace($from, $to, '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
$r = $this->writeRequest($xml);
$code = (int)$r->response->result->attributes()->code;
$msg = (string)$r->response->result->msg;
$r = $r->response->resData->children('urn:ietf:params:xml:ns:domain-1.0')->Data;
$name = (string)$r->name;
$trStatus = (string)$r->trStatus;
$reID = (string)$r->reID;
$reDate = (string)$r->reDate;
$return = array(
'code' => $code,
'msg' => $msg,
'name' => $name,
'trStatus' => $trStatus,
'reID' => $reID,
'reDate' => $reDate
);
} else if ($xmltype === 'oth') {
$xml = preg_replace($from, $to, '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
@ -1870,17 +1869,16 @@ class eppClient
<clTRID>{{ clTRID }}</clTRID>
</command>
</epp>');
$r = $this->writeRequest($xml);
$code = (int)$r->response->result->attributes()->code;
$msg = (string)$r->response->result->msg;
$return = array(
'code' => $code,
'msg' => $msg
);
}
$r = $this->writeRequest($xml);
$code = (int)$r->response->result->attributes()->code;
$msg = (string)$r->response->result->msg;
$return = array(
'code' => $code,
'msg' => $msg
);
}
} catch (\Exception $e) {
$return = array(
'error' => $e->getMessage()
@ -1923,9 +1921,9 @@ class eppClient
$from[] = '/{{ registrant }}/';
$to[] = htmlspecialchars($params['registrant']);
$text = '';
foreach ($params['contacts'] as $contactType => $contactID) {
$text .= '<domain:contact type="' . $contactType . '">' . $contactID . '</domain:contact>' . "\n";
}
foreach ($params['contacts'] as $contactType => $contactID) {
$text .= '<domain:contact type="' . $contactType . '">' . $contactID . '</domain:contact>' . "\n";
}
$from[] = '/{{ contacts }}/';
$to[] = $text;
$from[] = '/{{ authInfoPw }}/';
@ -1981,7 +1979,7 @@ class eppClient
return $return;
}
/**
* domainCreateDNSSEC
*/
@ -2015,36 +2013,36 @@ class eppClient
$from[] = '/{{ registrant }}/';
$to[] = htmlspecialchars($params['registrant']);
$text = '';
foreach ($params['contacts'] as $contactType => $contactID) {
$text .= '<domain:contact type="' . $contactType . '">' . $contactID . '</domain:contact>' . "\n";
}
foreach ($params['contacts'] as $contactType => $contactID) {
$text .= '<domain:contact type="' . $contactType . '">' . $contactID . '</domain:contact>' . "\n";
}
$from[] = '/{{ contacts }}/';
$to[] = $text;
$from[] = '/{{ authInfoPw }}/';
$to[] = htmlspecialchars($params['authInfoPw']);
if ($params['dnssec_records'] == 1) {
$from[] = '/{{ dnssec_data }}/';
$to[] = "<secDNS:dsData>
<secDNS:keyTag>".htmlspecialchars($params['keyTag_1'])."</secDNS:keyTag>
<secDNS:alg>".htmlspecialchars($params['alg_1'])."</secDNS:alg>
<secDNS:digestType>".htmlspecialchars($params['digestType_1'])."</secDNS:digestType>
<secDNS:digest>".htmlspecialchars($params['digest_1'])."</secDNS:digest>
if ($params['dnssec_records'] == 1) {
$from[] = '/{{ dnssec_data }}/';
$to[] = "<secDNS:dsData>
<secDNS:keyTag>" . htmlspecialchars($params['keyTag_1']) . "</secDNS:keyTag>
<secDNS:alg>" . htmlspecialchars($params['alg_1']) . "</secDNS:alg>
<secDNS:digestType>" . htmlspecialchars($params['digestType_1']) . "</secDNS:digestType>
<secDNS:digest>" . htmlspecialchars($params['digest_1']) . "</secDNS:digest>
</secDNS:dsData>";
} else if ($params['dnssec_records'] == 2) {
$from[] = '/{{ dnssec_data }}/';
$to[] = "<secDNS:dsData>
<secDNS:keyTag>".htmlspecialchars($params['keyTag_1'])."</secDNS:keyTag>
<secDNS:alg>".htmlspecialchars($params['alg_1'])."</secDNS:alg>
<secDNS:digestType>".htmlspecialchars($params['digestType_1'])."</secDNS:digestType>
<secDNS:digest>".htmlspecialchars($params['digest_1'])."</secDNS:digest>
} else if ($params['dnssec_records'] == 2) {
$from[] = '/{{ dnssec_data }}/';
$to[] = "<secDNS:dsData>
<secDNS:keyTag>" . htmlspecialchars($params['keyTag_1']) . "</secDNS:keyTag>
<secDNS:alg>" . htmlspecialchars($params['alg_1']) . "</secDNS:alg>
<secDNS:digestType>" . htmlspecialchars($params['digestType_1']) . "</secDNS:digestType>
<secDNS:digest>" . htmlspecialchars($params['digest_1']) . "</secDNS:digest>
</secDNS:dsData>
<secDNS:dsData>
<secDNS:keyTag>".htmlspecialchars($params['keyTag_2'])."</secDNS:keyTag>
<secDNS:alg>".htmlspecialchars($params['alg_2'])."</secDNS:alg>
<secDNS:digestType>".htmlspecialchars($params['digestType_2'])."</secDNS:digestType>
<secDNS:digest>".htmlspecialchars($params['digest_2'])."</secDNS:digest>
<secDNS:keyTag>" . htmlspecialchars($params['keyTag_2']) . "</secDNS:keyTag>
<secDNS:alg>" . htmlspecialchars($params['alg_2']) . "</secDNS:alg>
<secDNS:digestType>" . htmlspecialchars($params['digestType_2']) . "</secDNS:digestType>
<secDNS:digest>" . htmlspecialchars($params['digest_2']) . "</secDNS:digest>
</secDNS:dsData>";
}
}
$from[] = '/{{ clTRID }}/';
$clTRID = str_replace('.', '', round(microtime(1), 3));
$to[] = htmlspecialchars($this->prefix . '-domain-createDNSSEC-' . $clTRID);
@ -2103,7 +2101,7 @@ class eppClient
return $return;
}
/**
* domainCreateClaims
*/
@ -2137,9 +2135,9 @@ class eppClient
$from[] = '/{{ registrant }}/';
$to[] = htmlspecialchars($params['registrant']);
$text = '';
foreach ($params['contacts'] as $contactType => $contactID) {
$text .= '<domain:contact type="' . $contactType . '">' . $contactID . '</domain:contact>' . "\n";
}
foreach ($params['contacts'] as $contactType => $contactID) {
$text .= '<domain:contact type="' . $contactType . '">' . $contactID . '</domain:contact>' . "\n";
}
$from[] = '/{{ contacts }}/';
$to[] = $text;
$from[] = '/{{ authInfoPw }}/';
@ -2529,10 +2527,10 @@ class eppClient
$r = $this->writeRequest($xml);
$code = (int)$r->response->result->attributes()->code;
$msg = (string)$r->response->result->msg;
$messages = (int)($r->response->msgQ->attributes()->count ?? 0);
$last_id = (int)($r->response->msgQ->attributes()->id ?? 0);
$qDate = (string)($r->response->msgQ->qDate ?? '');
$last_msg = (string)($r->response->msgQ->msg ?? '');
$messages = (int)($r->response->msgQ->attributes()->count ?? 0);
$last_id = (int)($r->response->msgQ->attributes()->id ?? 0);
$qDate = (string)($r->response->msgQ->qDate ?? '');
$last_msg = (string)($r->response->msgQ->msg ?? '');
$return = array(
'code' => $code,