|
|
@@ -0,0 +1,200 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+use Illuminate\Database\Capsule\Manager as Capsule;
|
|
|
+
|
|
|
+class SWITCHEPP {
|
|
|
+
|
|
|
+ private $apiUrl;
|
|
|
+ private $port;
|
|
|
+ private $regId;
|
|
|
+ private $regPw;
|
|
|
+ private $passPhrase;
|
|
|
+ private $dnsSec;
|
|
|
+
|
|
|
+ public function __construct() {
|
|
|
+ $this->WgsSwitchEppGetModuleParams();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function WgsSwitchEppGetModuleParams() {
|
|
|
+ $getRegModuleDetail = Capsule::table('tblregistrars')->where('registrar', 'switchepp')->orderBy('id', 'asc')->get();
|
|
|
+ foreach ($getRegModuleDetail as $detail) {
|
|
|
+ $detail = (array) $detail;
|
|
|
+ if ($detail['setting'] == 'eppurl')
|
|
|
+ $this->apiUrl = decrypt($detail['value']);
|
|
|
+ if ($detail['setting'] == 'eppport')
|
|
|
+ $this->port = decrypt($detail['value']);
|
|
|
+ if ($detail['setting'] == 'registrar_id')
|
|
|
+ $this->regId = decrypt($detail['value']);
|
|
|
+ if ($detail['setting'] == 'registrar_password')
|
|
|
+ $this->regPw = decrypt($detail['value']);
|
|
|
+ if ($detail['setting'] == 'passphrase')
|
|
|
+ $this->passPhrase = decrypt($detail['value']);
|
|
|
+ if ($detail['setting'] == 'dnssec')
|
|
|
+ $this->dnsSec = decrypt($detail['value']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function WgsSwitchEppGetWHMCS_Admin() {
|
|
|
+ $admin = Capsule::table('tbladmins')->limit(1)->get();
|
|
|
+ return $admin[0]->id;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function WgsSwitchEppGetPoll() {
|
|
|
+
|
|
|
+ $client = $this->WgsSwitchEppConnect();
|
|
|
+ if (is_array($client)) {
|
|
|
+ $error = $client['msg'];
|
|
|
+ return ['status' => 'error', 'msg' => $error];
|
|
|
+ }
|
|
|
+
|
|
|
+ $login = $this->WgsSwitchEppLoggedIn($client);
|
|
|
+
|
|
|
+ if ($login['status'] == 'error')
|
|
|
+ return $login;
|
|
|
+
|
|
|
+ $loginXmlArr = simplexml_load_string($login['resp']);
|
|
|
+ $loginCode = $loginXmlArr->response->result->attributes()->code[0];
|
|
|
+ if ($loginCode == 1000) {
|
|
|
+ $poll = $this->WgsSwitchEppPoll($client);
|
|
|
+ $pollXmlArr = simplexml_load_string($poll['resp']);
|
|
|
+ $pollCode = $pollXmlArr->response->result->attributes()->code[0];
|
|
|
+ $msgid = $pollXmlArr->response->msgQ->attributes()->id[0];
|
|
|
+
|
|
|
+ if ($pollCode == 1300 || $pollCode == 1301) {
|
|
|
+ return ['status' => 'success', 'msg' => $pollXmlArr->response->result->msg, 'resp' => $poll['resp'], 'msgid' => $msgid];
|
|
|
+ } else {
|
|
|
+ return ['status' => 'error', 'msg' => $pollXmlArr->response->result->msg];
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ foreach ($loginXmlArr->response->result as $resp) {
|
|
|
+ $error = $resp->msg;
|
|
|
+ }
|
|
|
+ return ['status' => 'error', 'msg' => $error];
|
|
|
+ }
|
|
|
+ $logout = $this->WgsSwitchEppLogout($client);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function WgsSwitchEppPoll($client) {
|
|
|
+ $request = '<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
|
|
+ <command>
|
|
|
+ <poll op="req"/>
|
|
|
+ <clTRID>POLL-' . rand(10000, 99999) . '</clTRID>
|
|
|
+ </command>
|
|
|
+ </epp>';
|
|
|
+ $response = $client->request($request);
|
|
|
+ logModuleCall('SWITCH EPP Addon Module', 'Get Poll', $request, $response);
|
|
|
+ return ['status' => 'success', 'req' => $request, 'resp' => $response];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function WgsSwitchEppAckConfirm($msgId) {
|
|
|
+ $client = $this->WgsSwitchEppConnect();
|
|
|
+ if (is_array($client)) {
|
|
|
+ $error = $client['msg'];
|
|
|
+ return ['status' => 'error', 'msg' => $error];
|
|
|
+ }
|
|
|
+
|
|
|
+ $login = $this->WgsSwitchEppLoggedIn($client);
|
|
|
+
|
|
|
+ if ($login['status'] == 'error')
|
|
|
+ return $login;
|
|
|
+
|
|
|
+ $loginXmlArr = simplexml_load_string($login['resp']);
|
|
|
+ $loginCode = $loginXmlArr->response->result->attributes()->code[0];
|
|
|
+ if ($loginCode == 1000) {
|
|
|
+ $pollCnfrm = $this->WgsSwitchEppAckConfirmCommand($client, $msgId);
|
|
|
+ $pollCnfrmXmlArr = simplexml_load_string($pollCnfrm['resp']);
|
|
|
+ $pollCnfrmCode = $pollCnfrmXmlArr->response->result->attributes()->code[0];
|
|
|
+
|
|
|
+ if ($pollCnfrmCode == 1000) {
|
|
|
+ return ['status' => 'success', 'msg' => $pollCnfrmXmlArr->response->result->msg, 'resp' => $pollCnfrm['resp']];
|
|
|
+ } else {
|
|
|
+ return ['status' => 'error', 'msg' => $pollCnfrmXmlArr->response->result->msg];
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ foreach ($loginXmlArr->response->result as $resp) {
|
|
|
+ $error = $resp->msg;
|
|
|
+ }
|
|
|
+ return ['status' => 'error', 'msg' => $error];
|
|
|
+ }
|
|
|
+ $logout = $this->WgsSwitchEppLogout($client);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function WgsSwitchEppAckConfirmCommand($client, $msgId) {
|
|
|
+ $request = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
|
+ <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
|
|
+ <command>
|
|
|
+ <poll op="ack" msgID="' . $msgId . '"/>
|
|
|
+ <clTRID>POLLCF-' . rand(1000, 9999) . '</clTRID>
|
|
|
+ </command>
|
|
|
+ </epp>';
|
|
|
+ $response = $client->request($request);
|
|
|
+ logModuleCall('SWITCH EPP Addon Module', 'Confirm Acknowledge', $request, $response);
|
|
|
+ return ['status' => 'success', 'req' => $request, 'resp' => $response];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function WgsSwitchEppLoggedIn($client) {
|
|
|
+ if ($this->regId && $this->regPw) {
|
|
|
+ $request = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
|
+ <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
|
|
+ <command>
|
|
|
+ <login>
|
|
|
+ <clID>' . $this->regId . '</clID>
|
|
|
+ <pw>' . $this->regPw . '</pw>
|
|
|
+ <options>
|
|
|
+ <version>1.0</version>
|
|
|
+ <lang>en</lang>
|
|
|
+ </options>
|
|
|
+ <svcs>
|
|
|
+ <objURI>urn:ietf:params:xml:ns:domain-1.0</objURI>
|
|
|
+ <objURI>urn:ietf:params:xml:ns:contact-1.0</objURI>
|
|
|
+ <objURI>urn:ietf:params:xml:ns:host-1.0</objURI>
|
|
|
+ </svcs>
|
|
|
+ </login>
|
|
|
+ <clTRID>' . rand(9999999, 100000) . '</clTRID>
|
|
|
+ </command>
|
|
|
+ </epp>';
|
|
|
+ $response = $client->request($request);
|
|
|
+ return ['status' => 'success', 'req' => $request, 'resp' => $response];
|
|
|
+ } else {
|
|
|
+ return ['status' => 'error', 'msg' => 'Registrar id or Registrar password missing'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function WgsSwitchEppLogout($client) {
|
|
|
+ $request = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
|
+ <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
|
|
+ <epp:command xmlns:epp="urn:ietf:params:xml:ns:epp-1.0">
|
|
|
+ <epp:logout />
|
|
|
+ <epp:clTRID>' . $this->regId . '</epp:clTRID>
|
|
|
+ </epp:command>
|
|
|
+ </epp>';
|
|
|
+ $response = $client->request($request);
|
|
|
+ return ['status' => 'success', 'req' => $request, 'resp' => $response];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function WgsSwitchEppConnect() {
|
|
|
+ try {
|
|
|
+ $certFile = __DIR__ . '/../../../registrars/switchepp/cert/cert.pem';
|
|
|
+ $client = new Net_EPP_Client();
|
|
|
+ $use_ssl = true;
|
|
|
+ if (file_exists($certFile)) {
|
|
|
+ $context = stream_context_create();
|
|
|
+ stream_context_set_option($context, 'ssl', 'verify_peer', false);
|
|
|
+ stream_context_set_option($context, 'ssl', 'allow_self_signed', true);
|
|
|
+ stream_context_set_option($context, 'ssl', 'local_cert', $certFile);
|
|
|
+ stream_context_set_option($context, 'ssl', 'passphrase', $this->passPhrase);
|
|
|
+ $client->connect($this->apiUrl, $this->port, 300, $use_ssl, $context) or die("Not connected with epp server");
|
|
|
+ } else {
|
|
|
+ $context = false;
|
|
|
+ $client->connect($this->apiUrl, $this->port, 300, $use_ssl, $context) or die("Not connected with epp server");
|
|
|
+ }
|
|
|
+ } catch (Exception $e) {
|
|
|
+ $port = $this->port;
|
|
|
+ $client = ["error" => 'true', 'msg' => "Connection Error: " . $e->getMessage()];
|
|
|
+ }
|
|
|
+ return $client;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+?>
|