Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions generateSslPanelOtpToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,25 +53,26 @@
$order = Capsule::table('openprovidersslnew_orders')->where('service_id', $serviceId)->first();

require_once __DIR__ . '/modules/servers/openprovidersslnew/lib/helpers/ArrayHelper.php';
require_once __DIR__ . '/modules/servers/openprovidersslnew/lib/helpers/ConfigHelper.php';
require_once __DIR__ . '/modules/servers/openprovidersslnew/lib/API.php';
require_once __DIR__ . '/modules/servers/openprovidersslnew/lib/opApiException.php';
require_once __DIR__ . '/modules/servers/openprovidersslnew/lib/opApiWrapper.php';

$env = $product->configoption7 ? 'test' : 'production';
$env = $product->configoption4 ? 'test' : 'production';

$reply = opApiWrapper::generateOtpToken([
'username' => $env === 'production' ? $product->configoption1 : $product->configoption8,
'password' => $env === 'production' ? $product->configoption2 : $product->configoption9,
'apiUrl' => $env === 'production' ? $product->configoption3 : $product->configoption10,
'username' => $product->configoption1,
'password' => $product->configoption2,
'apiUrl' => ConfigHelper::getApiUrlFromConfig($env),
'id' => $order->order_id,
]);

$token = $reply['token'];
$defaultLanguage = isset($allLanguages[$product->configoption15]) ? $allLanguages[$product->configoption15] : null;
$defaultLanguage = isset($allLanguages[$product->configoption9]) ? $allLanguages[$product->configoption9] : null;
$language = isset($languages[$ca->getClient()['language']]) ? $languages[$ca->getClient()['language']] : $defaultLanguage;

header(sprintf('Location: %s/auth-order-otp-token?token=%s&language=%s',
$env === 'production' ? $product->configoption4 : $product->configoption11, $token,
ConfigHelper::getSslPanelUrlFromConfig($env), $token,
$language));

exit;
Expand Down
63 changes: 7 additions & 56 deletions modules/addons/openproviderssl_new/openproviderssl_new.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,65 +20,19 @@ function openproviderssl_new_config()
'author' => 'Openprovider',
'fields' => [
'option1' => [
'FriendlyName' => 'Openprovider API URL',
'Type' => 'text',
'Size' => '255',
'Default' => 'https://api.openprovider.eu',
],
'option2' => [
'FriendlyName' => 'API Username',
'Type' => 'text',
'Size' => '25',
],
'option3' => [
'option2' => [
'FriendlyName' => 'API Password',
'Type' => 'password',
'Size' => '25',
],
'option4' => [
'FriendlyName' => 'SSL Panel URL',
'Type' => 'text',
'Size' => '255',
'Default' => 'https://sslinhva.openprovider.eu',
],
'option5' => [
'FriendlyName' => 'Openprovider RCP URL',
'Type' => 'text',
'Size' => '255',
'Default' => 'https://rcp.openprovider.eu',
],
'option6' => [
'FriendlyName' => '!TEST! Mode?',
'option3' => [
'FriendlyName' => 'Test mode',
'Type' => 'yesno',
],
'option7' => [
'FriendlyName' => '!TEST! Openprovider API URL',
'Type' => 'text',
'Size' => '255',
'Default' => 'https://api.cte.openprovider.eu',
],
'option8' => [
'FriendlyName' => '!TEST! API Username',
'Type' => 'text',
'Size' => '25',
],
'option9' => [
'FriendlyName' => '!TEST! API Password',
'Type' => 'password',
'Size' => '25',
],
'option10' => [
'FriendlyName' => '!TEST! SSL Panel URL',
'Type' => 'text',
'Size' => '255',
'Default' => 'https://sslinhva.cte.openprovider.eu',
],
'option11' => [
'FriendlyName' => '!TEST! Openprovider RCP URL',
'Type' => 'text',
'Size' => '255',
'Default' => 'https://rcp.cte.openprovider.eu',
],
],
];
}
Expand All @@ -98,7 +52,7 @@ function openproviderssl_new_output($vars)
'global' => [
'mod_url' => '?module=openproviderssl_new',
'module' => 'openproviderssl_new',
'overview_orders_url' => $vars['option5'],
'overview_orders_url' => ConfigHelper::getRcpUrlFromConfig(),
],
];

