Advertisement
Guest User

Untitled

a guest
Jul 4th, 2024
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.13 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP7 Decoder for ionCube Encoder)
  6. *
  7. * @ Version : 5.0.1.0
  8. * @ Author : DeZender
  9. * @ Release on : 22.04.2022
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. class HetznerCloudHelper
  15. {
  16. static public function getLang()
  17. {
  18. $languageDir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR;
  19. $config = $GLOBALS['CONFIG'];
  20. $language = (isset($_SESSION['Language']) ? $_SESSION['Language'] : $config['Language']);
  21. $languageFile = (file_exists($languageDir . $language . '.php') ? $language : 'english');
  22.  
  23. if (file_exists(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . 'english.php')) {
  24. include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . 'english.php';
  25. }
  26.  
  27. require $languageDir . $languageFile . '.php';
  28. return isset($_LANG) ? $_LANG : [];
  29. }
  30. }
  31.  
  32. function HetznerCloud_MetaData()
  33. {
  34. return ['DisplayName' => 'Hetzner Cloud Automation', 'APIVersion' => '18.09.2019', 'RequiresServer' => true];
  35. }
  36.  
  37. function HetznerCloud_TestConnection($params)
  38. {
  39. try {
  40. $srvproJect = $params['serveraccesshash'];
  41. $splitsrvproJect = explode('_', $srvproJect);
  42. $ServerID = $splitsrvproJect[0];
  43. $ProJectID = $splitsrvproJect[1];
  44. $HetznerCloud = new WHMCS\Module\Server\HetznerCloud\HetznerCloud($ProJectID);
  45. $single = $HetznerCloud->serverGet($ServerID);
  46.  
  47. if ($ServerID == $single['server']['id']) {
  48. $success = true;
  49. }
  50. else {
  51. $errorMsg = 'Server ID: ' . $ServerID . ' Not Found';
  52. }
  53. }
  54. catch (Exception $e) {
  55. logModuleCall('HetznerCloud', __FUNCTION__, $params, $e->getMessage(), $e->getTraceAsString());
  56. $success = false;
  57. $errorMsg = $e->getMessage();
  58. }
  59.  
  60. return ['success' => $success, 'error' => $errorMsg];
  61. }
  62.  
  63. function HetznerCloud_ConfigOptions()
  64. {
  65. $ProjectID = WHMCS\Database\Capsule::table('mod_hcloud_project')->get();
  66. $_LANG = HetznerCloudHelper::getLang();
  67. $id = App::getFromRequest('id');
  68. $product = WHMCS\Product\Product::find(App::getFromRequest('id'));
  69. $prodName = WHMCS\Database\Capsule::table('tblproducts')->where('id', $id)->value('name');
  70. $addconfigrablegroupname = 'Hetzner Cloud-' . $prodName . '-Product Id-' . $id;
  71. $configurableoptionlinkresultDB = WHMCS\Database\Capsule::table('tblproductconfiggroups')->where('name', $addconfigrablegroupname)->value('id');
  72. $configurableoptionlinkresult = ($configurableoptionlinkresultDB ? $configurableoptionlinkresultDB : '0');
  73. $ProjectIDS = [];
  74.  
  75. foreach ($ProjectID as $HCloudProject) {
  76. $ProjectIDS[$HCloudProject->id] = $HCloudProject->projectname;
  77. }
  78.  
  79. $dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'userData';
  80. $hideName = ['.', '..', '.DS_Store'];
  81. $files = scandir($dir);
  82. $userData = [];
  83. $userData['none'] = 'None';
  84.  
  85. foreach ($files as $filename) {
  86. if (!in_array($filename, $hideName)) {
  87. $userData[$filename] = ucfirst($filename);
  88. }
  89. }
  90.  
  91. $projectIds = ($product->moduleConfigOption1 ? $product->moduleConfigOption1 : $ProjectID[0]->id);
  92. $HetznerCloud = new WHMCS\Module\Server\HetznerCloud\HetznerCloud($projectIds);
  93. $ServerTypeGetAll = $HetznerCloud->ServerTypeGetAll();
  94. $ServerType = [];
  95.  
  96. foreach ($ServerTypeGetAll['server_types'] as $ServerTypeAll) {
  97. $ServerType[$ServerTypeAll['name']] = $ServerTypeAll['description'] . '( ' . $ServerTypeAll['cores'] . ' vCPU, ' . $ServerTypeAll['memory'] . ' GB RAM, ' . $ServerTypeAll['disk'] . ' GB HDD)';
  98. }
  99.  
  100. $LocationGetAll = $HetznerCloud->LocationGetAll();
  101. $Location = [];
  102.  
  103. foreach ($LocationGetAll['locations'] as $LocationAll) {
  104. if ($LocationAll['name'] == $product->moduleConfigOption3) {
  105. $Location[$LocationAll['name']] = $LocationAll['city'] . ' (' . $HetznerCloud->codeToCountryName($LocationAll['country']) . ')';
  106. break;
  107. }
  108. else {
  109. $Location[$LocationAll['name']] = $LocationAll['city'] . ' (' . $HetznerCloud->codeToCountryName($LocationAll['country']) . ')';
  110. }
  111. }
  112.  
  113. $CustomFieldSSHID = WHMCS\Database\Capsule::table('tblcustomfields')->where('fieldname', 'ssh_key|SSH Public Key')->where('relid', $id)->value('relid');
  114.  
  115. if (empty($CustomFieldSSHID)) {
  116. $HetznerCloud->HCloud_Insert('tblcustomfields', ['type' => 'product', 'relid' => $id, 'fieldname' => 'ssh_key|SSH Public Key', 'fieldtype' => 'textarea', 'description' => $_LANG['ConfigOptions']['SSHRSA'], 'adminonly' => '', 'required' => '', 'showorder' => 'on']);
  117. }
  118.  
  119. $CustomFieldUDID = WHMCS\Database\Capsule::table('tblcustomfields')->where('fieldname', 'user_data|Custom Script')->where('relid', $id)->value('relid');
  120.  
  121. if (empty($CustomFieldUDID)) {
  122. $HetznerCloud->HCloud_Insert('tblcustomfields', ['type' => 'product', 'relid' => $id, 'fieldname' => 'user_data|Custom Script', 'fieldtype' => 'textarea', 'description' => $_LANG['ConfigOptions']['InitDesc'], 'adminonly' => '', 'required' => '', 'showorder' => 'on']);
  123. }
  124.  
  125. $CustomVMID = WHMCS\Database\Capsule::table('tblcustomfields')->where('fieldname', 'instanceId|Instance ID')->where('relid', $id)->value('relid');
  126.  
  127. if (empty($CustomVMID)) {
  128. ...............................................................
  129. ....................................
  130. ...............
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement