Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

Commit

Permalink
refactor(migration): to support v3.x.x of the ispapi registrar module
Browse files Browse the repository at this point in the history
BREAKING CHANGE: compatible with ispapi registrar module >= v3.0.0
  • Loading branch information
KaiSchwarz-cnic committed Apr 27, 2020
1 parent 2800a05 commit 4ceb7b4
Showing 1 changed file with 21 additions and 44 deletions.
65 changes: 21 additions & 44 deletions backend/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
}

require_once dirname(__FILE__)."/helper.php"; //HELPER WHICH CONTAINS HELPER FUNCTIONS

use WHMCS\Database\Capsule;
use WHMCS\Module\Registrar\Ispapi\Ispapi;

//############################
//HELPER FUNCTIONS
Expand All @@ -35,52 +37,27 @@ function logmessage($cronname, $status, $message, $query = null)
//THIS FUNCTION CALLS OUR HEXONET API AND IS USED FOR CRONS AND IN THE WHMCS ADMIN AREA
function ispapi_api_call($command)
{
require_once(dirname(__FILE__)."/../../../../includes/registrarfunctions.php");
$higher_version_required_message = "The ISPAPI DomainCheck Module requires ISPAPI Registrar Module v1.0.15 or higher!";

//CHECK IF THE ISPAPI REGISTRAR MODULE IS INSTALLED
$error = false;
$message = "";
if (file_exists(dirname(__FILE__)."/../../../../modules/registrars/ispapi/ispapi.php")) {
$file = "ispapi";
require_once(dirname(__FILE__)."/../../../../modules/registrars/".$file."/".$file.".php");
$funcname = $file.'_GetISPAPIModuleVersion';
if (function_exists($file.'_GetISPAPIModuleVersion')) {
$version = call_user_func($file.'_GetISPAPIModuleVersion');
//check if version = 1.0.15 or higher
if (version_compare($version, '1.0.15') >= 0) {
//check authentication
$registrarconfigoptions = getregistrarconfigoptions($file);
$ispapi_config = ispapi_config($registrarconfigoptions);
$checkAuthenticationCommand = array(
"command" => "CheckAuthentication",
);
$checkAuthentication = ispapi_call($checkAuthenticationCommand, $ispapi_config);
if ($checkAuthentication["CODE"] != "200") {
$error = true;
$message = "The \"".$file."\" registrar authentication failed! Please verify your registrar credentials and try again.";
}
} else {
$error = true;
$message = $higher_version_required_message;
}
} else {
$error = true;
$message = $higher_version_required_message;
}
} else {
$error = true;
$message = $higher_version_required_message;
//check registrar module availability and version number
$higher_version_required_message = "The ISPAPI Backorder Module requires ISPAPI Registrar Module v3.0.0 or higher!";
$version = Ispapi::getRegistrarModuleVersion('ispapi');
if ($version == "N/A" || version_compare($version, '3.0.0') < 0) {
return [
"CODE" => 549,
"DESCRIPTION" => $higher_version_required_message
];
}

$response = array();
if ($error) {
$response["CODE"] = 549;
$response["DESCRIPTION"] = $message;
} else {
$response = ispapi_call($command, $ispapi_config);
//check authentication
$r = Ispapi::call([
"COMMAND" => "CheckAuthentication"
]);
if ($r["CODE"] != "200") {
return [
"CODE" => 549,
"DESCRIPTION" => "The ISPAPI registrar authentication failed! Please verify your registrar credentials and try again."
];
}
return $response;

return Ispapi::call($command);
}

//THIS FUNCTION CALLS OUR LOCAL API AND IS USED FOR CUSTOMER AND ADMIN
Expand Down

0 comments on commit 4ceb7b4

Please sign in to comment.