From 13a349836c7cf60f7555a0bb3f4be01e412a5eaf Mon Sep 17 00:00:00 2001 From: Scott Claeys Date: Wed, 31 May 2023 20:38:31 -0500 Subject: [PATCH] Updated for PHP 8.1+ Compatibility with PHP 8.1+ --- .../RadWebHosting/Calls/CheckAvailability.php | 15 + .../RadWebHosting/Calls/DeleteNameServer.php | 15 + .../RadWebHosting/Calls/GetContactDetails.php | 15 + .../registrars/RadWebHosting/Calls/GetDns.php | 15 + .../Calls/GetEmailForwarding.php | 15 + .../RadWebHosting/Calls/GetEppCode.php | 15 + .../RadWebHosting/Calls/GetNameServers.php | 15 + .../RadWebHosting/Calls/GetRegistrarLock.php | 15 + .../RadWebHosting/Calls/ModifyNameServer.php | 15 + .../RadWebHosting/Calls/RegisterDomain.php | 15 + .../Calls/RegisterNameServer.php | 15 + .../RadWebHosting/Calls/ReleaseDomain.php | 15 + .../RadWebHosting/Calls/RenewDomain.php | 15 + .../RadWebHosting/Calls/RequestDelete.php | 15 + .../Calls/SaveContactDetails.php | 15 + .../RadWebHosting/Calls/SaveDns.php | 15 + .../Calls/SaveEmailForwarding.php | 15 + .../RadWebHosting/Calls/SaveNameServers.php | 15 + .../RadWebHosting/Calls/SaveRegistrarLock.php | 15 + .../registrars/RadWebHosting/Calls/Sync.php | 15 + .../RadWebHosting/Calls/ToggleIdProtect.php | 15 + .../RadWebHosting/Calls/TransferDomain.php | 15 + .../RadWebHosting/Calls/TransferSync.php | 15 + .../registrars/RadWebHosting/Core/Call.php | 164 ++++ .../RadWebHosting/Core/Configuration.php | 83 ++ .../registrars/RadWebHosting/Core/Loader.php | 37 + .../Helpers/ResultsListFactory.php | 35 + .../RadWebHosting/RadWebHosting.php | 734 ++++++++++++++++++ .../registrars/RadWebHosting/whmcs.json | 12 + 29 files changed, 1410 insertions(+) create mode 100644 RadWebHosting/modules/registrars/RadWebHosting/Calls/CheckAvailability.php create mode 100644 RadWebHosting/modules/registrars/RadWebHosting/Calls/DeleteNameServer.php create mode 100644 RadWebHosting/modules/registrars/RadWebHosting/Calls/GetContactDetails.php create mode 100644 RadWebHosting/modules/registrars/RadWebHosting/Calls/GetDns.php create mode 100644 RadWebHosting/modules/registrars/RadWebHosting/Calls/GetEmailForwarding.php create mode 100644 RadWebHosting/modules/registrars/RadWebHosting/Calls/GetEppCode.php create mode 100644 RadWebHosting/modules/registrars/RadWebHosting/Calls/GetNameServers.php create mode 100644 RadWebHosting/modules/registrars/RadWebHosting/Calls/GetRegistrarLock.php create mode 100644 RadWebHosting/modules/registrars/RadWebHosting/Calls/ModifyNameServer.php create mode 100644 RadWebHosting/modules/registrars/RadWebHosting/Calls/RegisterDomain.php create mode 100644 RadWebHosting/modules/registrars/RadWebHosting/Calls/RegisterNameServer.php create mode 100644 RadWebHosting/modules/registrars/RadWebHosting/Calls/ReleaseDomain.php create mode 100644 RadWebHosting/modules/registrars/RadWebHosting/Calls/RenewDomain.php create mode 100644 RadWebHosting/modules/registrars/RadWebHosting/Calls/RequestDelete.php create mode 100644 RadWebHosting/modules/registrars/RadWebHosting/Calls/SaveContactDetails.php create mode 100644 RadWebHosting/modules/registrars/RadWebHosting/Calls/SaveDns.php create mode 100644 RadWebHosting/modules/registrars/RadWebHosting/Calls/SaveEmailForwarding.php create mode 100644 RadWebHosting/modules/registrars/RadWebHosting/Calls/SaveNameServers.php create mode 100644 RadWebHosting/modules/registrars/RadWebHosting/Calls/SaveRegistrarLock.php create mode 100644 RadWebHosting/modules/registrars/RadWebHosting/Calls/Sync.php create mode 100644 RadWebHosting/modules/registrars/RadWebHosting/Calls/ToggleIdProtect.php create mode 100644 RadWebHosting/modules/registrars/RadWebHosting/Calls/TransferDomain.php create mode 100644 RadWebHosting/modules/registrars/RadWebHosting/Calls/TransferSync.php create mode 100644 RadWebHosting/modules/registrars/RadWebHosting/Core/Call.php create mode 100644 RadWebHosting/modules/registrars/RadWebHosting/Core/Configuration.php create mode 100644 RadWebHosting/modules/registrars/RadWebHosting/Core/Loader.php create mode 100644 RadWebHosting/modules/registrars/RadWebHosting/Helpers/ResultsListFactory.php create mode 100644 RadWebHosting/modules/registrars/RadWebHosting/RadWebHosting.php create mode 100644 RadWebHosting/modules/registrars/RadWebHosting/whmcs.json diff --git a/RadWebHosting/modules/registrars/RadWebHosting/Calls/CheckAvailability.php b/RadWebHosting/modules/registrars/RadWebHosting/Calls/CheckAvailability.php new file mode 100644 index 0000000..1e6e53e --- /dev/null +++ b/RadWebHosting/modules/registrars/RadWebHosting/Calls/CheckAvailability.php @@ -0,0 +1,15 @@ + + */ +class RegisterDomain extends Call +{ + public $action = "order/domains/register"; + + public $type = parent::TYPE_POST; +} diff --git a/RadWebHosting/modules/registrars/RadWebHosting/Calls/RegisterNameServer.php b/RadWebHosting/modules/registrars/RadWebHosting/Calls/RegisterNameServer.php new file mode 100644 index 0000000..29d9896 --- /dev/null +++ b/RadWebHosting/modules/registrars/RadWebHosting/Calls/RegisterNameServer.php @@ -0,0 +1,15 @@ + + */ +class TransferDomain extends Call +{ + public $action = "order/domains/transfer"; + + public $type = parent::TYPE_POST; +} \ No newline at end of file diff --git a/RadWebHosting/modules/registrars/RadWebHosting/Calls/TransferSync.php b/RadWebHosting/modules/registrars/RadWebHosting/Calls/TransferSync.php new file mode 100644 index 0000000..6111829 --- /dev/null +++ b/RadWebHosting/modules/registrars/RadWebHosting/Calls/TransferSync.php @@ -0,0 +1,15 @@ + + */ +abstract class Call +{ + const TYPE_GET = "GET"; + + const TYPE_POST = "POST"; + + const TYPE_PUT = "PUT"; + + const TYPE_DELETE = "DELETE"; + + /** + * Action path + * + * @var string + */ + public $action; + + /** + * Request type + * + * @var string + */ + public $type; + + /** + * Configuration + * + * @var Configuration + */ + public $config; + + /** + * params to send trough API + * + * @var mixed + */ + public $params; + + /** + * AbstractCall constructor + * + * @param Configuration $config + * @param $params + */ + public function __construct(Configuration $config, $params = []) + { + $this->config = $config; + $this->params = $params; + } + + /** + * Make request to API + * + * @return array|bool|mixed|\stdClass|string + */ + public function process() + { + try + { + $this->setVariablesInActionString(); + $url = "{$this->config->ApiEndpoint}/{$this->action}"; + + $client = new Client(); + if($this->isWhmcsVersionHigherOrEqual('8.0.0')) + { + $params = $this->type === self::TYPE_POST ? $this->params : []; + $request = $client->request($this->type, $url, ["headers" => $this->config->getAuthHeaders(), "form_params" => $params]); + $output = $request->getBody()->getContents(); + } else + { + $request = $client->createRequest($this->type, $url, ["headers" => $this->config->getAuthHeaders(), $this->getParamKeyName() => $this->params]); + $output = $client->send($request)->getBody()->getContents(); + } + } + catch (\GuzzleHttp\Exception\ClientException $ex) + { + $response = $ex->getResponse(); + $output = $response->getBody()->getContents(); + } + catch (\GuzzleHttp\Exception\ServerException $ex) + { + $response = $ex->getResponse(); + $output = $response->getBody()->getContents(); + } + catch (\Exception $ex) + { + $output = $ex->getMessage(); + } + + $result = json_decode($output, true); + if($result === null && is_string($output)) + { + $result = ["error" => $output]; + } + + return $result; + } + + /** + * Put variables from params to action string if possible + */ + protected function setVariablesInActionString() + { + //Check if params needs to be filled + if(strpos($this->action, ":") !== false) + { + //Get params names + $pos = 0; + $names = []; + while(($pos = strpos($this->action, ":", $pos)) !== false) + { + $pos++; + + $slash = strpos($this->action, "/", $pos); + $names[] = substr($this->action, $pos, $slash - $pos); + } + + foreach($names as $name) + { + $this->action = str_replace(":{$name}", $this->params[$name], $this->action); + } + } + } + + /** + * Get correct param name depending on the request type + * + * @return string + */ + protected function getParamKeyName() + { + $result = "query"; + if($this->type == self::TYPE_POST) + { + $result = "body"; + } + + return $result; + } + + private function isWhmcsVersionHigherOrEqual($toCompare) + { + if (isset($GLOBALS['CONFIG']['Version'])) + { + $version = explode('-', $GLOBALS['CONFIG']['Version']); + return (version_compare($version[0], $toCompare, '>=')); + } + + global $whmcs; + + return (version_compare($whmcs->getVersion()->getRelease(), $toCompare, '>=')); + } +} \ No newline at end of file diff --git a/RadWebHosting/modules/registrars/RadWebHosting/Core/Configuration.php b/RadWebHosting/modules/registrars/RadWebHosting/Core/Configuration.php new file mode 100644 index 0000000..486ae15 --- /dev/null +++ b/RadWebHosting/modules/registrars/RadWebHosting/Core/Configuration.php @@ -0,0 +1,83 @@ + + */ +class Configuration +{ + const FIELD_USERNAME = "Username"; + const FIELD_API_KEY = "ApiKey"; + const FIELD_API_ENDPOINT = "ApiEndpoint"; + + /** + * @var mixed + */ + protected $configuration; + + /** + * Get configuration values and create params + * + * @param $params + */ + public static function create($params) + { + //Get configuration fields from params + $config = [self::FIELD_USERNAME, self::FIELD_API_KEY, self::FIELD_API_ENDPOINT]; + foreach($config as $name) + { + $result[$name] = $params[$name]; + } + + return new Configuration($result); + } + + /** + * Create Configuration + * + * @param $params + * @throws \Exception + */ + public function __construct($params) + { + //Check if registrar is enabled in WHMCS configuration + if($params[self::FIELD_API_ENDPOINT] === null) + { + throw new \Exception("Domain registrar is deactivated in WHMCS configuration"); + } + + $this->configuration = $params; + } + + /** + * Get values from configuration array + * + * @param $name + * @return mixed + */ + public function __get($name) + { + return $this->configuration[$name]; + } + + /** + * Create authorization headers + * + * @return array + */ + public function getAuthHeaders() + { + $timestamp = time(); + $time = gmdate("y-m-d H", $timestamp); + $token = base64_encode(hash_hmac("sha256", $this->ApiKey, "{$this->Username}:$time")); + + return + [ + "username" => $this->Username, + "token" => $token, + "timestamp" => $timestamp, + ]; + } +} \ No newline at end of file diff --git a/RadWebHosting/modules/registrars/RadWebHosting/Core/Loader.php b/RadWebHosting/modules/registrars/RadWebHosting/Core/Loader.php new file mode 100644 index 0000000..51dbc8b --- /dev/null +++ b/RadWebHosting/modules/registrars/RadWebHosting/Core/Loader.php @@ -0,0 +1,37 @@ + + */ +class Loader +{ + private $rootdir; + + public function __construct($dir) + { + $this->rootdir = $dir; + $this->register(); + } + + protected function register() + { + spl_autoload_register(function($className) + { + $namespace = str_replace("\\Core","", __NAMESPACE__); + if (strpos($className, $namespace) === 0) + { + $className = str_replace("\\", DIRECTORY_SEPARATOR, $className); + $file = str_replace("ModulesGarden".DIRECTORY_SEPARATOR."DomainsReseller".DIRECTORY_SEPARATOR."Registrar".DIRECTORY_SEPARATOR."RadWebHosting", $this->rootdir, $className) . '.php'; + + if (file_exists($file)) + { + require_once $file; + } + } + }); + } +} diff --git a/RadWebHosting/modules/registrars/RadWebHosting/Helpers/ResultsListFactory.php b/RadWebHosting/modules/registrars/RadWebHosting/Helpers/ResultsListFactory.php new file mode 100644 index 0000000..8039294 --- /dev/null +++ b/RadWebHosting/modules/registrars/RadWebHosting/Helpers/ResultsListFactory.php @@ -0,0 +1,35 @@ +setStatus($domainResult["status"]); + if(!empty($domainResult["premiumCostPricing"])) + { + $searchResult->setPremiumCostPricing($domainResult["premiumCostPricing"]); + } + $resultList->append($searchResult); + } + return $resultList; + } + +} diff --git a/RadWebHosting/modules/registrars/RadWebHosting/RadWebHosting.php b/RadWebHosting/modules/registrars/RadWebHosting/RadWebHosting.php new file mode 100644 index 0000000..f10998a --- /dev/null +++ b/RadWebHosting/modules/registrars/RadWebHosting/RadWebHosting.php @@ -0,0 +1,734 @@ + [ + "Type" => "System", + "Value" => "RadWebHosting" + ], + "Description" => [ + "Type" => "System", + "Value" => "Don't have a Rad Web Hosting Account yet? Get one here: https://radwebhosting.com/domains-reseller " + ], + "Username" => [ + "FriendlyName" => "API Username", + "Type" => "text", + "Size" => "40", + "Description" => "Enter your email used in the main WHMCS" + ], + "ApiKey" => [ + "FriendlyName" => "API Key", + "Type" => "text", + "Size" => "40", + "Description" => "Enter your API key received from provider" + ], + "ApiEndpoint" => [ + "FriendlyName" => "API Endpoint", + "Type" => "text", + "Size" => "40", + "Description" => "Enter API endpoint", + "Default" => "https://radwebhosting.com/client_area/modules/addons/DomainsReseller/api/index.php" + ], + ]; + + return $configarray; +} + +/** + * Register Domain + * + * @param array $params + * @return array $return + */ +function RadWebHosting_RegisterDomain($params) +{ + $postfields = + [ + "domain" => $params["domainname"], + "regperiod" => (int)$params["regperiod"], + "domainfields" => base64_encode(serialize($params["additionalfields"])), + "addons" => + [ + "dnsmanagement" => $params['dnsmanagement'] ? 1 : 0, + "emailforwarding" => $params['emailforwarding'] ? 1 : 0, + "idprotection" => $params['idprotection'] ? 1 : 0, + ], + "nameservers" => + [ + $params["ns1"], + $params["ns2"], + $params["ns3"], + $params["ns4"], + $params["ns5"], + ], + "contacts" => + [ + "registrant" => + [ + 'firstname' => $params["firstname"], + 'lastname' => $params["lastname"], + 'companyname' => $params["companyname"], + 'email' => $params["email"], + 'address1' => $params["address1"], + 'address2' => $params["address2"], + 'city' => $params["city"], + 'state' => $params["state"], + 'postcode' => $params["postcode"], + 'country' => $params["country"], + 'phonenumber' => $params["phonenumber"], + 'tax_id' => $params['tax_id'] + ], + ] + ]; + try + { + $call = new Calls\RegisterDomain(Configuration::create($params), $postfields); + return $call->process(); + } + catch (\Exception $e) + { + return ['error' => $e->getMessage()]; + } +} + +/** + * Transfer Domain + * + * @param array $params + * @return array $return + */ +function RadWebHosting_TransferDomain($params) +{ + $postfields = + [ + "domain" => $params["domainname"], + "regperiod" => (int)$params["regperiod"], + "eppcode" => $params["eppcode"], + 'domainfields' => base64_encode(serialize($params["additionalfields"])), + "addons" => + [ + "dnsmanagement" => $params['dnsmanagement'] ? 1 : 0, + "emailforwarding" => $params['emailforwarding'] ? 1 : 0, + "idprotection" => $params['idprotection'] ? 1 : 0, + ], + "nameservers" => + [ + $params["ns1"], + $params["ns2"], + $params["ns3"], + $params["ns4"], + $params["ns5"], + ], + "contacts" => + [ + "registrant" => + [ + 'firstname' => $params["firstname"], + 'lastname' => $params["lastname"], + 'companyname' => $params["companyname"], + 'email' => $params["email"], + 'address1' => $params["address1"], + 'address2' => $params["address2"], + 'city' => $params["city"], + 'state' => $params["state"], + 'postcode' => $params["postcode"], + 'country' => $params["country"], + 'phonenumber' => $params["phonenumber"], + 'tax_id' => $params['tax_id'] + ], + ] + ]; + + try + { + $call = new Calls\TransferDomain(Configuration::create($params), $postfields); + return $call->process(); + } + catch (\Exception $e) + { + return ['error' => $e->getMessage()]; + } +} + +/** + * Renew Domain + * + * @param array $params + * @return array $return + */ +function RadWebHosting_RenewDomain($params) +{ + $postfields = + [ + "domain" => $params["domainname"], + "regperiod" => (int)$params["regperiod"], + "addons" => + [ + "dnsmanagement" => $params['dnsmanagement'] ? 1 : 0, + "emailforwarding" => $params['emailforwarding'] ? 1 : 0, + "idprotection" => $params['idprotection'] ? 1 : 0, + ], + ]; + + try + { + $call = new Calls\RenewDomain(Configuration::create($params), $postfields); + return $call->process(); + } + catch (\Exception $e) + { + return ['error' => $e->getMessage()]; + } +} + +/** + * Get name servers + * + * @param array $params + * @return array $return + */ +function RadWebHosting_GetNameservers($params) +{ + $postfields = + [ + "domain" => $params["domainname"] + ]; + + try + { + $call = new Calls\GetNameServers(Configuration::create($params), $postfields); + + $result = $call->process(); + unset($result['success']); + unset($result['message']); + + return $result; + } + catch (\Exception $e) + { + return ['error' => $e->getMessage()]; + } +} + +/** + * Save nameservers + * + * @param array $params + * @return array $return + */ +function RadWebHosting_SaveNameservers($params) +{ + $postfields = + [ + "domain" => $params["domainname"], + + "ns1" => $params["ns1"], + "ns2" => $params["ns2"], + "ns3" => $params["ns3"], + "ns4" => $params["ns4"], + "ns5" => $params["ns5"], + ]; + + try + { + $call = new Calls\SaveNameServers(Configuration::create($params), $postfields); + return $call->process(); + } + catch (\Exception $e) + { + return ['error' => $e->getMessage()]; + } +} + +/** + * Release Domain + * + * @param array $params + * @return array $return + */ +function RadWebHosting_ReleaseDomain($params) +{ + $postfields = + [ + "domain" => $params["domainname"], + "transfertag" => $params["transfertag"] + ]; + + try + { + $call = new Calls\ReleaseDomain(Configuration::create($params), $postfields); + return $call->process(); + } + catch (\Exception $e) + { + return ['error' => $e->getMessage()]; + } +} + +/** + * Get EPP Code + * + * @param array $params + * @return array $return + */ +function RadWebHosting_GetEPPCode($params) +{ + $postfields = + [ + "domain" => $params["domainname"], + ]; + + try + { + $call = new Calls\GetEppCode(Configuration::create($params), $postfields); + return $call->process(); + } + catch (\Exception $e) + { + return ['error' => $e->getMessage()]; + } +} + +/** + * Get Contact Details + * + * @param array $params + * @return array $return + */ +function RadWebHosting_GetContactDetails($params) +{ + $postfields = + [ + "domain" => $params["domainname"], + ]; + try + { + $call = new Calls\GetContactDetails(Configuration::create($params), $postfields); + $result = $call->process(); + $new = []; + foreach ($result as $key => $value) + { + $new[$key] = []; + foreach ($value as $detail => $info) + { + $new[$key][str_replace('_', ' ', $detail)] = $info; + } + } + return $new; + } + catch (\Exception $e) + { + return ['error' => $e->getMessage()]; + } +} + +/** + * Save Contact Details + * + * @param array $params + * @return array $return + */ +function RadWebHosting_SaveContactDetails($params) +{ + $postfields = + [ + "domain" => $params["domainname"], + "contactdetails" => $params["contactdetails"] + ]; + + try + { + $call = new Calls\SaveContactDetails(Configuration::create($params), $postfields); + return $call->process(); + } + catch (\Exception $e) + { + return ['error' => $e->getMessage()]; + } +} + +/** + * Get Lock Status + * + * @param array $params + * @return array $return + */ +function RadWebHosting_GetRegistrarLock($params) +{ + $postfields = + [ + "domain" => $params["domainname"], + ]; + + try + { + $call = new Calls\GetRegistrarLock(Configuration::create($params), $postfields); + return $call->process(); + } + catch (\Exception $e) + { + return ['error' => $e->getMessage()]; + } +} + +/** + * Update Lock Status + * + * @param array $params + * @return array $return + */ +function RadWebHosting_SaveRegistrarLock($params) +{ + $postfields = + [ + "domain" => $params["domainname"], + "lockstatus" => $params["lockenabled"] + ]; + + try + { + $call = new Calls\SaveRegistrarLock(Configuration::create($params), $postfields); + return $call->process(); + } + catch (\Exception $e) + { + return ['error' => $e->getMessage()]; + } +} + +/** + * Get DNS Records + * + * @param array $params + * @return array $return + */ +function RadWebHosting_GetDNS($params) +{ + $postfields = + [ + "domain" => $params["domainname"], + ]; + + try + { + $call = new Calls\GetDns(Configuration::create($params), $postfields); + return $call->process(); + } + catch (\Exception $e) + { + return ['error' => $e->getMessage()]; + } +} + +/** + * Save DNS Records + * + * @param array $params + * @return array $return + */ +function RadWebHosting_SaveDNS($params) +{ + $postfields = + [ + "domain" => $params["domainname"], + "dnsrecords" => $params["dnsrecords"] + ]; + + try + { + $call = new Calls\SaveDns(Configuration::create($params), $postfields); + return $call->process(); + } + catch (\Exception $e) + { + return ['error' => $e->getMessage()]; + } +} + +/** + * Register Name Server + * + * @param array $params + * @return array $return + */ +function RadWebHosting_RegisterNameserver($params) +{ + $postfields = + [ + "domain" => $params["domainname"], + + "nameserver" => $params["nameserver"], + "ipaddress" => $params["ipaddress"], + ]; + + try + { + $call = new Calls\RegisterNameServer(Configuration::create($params), $postfields); + return $call->process(); + } + catch (\Exception $e) + { + return ['error' => $e->getMessage()]; + } +} + +/** + * Update Name Server + * + * @param array $params + * @return array $return + */ +function RadWebHosting_ModifyNameserver($params) +{ + $postfields = + [ + "domain" => $params["domainname"], + + "nameserver" => $params["nameserver"], + "currentipaddress" => $params["currentipaddress"], + "newipaddress" => $params["newipaddress"], + ]; + + try + { + $call = new Calls\ModifyNameServer(Configuration::create($params), $postfields); + return $call->process(); + } + catch (\Exception $e) + { + return ['error' => $e->getMessage()]; + } +} + +/** + * Delete Name Server + * + * @param array $params + * @return array $return + */ +function RadWebHosting_DeleteNameserver($params) +{ + $postfields = + [ + "domain" => $params["domainname"], + "nameserver" => $params["nameserver"], + ]; + + try + { + $call = new Calls\DeleteNameServer(Configuration::create($params), $postfields); + return $call->process(); + } + catch (\Exception $e) + { + return ['error' => $e->getMessage()]; + } +} + +/** + * Delete Domain + * + * @param array $params + * @return array $return + */ +function RadWebHosting_RequestDelete($params) +{ + $postfields = + [ + "domain" => $params["domainname"] + ]; + + try + { + $call = new Calls\RequestDelete(Configuration::create($params), $postfields); + return $call->process(); + } + catch (\Exception $e) + { + return ['error' => $e->getMessage()]; + } +} + +/** + * Synchronize transfer domain + * + * @param array $params + * @return array $return + */ +function RadWebHosting_TransferSync($params) +{ + $postfields = + [ + "domain" => "{$params["sld"]}.{$params["tld"]}" + ]; + + try + { + $call = new Calls\TransferSync(Configuration::create($params), $postfields); + return $call->process(); + } + catch (\Exception $e) + { + return ['error' => $e->getMessage()]; + } +} + +/** + * Synchronize Registered Domains + * + * @param array $params + * @return array $return + */ +function RadWebHosting_Sync($params) +{ + $postfields = + [ + "domain" => "{$params["sld"]}.{$params["tld"]}" + ]; + + try + { + $call = new Calls\Sync(Configuration::create($params), $postfields); + return $call->process(); + } + catch (\Exception $e) + { + return ['error' => $e->getMessage()]; + } +} + +/** + * Get list of emails aliases + * + * @param array $params + * @return array $return + */ +function RadWebHosting_GetEmailForwarding($params) +{ + $postfields = + [ + "domain" => $params["domainname"] + ]; + + try + { + $call = new Calls\GetEmailForwarding(Configuration::create($params), $postfields); + return $call->process(); + } + catch (\Exception $e) + { + return ['error' => $e->getMessage()]; + } +} + +/** + * Save list of emails aliases + * + * @param array $params + * @return array $return + */ +function RadWebHosting_SaveEmailForwarding($params) +{ + $postfields = + [ + "domain" => $params["domainname"], + "prefix" => $params["prefix"], + "forwardto" => $params["forwardto"] + ]; + + try + { + $call = new Calls\SaveEmailForwarding(Configuration::create($params), $postfields); + return $call->process(); + } + catch (\Exception $e) + { + return ['error' => $e->getMessage()]; + } +} + +/** + * This function is called when the ID Protection setting is toggled on or off + * + * @param array $params + * @return array $return + */ +function RadWebHosting_IDProtectionToggle($params) +{ + $postfields = + [ + "domain" => $params["domainname"], + "status" => $params["protectenable"] + ]; + + try + { + $call = new Calls\ToggleIdProtect(Configuration::create($params), $postfields); + return $call->process(); + } + catch (\Exception $e) + { + return ['error' => $e->getMessage()]; + } +} + +/** + * This function is called when the ID Protection setting is toggled on or off + * + * @param $params + * @return array + */ +function RadWebHosting_IDProtectToggle($params) +{ + return RadWebHosting_IDProtectionToggle($params); +} + + +/** + * Send domain lookup request + * + * @param $params + * @return array|bool|mixed|stdClass|string + */ +function RadWebHosting_CheckAvailability($params) +{ + $postfields = + [ + "searchTerm" => $params["searchTerm"], + "punyCodeSearchTerm" => $params["punyCodeSearchTerm"], + "tldsToInclude" => $params["tldsToInclude"], + "isIdnDomain" => $params['isIdnDomain'], + "premiumEnabled" => $params['premiumEnabled'], + "isWhmcs" => 1 + ]; + + try + { + $call = new Calls\CheckAvailability(Configuration::create($params), $postfields); + $result = $call->process(); + return ResultsListFactory::createResultsList($result); + } + catch (\Exception $e) + { + \logModuleCall( + 'RadWebHosting', + 'DomainLookup', + $postfields, + ['error' => $e->getMessage()] + ); + return ResultsListFactory::createResultsList([]); } +} diff --git a/RadWebHosting/modules/registrars/RadWebHosting/whmcs.json b/RadWebHosting/modules/registrars/RadWebHosting/whmcs.json new file mode 100644 index 0000000..a62b1e0 --- /dev/null +++ b/RadWebHosting/modules/registrars/RadWebHosting/whmcs.json @@ -0,0 +1,12 @@ +{ + "schema": "1.0", + "type": "whmcs-addons", + "name": "RadWebHosting", + "license": "proprietary", + "category": "domains", + "description": { + "name": "RadWebHosting", + "tagline": "", + "long": "Don't have a Rad Web Hosting Account yet? Get one here: https://radwebhosting.com/domains-reseller " + } +}