Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * @ This file is created by http://DeZender.Net
- * @ deZender (PHP7 Decoder for ionCube Encoder)
- *
- * @ Version : 5.0.1.0
- * @ Author : DeZender
- * @ Release on : 22.04.2022
- * @ Official site : http://DeZender.Net
- *
- */
- class HetznerCloudHelper
- {
- static public function getLang()
- {
- $languageDir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR;
- $config = $GLOBALS['CONFIG'];
- $language = (isset($_SESSION['Language']) ? $_SESSION['Language'] : $config['Language']);
- $languageFile = (file_exists($languageDir . $language . '.php') ? $language : 'english');
- if (file_exists(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . 'english.php')) {
- include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . 'english.php';
- }
- require $languageDir . $languageFile . '.php';
- return isset($_LANG) ? $_LANG : [];
- }
- }
- function HetznerCloud_MetaData()
- {
- return ['DisplayName' => 'Hetzner Cloud Automation', 'APIVersion' => '18.09.2019', 'RequiresServer' => true];
- }
- function HetznerCloud_TestConnection($params)
- {
- try {
- $srvproJect = $params['serveraccesshash'];
- $splitsrvproJect = explode('_', $srvproJect);
- $ServerID = $splitsrvproJect[0];
- $ProJectID = $splitsrvproJect[1];
- $HetznerCloud = new WHMCS\Module\Server\HetznerCloud\HetznerCloud($ProJectID);
- $single = $HetznerCloud->serverGet($ServerID);
- if ($ServerID == $single['server']['id']) {
- $success = true;
- }
- else {
- $errorMsg = 'Server ID: ' . $ServerID . ' Not Found';
- }
- }
- catch (Exception $e) {
- logModuleCall('HetznerCloud', __FUNCTION__, $params, $e->getMessage(), $e->getTraceAsString());
- $success = false;
- $errorMsg = $e->getMessage();
- }
- return ['success' => $success, 'error' => $errorMsg];
- }
- function HetznerCloud_ConfigOptions()
- {
- $ProjectID = WHMCS\Database\Capsule::table('mod_hcloud_project')->get();
- $_LANG = HetznerCloudHelper::getLang();
- $id = App::getFromRequest('id');
- $product = WHMCS\Product\Product::find(App::getFromRequest('id'));
- $prodName = WHMCS\Database\Capsule::table('tblproducts')->where('id', $id)->value('name');
- $addconfigrablegroupname = 'Hetzner Cloud-' . $prodName . '-Product Id-' . $id;
- $configurableoptionlinkresultDB = WHMCS\Database\Capsule::table('tblproductconfiggroups')->where('name', $addconfigrablegroupname)->value('id');
- $configurableoptionlinkresult = ($configurableoptionlinkresultDB ? $configurableoptionlinkresultDB : '0');
- $ProjectIDS = [];
- foreach ($ProjectID as $HCloudProject) {
- $ProjectIDS[$HCloudProject->id] = $HCloudProject->projectname;
- }
- $dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'userData';
- $hideName = ['.', '..', '.DS_Store'];
- $files = scandir($dir);
- $userData = [];
- $userData['none'] = 'None';
- foreach ($files as $filename) {
- if (!in_array($filename, $hideName)) {
- $userData[$filename] = ucfirst($filename);
- }
- }
- $projectIds = ($product->moduleConfigOption1 ? $product->moduleConfigOption1 : $ProjectID[0]->id);
- $HetznerCloud = new WHMCS\Module\Server\HetznerCloud\HetznerCloud($projectIds);
- $ServerTypeGetAll = $HetznerCloud->ServerTypeGetAll();
- $ServerType = [];
- foreach ($ServerTypeGetAll['server_types'] as $ServerTypeAll) {
- $ServerType[$ServerTypeAll['name']] = $ServerTypeAll['description'] . '( ' . $ServerTypeAll['cores'] . ' vCPU, ' . $ServerTypeAll['memory'] . ' GB RAM, ' . $ServerTypeAll['disk'] . ' GB HDD)';
- }
- $LocationGetAll = $HetznerCloud->LocationGetAll();
- $Location = [];
- foreach ($LocationGetAll['locations'] as $LocationAll) {
- if ($LocationAll['name'] == $product->moduleConfigOption3) {
- $Location[$LocationAll['name']] = $LocationAll['city'] . ' (' . $HetznerCloud->codeToCountryName($LocationAll['country']) . ')';
- break;
- }
- else {
- $Location[$LocationAll['name']] = $LocationAll['city'] . ' (' . $HetznerCloud->codeToCountryName($LocationAll['country']) . ')';
- }
- }
- $CustomFieldSSHID = WHMCS\Database\Capsule::table('tblcustomfields')->where('fieldname', 'ssh_key|SSH Public Key')->where('relid', $id)->value('relid');
- if (empty($CustomFieldSSHID)) {
- $HetznerCloud->HCloud_Insert('tblcustomfields', ['type' => 'product', 'relid' => $id, 'fieldname' => 'ssh_key|SSH Public Key', 'fieldtype' => 'textarea', 'description' => $_LANG['ConfigOptions']['SSHRSA'], 'adminonly' => '', 'required' => '', 'showorder' => 'on']);
- }
- $CustomFieldUDID = WHMCS\Database\Capsule::table('tblcustomfields')->where('fieldname', 'user_data|Custom Script')->where('relid', $id)->value('relid');
- if (empty($CustomFieldUDID)) {
- $HetznerCloud->HCloud_Insert('tblcustomfields', ['type' => 'product', 'relid' => $id, 'fieldname' => 'user_data|Custom Script', 'fieldtype' => 'textarea', 'description' => $_LANG['ConfigOptions']['InitDesc'], 'adminonly' => '', 'required' => '', 'showorder' => 'on']);
- }
- $CustomVMID = WHMCS\Database\Capsule::table('tblcustomfields')->where('fieldname', 'instanceId|Instance ID')->where('relid', $id)->value('relid');
- if (empty($CustomVMID)) {
- ...............................................................
- ....................................
- ...............
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement