diff --git a/README.md b/README.md
index 0ef42cc..36ed326 100644
--- a/README.md
+++ b/README.md
@@ -48,9 +48,9 @@ Next, rename `epp.php` as `YourRegistryName.php`. Please ensure to replace "**Yo
Proceed to open the newly renamed file and locate the phrase "**Registrar_Adapter_EPP**". Replace it with "**Registrar_Adapter_YourRegistryName**".
-## 3. Addition of Synchronization Scripts:
+## 3. Addition of Synchronization Script:
-There are two additional scripts in the repository: **eppSync.php** and **eppClient.php**. These need to be placed in the main `[FOSSBilling]` directory.
+There is one additional script in the repository: **eppSync.php**. It needs to be placed in the main `[FOSSBilling]` directory.
Rename `eppSync.php` to `YourRegistryNameSync.php`.
diff --git a/eppClient.php b/eppClient.php
deleted file mode 100644
index 0de4ea9..0000000
--- a/eppClient.php
+++ /dev/null
@@ -1,2619 +0,0 @@
- 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
- )
- );
- if ($bind) {
- $opts['socket'] = array('bindto' => $bindip);
- }
- $context = stream_context_create($opts);
- $this->resource = stream_socket_client("tls://{$host}:{$port}", $errno, $errmsg, $timeout, STREAM_CLIENT_CONNECT, $context);
- if (!$this->resource) {
- throw new \exception("Cannot connect to server '{$host}': {$errmsg}");
- }
-
- return $this->readResponse();
- }
-
- /**
- * readResponse
- */
- public function readResponse()
- {
- $hdr = stream_get_contents($this->resource, 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->resource, ($unpacked[1] - 4));
- $xml = preg_replace('/>', ">\n<", $xml);
- $this->_response_log($xml);
- return $xml;
- }
-
- /**
- * writeRequest
- */
- public function writeRequest($xml)
- {
- $this->_request_log($xml);
- 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');
- }
- if (isset($r->response) && $r->response->result->attributes()->code >= 2000) {
- throw new \exception($r->response->result->msg);
- }
- return $r;
- }
-
- /**
- * disconnect
- */
- public function disconnect()
- {
- if (!fclose($this->resource)) {
- throw new \exception('Error closing the connection.');
- }
- $this->resource = null;
- }
-
- /**
- * wrapper for functions
- */
- public function __call($func, $args)
- {
- if (!function_exists($func)) {
- throw new \Exception("Call to undefined method Epp::$func().");
- }
-
- if ($func === 'connect') {
- try {
- $result = call_user_func_array($func, $args);
- } catch (\ErrorException $e) {
- throw new \Exception($e->getMessage());
- }
-
- if (!is_resource($this->resource)) {
- throw new \Exception('An error occured while trying to connect to EPP server.');
- }
-
- $result = null;
- } elseif (!is_resource($this->resource)) {
- throw new EppNotConnectedException();
- } else {
- array_unshift($args, $this->resource);
- try {
- $result = call_user_func_array($func, $args);
- } catch (\ErrorException $e) {
- throw new \Exception($e->getMessage());
- }
- }
-
- return $result;
- }
-
- /**
- * login
- */
- public function login($params = array())
- {
- $return = array();
- try {
- $from = $to = array();
- $from[] = '/{{ clID }}/';
- $to[] = htmlspecialchars($params['clID']);
- $from[] = '/{{ pwd }}/';
- $to[] = htmlspecialchars($params['pw']);
- if (isset($params['newpw']) && !empty($params['newpw'])) {
- $from[] = '/{{ newpw }}/';
- $to[] = PHP_EOL . ' ' . htmlspecialchars($params['newpw']) . '';
- } else {
- $from[] = '/{{ newpw }}/';
- $to[] = '';
- }
- $from[] = '/{{ clTRID }}/';
- $microtime = str_replace('.', '', round(microtime(1), 3));
- $to[] = htmlspecialchars($params['prefix'] . '-login-' . $microtime);
- $xml = preg_replace($from, $to, '
-
-
-
- {{ clID }}
- {{ pwd }}{{ newpw }}
-
- 1.0
- en
-
-
- urn:ietf:params:xml:ns:domain-1.0
- urn:ietf:params:xml:ns:contact-1.0
- urn:ietf:params:xml:ns:host-1.0
-
- urn:ietf:params:xml:ns:secDNS-1.1
-
-
-
- {{ clTRID }}
-
-');
- $r = $this->writeRequest($xml);
- $code = (int)$r->response->result->attributes()->code;
- if ($code == 1000) {
- $this->isLoggedIn = true;
- $this->prefix = $params['prefix'];
- }
-
- $return = array(
- 'code' => $code,
- 'msg' => $r->response->result->msg
- );
- } catch (\Exception $e) {
- $return = array(
- 'error' => $e->getMessage()
- );
- }
-
- return $return;
- }
-
- /**
- * logout
- */
- public function logout($params = array())
- {
- if (!$this->isLoggedIn) {
- return array(
- 'code' => 2002,
- 'msg' => 'Command use error'
- );
- }
-
- $return = array();
- try {
- $from = $to = array();
- $from[] = '/{{ clTRID }}/';
- $microtime = str_replace('.', '', round(microtime(1), 3));
- $to[] = htmlspecialchars($this->prefix . '-logout-' . $microtime);
- $xml = preg_replace($from, $to, '
-
-
-
- {{ clTRID }}
-
-');
- $r = $this->writeRequest($xml);
- $code = (int)$r->response->result->attributes()->code;
- if ($code == 1500) {
- $this->isLoggedIn = false;
- }
-
- $return = array(
- 'code' => $code,
- 'msg' => $r->response->result->msg
- );
- } catch (\Exception $e) {
- $return = array(
- 'error' => $e->getMessage()
- );
- }
-
- return $return;
- }
-
- /**
- * hello
- */
- public function hello()
- {
- if (!$this->isLoggedIn) {
- return array(
- 'code' => 2002,
- 'msg' => 'Command use error'
- );
- }
-
- $return = array();
- try {
- $from = $to = array();
- $from[] = '/{{ clTRID }}/';
- $microtime = str_replace('.', '', round(microtime(1), 3));
- $to[] = htmlspecialchars($this->prefix . '-hello-' . $microtime);
- $xml = preg_replace($from, $to, '
-
-
-');
- $r = $this->writeRequest($xml);
- } catch (\Exception $e) {
- $return = array(
- 'error' => $e->getMessage()
- );
- }
-
- return $r->asXML();
- }
-
- /**
- * hostCheck
- */
- public function hostCheck($params = array())
- {
- if (!$this->isLoggedIn) {
- return array(
- 'code' => 2002,
- 'msg' => 'Command use error'
- );
- }
-
- $return = array();
- try {
- $from = $to = array();
- $from[] = '/{{ name }}/';
- $to[] = htmlspecialchars($params['hostname']);
- $from[] = '/{{ clTRID }}/';
- $microtime = str_replace('.', '', round(microtime(1), 3));
- $to[] = htmlspecialchars($this->prefix . '-host-check-' . $microtime);
- $from[] = "/<\w+:\w+>\s*<\/\w+:\w+>\s+/ims";
- $to[] = '';
- $xml = preg_replace($from, $to, '
-
-
-
-
- {{ name }}
-
-
- {{ clTRID }}
-
-');
- $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:host-1.0')->chkData;
-
- $i = 0;
- foreach ($r->cd as $cd) {
- $i++;
- $hosts[$i]['name'] = (string)$cd->name;
- $hosts[$i]['reason'] = (string)$cd->reason;
- $hosts[$i]['avail'] = (int)$cd->name->attributes()->avail;
- }
-
- $return = array(
- 'code' => $code,
- 'msg' => $msg,
- 'hosts' => $hosts
- );
- } catch (\Exception $e) {
- $return = array(
- 'error' => $e->getMessage()
- );
- }
-
- return $return;
- }
-
- /**
- * hostInfo
- */
- public function hostInfo($params = array())
- {
- if (!$this->isLoggedIn) {
- return array(
- 'code' => 2002,
- 'msg' => 'Command use error'
- );
- }
-
- $return = array();
- try {
- $from = $to = array();
- $from[] = '/{{ name }}/';
- $to[] = htmlspecialchars($params['hostname']);
- $from[] = '/{{ clTRID }}/';
- $microtime = str_replace('.', '', round(microtime(1), 3));
- $to[] = htmlspecialchars($this->prefix . '-host-info-' . $microtime);
- $from[] = "/<\w+:\w+>\s*<\/\w+:\w+>\s+/ims";
- $to[] = '';
- $xml = preg_replace($from, $to, '
-
-
-
-
- {{ name }}
-
-
- {{ clTRID }}
-
-');
- $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:host-1.0')->infData[0];
- $name = (string)$r->name;
- $addr = array();
- foreach ($r->addr as $ns) {
- $addr[] = (string)$ns;
- }
- $status = array();
- $i = 0;
- foreach ($r->status as $e) {
- $i++;
- $status[$i] = (string)$e->attributes()->s;
- }
- $clID = (string)$r->clID;
- $crID = (string)$r->crID;
- $crDate = (string)$r->crDate;
- $upID = (string)$r->upID;
- $upDate = (string)$r->upDate;
-
- $return = array(
- 'code' => $code,
- 'msg' => $msg,
- 'name' => $name,
- 'status' => $status,
- 'addr' => $addr,
- 'clID' => $clID,
- 'crID' => $crID,
- 'crDate' => $crDate,
- 'upID' => $upID,
- 'upDate' => $upDate
- );
- } catch (\Exception $e) {
- $return = array(
- 'error' => $e->getMessage()
- );
- }
-
- return $return;
- }
-
- /**
- * hostCreate
- */
- public function hostCreate($params = array())
- {
- if (!$this->isLoggedIn) {
- return array(
- 'code' => 2002,
- 'msg' => 'Command use error'
- );
- }
-
- $return = array();
- try {
- $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[] = '/{{ clTRID }}/';
- $clTRID = str_replace('.', '', round(microtime(1), 3));
- $to[] = htmlspecialchars($this->prefix . '-host-create-' . $clTRID);
- $from[] = "/<\w+:\w+>\s*<\/\w+:\w+>\s+/ims";
- $to[] = '';
- $xml = preg_replace($from, $to, '
-
-
-
-
- {{ name }}
- {{ ip }}
-
-
- {{ clTRID }}
-
-');
- $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:host-1.0')->creData;
- $name = (string)$r->name;
-
- $return = array(
- 'code' => $code,
- 'msg' => $msg,
- 'name' => $name
- );
- } catch (\Exception $e) {
- $return = array(
- 'error' => $e->getMessage()
- );
- }
-
- return $return;
- }
-
- /**
- * hostUpdate
- */
- public function hostUpdate($params = array())
- {
- if (!$this->isLoggedIn) {
- return array(
- 'code' => 2002,
- 'msg' => 'Command use error'
- );
- }
-
- $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[] = '/{{ clTRID }}/';
- $clTRID = str_replace('.', '', round(microtime(1), 3));
- $to[] = htmlspecialchars($this->prefix . '-host-update-' . $clTRID);
- $xml = preg_replace($from, $to, '
-
-
-
-
- {{ name }}
-
- {{ ip2 }}
-
-
- {{ ip1 }}
-
-
-
- {{ clTRID }}
-
-');
- $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()
- );
- }
-
- return $return;
- }
-
- /**
- * hostDelete
- */
- public function hostDelete($params = array())
- {
- if (!$this->isLoggedIn) {
- return array(
- 'code' => 2002,
- 'msg' => 'Command use error'
- );
- }
-
- $return = array();
- try {
- $from = $to = array();
- $from[] = '/{{ name }}/';
- $to[] = htmlspecialchars($params['hostname']);
- $from[] = '/{{ clTRID }}/';
- $clTRID = str_replace('.', '', round(microtime(1), 3));
- $to[] = htmlspecialchars($this->prefix . '-host-delete-' . $clTRID);
- $xml = preg_replace($from, $to, '
-
-
-
-
- {{ name }}
-
-
- {{ clTRID }}
-
- ');
- $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()
- );
- }
-
- return $return;
- }
-
- /**
- * contactCheck
- */
- public function contactCheck($params = array())
- {
- if (!$this->isLoggedIn) {
- return array(
- 'code' => 2002,
- 'msg' => 'Command use error'
- );
- }
-
- $return = array();
- try {
- $from = $to = array();
- $from[] = '/{{ id }}/';
- $id = $params['contact'];
- $to[] = htmlspecialchars($id);
- $from[] = '/{{ clTRID }}/';
- $microtime = str_replace('.', '', round(microtime(1), 3));
- $to[] = htmlspecialchars($this->prefix . '-contact-check-' . $microtime);
- $from[] = "/<\w+:\w+>\s*<\/\w+:\w+>\s+/ims";
- $to[] = '';
- $xml = preg_replace($from, $to, '
-
-
-
-
- {{ id }}
-
-
- {{ clTRID }}
-
-');
- $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: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;
- $contacts[$i]['reason'] = (string)$cd->reason;
- }
-
- $return = array(
- 'code' => $code,
- 'msg' => $msg,
- 'contacts' => $contacts
- );
- } catch (\Exception $e) {
- $return = array(
- 'error' => $e->getMessage()
- );
- }
-
- return $return;
- }
-
- /**
- * contactInfo
- */
- public function contactInfo($params = array())
- {
- if (!$this->isLoggedIn) {
- return array(
- 'code' => 2002,
- 'msg' => 'Command use error'
- );
- }
-
- $return = array();
- try {
- $from = $to = array();
- $from[] = '/{{ id }}/';
- $to[] = htmlspecialchars($params['contact']);
- $from[] = '/{{ authInfo }}/';
- $authInfo = (isset($params['authInfoPw']) ? "\n\n" : '');
- $to[] = $authInfo;
- $from[] = '/{{ clTRID }}/';
- $microtime = str_replace('.', '', round(microtime(1), 3));
- $to[] = htmlspecialchars($this->prefix . '-contact-info-' . $microtime);
- $from[] = "/<\w+:\w+>\s*<\/\w+:\w+>\s+/ims";
- $to[] = '';
- $xml = preg_replace($from, $to, '
-
-
-
-
- {{ id }}
- {{ authInfo }}
-
-
- {{ clTRID }}
-
-');
- $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:contact-1.0')->infData[0];
-
- foreach ($r->postalInfo as $e) {
- $name = (string)$e->name;
- $org = (string)$e->org;
- $street1 = $street2 = $street3 = '';
- for ($i = 0; $i <= 2; $i++) {
- ${'street' . ($i + 1)} = (string)$e->addr->street[$i];
- }
- $city = (string)$e->addr->city;
- $state = (string)$e->addr->sp;
- $postal = (string)$e->addr->pc;
- $country = (string)$e->addr->cc;
- }
- $id = (string)$r->id;
- $status = array();
- $i = 0;
- foreach ($r->status as $e) {
- $i++;
- $status[$i] = (string)$e->attributes()->s;
- }
- $roid = (string)$r->roid;
- $voice = (string)$r->voice;
- $fax = (string)$r->fax;
- $email = (string)$r->email;
- $clID = (string)$r->clID;
- $crID = (string)$r->crID;
- $crDate = (string)$r->crDate;
- $upID = (string)$r->upID;
- $upDate = (string)$r->upDate;
- $authInfo = (string)$r->authInfo->pw;
-
- $return = array(
- 'id' => $id,
- 'roid' => $roid,
- 'code' => $code,
- 'status' => $status,
- 'msg' => $msg,
- 'name' => $name,
- 'org' => $org,
- 'street1' => $street1,
- 'street2' => $street2,
- 'street3' => $street3,
- 'city' => $city,
- 'state' => $state,
- 'postal' => $postal,
- 'country' => $country,
- 'voice' => $voice,
- 'fax' => $fax,
- 'email' => $email,
- 'clID' => $clID,
- 'crID' => $crID,
- 'crDate' => $crDate,
- 'upID' => $upID,
- 'upDate' => $upDate,
- 'authInfo' => $authInfo
- );
- } catch (\Exception $e) {
- $return = array(
- 'error' => $e->getMessage()
- );
- }
-
- return $return;
- }
-
- /**
- * contactCreate
- */
- public function contactCreate($params = array())
- {
- if (!$this->isLoggedIn) {
- return array(
- 'code' => 2002,
- 'msg' => 'Command use error'
- );
- }
-
- $return = array();
- try {
- $from = $to = array();
- $from[] = '/{{ type }}/';
- $to[] = htmlspecialchars($params['type']);
- $from[] = '/{{ id }}/';
- $to[] = htmlspecialchars($params['id']);
- $from[] = '/{{ name }}/';
- $to[] = htmlspecialchars($params['firstname'] . ' ' . $params['lastname']);
- $from[] = '/{{ org }}/';
- $to[] = htmlspecialchars($params['companyname']);
- $from[] = '/{{ street1 }}/';
- $to[] = htmlspecialchars($params['address1']);
- $from[] = '/{{ street2 }}/';
- $to[] = htmlspecialchars($params['address2']);
- $from[] = '/{{ street3 }}/';
- $street3 = (isset($params['address3']) ? $params['address3'] : '');
- $to[] = htmlspecialchars($street3);
- $from[] = '/{{ city }}/';
- $to[] = htmlspecialchars($params['city']);
- $from[] = '/{{ state }}/';
- $to[] = htmlspecialchars($params['state']);
- $from[] = '/{{ postcode }}/';
- $to[] = htmlspecialchars($params['postcode']);
- $from[] = '/{{ country }}/';
- $to[] = htmlspecialchars($params['country']);
- $from[] = '/{{ phonenumber }}/';
- $to[] = htmlspecialchars($params['fullphonenumber']);
- $from[] = '/{{ email }}/';
- $to[] = htmlspecialchars($params['email']);
- $from[] = '/{{ authInfo }}/';
- $to[] = htmlspecialchars($params['authInfoPw']);
- $from[] = '/{{ clTRID }}/';
- $microtime = str_replace('.', '', round(microtime(1), 3));
- $to[] = htmlspecialchars($this->prefix . '-contact-create-' . $microtime);
- $from[] = "/<\w+:\w+>\s*<\/\w+:\w+>\s+/ims";
- $to[] = '';
- $xml = preg_replace($from, $to, '
-
-
-
-
- {{ id }}
-
- {{ name }}
- {{ org }}
-
- {{ street1 }}
- {{ street2 }}
- {{ street3 }}
- {{ city }}
- {{ state }}
- {{ postcode }}
- {{ country }}
-
-
- {{ phonenumber }}
-
- {{ email }}
-
- {{ authInfo }}
-
-
-
- {{ clTRID }}
-
-');
- $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:contact-1.0')->creData;
- $id = (string)$r->id;
-
- $return = array(
- 'code' => $code,
- 'msg' => $msg,
- 'id' => $id
- );
- } catch (\Exception $e) {
- $return = array(
- 'error' => $e->getMessage()
- );
- }
-
- return $return;
- }
-
- /**
- * contactUpdate
- */
- public function contactUpdate($params = array())
- {
- if (!$this->isLoggedIn) {
- return array(
- 'code' => 2002,
- 'msg' => 'Command use error'
- );
- }
-
- $return = array();
- try {
- $from = $to = array();
- $from[] = '/{{ type }}/';
- $to[] = htmlspecialchars($params['type']);
- $from[] = '/{{ id }}/';
- $to[] = htmlspecialchars($params['id']);
- $from[] = '/{{ name }}/';
- $to[] = htmlspecialchars($params['firstname'] . ' ' . $params['lastname']);
- $from[] = '/{{ org }}/';
- $to[] = htmlspecialchars($params['companyname']);
- $from[] = '/{{ street1 }}/';
- $to[] = htmlspecialchars($params['address1']);
- $from[] = '/{{ street2 }}/';
- $to[] = htmlspecialchars($params['address2']);
- $from[] = '/{{ street3 }}/';
- $street3 = (isset($params['address3']) ? $params['address3'] : '');
- $to[] = htmlspecialchars($street3);
- $from[] = '/{{ city }}/';
- $to[] = htmlspecialchars($params['city']);
- $from[] = '/{{ state }}/';
- $to[] = htmlspecialchars($params['state']);
- $from[] = '/{{ postcode }}/';
- $to[] = htmlspecialchars($params['postcode']);
- $from[] = '/{{ country }}/';
- $to[] = htmlspecialchars($params['country']);
- $from[] = '/{{ voice }}/';
- $to[] = htmlspecialchars($params['fullphonenumber']);
- $from[] = '/{{ email }}/';
- $to[] = htmlspecialchars($params['email']);
- $from[] = '/{{ clTRID }}/';
- $microtime = str_replace('.', '', round(microtime(1), 3));
- $to[] = htmlspecialchars($this->prefix . '-contact-update-' . $microtime);
- $from[] = "/<\w+:\w+>\s*<\/\w+:\w+>\s+/ims";
- $to[] = '';
- $xml = preg_replace($from, $to, '
-
-
-
-
- {{ id }}
-
-
- {{ name }}
- {{ org }}
-
- {{ street1 }}
- {{ street2 }}
- {{ street3 }}
- {{ city }}
- {{ state }}
- {{ postcode }}
- {{ country }}
-
-
- {{ voice }}
-
- {{ email }}
-
-
-
- {{ clTRID }}
-
-');
- $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()
- );
- }
-
- return $return;
- }
-
- /**
- * contactDelete
- */
- public function contactDelete($params = array())
- {
- if (!$this->isLoggedIn) {
- return array(
- 'code' => 2002,
- 'msg' => 'Command use error'
- );
- }
-
- $return = array();
- try {
- $from = $to = array();
- $from[] = '/{{ id }}/';
- $to[] = htmlspecialchars($params['contact']);
- $from[] = '/{{ clTRID }}/';
- $clTRID = str_replace('.', '', round(microtime(1), 3));
- $to[] = htmlspecialchars($this->prefix . '-contact-delete-' . $clTRID);
- $xml = preg_replace($from, $to, '
-
-
-
-
- {{ id }}
-
-
- {{ clTRID }}
-
-');
- $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()
- );
- }
-
- return $return;
- }
-
- /**
- * domainCheck
- */
- public function domainCheck($params = array())
- {
- if (!$this->isLoggedIn) {
- return array(
- 'code' => 2002,
- 'msg' => 'Command use error'
- );
- }
-
- $return = array();
- try {
- $from = $to = array();
- $text = '';
- foreach ($params['domains'] as $name) {
- $text .= '' . $name . '' . "\n";
- }
- $from[] = '/{{ names }}/';
- $to[] = $text;
- $from[] = '/{{ clTRID }}/';
- $microtime = str_replace('.', '', round(microtime(1), 3));
- $to[] = htmlspecialchars($this->prefix . '-domain-check-' . $microtime);
- $from[] = "/<\w+:\w+>\s*<\/\w+:\w+>\s+/ims";
- $to[] = '';
- $xml = preg_replace($from, $to, '
-
-
-
-
- {{ names }}
-
-
- {{ clTRID }}
-
-');
- $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')->chkData;
-
- $i = 0;
- foreach ($r->cd as $cd) {
- $i++;
- $domains[$i]['name'] = (string)$cd->name;
- $domains[$i]['avail'] = (int)$cd->name->attributes()->avail;
- $domains[$i]['reason'] = (string)$cd->reason;
- }
-
- $return = array(
- 'code' => $code,
- 'msg' => $msg,
- 'domains' => $domains
- );
- } catch (\Exception $e) {
- $return = array(
- 'error' => $e->getMessage()
- );
- }
-
- return $return;
- }
-
- /**
- * domainCheckClaims
- */
- public function domainCheckClaims($params = array())
- {
- if (!$this->isLoggedIn) {
- return array(
- 'code' => 2002,
- 'msg' => 'Command use error'
- );
- }
-
- $return = array();
- try {
- $from = $to = array();
- $from[] = '/{{ name }}/';
- $to[] = htmlspecialchars($params['domainname']);
- $from[] = '/{{ clTRID }}/';
- $microtime = str_replace('.', '', round(microtime(1), 3));
- $to[] = htmlspecialchars($this->prefix . '-domain-checkClaims-' . $microtime);
- $from[] = "/<\w+:\w+>\s*<\/\w+:\w+>\s+/ims";
- $to[] = '';
- $xml = preg_replace($from, $to, '
-
-
-
-
- {{ name }}
-
-
-
-
- claims
-
-
- {{ clTRID }}
-
-');
- $r = $this->writeRequest($xml);
- $code = (int)$r->response->result->attributes()->code;
- $msg = (string)$r->response->result->msg;
- $phase = $r->response->extension->children('urn:ietf:params:xml:ns:launch-1.0')->chkData->phase;
- $status = $r->response->extension->children('urn:ietf:params:xml:ns:launch-1.0')->chkData->cd->name->attributes()->exists;
- $name = $r->response->extension->children('urn:ietf:params:xml:ns:launch-1.0')->chkData->cd->name;
- $claimKey = $r->response->extension->children('urn:ietf:params:xml:ns:launch-1.0')->chkData->cd->claimKey;
-
- $return = array(
- 'code' => $code,
- 'msg' => $msg,
- 'domain' => $name,
- 'status' => $status,
- 'phase' => $phase,
- 'claimKey' => $claimKey
- );
- } catch (\Exception $e) {
- $return = array(
- 'error' => $e->getMessage()
- );
- }
-
- return $return;
- }
-
- /**
- * domainInfo
- */
- public function domainInfo($params = array())
- {
- if (!$this->isLoggedIn) {
- return array(
- 'code' => 2002,
- 'msg' => 'Command use error'
- );
- }
-
- $return = array();
- try {
- $from = $to = array();
- $from[] = '/{{ domainname }}/';
- $to[] = htmlspecialchars($params['domainname']);
- $from[] = '/{{ authInfo }}/';
- $authInfo = (isset($params['authInfoPw']) ? "\n\n" : '');
- $to[] = $authInfo;
- $from[] = '/{{ clTRID }}/';
- $microtime = str_replace('.', '', round(microtime(1), 3));
- $to[] = htmlspecialchars($this->prefix . '-domain-info-' . $microtime);
- $from[] = "/<\w+:\w+>\s*<\/\w+:\w+>\s+/ims";
- $to[] = '';
- $xml = preg_replace($from, $to, '
-
-
-
-
- {{ domainname }}
- {{ authInfo }}
-
-
- {{ clTRID }}
-
-');
- $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')->infData;
- $name = (string)$r->name;
- $roid = (string)$r->roid;
- $status = array();
- $i = 0;
- foreach ($r->status as $e) {
- $i++;
- $status[$i] = (string)$e->attributes()->s;
- }
- $registrant = (string)$r->registrant;
- $contact = array();
- $i = 0;
- foreach ($r->contact as $e) {
- $i++;
- $contact[$i]['type'] = (string)$e->attributes()->type;
- $contact[$i]['id'] = (string)$e;
- }
- $ns = array();
- $i = 0;
- foreach ($r->ns->hostObj as $hostObj) {
- $i++;
- $ns[$i] = (string)$hostObj;
- }
- $host = array();
- $i = 0;
- foreach ($r->host as $hostname) {
- $i++;
- $host[$i] = (string)$hostname;
- }
- $clID = (string)$r->clID;
- $crID = (string)$r->crID;
- $crDate = (string)$r->crDate;
- $upID = (string)$r->upID;
- $upDate = (string)$r->upDate;
- $exDate = (string)$r->exDate;
- $trDate = (string)$r->trDate;
- $authInfo = (string)$r->authInfo->pw;
-
- $return = array(
- 'code' => $code,
- 'msg' => $msg,
- 'name' => $name,
- 'roid' => $roid,
- 'status' => $status,
- 'registrant' => $registrant,
- 'contact' => $contact,
- 'ns' => $ns,
- 'host' => $host,
- 'clID' => $clID,
- 'crID' => $crID,
- 'crDate' => $crDate,
- 'upID' => $upID,
- 'upDate' => $upDate,
- 'exDate' => $exDate,
- 'trDate' => $trDate,
- 'authInfo' => $authInfo
- );
- } catch (\Exception $e) {
- $return = array(
- 'error' => $e->getMessage()
- );
- }
-
- return $return;
- }
-
- /**
- * domainUpdateNS
- */
- public function domainUpdateNS($params = array())
- {
- if (!$this->isLoggedIn) {
- return array(
- 'code' => 2002,
- 'msg' => 'Command use error'
- );
- }
-
- $return = array();
- try {
- $from = $to = array();
- $from[] = '/{{ name }}/';
- $to[] = htmlspecialchars($params['domainname']);
- $from[] = '/{{ clTRID }}/';
- $clTRID = str_replace('.', '', round(microtime(1), 3));
- $to[] = htmlspecialchars($this->prefix . '-domain-info-' . $clTRID);
- $xml = preg_replace($from, $to, '
-
-
-
-
- {{ name }}
-
-
- {{ clTRID }}
-
- ');
- $r = $this->writeRequest($xml);
- $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) {
- $i++;
- $ns = (string)$ns;
- if (!$ns) {
- continue;
- }
-
- $rem["ns{$i}"] = $ns;
- }
-
- foreach ($params as $k => $v) {
- if (!$v) {
- continue;
- }
-
- if (!preg_match("/^ns\d$/i", $k)) {
- continue;
- }
-
- if ($k0 = array_search($v, $rem)) {
- unset($rem[$k0]);
- } else {
- $add[$k] = $v;
- }
- }
-
- if (!empty($add) || !empty($rem)) {
- $from = $to = array();
- $text = '';
- foreach ($add as $k => $v) {
- $text.= '' . $v . '' . "\n";
- }
-
- $from[] = '/{{ add }}/';
- $to[] = (empty($text) ? '' : "\n{$text}\n");
- $text = '';
- foreach ($rem as $k => $v) {
- $text.= '' . $v . '' . "\n";
- }
-
- $from[] = '/{{ rem }}/';
- $to[] = (empty($text) ? '' : "\n{$text}\n");
- $from[] = '/{{ name }}/';
- $to[] = htmlspecialchars($params['domainname']);
- $from[] = '/{{ clTRID }}/';
- $clTRID = str_replace('.', '', round(microtime(1), 3));
- $to[] = htmlspecialchars($this->prefix . '-domain-updateNS-' . $clTRID);
- $xml = preg_replace($from, $to, '
-
-
-
-
- {{ name }}
- {{ add }}
- {{ rem }}
-
-
- {{ clTRID }}
-
- ');
- $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()
- );
- }
-
- return $return;
- }
-
- /**
- * domainUpdateContact
- */
- public function domainUpdateContact($params = array())
- {
- if (!$this->isLoggedIn) {
- return array(
- 'code' => 2002,
- 'msg' => 'Command use error'
- );
- }
-
- $return = array();
- try {
- $from = $to = array();
- $from[] = '/{{ name }}/';
- $to[] = htmlspecialchars($params['domainname']);
- if ($params['contacttype'] === 'registrant') {
- $from[] = '/{{ add }}/';
- $to[] = "";
- $from[] = '/{{ rem }}/';
- $to[] = "";
- $from[] = '/{{ chg }}/';
- $to[] = "".htmlspecialchars($params['new_contactid'])."\n";
- } else {
- $from[] = '/{{ add }}/';
- $to[] = "".htmlspecialchars($params['new_contactid'])."\n";
- $from[] = '/{{ rem }}/';
- $to[] = "".htmlspecialchars($params['old_contactid'])."\n";
- $from[] = '/{{ chg }}/';
- $to[] = "";
- }
- $from[] = '/{{ clTRID }}/';
- $clTRID = str_replace('.', '', round(microtime(1), 3));
- $to[] = htmlspecialchars($this->prefix . '-domain-updateContact-' . $clTRID);
- $from[] = "/<\w+:\w+>\s*<\/\w+:\w+>\s+/ims";
- $to[] = '';
- $xml = preg_replace($from, $to, '
-
-
-
-
- {{ name }}
- {{ add }}
- {{ rem }}
- {{ chg }}
-
-
- {{ clTRID }}
-
-');
- $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()
- );
- }
-
- return $return;
- }
-
- /**
- * domainUpdateStatus
- */
- public function domainUpdateStatus($params = array())
- {
- if (!$this->isLoggedIn) {
- return array(
- 'code' => 2002,
- 'msg' => 'Command use error'
- );
- }
-
- $return = array();
- try {
- $from = $to = array();
- $from[] = '/{{ name }}/';
- $to[] = htmlspecialchars($params['domainname']);
- if ($params['command'] === 'add') {
- $from[] = '/{{ add }}/';
- $to[] = "\n";
- $from[] = '/{{ rem }}/';
- $to[] = "";
- } else if ($params['command'] === 'rem') {
- $from[] = '/{{ add }}/';
- $to[] = "";
- $from[] = '/{{ rem }}/';
- $to[] = "\n";
- }
- $from[] = '/{{ clTRID }}/';
- $clTRID = str_replace('.', '', round(microtime(1), 3));
- $to[] = htmlspecialchars($this->prefix . '-domain-updateStatus-' . $clTRID);
- $from[] = "/<\w+:\w+>\s*<\/\w+:\w+>\s+/ims";
- $to[] = '';
- $xml = preg_replace($from, $to, '
-
-
-
-
- {{ name }}
- {{ add }}
- {{ rem }}
-
-
- {{ clTRID }}
-
-');
- $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()
- );
- }
-
- return $return;
- }
-
- /**
- * domainUpdateAuthinfo
- */
- public function domainUpdateAuthinfo($params = array())
- {
- if (!$this->isLoggedIn) {
- return array(
- 'code' => 2002,
- 'msg' => 'Command use error'
- );
- }
-
- $return = array();
- try {
- $from = $to = array();
- $from[] = '/{{ name }}/';
- $to[] = htmlspecialchars($params['domainname']);
- $from[] = '/{{ authInfo }}/';
- $to[] = htmlspecialchars($params['authInfo']);
- $from[] = '/{{ clTRID }}/';
- $clTRID = str_replace('.', '', round(microtime(1), 3));
- $to[] = htmlspecialchars($this->prefix . '-domain-updateAuthinfo-' . $clTRID);
- $from[] = "/<\w+:\w+>\s*<\/\w+:\w+>\s+/ims";
- $to[] = '';
- $xml = preg_replace($from, $to, '
-
-
-
-
- {{ name }}
-
-
- {{ authInfo }}
-
-
-
-
- {{ clTRID }}
-
-');
- $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()
- );
- }
-
- return $return;
- }
-
- /**
- * domainUpdateDNSSEC
- */
- public function domainUpdateDNSSEC($params = array())
- {
- if (!$this->isLoggedIn) {
- return array(
- 'code' => 2002,
- 'msg' => 'Command use error'
- );
- }
-
- $return = array();
- try {
- $from = $to = array();
- $from[] = '/{{ name }}/';
- $to[] = htmlspecialchars($params['domainname']);
- if ($params['command'] == 'add') {
- $from[] = '/{{ add }}/';
- $to[] = "
-
- ".htmlspecialchars($params['keyTag_1'])."
- ".htmlspecialchars($params['alg_1'])."
- ".htmlspecialchars($params['digestType_1'])."
- ".htmlspecialchars($params['digest_1'])."
-
- ";
- $from[] = '/{{ rem }}/';
- $to[] = "";
- $from[] = '/{{ addrem }}/';
- $to[] = "";
- } else if ($params['command'] == 'rem') {
- $from[] = '/{{ add }}/';
- $to[] = "";
- $from[] = '/{{ rem }}/';
- $to[] = "
-
- ".htmlspecialchars($params['keyTag_1'])."
- ".htmlspecialchars($params['alg_1'])."
- ".htmlspecialchars($params['digestType_1'])."
- ".htmlspecialchars($params['digest_1'])."
-
- ";
- $from[] = '/{{ addrem }}/';
- $to[] = "";
- } else if ($params['command'] == 'addrem') {
- $from[] = '/{{ add }}/';
- $to[] = "";
- $from[] = '/{{ rem }}/';
- $to[] = "";
- $from[] = '/{{ addrem }}/';
- $to[] = "
-
- ".htmlspecialchars($params['keyTag_1'])."
- ".htmlspecialchars($params['alg_1'])."
- ".htmlspecialchars($params['digestType_1'])."
- ".htmlspecialchars($params['digest_1'])."
-
-
-
-
- ".htmlspecialchars($params['keyTag_2'])."
- ".htmlspecialchars($params['alg_2'])."
- ".htmlspecialchars($params['digestType_2'])."
- ".htmlspecialchars($params['digest_2'])."
-
- ";
- }
- $from[] = '/{{ clTRID }}/';
- $clTRID = str_replace('.', '', round(microtime(1), 3));
- $to[] = htmlspecialchars($this->prefix . '-domain-updateDNSSEC-' . $clTRID);
- $from[] = "/<\w+:\w+>\s*<\/\w+:\w+>\s+/ims";
- $to[] = '';
- $xml = preg_replace($from, $to, '
-
-
-
-
- {{ name }}
-
-
-
-
- {{ add }}
- {{ rem }}
- {{ addrem }}
-
-
- {{ clTRID }}
-
-');
- $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()
- );
- }
-
- return $return;
- }
-
- /**
- * domainTransfer
- */
- public function domainTransfer($params = array())
- {
- if (!$this->isLoggedIn) {
- return array(
- 'code' => 2002,
- 'msg' => 'Command use error'
- );
- }
-
- $return = array();
- try {
- $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;
- }
- $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, '
-
-
-
-
- {{ name }}
- {{ years }}
-
- {{ authInfoPw }}
-
-
-
- {{ clTRID }}
-
- ');
-
- $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, '
-
-
-
-
- {{ name }}
-
-
- {{ clTRID }}
-
- ');
-
- $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, '
-
-
-
-
- {{ name }}
-
-
- {{ clTRID }}
-
- ');
-
- $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()
- );
- }
-
- return $return;
- }
-
- /**
- * domainCreate
- */
- public function domainCreate($params = array())
- {
- if (!$this->isLoggedIn) {
- return array(
- 'code' => 2002,
- 'msg' => 'Command use error'
- );
- }
-
- $return = array();
- try {
- $from = $to = array();
- $from[] = '/{{ name }}/';
- $to[] = htmlspecialchars($params['domainname']);
- $from[] = '/{{ period }}/';
- $to[] = (int)($params['period']);
- if (isset($params['nss'])) {
- $text = '';
- foreach ($params['nss'] as $hostObj) {
- $text .= '' . $hostObj . '' . "\n";
- }
- $from[] = '/{{ hostObjs }}/';
- $to[] = $text;
- } else {
- $from[] = '/{{ hostObjs }}/';
- $to[] = '';
- }
- $from[] = '/{{ registrant }}/';
- $to[] = htmlspecialchars($params['registrant']);
- $text = '';
- foreach ($params['contacts'] as $contactType => $contactID) {
- $text .= '' . $contactID . '' . "\n";
- }
- $from[] = '/{{ contacts }}/';
- $to[] = $text;
- $from[] = '/{{ authInfoPw }}/';
- $to[] = htmlspecialchars($params['authInfoPw']);
- $from[] = '/{{ clTRID }}/';
- $clTRID = str_replace('.', '', round(microtime(1), 3));
- $to[] = htmlspecialchars($this->prefix . '-domain-create-' . $clTRID);
- $from[] = "/<\w+:\w+>\s*<\/\w+:\w+>\s+/ims";
- $to[] = '';
- $xml = preg_replace($from, $to, '
-
-
-
-
- {{ name }}
- {{ period }}
-
- {{ hostObjs }}
-
- {{ registrant }}
- {{ contacts }}
-
- {{ authInfoPw }}
-
-
-
- {{ clTRID }}
-
-');
- $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')->creData;
- $name = (string)$r->name;
- $crDate = (string)$r->crDate;
- $exDate = (string)$r->exDate;
-
- $return = array(
- 'code' => $code,
- 'msg' => $msg,
- 'name' => $name,
- 'crDate' => $crDate,
- 'exDate' => $exDate
- );
- } catch (\Exception $e) {
- $return = array(
- 'error' => $e->getMessage()
- );
- }
-
- return $return;
- }
-
- /**
- * domainCreateDNSSEC
- */
- public function domainCreateDNSSEC($params = array())
- {
- if (!$this->isLoggedIn) {
- return array(
- 'code' => 2002,
- 'msg' => 'Command use error'
- );
- }
-
- $return = array();
- try {
- $from = $to = array();
- $from[] = '/{{ name }}/';
- $to[] = htmlspecialchars($params['domainname']);
- $from[] = '/{{ period }}/';
- $to[] = (int)($params['period']);
- if (isset($params['nss'])) {
- $text = '';
- foreach ($params['nss'] as $hostObj) {
- $text .= '' . $hostObj . '' . "\n";
- }
- $from[] = '/{{ hostObjs }}/';
- $to[] = $text;
- } else {
- $from[] = '/{{ hostObjs }}/';
- $to[] = '';
- }
- $from[] = '/{{ registrant }}/';
- $to[] = htmlspecialchars($params['registrant']);
- $text = '';
- foreach ($params['contacts'] as $contactType => $contactID) {
- $text .= '' . $contactID . '' . "\n";
- }
- $from[] = '/{{ contacts }}/';
- $to[] = $text;
- $from[] = '/{{ authInfoPw }}/';
- $to[] = htmlspecialchars($params['authInfoPw']);
- if ($params['dnssec_records'] == 1) {
- $from[] = '/{{ dnssec_data }}/';
- $to[] = "
- ".htmlspecialchars($params['keyTag_1'])."
- ".htmlspecialchars($params['alg_1'])."
- ".htmlspecialchars($params['digestType_1'])."
- ".htmlspecialchars($params['digest_1'])."
- ";
- } else if ($params['dnssec_records'] == 2) {
- $from[] = '/{{ dnssec_data }}/';
- $to[] = "
- ".htmlspecialchars($params['keyTag_1'])."
- ".htmlspecialchars($params['alg_1'])."
- ".htmlspecialchars($params['digestType_1'])."
- ".htmlspecialchars($params['digest_1'])."
-
-
- ".htmlspecialchars($params['keyTag_2'])."
- ".htmlspecialchars($params['alg_2'])."
- ".htmlspecialchars($params['digestType_2'])."
- ".htmlspecialchars($params['digest_2'])."
- ";
- }
- $from[] = '/{{ clTRID }}/';
- $clTRID = str_replace('.', '', round(microtime(1), 3));
- $to[] = htmlspecialchars($this->prefix . '-domain-createDNSSEC-' . $clTRID);
- $from[] = "/<\w+:\w+>\s*<\/\w+:\w+>\s+/ims";
- $to[] = '';
- $xml = preg_replace($from, $to, '
-
-
-
-
- {{ name }}
- {{ period }}
-
- {{ hostObjs }}
-
- {{ registrant }}
- {{ contacts }}
-
- {{ authInfoPw }}
-
-
-
-
-
- {{ dnssec_data }}
-
-
-
-
- {{ clTRID }}
-
-');
- $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')->creData;
- $name = (string)$r->name;
- $crDate = (string)$r->crDate;
- $exDate = (string)$r->exDate;
-
- $return = array(
- 'code' => $code,
- 'msg' => $msg,
- 'name' => $name,
- 'crDate' => $crDate,
- 'exDate' => $exDate
- );
- } catch (\Exception $e) {
- $return = array(
- 'error' => $e->getMessage()
- );
- }
-
- return $return;
- }
-
- /**
- * domainCreateClaims
- */
- public function domainCreateClaims($params = array())
- {
- if (!$this->isLoggedIn) {
- return array(
- 'code' => 2002,
- 'msg' => 'Command use error'
- );
- }
-
- $return = array();
- try {
- $from = $to = array();
- $from[] = '/{{ name }}/';
- $to[] = htmlspecialchars($params['domainname']);
- $from[] = '/{{ period }}/';
- $to[] = (int)($params['period']);
- if (isset($params['nss'])) {
- $text = '';
- foreach ($params['nss'] as $hostObj) {
- $text .= '' . $hostObj . '' . "\n";
- }
- $from[] = '/{{ hostObjs }}/';
- $to[] = $text;
- } else {
- $from[] = '/{{ hostObjs }}/';
- $to[] = '';
- }
- $from[] = '/{{ registrant }}/';
- $to[] = htmlspecialchars($params['registrant']);
- $text = '';
- foreach ($params['contacts'] as $contactType => $contactID) {
- $text .= '' . $contactID . '' . "\n";
- }
- $from[] = '/{{ contacts }}/';
- $to[] = $text;
- $from[] = '/{{ authInfoPw }}/';
- $to[] = htmlspecialchars($params['authInfoPw']);
- $from[] = '/{{ noticeID }}/';
- $to[] = htmlspecialchars($params['noticeID']);
- $from[] = '/{{ notAfter }}/';
- $to[] = htmlspecialchars($params['notAfter']);
- $from[] = '/{{ acceptedDate }}/';
- $to[] = htmlspecialchars($params['acceptedDate']);
- $from[] = '/{{ clTRID }}/';
- $clTRID = str_replace('.', '', round(microtime(1), 3));
- $to[] = htmlspecialchars($this->prefix . '-domain-createClaims-' . $clTRID);
- $from[] = "/<\w+:\w+>\s*<\/\w+:\w+>\s+/ims";
- $to[] = '';
- $xml = preg_replace($from, $to, '
-
-
-
-
- {{ name }}
- {{ period }}
-
- {{ hostObjs }}
-
- {{ registrant }}
- {{ contacts }}
-
- {{ authInfoPw }}
-
-
-
-
- claims
-
- {{ noticeID }}
- {{ notAfter }}
- {{ acceptedDate }}
-
-
-
-
- {{ clTRID }}
-
-');
- $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')->creData;
- $name = (string)$r->name;
- $crDate = (string)$r->crDate;
- $exDate = (string)$r->exDate;
-
- $return = array(
- 'code' => $code,
- 'msg' => $msg,
- 'name' => $name,
- 'crDate' => $crDate,
- 'exDate' => $exDate
- );
- } catch (\Exception $e) {
- $return = array(
- 'error' => $e->getMessage()
- );
- }
-
- return $return;
- }
-
- /**
- * domainRenew
- */
- public function domainRenew($params = array())
- {
- if (!$this->isLoggedIn) {
- return array(
- 'code' => 2002,
- 'msg' => 'Command use error'
- );
- }
-
- $return = array();
- try {
- $from = $to = array();
- $from[] = '/{{ name }}/';
- $to[] = htmlspecialchars($params['domainname']);
- $from[] = '/{{ clTRID }}/';
- $clTRID = str_replace('.', '', round(microtime(1), 3));
- $to[] = htmlspecialchars($this->prefix . '-domain-renew-' . $clTRID);
- $from[] = "/<\w+:\w+>\s*<\/\w+:\w+>\s+/ims";
- $to[] = '';
- $xml = preg_replace($from, $to, '
-
-
-
-
- {{ name }}
-
-
- {{ clTRID }}
-
-');
- $r = $this->writeRequest($xml);
- $r = $r->response->resData->children('urn:ietf:params:xml:ns:domain-1.0')->infData;
-
- $expDate = (string)$r->exDate;
- $expDate = preg_replace("/^(\d+\-\d+\-\d+)\D.*$/", "$1", $expDate);
- $from = $to = array();
- $from[] = '/{{ name }}/';
- $to[] = htmlspecialchars($params['domainname']);
- $from[] = '/{{ regperiod }}/';
- $to[] = htmlspecialchars($params['regperiod']);
- $from[] = '/{{ expDate }}/';
- $to[] = htmlspecialchars($expDate);
- $from[] = '/{{ clTRID }}/';
- $clTRID = str_replace('.', '', round(microtime(1), 3));
- $to[] = htmlspecialchars($this->prefix . '-domain-renew-' . $clTRID);
- $xml = preg_replace($from, $to, '
-
-
-
-
- {{ name }}
- {{ expDate }}
- {{ regperiod }}
-
-
- {{ clTRID }}
-
-');
- $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')->renData;
- $name = (string)$r->name;
- $exDate = (string)$r->exDate;
-
- $return = array(
- 'code' => $code,
- 'msg' => $msg,
- 'name' => $name,
- 'exDate' => $exDate
- );
- } catch (\Exception $e) {
- $return = array(
- 'error' => $e->getMessage()
- );
- }
-
- return $return;
- }
-
- /**
- * domainDelete
- */
- public function domainDelete($params = array())
- {
- if (!$this->isLoggedIn) {
- return array(
- 'code' => 2002,
- 'msg' => 'Command use error'
- );
- }
-
- $return = array();
- try {
- $from = $to = array();
- $from[] = '/{{ name }}/';
- $to[] = htmlspecialchars($params['domainname']);
- $from[] = '/{{ clTRID }}/';
- $clTRID = str_replace('.', '', round(microtime(1), 3));
- $to[] = htmlspecialchars($this->prefix . '-domain-delete-' . $clTRID);
- $from[] = "/<\w+:\w+>\s*<\/\w+:\w+>\s+/ims";
- $to[] = '';
- $xml = preg_replace($from, $to, '
-
-
-
-
- {{ name }}
-
-
- {{ clTRID }}
-
-');
- $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()
- );
- }
-
- return $return;
- }
-
- /**
- * domainRestore
- */
- public function domainRestore($params = array())
- {
- if (!$this->isLoggedIn) {
- return array(
- 'code' => 2002,
- 'msg' => 'Command use error'
- );
- }
-
- $return = array();
- try {
- $from = $to = array();
- $from[] = '/{{ name }}/';
- $to[] = htmlspecialchars($params['domainname']);
- $from[] = '/{{ clTRID }}/';
- $clTRID = str_replace('.', '', round(microtime(1), 3));
- $to[] = htmlspecialchars($this->prefix . '-domain-restore-' . $clTRID);
- $from[] = "/<\w+:\w+>\s*<\/\w+:\w+>\s+/ims";
- $to[] = '';
- $xml = preg_replace($from, $to, '
-
-
-
-
- {{ name }}
-
-
-
-
-
-
-
-
- {{ clTRID }}
-
-');
- $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()
- );
- }
-
- return $return;
- }
-
- /**
- * domainReport
- */
- public function domainReport($params = array())
- {
- if (!$this->isLoggedIn) {
- return array(
- 'code' => 2002,
- 'msg' => 'Command use error'
- );
- }
-
- $return = array();
- try {
- $from = $to = array();
- $from[] = '/{{ name }}/';
- $to[] = htmlspecialchars($params['domainname']);
- $from[] = '/{{ clTRID }}/';
- $clTRID = str_replace('.', '', round(microtime(1), 3));
- $to[] = htmlspecialchars($this->prefix . '-domain-report-' . $clTRID);
- $from[] = "/<\w+:\w+>\s*<\/\w+:\w+>\s+/ims";
- $to[] = '';
- $xml = preg_replace($from, $to, '
-
-
-
-
- {{ name }}
-
-
-
-
-
-
-
- Pre-delete registration data goes here.
- Both XML and free text are allowed.
- Post-restore registration data goes here.
- Both XML and free text are allowed.
- 2019-10-10T22:00:00.0Z
- 2019-10-20T22:00:00.0Z
- Registrant error.
- This registrar has not restored the
- Registered Name in order to assume the rights to use
- or sell the Registered Name for itself or for any
- third party.
- The information in this report is
- true to best of this registrars knowledge, and this
- registrar acknowledges that intentionally supplying
- false information in this report shall constitute an
- incurable material breach of the
- Registry-Registrar Agreement.
- Supporting information goes
- here.
-
-
-
-
- {{ clTRID }}
-
- ');
- $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()
- );
- }
-
- return $return;
- }
-
- /**
- * pollReq
- */
- public function pollReq()
- {
- if (!$this->isLoggedIn) {
- return array(
- 'code' => 2002,
- 'msg' => 'Command use error'
- );
- }
-
- $return = array();
- try {
- $from = $to = array();
- $from[] = '/{{ clTRID }}/';
- $clTRID = str_replace('.', '', round(microtime(1), 3));
- $to[] = htmlspecialchars($this->prefix . '-poll-req-' . $clTRID);
- $from[] = "/<\w+:\w+>\s*<\/\w+:\w+>\s+/ims";
- $to[] = '';
- $xml = preg_replace($from, $to, '
-
-
-
- {{ clTRID }}
-
- ');
- $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 ?? '');
-
- $return = array(
- 'code' => $code,
- 'msg' => $msg,
- 'messages' => $messages,
- 'last_id' => $last_id,
- 'qDate' => $qDate,
- 'last_msg' => $last_msg
- );
- } catch (\Exception $e) {
- $return = array(
- 'error' => $e->getMessage()
- );
- }
-
- return $return;
- }
-
- /**
- * pollAck
- */
- public function pollAck($params = array())
- {
- if (!$this->isLoggedIn) {
- return array(
- 'code' => 2002,
- 'msg' => 'Command use error'
- );
- }
-
- $return = array();
- try {
- $from = $to = array();
- $from[] = '/{{ message }}/';
- $to[] = htmlspecialchars($params['msgID']);
- $from[] = '/{{ clTRID }}/';
- $clTRID = str_replace('.', '', round(microtime(1), 3));
- $to[] = htmlspecialchars($this->prefix . '-poll-ack-' . $clTRID);
- $from[] = "/<\w+:\w+>\s*<\/\w+:\w+>\s+/ims";
- $to[] = '';
- $xml = preg_replace($from, $to, '
-
-
-
- {{ clTRID }}
-
- ');
- $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()
- );
- }
-
- return $return;
- }
-
- public function _response_log($content)
- {
- $handle = fopen(dirname(__FILE__) . '/epp_response.log', 'a');
- ob_start();
- echo "\n==================================\n";
- ob_end_clean();
- fwrite($handle, $content);
- fclose($handle);
- }
-
- public function _request_log($content)
- {
- $handle = fopen(dirname(__FILE__) . '/epp_request.log', 'a');
- ob_start();
- echo "\n==================================\n";
- ob_end_clean();
- fwrite($handle, $content);
- fclose($handle);
- }
-}
diff --git a/eppSync.php b/eppSync.php
index 5107103..6b4e234 100644
--- a/eppSync.php
+++ b/eppSync.php
@@ -1,28 +1,19 @@
prepare("SELECT * FROM tld_registrar WHERE registrar = :registrar");
-
- // Bind the $registrar value to the :registrar parameter
$stmt->bindValue(":registrar", $registrar);
-
- // Execute the prepared statement
$stmt->execute();
-
- // Fetch all rows from the result set
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
$config = [];
@@ -35,20 +26,20 @@
if (empty($config))
{
- throw new Exception("Database cannot be accessed right now.");
+ exit("Database cannot be accessed right now.".PHP_EOL);
}
}
catch(PDOException $e)
{
- echo "Database error: " . $e->getMessage();
+ exit("Database error: " . $e->getMessage().PHP_EOL);
}
catch(Exception $e)
{
- echo "General error: " . $e->getMessage();
+ exit("General error: " . $e->getMessage().PHP_EOL);
}
-function connectEpp(string $registry, $config)
+function connectEpp($config)
{
try
{
@@ -62,8 +53,7 @@ function connectEpp(string $registry, $config)
"prefix" => "tembo", ]);
if (array_key_exists("error", $login))
{
- echo "Login Error: " . $login["error"] . PHP_EOL;
- exit();
+ exit("Login Error: " . $login["error"]. PHP_EOL);
}
else
{
@@ -73,7 +63,7 @@ function connectEpp(string $registry, $config)
}
catch(EppException $e)
{
- return "Error : " . $e->getMessage();
+ exit("Error : " . $e->getMessage().PHP_EOL);
}
}
@@ -84,20 +74,38 @@ function connectEpp(string $registry, $config)
$stmt->execute();
$domains = $stmt->fetchAll(PDO::FETCH_ASSOC);
- $epp = connectEpp("generic", $config);
+ $epp = connectEpp($config);
foreach ($domains as $domainRow) {
- // Combine sld and tld into a single domain name
$domain = $domainRow['sld'] . $domainRow['tld'];
-
$params = ["domainname" => $domain];
$domainInfo = $epp->domainInfo($params);
- if (array_key_exists("error", $domainInfo)) {
- echo "DomainInfo Error: " . $domainInfo["error"] . " (" . $domain . ")" . PHP_EOL;
+ if (array_key_exists("error", $domainInfo) || (isset($domainInfo['code']) && $domainInfo['code'] == 2303)) {
+ if (strpos($domainInfo["error"], "Domain does not exist") !== false || (isset($domainInfo['code']) && $domainInfo['code'] == 2303)) {
+ $stmt = $pdo->prepare('DELETE FROM service_domain WHERE sld = :sld AND tld = :tld');
+ $stmt->bindValue(':sld', $domainRow['sld']);
+ $stmt->bindValue(':tld', $domainRow['tld']);
+ $stmt->execute();
+ }
+ $stmt = $pdo->prepare('SELECT id FROM service_domain WHERE sld = :sld AND tld = :tld');
+ $stmt->bindValue(':sld', $domainRow['sld']);
+ $stmt->bindValue(':tld', $domainRow['tld']);
+ $stmt->execute();
+ $serviceDomain = $stmt->fetch(PDO::FETCH_ASSOC);
+ if ($serviceDomain) {
+ $serviceId = $serviceDomain['id'];
+ $stmt = $pdo->prepare('UPDATE client_order SET canceled_at = :canceled_at, status = :status, reason = :reason WHERE service_id = :service_id');
+ $stmt->bindValue(':canceled_at', date('Y-m-d H:i:s'));
+ $stmt->bindValue(':status', 'cancelled');
+ $stmt->bindValue(':reason', 'domain deleted');
+ $stmt->bindValue(':service_id', $serviceId);
+ $stmt->execute();
+ }
+ echo $domainInfo["error"] . " (" . $domain . ")" . PHP_EOL;
continue;
}
-
+
$ns = $domainInfo['ns'];
$ns1 = isset($ns[1]) ? $ns[1] : null;
@@ -126,30 +134,111 @@ function connectEpp(string $registry, $config)
$locked = 0;
}
- // Prepare the UPDATE statement
- $stmt = $pdo->prepare('UPDATE service_domain SET ns1 = :ns1, ns2 = :ns2, ns3 = :ns3, ns4 = :ns4, expires_at = :expires_at, locked = :locked, transfer_code = :transfer_code WHERE sld = :sld AND tld = :tld');
+ $sqlCheck = 'SELECT COUNT(*) FROM extension WHERE name = :name AND status = :status';
+ $stmtCheck = $pdo->prepare($sqlCheck);
+ $stmtCheck->bindValue(':name', 'registrar');
+ $stmtCheck->bindValue(':status', 'installed');
+ $stmtCheck->execute();
+ $count = $stmtCheck->fetchColumn();
- // Bind the values to the statement
+ // Prepare the UPDATE statement
+ $stmt = $pdo->prepare('UPDATE service_domain SET ns1 = :ns1, ns2 = :ns2, ns3 = :ns3, ns4 = :ns4, expires_at = :expires_at, locked = :locked, synced_at = :synced_at, transfer_code = :transfer_code WHERE sld = :sld AND tld = :tld');
$stmt->bindValue(':ns1', $ns1);
$stmt->bindValue(':ns2', $ns2);
$stmt->bindValue(':ns3', $ns3);
$stmt->bindValue(':ns4', $ns4);
$stmt->bindValue(':expires_at', $formattedExDate);
$stmt->bindValue(':locked', $locked);
+ $stmt->bindValue(':synced_at', date('Y-m-d H:i:s'));
$stmt->bindValue(':transfer_code', $domainInfo["authInfo"]);
$stmt->bindValue(':sld', $domainRow['sld']);
$stmt->bindValue(':tld', $domainRow['tld']);
-
- // Execute the statement
$stmt->execute();
- $sqlCheck = 'SELECT COUNT(*) FROM extension WHERE name = :name AND status = :status';
- $stmtCheck = $pdo->prepare($sqlCheck);
- $stmtCheck->bindValue(':name', 'registrar');
- $stmtCheck->bindValue(':status', 'installed');
- $stmtCheck->execute();
- $count = $stmtCheck->fetchColumn();
+ $stmt = $pdo->prepare('SELECT id FROM service_domain WHERE sld = :sld AND tld = :tld');
+ $stmt->bindValue(':sld', $domainRow['sld']);
+ $stmt->bindValue(':tld', $domainRow['tld']);
+ $stmt->execute();
+ $serviceDomain = $stmt->fetch(PDO::FETCH_ASSOC);
+ if ($serviceDomain) {
+ $serviceId = $serviceDomain['id'];
+ $stmt = $pdo->prepare('UPDATE client_order SET expires_at = :expires_at WHERE service_id = :service_id');
+ $stmt->bindValue(':expires_at', $formattedExDate);
+ $stmt->bindValue(':service_id', $serviceId);
+ $stmt->execute();
+
+ if ($count > 0) {
+ $stmt = $pdo->prepare('SELECT registrant_contact_id FROM domain_meta WHERE domain_id = :id');
+ $stmt->bindValue(':id', $serviceId);
+ $stmt->execute();
+ $result = $stmt->fetch(PDO::FETCH_ASSOC);
+ $registrant_contact_id = $result['registrant_contact_id'];
+
+ $contact_params = ["contact" => $registrant_contact_id];
+ $contactInfo = $epp->contactInfo($contact_params);
+
+ if (array_key_exists('error', $contactInfo))
+ {
+ echo 'ContactInfo Error: ' . $contactInfo['error'] . PHP_EOL;
+ }
+ else
+ {
+ try {
+ // Prepare the UPDATE statement
+ $stmt = $pdo->prepare('
+ UPDATE service_domain
+ SET
+ contact_email = :contact_email,
+ contact_company = :contact_company,
+ contact_first_name = :contact_first_name,
+ contact_last_name = :contact_last_name,
+ contact_address1 = :contact_address1,
+ contact_address2 = :contact_address2,
+ contact_city = :contact_city,
+ contact_state = :contact_state,
+ contact_postcode = :contact_postcode,
+ contact_country = :contact_country,
+ contact_phone_cc = :contact_phone_cc,
+ contact_phone = :contact_phone
+ WHERE id = :id
+ ');
+
+ // Split name into first and last names
+ $nameParts = explode(' ', $contactInfo['name']);
+ $contactFirstName = array_shift($nameParts); // First part of the name
+ $contactLastName = implode(' ', $nameParts); // Remaining parts as the last name
+
+ // Split phone into country code and number
+ $phoneParts = explode('.', $contactInfo['voice']);
+ $contactPhoneCC = isset($phoneParts[0]) ? $phoneParts[0] : null;
+ $contactPhone = isset($phoneParts[1]) ? $phoneParts[1] : null;
+
+ // Bind values, setting them to NULL if they are empty
+ $stmt->bindValue(':contact_email', !empty($contactInfo['email']) ? $contactInfo['email'] : null);
+ $stmt->bindValue(':contact_company', !empty($contactInfo['org']) ? $contactInfo['org'] : null);
+ $stmt->bindValue(':contact_first_name', !empty($contactFirstName) ? $contactFirstName : null);
+ $stmt->bindValue(':contact_last_name', !empty($contactLastName) ? $contactLastName : null);
+ $stmt->bindValue(':contact_address1', !empty($contactInfo['street1']) ? $contactInfo['street1'] : null);
+ $stmt->bindValue(':contact_address2', !empty($contactInfo['street2']) ? $contactInfo['street2'] : null);
+ $stmt->bindValue(':contact_city', !empty($contactInfo['city']) ? $contactInfo['city'] : null);
+ $stmt->bindValue(':contact_state', !empty($contactInfo['state']) ? $contactInfo['state'] : null);
+ $stmt->bindValue(':contact_postcode', !empty($contactInfo['postal']) ? $contactInfo['postal'] : null);
+ $stmt->bindValue(':contact_country', !empty($contactInfo['country']) ? $contactInfo['country'] : null);
+ $stmt->bindValue(':contact_phone_cc', !empty($contactPhoneCC) ? $contactPhoneCC : null);
+ $stmt->bindValue(':contact_phone', !empty($contactPhone) ? $contactPhone : null);
+ $stmt->bindValue(':id', $serviceId);
+ $stmt->execute();
+
+ echo "Update successful for contact: ".$contactInfo['id'].PHP_EOL;
+
+ } catch (PDOException $e) {
+ exit("Database error: " . $e->getMessage().PHP_EOL);
+ }
+ }
+ }
+ }
+
if ($count > 0) {
$selectStmt = $pdo->prepare('SELECT id FROM service_domain WHERE sld = :sld AND tld = :tld LIMIT 1');
$selectStmt->bindValue(':sld', $domainRow['sld']);
@@ -217,7 +306,509 @@ function connectEpp(string $registry, $config)
$logout = $epp->logout();
echo "Logout Result: " . $logout["code"] . ": " . $logout["msg"][0] . PHP_EOL;
} catch (PDOException $e) {
- echo "Database error: " . $e->getMessage();
+ exit("Database error: " . $e->getMessage().PHP_EOL);
} catch(EppException $e) {
- echo "Error: ", $e->getMessage();
+ exit("Error: " . $e->getMessage().PHP_EOL);
+}
+
+// Mini EPP Clinet Class
+class eppClient
+{
+ private $resource;
+ private $isLoggedIn;
+ private $prefix;
+
+ public function __construct()
+ {
+ if (!extension_loaded('SimpleXML')) {
+ exit('PHP extension SimpleXML is not loaded.'.PHP_EOL);
+ }
+ }
+
+ /**
+ * connect
+ */
+ public function connect($params = array())
+ {
+ $host = (string)$params['host'];
+ $port = (int)$params['port'];
+ $timeout = (int)$params['timeout'];
+ $tls = (string)$params['tls'];
+ $bind = (string)$params['bind'];
+ $bindip = (string)$params['bindip'];
+ if ($tls !== '1.3' && $tls !== '1.2' && $tls !== '1.1') {
+ exit('Invalid TLS version specified.'.PHP_EOL);
+ }
+ $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
+ )
+ );
+ if ($bind) {
+ $opts['socket'] = array('bindto' => $bindip);
+ }
+ $context = stream_context_create($opts);
+ $this->resource = stream_socket_client("tls://{$host}:{$port}", $errno, $errmsg, $timeout, STREAM_CLIENT_CONNECT, $context);
+ if (!$this->resource) {
+ exit("Cannot connect to server '{$host}': {$errmsg}".PHP_EOL);
+ }
+
+ return $this->readResponse();
+ }
+
+ /**
+ * readResponse
+ */
+ public function readResponse()
+ {
+ $hdr = stream_get_contents($this->resource, 4);
+ if ($hdr === false) {
+ exit('Connection appears to have closed.'.PHP_EOL);
+ }
+ if (strlen($hdr) < 4) {
+ exit('Failed to read header from the connection.'.PHP_EOL);
+ }
+ $unpacked = unpack('N', $hdr);
+ $xml = fread($this->resource, ($unpacked[1] - 4));
+ $xml = preg_replace('/>', ">\n<", $xml);
+ $this->_response_log($xml);
+ return $xml;
+ }
+
+ /**
+ * writeRequest
+ */
+ public function writeRequest($xml)
+ {
+ $this->_request_log($xml);
+ if (fwrite($this->resource, pack('N', (strlen($xml) + 4)) . $xml) === false) {
+ exit('Error writing to the connection.'.PHP_EOL);
+ }
+ $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) {
+ echo $r->response->result->msg.PHP_EOL;
+ }
+ return $r;
+ }
+
+ /**
+ * disconnect
+ */
+ public function disconnect()
+ {
+ if (!fclose($this->resource)) {
+ exit('Error closing the connection.'.PHP_EOL);
+ }
+ $this->resource = null;
+ }
+
+ /**
+ * wrapper for functions
+ */
+ public function __call($func, $args)
+ {
+ if (!function_exists($func)) {
+ exit("Call to undefined method Epp::$func().".PHP_EOL);
+ }
+
+ if ($func === 'connect') {
+ try {
+ $result = call_user_func_array($func, $args);
+ } catch (\ErrorException $e) {
+ exit($e->getMessage().PHP_EOL);
+ }
+
+ if (!is_resource($this->resource)) {
+ exit('An error occured while trying to connect to EPP server.'.PHP_EOL);
+ }
+
+ $result = null;
+ } elseif (!is_resource($this->resource)) {
+ exit('Not connected to EPP server.'.PHP_EOL);
+ } else {
+ array_unshift($args, $this->resource);
+ try {
+ $result = call_user_func_array($func, $args);
+ } catch (\ErrorException $e) {
+ exit($e->getMessage().PHP_EOL);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * login
+ */
+ public function login($params = array())
+ {
+ $return = array();
+ try {
+ $from = $to = array();
+ $from[] = '/{{ clID }}/';
+ $to[] = htmlspecialchars($params['clID']);
+ $from[] = '/{{ pwd }}/';
+ $to[] = htmlspecialchars($params['pw']);
+ if (isset($params['newpw']) && !empty($params['newpw'])) {
+ $from[] = '/{{ newpw }}/';
+ $to[] = PHP_EOL . ' ' . htmlspecialchars($params['newpw']) . '';
+ } else {
+ $from[] = '/{{ newpw }}/';
+ $to[] = '';
+ }
+ $from[] = '/{{ clTRID }}/';
+ $microtime = str_replace('.', '', round(microtime(1), 3));
+ $to[] = htmlspecialchars($params['prefix'] . '-login-' . $microtime);
+ $xml = preg_replace($from, $to, '
+
+
+
+ {{ clID }}
+ {{ pwd }}{{ newpw }}
+
+ 1.0
+ en
+
+
+ urn:ietf:params:xml:ns:domain-1.0
+ urn:ietf:params:xml:ns:contact-1.0
+ urn:ietf:params:xml:ns:host-1.0
+
+ urn:ietf:params:xml:ns:secDNS-1.1
+ urn:ietf:params:xml:ns:rgp-1.0
+
+
+
+ {{ clTRID }}
+
+');
+ $r = $this->writeRequest($xml);
+ $code = (int)$r->response->result->attributes()->code;
+ if ($code == 1000) {
+ $this->isLoggedIn = true;
+ $this->prefix = $params['prefix'];
+ }
+
+ $return = array(
+ 'code' => $code,
+ 'msg' => $r->response->result->msg
+ );
+ } catch (\Exception $e) {
+ $return = array(
+ 'error' => $e->getMessage()
+ );
+ }
+
+ return $return;
+ }
+
+ /**
+ * logout
+ */
+ public function logout($params = array())
+ {
+ if (!$this->isLoggedIn) {
+ return array(
+ 'code' => 2002,
+ 'msg' => 'Command use error'
+ );
+ }
+
+ $return = array();
+ try {
+ $from = $to = array();
+ $from[] = '/{{ clTRID }}/';
+ $microtime = str_replace('.', '', round(microtime(1), 3));
+ $to[] = htmlspecialchars($this->prefix . '-logout-' . $microtime);
+ $xml = preg_replace($from, $to, '
+
+
+
+ {{ clTRID }}
+
+');
+ $r = $this->writeRequest($xml);
+ $code = (int)$r->response->result->attributes()->code;
+ if ($code == 1500) {
+ $this->isLoggedIn = false;
+ }
+
+ $return = array(
+ 'code' => $code,
+ 'msg' => $r->response->result->msg
+ );
+ } catch (\Exception $e) {
+ $return = array(
+ 'error' => $e->getMessage()
+ );
+ }
+
+ return $return;
+ }
+
+ /**
+ * domainInfo
+ */
+ public function domainInfo($params = array())
+ {
+ if (!$this->isLoggedIn) {
+ return array(
+ 'code' => 2002,
+ 'msg' => 'Command use error'
+ );
+ }
+
+ $return = array();
+ try {
+ $from = $to = array();
+ $from[] = '/{{ domainname }}/';
+ $to[] = htmlspecialchars($params['domainname']);
+ $from[] = '/{{ authInfo }}/';
+ $authInfo = (isset($params['authInfoPw']) ? "\n\n" : '');
+ $to[] = $authInfo;
+ $from[] = '/{{ clTRID }}/';
+ $microtime = str_replace('.', '', round(microtime(1), 3));
+ $to[] = htmlspecialchars($this->prefix . '-domain-info-' . $microtime);
+ $from[] = "/<\w+:\w+>\s*<\/\w+:\w+>\s+/ims";
+ $to[] = '';
+ $xml = preg_replace($from, $to, '
+
+
+
+
+ {{ domainname }}
+ {{ authInfo }}
+
+
+ {{ clTRID }}
+
+');
+ $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')->infData;
+ $name = (string)$r->name;
+ $roid = (string)$r->roid;
+ $status = array();
+ $i = 0;
+ foreach ($r->status as $e) {
+ $i++;
+ $status[$i] = (string)$e->attributes()->s;
+ }
+ $registrant = (string)$r->registrant;
+ $contact = array();
+ $i = 0;
+ foreach ($r->contact as $e) {
+ $i++;
+ $contact[$i]['type'] = (string)$e->attributes()->type;
+ $contact[$i]['id'] = (string)$e;
+ }
+ $ns = array();
+ $i = 0;
+ if (isset($r->ns->hostObj) && (is_array($r->ns->hostObj) || is_object($r->ns->hostObj))) {
+ foreach ($r->ns->hostObj as $hostObj) {
+ $i++;
+ $ns[$i] = (string)$hostObj;
+ }
+ } else {
+ $ns = [];
+ }
+ $host = array();
+ $i = 0;
+ foreach ($r->host as $hostname) {
+ $i++;
+ $host[$i] = (string)$hostname;
+ }
+ $clID = (string)$r->clID;
+ $crID = (string)$r->crID;
+ $crDate = (string)$r->crDate;
+ $upID = (string)$r->upID;
+ $upDate = (string)$r->upDate;
+ $exDate = (string)$r->exDate;
+ $trDate = (string)$r->trDate;
+ $authInfo = (string)$r->authInfo->pw;
+
+ $return = array(
+ 'code' => $code,
+ 'msg' => $msg,
+ 'name' => $name,
+ 'roid' => $roid,
+ 'status' => $status,
+ 'registrant' => $registrant,
+ 'contact' => $contact,
+ 'ns' => $ns,
+ 'host' => $host,
+ 'clID' => $clID,
+ 'crID' => $crID,
+ 'crDate' => $crDate,
+ 'upID' => $upID,
+ 'upDate' => $upDate,
+ 'exDate' => $exDate,
+ 'trDate' => $trDate,
+ 'authInfo' => $authInfo
+ );
+ } catch (\Exception $e) {
+ $return = array(
+ 'error' => $e->getMessage()
+ );
+ }
+
+ return $return;
+ }
+
+ /**
+ * contactInfo
+ */
+ public function contactInfo($params = array())
+ {
+ if (!$this->isLoggedIn) {
+ return array(
+ 'code' => 2002,
+ 'msg' => 'Command use error'
+ );
+ }
+
+ $return = array();
+ try {
+ $from = $to = array();
+ $from[] = '/{{ id }}/';
+ $to[] = htmlspecialchars($params['contact']);
+ $from[] = '/{{ authInfo }}/';
+ $authInfo = (isset($params['authInfoPw']) ? "\n\n" : '');
+ $to[] = $authInfo;
+ $from[] = '/{{ clTRID }}/';
+ $microtime = str_replace('.', '', round(microtime(1), 3));
+ $to[] = htmlspecialchars($this->prefix . '-contact-info-' . $microtime);
+ $from[] = "/<\w+:\w+>\s*<\/\w+:\w+>\s+/ims";
+ $to[] = '';
+ $xml = preg_replace($from, $to, '
+
+
+
+
+ {{ id }}
+ {{ authInfo }}
+
+
+ {{ clTRID }}
+
+');
+ $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:contact-1.0')->infData[0];
+
+ foreach ($r->postalInfo as $e) {
+ $name = (string)$e->name;
+ $org = (string)$e->org;
+ $street1 = $street2 = $street3 = '';
+ for ($i = 0; $i <= 2; $i++) {
+ ${'street' . ($i + 1)} = (string)$e->addr->street[$i];
+ }
+ $city = (string)$e->addr->city;
+ $state = (string)$e->addr->sp;
+ $postal = (string)$e->addr->pc;
+ $country = (string)$e->addr->cc;
+ }
+ $id = (string)$r->id;
+ $status = array();
+ $i = 0;
+ foreach ($r->status as $e) {
+ $i++;
+ $status[$i] = (string)$e->attributes()->s;
+ }
+ $roid = (string)$r->roid;
+ $voice = (string)$r->voice;
+ $fax = (string)$r->fax;
+ $email = (string)$r->email;
+ $clID = (string)$r->clID;
+ $crID = (string)$r->crID;
+ $crDate = (string)$r->crDate;
+ $upID = (string)$r->upID;
+ $upDate = (string)$r->upDate;
+ $authInfo = (string)$r->authInfo->pw;
+
+ $return = array(
+ 'id' => $id,
+ 'roid' => $roid,
+ 'code' => $code,
+ 'status' => $status,
+ 'msg' => $msg,
+ 'name' => $name,
+ 'org' => $org,
+ 'street1' => $street1,
+ 'street2' => $street2,
+ 'street3' => $street3,
+ 'city' => $city,
+ 'state' => $state,
+ 'postal' => $postal,
+ 'country' => $country,
+ 'voice' => $voice,
+ 'fax' => $fax,
+ 'email' => $email,
+ 'clID' => $clID,
+ 'crID' => $crID,
+ 'crDate' => $crDate,
+ 'upID' => $upID,
+ 'upDate' => $upDate,
+ 'authInfo' => $authInfo
+ );
+ } catch (\Exception $e) {
+ $return = array(
+ 'error' => $e->getMessage()
+ );
+ }
+
+ return $return;
+ }
+
+ public function _response_log($content)
+ {
+ $handle = fopen(dirname(__FILE__) . '/data/log/epp_response.log', 'a');
+ ob_start();
+ echo "\n==================================\n";
+ ob_end_clean();
+ fwrite($handle, $content);
+ fclose($handle);
+ }
+
+ public function _request_log($content)
+ {
+ $handle = fopen(dirname(__FILE__) . '/data/log/epp_request.log', 'a');
+ ob_start();
+ echo "\n==================================\n";
+ ob_end_clean();
+ fwrite($handle, $content);
+ fclose($handle);
+ }
}
diff --git a/install_epp_module.sh b/install_epp_module.sh
index cc07801..f259eda 100644
--- a/install_epp_module.sh
+++ b/install_epp_module.sh
@@ -27,11 +27,6 @@ sed -i "s/Registrar_Adapter_EPP/Registrar_Adapter_${safe_registry_name}/g" "$fos
# Move and rename eppSync.php
mv /tmp/fossbilling-epp-rfc/eppSync.php "$fossbilling_path/${safe_registry_name}Sync.php"
-# Check if eppClient.php exists and move if not
-if [ ! -f "$fossbilling_path/eppClient.php" ]; then
- mv /tmp/fossbilling-epp-rfc/eppClient.php "$fossbilling_path/"
-fi
-
# Edit the renamed eppSync.php
sed -i "s/\$registrar = \"Epp\";/\$registrar = \"${safe_registry_name}\";/g" "$fossbilling_path/${safe_registry_name}Sync.php"