Expand Down Expand Up @@ -156,12 +110,9 @@ function openproviderssl_new_output($vars)
'hidden' => false,
'paytype' => 'recurring',
'module' => 'openprovidersslnew',
'configoption1' => $vars['option2'],
'configoption2' => $vars['option3'],
'configoption3' => $vars['option1'],
'configoption4' => $vars['option4'],
'configoption5' => $vars['option5'],
'configoption6' => $product['name'],
'configoption1' => $vars['option1'],
'configoption2' => $vars['option2'],
'configoption3' => $product['name'],
'pricing' => [
1 => [
'monthly' => -1,
Expand Down
2 changes: 1 addition & 1 deletion modules/servers/openprovidersslnew/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ function create($params)
$params['technicalHandle'] = $techHandle;
}

$product = Capsule::table('openprovidersslnew_products')->where('name', $params['configoption6'])->first();
$product = Capsule::table('openprovidersslnew_products')->where('name', $params['configoption3'])->first();
$productId = $product->product_id;

$hosting = Capsule::table('tblhosting')->where('id', $params['serviceid'])->first();
Expand Down
16 changes: 16 additions & 0 deletions modules/servers/openprovidersslnew/lib/configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,20 @@ class opConfig
"on" and "default" to use the Openprovider account's default setting.
*/
static public $renewBehaviour = 'on';

/*
* List of api urls.
* For Production mode
*/
static public $apiUrl = 'https://api.openprovider.eu';
static public $sslPanelUrl = 'https://sslpanel.io';
static public $rcpUrl = 'https://cp.openprovider.eu';

/*
* List of api urls
* For Test mode
*/
static public $apiCteUrl = 'https://api.cte.openprovider.eu';
static public $sslPanelCteUrl = 'https://sslinhva.cte.openprovider.eu';
static public $rcpCteUrl = 'https://rcp.cte.openprovider.eu';
}
88 changes: 57 additions & 31 deletions modules/servers/openprovidersslnew/lib/helpers/ConfigHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,42 @@
*/
class ConfigHelper
{
const ENV_PRODUCTION = 'production';
const ENV_TEST = 'test';

/**
* @var array
*/
private static $serverParamsMap = [
'production' => [
self::ENV_PRODUCTION => [
'username' => 'configoption1',
'password' => 'configoption2',
'opApiUrl' => 'configoption3',
'sslPanelUrl' => 'configoption4',
'opRcpUrl' => 'configoption5',
'defaultTechnicalContact' => 'configoption13',
'defaultLanguage' => 'configoption15',
'defaultTechnicalContact' => 'configoption5',
'defaultLanguage' => 'configoption6',
],
'test' => [
'username' => 'configoption8',
'password' => 'configoption9',
'opApiUrl' => 'configoption10',
'sslPanelUrl' => 'configoption11',
'opRcpUrl' => 'configoption12',
'defaultTechnicalContact' => 'configoption14',
'defaultLanguage' => 'configoption15',
self::ENV_TEST => [
'username' => 'configoption1',
'password' => 'configoption2',
'defaultTechnicalContact' => 'configoption5',
'defaultLanguage' => 'configoption6',
],
];

private static $parametersToMaskInLogs = [
'configoption2',
'configoption9',
];

/**
* @var array
*/
private static $addonParamsMap = [
'production' => [
'opApiUrl' => 'option1',
'username' => 'option2',
'password' => 'option3',
'sslPanelUrl' => 'option4',
'opRcpUrl' => 'option5',
self::ENV_PRODUCTION => [
'username' => 'option1',
'password' => 'option2',
],
'test' => [
'opApiUrl' => 'option7',
'username' => 'option8',
'password' => 'option9',
'sslPanelUrl' => 'option10',
'opRcpUrl' => 'option11',
self::ENV_TEST => [
'username' => 'option1',
'password' => 'option2',
],
];

Expand All @@ -69,7 +59,7 @@ public static function getServerCredentialsArray($params)
return [
'username' => ArrayHelper::getValue($config, 'username'),
'password' => ArrayHelper::getValue($config, 'password'),
'apiUrl' => ArrayHelper::getValue($config, 'opApiUrl'),
'apiUrl' => self::getApiUrlFromConfig(EnvHelper::getServerEnvironmentFromParams($params)),
'clientInformation' => self::getClientInformationFrom($params),
];
}
Expand All @@ -80,7 +70,7 @@ public static function getServerCredentialsArray($params)
*
* @return array
*/
public static function getServerConfigurationFromParams($params, $env = 'production')
public static function getServerConfigurationFromParams($params, $env = self::ENV_PRODUCTION)
{
return self::getConfigurationFromParamsAndMap($params, ArrayHelper::getValue(self::$serverParamsMap, $env));
}
Expand Down Expand Up @@ -131,7 +121,7 @@ public static function getAddonCredentialsArray($params)
return [
'username' => ArrayHelper::getValue($config, 'username'),
'password' => ArrayHelper::getValue($config, 'password'),
'apiUrl' => ArrayHelper::getValue($config, 'opApiUrl'),
'apiUrl' => self::getApiUrlFromConfig(EnvHelper::getAddonEnvironmentFromParams($params)),
'clientInformation' => self::getClientInformationFrom($params),
];
}
Expand All @@ -142,7 +132,7 @@ public static function getAddonCredentialsArray($params)
*
* @return array
*/
public static function getAddonConfigurationFromParams($params, $env = 'production')
public static function getAddonConfigurationFromParams($params, $env = self::ENV_PRODUCTION)
{
return self::getConfigurationFromParamsAndMap($params, ArrayHelper::getValue(self::$addonParamsMap, $env));
}
Expand All @@ -164,4 +154,40 @@ public static function getParametersToMaskInLogs($params, $additionalParameterNa

return $result;
}

/**
* @param string $env
*
* @return string Openprovider api url
*/
public static function getApiUrlFromConfig($env = self::ENV_PRODUCTION)
{
return $env == self::ENV_PRODUCTION ?
opConfig::$apiUrl :
opConfig::$apiCteUrl;
}

/**
* @param string $env
*
* @return string Ssl panel url
*/
public static function getSslPanelUrlFromConfig($env = self::ENV_PRODUCTION)
{
return $env == self::ENV_PRODUCTION ?
opConfig::$sslPanelUrl :
opConfig::$sslPanelCteUrl;
}

/**
* @param string $env
*
* @return string Openprovider reseller control panel url
*/
public static function getRcpUrlFromConfig($env = self::ENV_PRODUCTION)
{
return $env == self::ENV_PRODUCTION ?
opConfig::$rcpUrl :
opConfig::$rcpCteUrl;
}
}
6 changes: 3 additions & 3 deletions modules/servers/openprovidersslnew/lib/helpers/EnvHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static function getServerEnvironmentFromParams($params)
{
$params = (array)$params;

return ArrayHelper::getValue($params, 'configoption7') ? 'test' : 'production';
return ArrayHelper::getValue($params, 'configoption4') ? 'test' : 'production';
}

/**
Expand All @@ -26,6 +26,6 @@ public static function getAddonEnvironmentFromParams($params)
{
$params = (array)$params;

return ArrayHelper::getValue($params, 'option6') ? 'test' : 'production';
return ArrayHelper::getValue($params, 'option3') ? 'test' : 'production';
}
}
}
Loading