Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- *
- * @ This file is created by http://DeZender.Net
- * @ deZender (PHP5 Decoder for ionCube Encoder)
- *
- * @ Version : 3.5.0.0
- * @ Author : DeZender
- * @ Release on : 22.06.2018
- * @ Official site : http://DeZender.Net
- *
- */
- if (!defined('WHMCS')) {
- exit('This file cannot be accessed directly');
- }
- esx_load_functions();
- /**
- * Addon Module Sample File
- *
- * This example addon module demonstrates all the functions an addon module can contain.
- * Please refer to the full documentation @ http://docs.whmcs.com/Addon_Modules for more details.
- *
- * @package WHMCS
- * @author WHMCS Limited <development@whmcs.com>
- * @copyright Copyright (c) WHMCS Limited 2005-2013
- * @license http://www.whmcs.com/license/ WHMCS Eula
- * @version $Id$
- * @link http://www.whmcs.com/
- */
- function esx_configoptions()
- {
- $configarray = array();
- return $configarray;
- }
- function esx_licenseactive()
- {
- $return = 'Active';
- $sql = "SELECT * FROM mod_whmcslab_addons WHERE modname = 'esx' LIMIT 1";
- $result = mysql_query($sql);
- $dbdata = mysql_fetch_object($result);
- $dbdata->config = unserialize($dbdata->config);
- $licensekeystatus = esxaddon_check_license2($dbdata->licensekey, $dbdata->localkey);
- if ($licensekeystatus != 'Active') {
- $return = $licensekeystatus;
- }
- return $return;
- }
- function esx_clientarea($vars)
- {
- if (($status = esx_licenseactive()) != 'Active') {
- return null;
- }
- $sql = "SELECT * FROM mod_whmcslab_addons WHERE modname = 'esx' LIMIT 1";
- $result = mysql_query($sql);
- $dbdata = mysql_fetch_object($result);
- $dbdata->config = unserialize($dbdata->config);
- $modulelink = $vars['modulelink'];
- $_ESXADDON_LANG = esx_load_lang($dbdata->language);
- return array('templatefile' => 'esx_clientarea', 'requirelogin' => true, 'vars' => array('_ESXADDON_LANG' => $_ESXADDON_LANG, '_ESXADDON_VARS' => esx_getclientareavars($vars)));
- }
- function esx_getclientareavars($vars)
- {
- $sql = "SELECT * FROM mod_whmcslab_addons WHERE modname = 'esx' LIMIT 1";
- $result = mysql_query($sql);
- $dbdata = mysql_fetch_object($result);
- $dbdata->config = unserialize($dbdata->config);
- $modulelink = $vars['modulelink'];
- $_ESXADDON_LANG = esx_load_lang($dbdata->language);
- $byte = 1073741824;
- $summary_patterns = array('guestMemoryUsage', 'memorySizeMB', 'overallCpuUsage', 'maxCpuUsage', 'committed', 'uncommitted', 'guestFullName', 'numCpu', 'capacity', 'freeSpace', 'powerState', 'ipAddress', 'uptimeSeconds', 'bootTime', 'toolsStatus', 'committed', 'uncommitted');
- $matches = array();
- $ssh = esx_loginserverssh($vars);
- if ($ssh != false) {
- $summary = $ssh->exec('vim-cmd vmsvc/power.getstate ' . $vars['customfields']['esxvmid']);
- $state = explode("\n", $summary);
- if ($state[1] == 'Suspended') {
- $matches['suspended'] = true;
- }
- $summary = $ssh->exec('vim-cmd vmsvc/get.summary ' . $vars['customfields']['esxvmid']);
- $summary = str_replace('guestFullName = <unset>,', '', $summary);
- $summary = str_replace('<unset>', '', $summary);
- foreach ($summary_patterns as $pattern) {
- preg_match('/' . $pattern . '\\s=\\s(.*),/', $summary, $pattern_match);
- $matches[$pattern] = (isset($pattern_match[1]) ? str_replace('"', '', $pattern_match[1]) : '-');
- }
- $matches['powerState'] = str_replace('O', ' O', ucfirst($matches['powerState']));
- $matches['uptimeSeconds'] = ($matches['uptimeSeconds'] ? esx_secondstotime($matches['uptimeSeconds']) : '-');
- $matches['memoryPercent'] = round($matches['guestMemoryUsage'] / $matches['memorySizeMB'] * 100);
- $matches['cpuPercent'] = round($matches['overallCpuUsage'] / $matches['maxCpuUsage'] * 100);
- $summary = $ssh->exec('vim-cmd vmsvc/get.guest ' . $vars['customfields']['esxvmid']);
- preg_match('/disk\\s=\\s(.*)],/s', $summary, $pattern_match);
- preg_match_all('/diskPath\\s=\\s"(.*)",/i', $pattern_match[1], $paths);
- preg_match_all('/capacity\\s=\\s(.*),/i', $pattern_match[1], $capacities);
- preg_match_all('/freeSpace\\s=\\s(.*),/i', $pattern_match[1], $freespaces);
- $matches['paths'] = $paths[1];
- $matches['capacities'] = $capacities[1];
- $matches['freespaces'] = $freespaces[1];
- $matches['diskdata'] = '{';
- $matches['storageGuestSize'] = 0;
- $matches['storageGuestFreeSpace'] = 0;
- foreach ($matches['paths'] as $key => $val) {
- $matches['storageGuestSize'] = $matches['storageGuestSize'] + round($matches['capacities'][$key] / $byte, 2);
- $matches['storageGuestFreeSpace'] = $matches['storageGuestFreeSpace'] + round($matches['freespaces'][$key] / $byte, 2);
- $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) . ']] },';
- }
- $matches['diskdata'] = rtrim($matches['diskdata'], ',') . '}';
- $matches['storageSize'] = round(($matches['uncommitted'] + $matches['committed']) / $byte, 2);
- $matches['storageFreeSpace'] = round($matches['uncommitted'] / $byte, 2);
- $matches['storagePercent'] = round(($matches['storageSize'] - $matches['storageFreeSpace']) / $matches['storageSize'] * 100);
- $matches['storageGuestPercent'] = round(($matches['storageGuestSize'] - $matches['storageGuestFreeSpace']) / $matches['storageGuestSize'] * 100);
- }
- $matches['serviceid'] = $vars['serviceid'];
- $sql = "SELECT * FROM mod_whmcslab_addons WHERE modname = 'esx' LIMIT 1";
- $result = mysql_query($sql);
- $dbdata = mysql_fetch_object($result);
- $matches['esxconfig'] = unserialize($dbdata->config);
- $matches['username'] = $vars['username'];
- $matches['password'] = $vars['password'];
- return $matches;
- }
- function esx_esxaction($vars)
- {
- if (($status = esx_licenseactive()) != 'Active') {
- return null;
- }
- $sql = "SELECT * FROM mod_whmcslab_addons WHERE modname = 'esx' LIMIT 1";
- $result = mysql_query($sql);
- $dbdata = mysql_fetch_object($result);
- $dbdata->config = unserialize($dbdata->config);
- $_ESXADDON_LANG = esx_load_lang($dbdata->language);
- switch ($_POST['esx']) {
- case 'shutdown':
- $process = 'power.shutdown';
- $error = $_ESXADDON_LANG['ERRORSHUTDOWNORVM'];
- break;
- case 'reset':
- $process = 'power.reset';
- $error = $_ESXADDON_LANG['ERRORSHUTDOWN'];
- break;
- case 'poweroff':
- $process = 'power.off';
- $error = $_ESXADDON_LANG['ERRORSHUTDOWN'];
- break;
- case 'poweron':
- $process = 'power.on';
- $error = $_ESXADDON_LANG['ERRORBOOT'];
- ..........................................................................
- ......................................
- ..............
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement