Advertisement
Guest User

Untitled

a guest
Jul 30th, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.90 KB | None | 0 0
  1. <?php
  2. /*
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP5 Decoder for ionCube Encoder)
  6. *
  7. * @ Version : 3.5.0.0
  8. * @ Author : DeZender
  9. * @ Release on : 22.06.2018
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. if (!defined('WHMCS')) {
  15. exit('This file cannot be accessed directly');
  16. }
  17.  
  18. esx_load_functions();
  19. /**
  20. * Addon Module Sample File
  21. *
  22. * This example addon module demonstrates all the functions an addon module can contain.
  23. * Please refer to the full documentation @ http://docs.whmcs.com/Addon_Modules for more details.
  24. *
  25. * @package WHMCS
  26. * @author WHMCS Limited <development@whmcs.com>
  27. * @copyright Copyright (c) WHMCS Limited 2005-2013
  28. * @license http://www.whmcs.com/license/ WHMCS Eula
  29. * @version $Id$
  30. * @link http://www.whmcs.com/
  31. */
  32.  
  33. function esx_configoptions()
  34. {
  35. $configarray = array();
  36.  
  37. return $configarray;
  38. }
  39.  
  40. function esx_licenseactive()
  41. {
  42. $return = 'Active';
  43. $sql = "SELECT * FROM mod_whmcslab_addons WHERE modname = 'esx' LIMIT 1";
  44. $result = mysql_query($sql);
  45. $dbdata = mysql_fetch_object($result);
  46. $dbdata->config = unserialize($dbdata->config);
  47. $licensekeystatus = esxaddon_check_license2($dbdata->licensekey, $dbdata->localkey);
  48.  
  49. if ($licensekeystatus != 'Active') {
  50. $return = $licensekeystatus;
  51. }
  52.  
  53. return $return;
  54. }
  55.  
  56. function esx_clientarea($vars)
  57. {
  58. if (($status = esx_licenseactive()) != 'Active') {
  59. return null;
  60. }
  61.  
  62. $sql = "SELECT * FROM mod_whmcslab_addons WHERE modname = 'esx' LIMIT 1";
  63. $result = mysql_query($sql);
  64. $dbdata = mysql_fetch_object($result);
  65. $dbdata->config = unserialize($dbdata->config);
  66. $modulelink = $vars['modulelink'];
  67. $_ESXADDON_LANG = esx_load_lang($dbdata->language);
  68.  
  69. return array('templatefile' => 'esx_clientarea', 'requirelogin' => true, 'vars' => array('_ESXADDON_LANG' => $_ESXADDON_LANG, '_ESXADDON_VARS' => esx_getclientareavars($vars)));
  70. }
  71.  
  72. function esx_getclientareavars($vars)
  73. {
  74. $sql = "SELECT * FROM mod_whmcslab_addons WHERE modname = 'esx' LIMIT 1";
  75. $result = mysql_query($sql);
  76. $dbdata = mysql_fetch_object($result);
  77. $dbdata->config = unserialize($dbdata->config);
  78. $modulelink = $vars['modulelink'];
  79. $_ESXADDON_LANG = esx_load_lang($dbdata->language);
  80. $byte = 1073741824;
  81. $summary_patterns = array('guestMemoryUsage', 'memorySizeMB', 'overallCpuUsage', 'maxCpuUsage', 'committed', 'uncommitted', 'guestFullName', 'numCpu', 'capacity', 'freeSpace', 'powerState', 'ipAddress', 'uptimeSeconds', 'bootTime', 'toolsStatus', 'committed', 'uncommitted');
  82. $matches = array();
  83. $ssh = esx_loginserverssh($vars);
  84.  
  85. if ($ssh != false) {
  86. $summary = $ssh->exec('vim-cmd vmsvc/power.getstate ' . $vars['customfields']['esxvmid']);
  87. $state = explode("\n", $summary);
  88.  
  89. if ($state[1] == 'Suspended') {
  90. $matches['suspended'] = true;
  91. }
  92.  
  93. $summary = $ssh->exec('vim-cmd vmsvc/get.summary ' . $vars['customfields']['esxvmid']);
  94. $summary = str_replace('guestFullName = <unset>,', '', $summary);
  95. $summary = str_replace('<unset>', '', $summary);
  96.  
  97. foreach ($summary_patterns as $pattern) {
  98. preg_match('/' . $pattern . '\\s=\\s(.*),/', $summary, $pattern_match);
  99. $matches[$pattern] = (isset($pattern_match[1]) ? str_replace('"', '', $pattern_match[1]) : '-');
  100. }
  101. $matches['powerState'] = str_replace('O', ' O', ucfirst($matches['powerState']));
  102. $matches['uptimeSeconds'] = ($matches['uptimeSeconds'] ? esx_secondstotime($matches['uptimeSeconds']) : '-');
  103. $matches['memoryPercent'] = round($matches['guestMemoryUsage'] / $matches['memorySizeMB'] * 100);
  104. $matches['cpuPercent'] = round($matches['overallCpuUsage'] / $matches['maxCpuUsage'] * 100);
  105. $summary = $ssh->exec('vim-cmd vmsvc/get.guest ' . $vars['customfields']['esxvmid']);
  106. preg_match('/disk\\s=\\s(.*)],/s', $summary, $pattern_match);
  107. preg_match_all('/diskPath\\s=\\s"(.*)",/i', $pattern_match[1], $paths);
  108. preg_match_all('/capacity\\s=\\s(.*),/i', $pattern_match[1], $capacities);
  109. preg_match_all('/freeSpace\\s=\\s(.*),/i', $pattern_match[1], $freespaces);
  110. $matches['paths'] = $paths[1];
  111. $matches['capacities'] = $capacities[1];
  112. $matches['freespaces'] = $freespaces[1];
  113. $matches['diskdata'] = '{';
  114. $matches['storageGuestSize'] = 0;
  115. $matches['storageGuestFreeSpace'] = 0;
  116.  
  117. foreach ($matches['paths'] as $key => $val) {
  118. $matches['storageGuestSize'] = $matches['storageGuestSize'] + round($matches['capacities'][$key] / $byte, 2);
  119. $matches['storageGuestFreeSpace'] = $matches['storageGuestFreeSpace'] + round($matches['freespaces'][$key] / $byte, 2);
  120. $matches['diskdata'] .= (string) $key . " : { 'capacity' : '" . round($matches['capacities'][$key] / $byte, 2) . " GB', 'path': '" . addslashes($matches['paths'][$key]) . "', 'diskinfo' : [['Title', 'Size'], ['" . $_ESXADDON_LANG['FREESPACE'] . ': ' . round($matches['freespaces'][$key] / $byte, 2) . " GB', " . round($matches['freespaces'][$key] / $byte, 2) . "], ['" . $_ESXADDON_LANG['USEDSPACE'] . ' ' . round(($matches['capacities'][$key] - $matches['freespaces'][$key]) / $byte, 2) . " GB', " . round(($matches['capacities'][$key] - $matches['freespaces'][$key]) / $byte, 2) . ']] },';
  121. }
  122. $matches['diskdata'] = rtrim($matches['diskdata'], ',') . '}';
  123. $matches['storageSize'] = round(($matches['uncommitted'] + $matches['committed']) / $byte, 2);
  124. $matches['storageFreeSpace'] = round($matches['uncommitted'] / $byte, 2);
  125. $matches['storagePercent'] = round(($matches['storageSize'] - $matches['storageFreeSpace']) / $matches['storageSize'] * 100);
  126. $matches['storageGuestPercent'] = round(($matches['storageGuestSize'] - $matches['storageGuestFreeSpace']) / $matches['storageGuestSize'] * 100);
  127. }
  128.  
  129. $matches['serviceid'] = $vars['serviceid'];
  130. $sql = "SELECT * FROM mod_whmcslab_addons WHERE modname = 'esx' LIMIT 1";
  131. $result = mysql_query($sql);
  132. $dbdata = mysql_fetch_object($result);
  133. $matches['esxconfig'] = unserialize($dbdata->config);
  134. $matches['username'] = $vars['username'];
  135. $matches['password'] = $vars['password'];
  136.  
  137. return $matches;
  138. }
  139.  
  140. function esx_esxaction($vars)
  141. {
  142. if (($status = esx_licenseactive()) != 'Active') {
  143. return null;
  144. }
  145.  
  146. $sql = "SELECT * FROM mod_whmcslab_addons WHERE modname = 'esx' LIMIT 1";
  147. $result = mysql_query($sql);
  148. $dbdata = mysql_fetch_object($result);
  149. $dbdata->config = unserialize($dbdata->config);
  150. $_ESXADDON_LANG = esx_load_lang($dbdata->language);
  151.  
  152. switch ($_POST['esx']) {
  153. case 'shutdown':
  154. $process = 'power.shutdown';
  155. $error = $_ESXADDON_LANG['ERRORSHUTDOWNORVM'];
  156.  
  157. break;
  158.  
  159. case 'reset':
  160. $process = 'power.reset';
  161. $error = $_ESXADDON_LANG['ERRORSHUTDOWN'];
  162.  
  163. break;
  164.  
  165. case 'poweroff':
  166. $process = 'power.off';
  167. $error = $_ESXADDON_LANG['ERRORSHUTDOWN'];
  168.  
  169. break;
  170.  
  171. case 'poweron':
  172. $process = 'power.on';
  173. $error = $_ESXADDON_LANG['ERRORBOOT'];
  174. ..........................................................................
  175. ......................................
  176. ..............
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement