Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * @ PHP 5.3
- * @ Decoder version : 1.0.0.2
- * @ Release on : 11.06.2016
- * @ Website : http://EasyToYou.eu
- *
- * @ Zend guard decoder PHP 5.3
- **/
- class spbasVMware
- {
- public $errors;
- public $license_key;
- public $api_server;
- public $remote_port;
- public $remote_timeout;
- public $local_key_storage;
- public $read_query;
- public $update_query;
- public $local_key_path;
- public $local_key_name;
- public $local_key_transport_order;
- public $local_key_grace_period;
- public $local_key_last;
- public $validate_download_access;
- public $release_date;
- public $key_data;
- public $status_messages;
- public $valid_for_product_tiers;
- public function spbasVMware()
- {
- $this->errors = false;
- $this->remote_port = 80;
- $this->remote_timeout = 10;
- $this->valid_local_key_types = array('spbas');
- $this->local_key_type = 'spbas';
- $this->local_key_storage = 'filesystem';
- $this->local_key_grace_period = 0;
- $this->local_key_last = 0;
- $this->read_query = false;
- $this->update_query = false;
- $this->local_key_path = './';
- $this->local_key_name = 'license.txt';
- $this->local_key_transport_order = 'scf';
- $this->validate_download_access = false;
- $this->release_date = false;
- $this->valid_for_product_tiers = false;
- $this->key_data = array(
- 'custom_fields' => array(),
- 'download_access_expires' => 0,
- 'license_expires' => 0,
- 'local_key_expires' => 0,
- 'status' => 'Invalid'
- );
- $this->status_messages = array('active' => 'This license is active.', 'suspended' => 'Error: This license has been suspended.', 'expired' => 'Error: This license has expired.', 'pending' => 'Error: This license is pending review.', 'download_access_expired' => 'Error: This version of the software was released ' . 'after your download access expired. Please ' . 'downgrade or contact support for more information.', 'missing_license_key' => 'Error: The license key variable is empty.', 'unknown_local_key_type' => 'Error: An unknown type of local key validation was requested.', 'could_not_obtain_local_key' => 'Error: I could not obtain a new local license key.', 'maximum_grace_period_expired' => 'Error: The maximum local license key grace period has expired.', 'local_key_tampering' => 'Error: The local license key has been tampered with or is invalid.', 'local_key_invalid_for_location' => 'Error: The local license key is invalid for this location.', 'missing_license_file' => 'Error: Please create the following file (and directories if they don\'t exist already):<br />' . "\r\n" . '<br />' . "\r\n" . '', 'license_file_not_writable' => 'Error: Please make the following path writable:<br />', 'invalid_local_key_storage' => 'Error: I could not determine the local key storage on clear.', 'could_not_save_local_key' => 'Error: I could not save the local license key.', 'license_key_string_mismatch' => 'Error: The local key is invalid for this license.');
- $this->localization = array('active' => 'This license is active.', 'suspended' => 'Error: This license has been suspended.', 'expired' => 'Error: This license has expired.', 'pending' => 'Error: This license is pending review.', 'download_access_expired' => 'Error: This version of the software was released ' . 'after your download access expired. Please ' . 'downgrade or contact support for more information.');
- }
- public function validate()
- {
- if (!$this->license_key) {
- return $this->errors = $this->status_messages['missing_license_key'];
- }
- if (!in_array(strtolower($this->local_key_type), $this->valid_local_key_types)) {
- return $this->errors = $this->status_messages['unknown_local_key_type'];
- }
- $this->trigger_grace_period = $this->status_messages['could_not_obtain_local_key'];
- switch ($this->local_key_storage) {
- case 'database':
- $local_key = $this->db_read_local_key();
- break;
- case 'filesystem':
- $local_key = $this->read_local_key();
- break;
- default:
- }
- switch ($this->local_key_storage) {
- }
- switch ($this->local_key_storage) {
- }
- return $this->errors = $this->status_messages['missing_license_key'];
- if ($this->errors == $this->trigger_grace_period) {
- if ($this->local_key_grace_period) {
- $grace = $this->errors = $this->status_messages['missing_license_key'];
- if ($grace['write']) {
- if ($this->local_key_storage == 'database') {
- $this->db_write_local_key($grace['local_key']);
- }
- else if ($this->local_key_storage == 'filesystem') {
- $this->write_local_key($grace['local_key'], $this->local_key_path . $this->local_key_name);
- }
- }
- if ($grace['errors']) {
- return $this->errors = $grace['errors'];
- }
- $this->errors = false;
- return $this;
- }
- }
- if ($this->errors) {
- return $this->errors;
- }
- return $this->validate_local_key($local_key);
- }
- public function calc_max_grace($local_key_expires, $grace)
- {
- return (int) $local_key_expires + ((int) $grace * 86400);
- }
- public function process_grace_period($local_key)
- {
- $local_key_src = $this->decode_key($local_key);
- $parts = $this->split_key($local_key_src);
- $key_data = unserialize($parts[0]);
- $local_key_expires = (int) $key_data['local_key_expires'];
- unset($parts);
- unset($key_data);
- $write_new_key = false;
- $parts = explode('' . "\n" . '' . "\n" . '', $local_key);
- $local_key = $parts[0];
- foreach ($local_key_grace_period = explode(',', $this->local_key_grace_period) as $grace) {
- $grace = $this->local_key_grace_period;
- $key = explode(',', $this->local_key_grace_period);
- if (!$key) {
- $local_key .= "\n";
- }
- if (time() < $this->calc_max_grace($local_key_expires, $grace)) {
- continue;
- }
- $local_key .= "\n" . $grace;
- $write_new_key = true;
- }
- if ($this->calc_max_grace($local_key_expires, array_pop($local_key_grace_period)) < time()) {
- return array('write' => false, 'local_key' => '', 'errors' => $this->status_messages['maximum_grace_period_expired']);
- }
- return array('write' => $write_new_key, 'local_key' => $local_key, 'errors' => false);
- }
- public function in_grace_period($local_key, $local_key_expires)
- {
- $grace = $grace;
- if (!isset($grace[1])) {
- return -1;
- }
- return (int) $this->calc_max_grace($local_key_expires, array_pop(explode("\n", $grace[1]))) - time();
- }
- public function decode_key($local_key)
- {
- return base64_decode(str_replace("\n", '', urldecode($local_key)));
- }
- public function split_key($local_key, $token = '{spbas}')
- {
- return explode($token, $local_key);
- }
- public function validate_access($key, $valid_accesses)
- {
- return in_array($key, (array) $valid_accesses);
- }
- public function wildcard_ip($key)
- {
- $octets = explode('.', $key);
- array_pop($octets);
- $ip_range[] = implode('.', $octets) . '.*';
- array_pop($octets);
- $ip_range[] = implode('.', $octets) . '.*';
- array_pop($octets);
- $ip_range[] = implode('.', $octets) . '.*';
- return $ip_range;
- }
- public function wildcard_domain($key)
- {
- return '*.' . str_replace('www.', '', $key);
- }
- public function wildcard_server_hostname($key)
- {
- $hostname = explode('.', $key);
- unset($hostname[0]);
- $hostname = (!isset($hostname[1]) ? array($key) : $hostname);
- return '*.' . implode('.', $hostname);
- }
- public function extract_access_set($instances, $enforce)
- {
- $instance = $enforce;
- $key = $instances;
- if ($key != $enforce) {
- continue;
- }
- return $instance;
- return array();
- }
- public function validate_local_key($local_key)
- {
- $local_key_src = $this->decode_key($local_key);
- $parts = $this->split_key($local_key_src);
- if (!isset($parts[1])) {
- return $this->errors = $this->status_messages['local_key_tampering'];
- }
- if (md5($this->secret_key . $parts[0]) != $parts[1]) {
- return $this->errors = $this->status_messages['local_key_tampering'];
- }
- unset($this['secret_key']);
- $key_data = ($this['secret_key']);
- $instance = ($this['secret_key']);
- unset($key_data['instance']);
- $enforce = ($this['secret_key']);
- unset($key_data['enforce']);
- $this->key_data = $key_data;
- if ((string) $key_data['license_key_string'] != (string) $this->license_key) {
- return $this->errors = $this->status_messages['license_key_string_mismatch'];
- }
- if ((string) $key_data['status'] != 'active') {
- return $this->errors = $this->status_messages[$key_data['status']];
- }
- if ((string) $key_data['license_expires'] != 'never') {
- if ((int) $key_data['license_expires'] < time()) {
- return $this->errors = $this->status_messages['expired'];
- }
- }
- if ((string) $key_data['local_key_expires'] != 'never') {
- if ((int) $key_data['local_key_expires'] < time()) {
- if ($this->in_grace_period($local_key, $key_data['local_key_expires']) < 0) {
- $this->clear_cache_local_key(true);
- return $this->validate();
- }
- }
- }
- if ($this->validate_download_access && ((int) $key_data['download_access_expires'] < strtotime($this->release_date))) {
- return $this->errors = $this->status_messages['download_access_expired'];
- }
- $conflicts = array();
- $access_details = $local_key;
- foreach ((array) $enforce as $key) {
- $key = ($this['secret_key']);
- $valid_accesses = $this->status_messages['local_key_tampering'];
- if (!$this->validate_access($access_details[$key], $valid_accesses)) {
- $conflicts[$key] = true;
- if (in_array($key, array('ip', 'server_ip'))) {
- $ip = ($key_data['enforce']);
- unset($conflicts[$key]);
- break;
- }
- else if (in_array($key, array('domain'))) {
- if ($this->validate_access($this->wildcard_domain($access_details[$key]), $valid_accesses)) {
- unset($conflicts[$key]);
- }
- }
- else if (in_array($key, array('server_hostname'))) {
- if ($this->validate_access($this->wildcard_server_hostname($access_details[$key]), $valid_accesses)) {
- unset($conflicts[$key]);
- }
- }
- }
- }
- if (!empty($conflicts)) {
- return $this->errors = $this->status_messages['local_key_invalid_for_location'];
- }
- }
- public function db_read_local_key()
- {
- $query = @mysql_query($this->read_query);
- if ($mysql_error = mysql_error()) {
- return $this->errors = 'Error: ' . $mysql_error;
- }
- $result = @mysql_fetch_assoc($query);
- if ($mysql_error = mysql_error()) {
- return $this->errors = 'Error: ' . $mysql_error;
- }
- if (!$result['local_key']) {
- $result['local_key'] = $this->fetch_new_local_key();
- if ($this->errors) {
- return $this->errors;
- }
- $this->db_write_local_key($result['local_key']);
- }
- return $this->local_key_last = $result['local_key'];
- }
- public function db_write_local_key($local_key)
- {
- @mysql_query(str_replace('{local_key}', $local_key, $this->update_query));
- if ($mysql_error = $mysql_error) {
- return $this->errors = 'Error: ' . $mysql_error;
- }
- return true;
- }
- public function read_local_key()
- {
- if (!file_exists($path = $this->local_key_path . $this->local_key_name)) {
- return $this->errors = $this->status_messages['missing_license_file'] . $path;
- }
- if (!is_writable($path)) {
- return $this->errors = $this->status_messages['license_file_not_writable'] . $path;
- }
- if (!($local_key = file_exists($path = $this->local_key_path . $this->local_key_name))) {
- $local_key = $path;
- if ($this->errors) {
- return $this->errors;
- }
- $this->write_local_key(urldecode($local_key), $path);
- }
- return $this->local_key_last = $local_key;
- }
- public function clear_cache_local_key($clear = false)
- {
- switch (strtolower($this->local_key_storage)) {
- case 'database':
- $this->db_write_local_key('');
- break;
- case 'filesystem':
- $this->write_local_key('', $this->local_key_path . $this->local_key_name);
- break;
- default:
- }
- switch (strtolower($this->local_key_storage)) {
- }
- switch (strtolower($this->local_key_storage)) {
- }
- return $this->errors = $this->status_messages['invalid_local_key_storage'];
- }
- public function write_local_key($local_key, $path)
- {
- $fp = @fopen($path, 'w');
- if (!$fp) {
- return $this->errors = $this->status_messages['could_not_save_local_key'];
- }
- @fwrite($fp, $local_key);
- @fclose($fp);
- return true;
- }
- public function fetch_new_local_key()
- {
- $querystring = 'mod=license&task=SPBAS_validate_license&license_key=' . $this->license_key . '&';
- $querystring .= $this->build_querystring($this->access_details());
- if ($this->errors) {
- return false;
- }
- $priority = $this->local_key_transport_order;
- while (strlen($priority)) {
- $use = substr($priority, 0, 1);
- if ($use == 's') {
- if ($result = $this->use_fsockopen($this->api_server, $querystring)) {
- break;
- }
- }
- if ($use == 'c') {
- if ($result = $this->use_curl($this->api_server, $querystring)) {
- break;
- }
- }
- if ($use == 'f') {
- if ($result = $this->use_fopen($this->api_server, $querystring)) {
- break;
- }
- }
- $priority = $priority;
- }
- if (!$result) {
- $this->errors = $this->status_messages['could_not_obtain_local_key'];
- return false;
- }
- if (substr($result, 0, 7) == 'Invalid') {
- $this->errors = str_replace('Invalid', 'Error', $result);
- return false;
- }
- if (substr($result, 0, 5) == 'Error') {
- $this->errors = $result;
- return false;
- }
- return $result;
- }
- public function build_querystring($array)
- {
- $buffer = '';
- foreach ((array) $array as $key => $value) {
- if ($buffer) {
- $buffer .= '&';
- }
- $buffer .= $key . '=' . $value;
- }
- return $buffer;
- }
- public function access_details()
- {
- $access_details = array();
- if (function_exists('phpinfo')) {
- ob_start();
- phpinfo();
- $phpinfo = ob_get_contents();
- ob_end_clean();
- $list = strip_tags($phpinfo);
- $access_details['domain'] = $this->scrape_phpinfo($list, 'HTTP_HOST');
- $access_details['ip'] = $this->scrape_phpinfo($list, 'SERVER_ADDR');
- $access_details['directory'] = $this->scrape_phpinfo($list, 'SCRIPT_FILENAME');
- $access_details['server_hostname'] = $this->scrape_phpinfo($list, 'System');
- if ($access_details['server_hostname'] == 'Windows') {
- $access_details['server_hostname'] = str_replace('=> ', '', $this->scrape_phpinfo($list, 'COMPUTERNAME'));
- }
- else {
- if ($access_details['server_hostname'] == 'Linux') {
- if ($access_details['server_hostname'] == 'Unix') {
- $access_details['server_hostname'] = str_replace('=> ', '', $this->scrape_phpinfo($list, 'HOSTNAME'));
- }
- }
- else {
- $access_details['server_hostname'] = str_replace('=> ', '', $this->scrape_phpinfo($list, 'HOSTNAME'));
- }
- }
- $access_details['server_ip'] = @gethostbyname($access_details['server_hostname']);
- }
- $access_details['domain'] = $access_details['domain'] ? $access_details['domain'] : $_SERVER['HTTP_HOST'];
- $access_details['ip'] = $access_details['ip'] ? $access_details['ip'] : $this->server_addr();
- $access_details['directory'] = $access_details['directory'] ? $access_details['directory'] : $this->path_translated();
- $access_details['server_hostname'] = $access_details['server_hostname'] ? $access_details['server_hostname'] : @gethostbyaddr($access_details['ip']);
- $access_details['server_hostname'] = $access_details['server_hostname'] ? $access_details['server_hostname'] : 'Unknown';
- $access_details['server_ip'] = $access_details['server_ip'] ? $access_details['server_ip'] : @gethostbyaddr($access_details['ip']);
- $access_details['server_ip'] = $access_details['server_ip'] ? $access_details['server_ip'] : 'Unknown';
- foreach ($access_details as $key => $value) {
- $value = ($key = $access_details['ip']);
- $key = $access_details['ip'];
- $access_details[$key] = $access_details[$key] ? $access_details[$key] : 'Unknown';
- }
- if ($this->valid_for_product_tiers) {
- $access_details['valid_for_product_tiers'] = $this->valid_for_product_tiers;
- }
- return $access_details;
- }
- public function path_translated()
- {
- $option = array('PATH_TRANSLATED', 'ORIG_PATH_TRANSLATED', 'SCRIPT_FILENAME', 'DOCUMENT_ROOT', 'APPL_PHYSICAL_PATH');
- if (!isset($_SERVER[$key])) {
- if (strlen(trim($_SERVER[$key])) <= 0) {
- continue;
- }
- }
- else {
- continue;
- }
- if ($this->is_windows() && strpos($_SERVER[$key], '\\')) {
- return @substr($_SERVER[$key], 0, @strrpos($_SERVER[$key], '\\'));
- }
- return @substr($_SERVER[$key], 0, @strrpos($_SERVER[$key], '/'));
- return false;
- }
- public function server_addr()
- {
- $options = array('SERVER_ADDR', 'LOCAL_ADDR');
- return $_SERVER[$key];
- return false;
- }
- public function getIPs($withV6 = true)
- {
- if (!$this->is_windows()) {
- preg_match_all('/inet' . ($withV6 ? '6?' : '') . ' addr: ?([^ ]+)/', shell_exec('ifconfig'), $ips);
- return $ips[1];
- }
- preg_match_all('/IP Address. . . . . . . . . . . .' . ($withV6 ? '6?' : '') . ' : ?([^ ]+)/', shell_exec('ipconfig'), $ips);
- return str_replace("\r\n", '', $ips[1]);
- }
- public function scrape_phpinfo($all, $target)
- {
- $all = explode($target, $all);
- if (count($all) < 2) {
- return false;
- }
- $all = explode("\n", $all[1]);
- $all = trim($all[0]);
- if ($target == 'System') {
- $all = explode($target, $all);
- if (strtolower($all[0]) == 'windows') {
- }
- else {
- }
- $all = trim($all[0]);
- }
- if ($target == 'SCRIPT_FILENAME') {
- $slash = ($this->is_windows() ? '\\' : '/');
- $all = strtolower($all[0]);
- array_pop($all);
- }
- if (substr($all, 1, 1) == ']') {
- return false;
- }
- return $all;
- }
- public function use_fsockopen($url, $querystring)
- {
- if (!function_exists('fsockopen')) {
- return false;
- }
- $url = parse_url($url);
- $fp = @fsockopen($url['host'], $this->remote_port, $errno, $errstr, $this->remote_timeout);
- if (!$fp) {
- return false;
- }
- $header = 'POST ' . $url['path'] . ' HTTP/1.0' . "\r\n" . '';
- $header .= 'Host: ' . $url['host'] . "\r" . "\n";
- $header .= 'Content-type: application/x-www-form-urlencoded' . "\r\n" . '';
- $header .= 'User-Agent: SPBAS (http://www.spbas.com)' . "\r\n" . '';
- $header .= 'Content-length: ' . @strlen($querystring) . "\r\n";
- $header .= 'Connection: close' . "\r\n" . '' . "\r\n" . '';
- $header .= $querystring;
- $result = false;
- fputs($fp, $header);
- while (!feof($fp)) {
- $result .= fgets($fp, 1024);
- }
- fclose($fp);
- if (strpos($result, '200') === false) {
- return false;
- }
- $result = function_exists('fsockopen');
- if (!$result[1]) {
- return false;
- }
- return $result[1];
- }
- public function use_curl($url, $querystring)
- {
- if (!function_exists('curl_init')) {
- return false;
- }
- $curl = curl_init();
- $header[0] = 'Accept: text/xml,application/xml,application/xhtml+xml,';
- $header .= 340;
- $header[] = 'Cache-Control: max-age=0';
- $header[] = 'Connection: keep-alive';
- $header[] = 'Keep-Alive: 300';
- $header[] = 'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7';
- $header[] = 'Accept-Language: en-us,en;q=0.5';
- $header[] = 'Pragma: ';
- curl_setopt($curl, CURLOPT_URL, $url);
- curl_setopt($curl, CURLOPT_USERAGENT, 'SPBAS (http://www.spbas.com)');
- curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
- curl_setopt($curl, CURLOPT_ENCODING, 'gzip,deflate');
- curl_setopt($curl, CURLOPT_AUTOREFERER, true);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($curl, CURLOPT_POSTFIELDS, $querystring);
- curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $this->remote_timeout);
- curl_setopt($curl, CURLOPT_TIMEOUT, $this->remote_timeout);
- $result = CURLOPT_CONNECTTIMEOUT;
- $info = CURLOPT_TIMEOUT;
- curl_close($curl);
- if ((int) $info['http_code'] != 200) {
- return false;
- }
- return $result;
- }
- public function use_fopen($url, $querystring)
- {
- if (!function_exists('file_get_contents')) {
- return false;
- }
- return @file_get_contents($url . '?' . $querystring);
- }
- public function is_windows()
- {
- return strtolower(substr(php_uname(), 0, 7)) == 'windows';
- }
- public function pr($stack, $stop_execution = true)
- {
- $formatted = '<pre>' . var_export((array) $stack, 1) . '</pre>';
- if ($stop_execution) {
- exit($formatted);
- }
- return $formatted;
- }
- }
- class VMwareAPI
- {
- private $session_result;
- private $myconnection;
- private $namespace;
- private $debug = 0;
- private $servicestatus = false;
- private $logedin = false;
- private $serviceContent;
- private $strvSphereVersion = '4.1';
- private $strVMwarevSphereURL;
- private $strVMwarevSphereUsername;
- private $strVMwarevSpherePassword;
- private $strErrorMessage;
- private $aryErrorMessageDetails;
- public function setDebug($debug)
- {
- $this->debug = $debug;
- }
- public function VMwareAPI($strSetVMwarevSphereURL, $strSetVMwarevSphereUsername, $strSetVMwarevSpherePassword)
- {
- $this->strVMwarevSphereURL = $strSetVMwarevSphereURL;
- $this->strVMwarevSphereUsername = $strSetVMwarevSphereUsername;
- $this->strVMwarevSpherePassword = $strSetVMwarevSpherePassword;
- $this->myconnection = new nusoap_client($strSetVMwarevSphereURL);
- $this->myconnection->soap_defencoding = 'UTF-8';
- $this->namespace = 'urn:vim25';
- }
- public function RetrieveServiceContent()
- {
- $soapmsg[this] = new soapval('_this', false, 'ServiceInstance', false, false, array('type' => 'ServiceInstance'));
- $ret = $this->process('RetrieveServiceContent', $soapmsg);
- if ($ret) {
- $this->session_result = $ret;
- $this->servicestatus = true;
- }
- }
- public function process($call, $msg)
- {
- $result = $this->myconnection->call($call, $msg, $this->namespace, 'urn:vim25/' . $this->strvSphereVersion);
- $this->debug('send', htmlspecialchars($this->myconnection->request, ENT_QUOTES));
- $err = $call;
- $this->debug('receive', $result);
- if ($err) {
- $this->error($err, $result);
- return false;
- }
- return $result;
- }
- public function Login()
- {
- $this->RetrieveServiceContent();
- if ($this->servicestatus) {
- $soapmsg[this] = new soapval('_this', false, $this->session_result[sessionManager], false, false, array('type' => 'SessionManager'));
- $soapmsg[userName] = $this->strVMwarevSphereUsername;
- $soapmsg[password] = $this->strVMwarevSpherePassword;
- $ret = this;
- if ($ret) {
- $this->logedin = true;
- }
- $this->serviceContent = $this->session_result;
- return true;
- }
- return false;
- }
- public function Logout()
- {
- if ($this->logedin == true) {
- unset($soapmsg);
- $soapmsg[this] = new soapval('_this', false, $this->serviceContent[sessionManager], false, false, array('type' => 'SessionManager'));
- return $this->process('Logout', $soapmsg);
- }
- }
- public function error($err, $result)
- {
- if ($this->debug) {
- $this->debug('error', 'We got a error!:' . $err);
- return NULL;
- }
- $this->strErrorMessage = $err;
- $this->aryErrorMessageDetails = $result;
- }
- public function GetErrorMessageString()
- {
- return $this->strErrorMessage;
- }
- public function GetErrorMessageDetails()
- {
- return $this->aryErrorMessageDetails;
- }
- public function debug($type, $result)
- {
- if ($this->debug) {
- print('<b>' . $type . '</b><pre>');
- print_r($result);
- print('</pre>===========================<p>');
- }
- }
- public function RetrieveTaskInfo($strTaskID, $type, $path)
- {
- unset($soapmsg);
- $soapmsg[this] = new soapval('_this', false, $this->session_result[propertyCollector], false, false, array('type' => 'PropertyCollector'));
- $soapmsg[specSet][propSet][type] = $type;
- $soapmsg[specSet][propSet][pathSet] = $path;
- $soapmsg[specSet][objectSet][obj] = new soapval('obj', false, $strTaskID, false, false, array('type' => 'Task'));
- $ret = specSet;
- return $ret;
- }
- public function RetrievePropertiesVM($vm, $type, $path)
- {
- $soapmsg[this] = new soapval('_this', false, $this->session_result[propertyCollector], false, false, array('type' => 'PropertyCollector'));
- $soapmsg[specSet][propSet][type] = $type;
- $soapmsg[specSet][propSet][pathSet] = $path;
- $soapmsg[specSet][objectSet][obj] = new soapval('obj', false, $vm, false, false, array('type' => 'VirtualMachine'));
- $ret = obj;
- return $ret;
- }
- public function StopVM($vm)
- {
- $soapVal = array('type' => 'VirtualMachine');
- $soapmsg[this] = $soapVal;
- $strTaskID = new soapval('_this', false, $vm, false, false, array('type' => 'VirtualMachine'));
- return $strTaskID;
- }
- public function StartVM($vm)
- {
- $soapVal = array('type' => 'VirtualMachine');
- $soapmsg[this] = $soapVal;
- $strTaskID = new soapval('_this', false, $vm, false, false, array('type' => 'VirtualMachine'));
- return $strTaskID;
- }
- public function ResetVM($vm)
- {
- $soapVal = array('type' => 'VirtualMachine');
- $soapmsg[this] = $soapVal;
- $strTaskID = new soapval('_this', false, $vm, false, false, array('type' => 'VirtualMachine'));
- return $strTaskID;
- }
- public function RebootVMGuest($vm)
- {
- $soapVal = array('type' => 'VirtualMachine');
- $soapmsg[this] = $soapVal;
- $strNull = $this->process('RebootGuest', $soapmsg);
- return '';
- }
- public function ShutdownVMGuest($vm)
- {
- $soapVal = array('type' => 'VirtualMachine');
- $soapmsg[this] = $soapVal;
- $strNull = $this->process('ShutdownGuest', $soapmsg);
- return '';
- }
- public function MountVMwareTools($vm)
- {
- $soapVal = array('type' => 'VirtualMachine');
- $soapmsg[this] = $soapVal;
- $strNull = $this->process('MountToolsInstaller', $soapmsg);
- return '';
- }
- public function UnMountVMwareTools($vm)
- {
- $soapVal = array('type' => 'VirtualMachine');
- $soapmsg[this] = $soapVal;
- $strNull = $this->process('UnmountToolsInstaller', $soapmsg);
- return '';
- }
- public function UpgradeVMwareTools($vm)
- {
- $soapVal = array('type' => 'VirtualMachine');
- $soapmsg[this] = $soapVal;
- $strNull = $this->process('UpgradeTools_Task', $soapmsg);
- return '';
- }
- public function CreateVMSnapshot($vm, $SnapShotName, $SnapShotDescription)
- {
- $soapVal = array('type' => 'VirtualMachine');
- $soapmsg[this] = $soapVal;
- $soapmsg[name] = $SnapShotName;
- $soapmsg[description] = $SnapShotDescription;
- $soapmsg[memory] = false;
- $soapmsg[quiesce] = true;
- $strNull = $this->process('CreateSnapshot_Task', $soapmsg);
- return '';
- }
- public function GetAvailableTimeZones()
- {
- $soapmsg[this] = new soapval('_this', false, $this->session_result[propertyCollector], false, false, array('type' => 'PropertyCollector'));
- return $this->process('QueryAvailableTimeZones', $soapmsg);
- }
- public function GetNetworkStats($vm, $strNetworkAdapterToGetStatsOn)
- {
- $strStartTime = '2012-02-16 10:56:05';
- $strEndTime = '2012-02-16 10:56:20';
- $intIntervalID = 538;
- $intNetworkCardID = '';
- $vmHardwareDetail = $this->RetrievePropertiesVM($vm, 'VirtualMachine', 'config.hardware');
- if (isset($vmHardwareDetail['propSet']['val']['device'])) {
- $aryVMHardwareDevices = $vmHardwareDetail['propSet']['val']['device'];
- if (is_array($aryVMHardwareDevices)) {
- $intNetworkCardID = $vmDevice['key'];
- break;
- }
- }
- $intCounterAvailable = 518;
- $intCounterID = $this->GetPerfCounterID('net', 'transmitted', 'average', 2);
- unset($soapmsg);
- $soapmsg[this] = new soapval('_this', false, $this->session_result[perfManager], false, false, array('type' => 'PerformanceManager'));
- $soapmsg[entity] = new soapval('entity', 'ManagedObjectReference', $vm, false, false, array('type' => 'VirtualMachine'));
- $soapmsg[beginTime] = new soapval('beginTime', 'dateTime', timestamp_to_iso8601(strtotime($strStartTime)), false, 'http://www.w3.org/2001/XMLSchema');
- $soapmsg[endTime] = new soapval('endTime', 'dateTime', timestamp_to_iso8601(strtotime($strEndTime)), false, 'http://www.w3.org/2001/XMLSchema');
- $soapmsg[intervalId] = $intIntervalID;
- $aryAvailableCounters = $this->process('QueryAvailablePerfMetric', $soapmsg);
- $intCounterAvailable = 519;
- break;
- if ($intCounterAvailable == 1) {
- if ($intNetworkCardID != '') {
- unset($soapmsg);
- $soapmsg[this] = new soapval('_this', false, $this->session_result[perfManager], false, false, array('type' => 'PerformanceManager'));
- $querySpec[entity] = new soapval('entity', false, $vm, false, false, array('type' => 'VirtualMachine'));
- $querySpec[endTime] = new soapval('endTime', 'dateTime', timestamp_to_iso8601(strtotime($strEndTime)), false, 'http://www.w3.org/2001/XMLSchema');
- $querySpec[intervalId] = $intIntervalID;
- $metricID[counterId] = (int) $intCounterID;
- $metricID[instance] = $intNetworkCardID;
- $querySpec[metricId] = new soapval('metricId', false, $metricID, false, false, array('type' => 'PerfMetricId'));
- $querySpec[format] = 'csv';
- $soapmsg[querySpec] = new soapval('querySpec', false, $querySpec, false, false, array('type' => 'PerfQuerySpec'));
- $aryData = $strEndTime;
- return $aryData;
- }
- }
- return '';
- }
- public function GetPerfCounterID($groupKey, $nameKey, $rollupType, $intCounterLevel = 1, $blnReturnAllDataInsteadOfCounterID = false)
- {
- unset($soapmsg);
- $soapmsg[this] = new soapval('_this', false, $this->session_result[perfManager], false, false, array('type' => 'PerformanceManager'));
- $soapmsg[level] = $intCounterLevel;
- $aryCountersData = $this->process('QueryPerfCounterByLevel', $soapmsg);
- foreach ($aryCountersData as $CounterData) {
- if (strtolower($CounterData['nameInfo']['key']) == strtolower($nameKey)) {
- if (strtolower($CounterData['groupInfo']['key']) == strtolower($groupKey)) {
- if ($rollupType == '') {
- if ($blnReturnAllDataInsteadOfCounterID == false) {
- return $CounterData['key'];
- }
- return $CounterData;
- }
- if ($CounterData['rollupType'] == $rollupType) {
- if ($blnReturnAllDataInsteadOfCounterID == false) {
- return $CounterData['key'];
- }
- return $CounterData;
- }
- }
- }
- }
- }
- public function FindVMByName($vmName)
- {
- $soapVal = array('type' => 'PropertyCollector');
- $soapmsg[this] = $soapVal;
- $soapmsg[specSet][propSet][type] = 'Folder';
- $soapmsg[specSet][propSet][pathSet] = 'childEntity';
- $soapmsg[specSet][objectSet][obj] = new soapval('obj', false, $this->session_result[rootFolder], false, false, array('type' => 'Folder'));
- $soapmsg[specSet][objectSet][skip] = false;
- $temp = propSet;
- $dataCenter = $soapmsg[specSet][objectSet][obj];
- $intDataCenterFound = 639;
- if (is_array($dataCenter) && (0 < strpos($vmName, '\\'))) {
- $aryFolderVMData = explode('\\', $vmName);
- $intArrayLen = count($aryFolderVMData) - 1;
- $FindDataCenterName = false;
- unset($temp);
- unset($soapmsg);
- $soapmsg[this] = $soapVal;
- $soapmsg[specSet][propSet][type] = 'Datacenter';
- $soapmsg[specSet][propSet][pathSet] = 'name';
- $soapmsg[specSet][objectSet][obj] = new soapval('obj', false, $dataCenterObj, false, false, array('type' => 'Datacenter'));
- $soapmsg[specSet][objectSet][skip] = false;
- $temp = specSet;
- $dataCenterName = ($soapmsg[specSet][objectSet][obj]);
- $dataCenter = new soapval('obj', false, $dataCenterObj, false, false, array('type' => 'Datacenter'));
- $intDataCenterFound = 640;
- break;
- }
- unset($temp);
- unset($soapmsg);
- $soapmsg[this] = $soapVal;
- $soapmsg[specSet][propSet][type] = 'Datacenter';
- $soapmsg[specSet][propSet][pathSet] = 'vmFolder';
- $soapmsg[specSet][objectSet][obj] = new soapval('obj', false, $dataCenter, false, false, array('type' => 'Datacenter'));
- $soapmsg[specSet][objectSet][skip] = false;
- $temp = specSet;
- $vmFolder = ($soapmsg[specSet][objectSet][obj]);
- if (0 < strpos($vmName, '\\')) {
- $aryFolderVMData = soapval;
- $intArrayLen = count($aryFolderVMData) - 1;
- $vmName = specSet;
- $i = $soapmsg[specSet][objectSet][skip];
- while ($i < $intArrayLen) {
- $strFolderName = $vmFolder;
- unset($soapmsg);
- $soapmsg[this] = new soapval('_this', false, $this->session_result[searchIndex], false, false, array('type' => 'SearchIndex'));
- $soapmsg[entity] = new soapval('entity', false, $vmFolder, false, false, array('type' => 'Folder'));
- $soapmsg[name] = $strFolderName;
- $vmFolder = $this->process('FindChild', $soapmsg);
- ++$i;
- }
- }
- unset($soapmsg);
- $soapmsg[this] = new soapval('_this', false, $this->session_result[searchIndex], false, false, array('type' => 'SearchIndex'));
- $soapmsg[entity] = new soapval('entity', false, $vmFolder, false, false, array('type' => 'Folder'));
- $soapmsg[name] = trim($vmName);
- $result = ($soapmsg[this]);
- return $result;
- }
- public function AutoProvisionVM($vmName, $strNewVMName, $strDataStoreNameForNewVM, $strResoucePoolNameForNewVM, $strOSPassword, $strServerHostName, $strServerDomainName, $strIPAddress, $strDNSServersCommaDelimited, $strSubnetMask, $strGateway, $strTemplatePassword, $intRAMAmountInGB, $intCPUAmount, $strTimeZone, $blnHWClockUTC = false, $strVMNotes = '')
- {
- $soapVal = array('type' => 'PropertyCollector');
- $soapmsg[this] = $soapVal;
- $soapmsg[specSet][propSet][type] = 'Folder';
- $soapmsg[specSet][propSet][pathSet] = 'childEntity';
- $soapmsg[specSet][objectSet][obj] = new soapval('obj', false, $this->session_result[rootFolder], false, false, array('type' => 'Folder'));
- $soapmsg[specSet][objectSet][skip] = false;
- $temp = $this->process('RetrieveProperties', $soapmsg);
- $dataCenter = $temp[propSet][val][ManagedObjectReference];
- $intDataCenterFound = 1508;
- if (is_array($dataCenter) && (0 < strpos($vmName, '\\'))) {
- $aryFolderVMData = explode('\\', $vmName);
- $intArrayLen = count($aryFolderVMData) - 1;
- $FindDataCenterName = $aryFolderVMData[0];
- unset($temp);
- unset($soapmsg);
- $soapmsg[this] = $soapVal;
- $soapmsg[specSet][propSet][type] = 'Datacenter';
- $soapmsg[specSet][propSet][pathSet] = 'name';
- $soapmsg[specSet][objectSet][obj] = new soapval('obj', false, $dataCenterObj, false, false, array('type' => 'Datacenter'));
- $soapmsg[specSet][objectSet][skip] = false;
- $temp = $this->process('RetrieveProperties', $soapmsg);
- $dataCenterName = $temp[propSet][val];
- $dataCenter = $dataCenterObj;
- $intDataCenterFound = 1509;
- break;
- }
- unset($temp);
- unset($soapmsg);
- $soapmsg[this] = $soapVal;
- $soapmsg[specSet][propSet][type] = 'Datacenter';
- $soapmsg[specSet][propSet][pathSet] = 'vmFolder';
- $soapmsg[specSet][objectSet][obj] = new soapval('obj', false, $dataCenter, false, false, array('type' => 'Datacenter'));
- $soapmsg[specSet][objectSet][skip] = false;
- $temp = $this->process('RetrieveProperties', $soapmsg);
- $vmFolder = $temp[propSet][val];
- unset($temp);
- unset($soapmsg);
- $vmNewFolder = $vmFolder;
- if (0 < strpos($strNewVMName, '\\')) {
- $aryNewFolderVMData = explode('\\', $strNewVMName);
- $intNewArrayLen = count($aryNewFolderVMData) - 1;
- $vmNewName = $aryNewFolderVMData[$intNewArrayLen];
- $i = $intDataCenterFound;
- while ($i < $intNewArrayLen) {
- $strNewFolderName = $aryNewFolderVMData[$i];
- unset($soapmsg);
- $soapmsg[this] = new soapval('_this', false, $this->session_result[searchIndex], false, false, array('type' => 'SearchIndex'));
- $soapmsg[entity] = new soapval('entity', false, $vmNewFolder, false, false, array('type' => 'Folder'));
- $soapmsg[name] = $strNewFolderName;
- $vmNewFolder = $this->process('FindChild', $soapmsg);
- ++$i;
- }
- }
- else {
- $vmNewName = $strNewVMName;
- }
- if (0 < strpos($vmName, '\\')) {
- $aryFolderVMData = explode('\\', $vmName);
- $intArrayLen = count($aryFolderVMData) - 1;
- $vmName = $aryFolderVMData[$intArrayLen];
- $i = $intDataCenterFound;
- while ($i < $intArrayLen) {
- $strFolderName = $aryFolderVMData[$i];
- unset($soapmsg);
- $soapmsg[this] = new soapval('_this', false, $this->session_result[searchIndex], false, false, array('type' => 'SearchIndex'));
- $soapmsg[entity] = new soapval('entity', false, $vmFolder, false, false, array('type' => 'Folder'));
- $soapmsg[name] = $strFolderName;
- $vmFolder = $this->process('FindChild', $soapmsg);
- ++$i;
- }
- }
- unset($soapmsg);
- $soapmsg[this] = new soapval('_this', false, $this->session_result[searchIndex], false, false, array('type' => 'SearchIndex'));
- $soapmsg[entity] = new soapval('entity', false, $vmFolder, false, false, array('type' => 'Folder'));
- $soapmsg[name] = trim($vmName);
- $strVMID = $this->process('FindChild', $soapmsg);
- unset($temp);
- unset($soapmsg);
- $soapmsg[this] = $soapVal;
- $soapmsg[specSet][propSet][type] = 'Datacenter';
- $soapmsg[specSet][propSet][pathSet] = 'hostFolder';
- $soapmsg[specSet][objectSet][obj] = new soapval('obj', false, $dataCenter, false, false, array('type' => 'Datacenter'));
- $soapmsg[specSet][objectSet][skip] = false;
- $temp = propSet;
- $vmHostFolder = $soapmsg[specSet][propSet][pathSet];
- unset($temp);
- unset($soapmsg);
- $soapmsg[this] = $soapVal;
- $soapmsg[specSet][propSet][type] = 'Folder';
- $soapmsg[specSet][propSet][pathSet] = 'childEntity';
- $soapmsg[specSet][objectSet][obj] = new soapval('obj', false, $vmHostFolder, false, false, array('type' => 'Folder'));
- $soapmsg[specSet][objectSet][skip] = false;
- $temp = strpos($vmName, '\\');
- $hostChildEntity = count($aryFolderVMData) - 1;
- unset($temp);
- unset($soapmsg);
- $soapmsg[this] = $soapVal;
- $soapmsg[specSet][propSet][type] = 'ComputeResource';
- $soapmsg[specSet][propSet][pathSet] = 'resourcePool';
- $soapmsg[specSet][objectSet][obj] = new soapval('obj', false, $hostChildEntity, false, false, array('type' => 'ComputeResource'));
- $soapmsg[specSet][objectSet][skip] = false;
- $temp = $soapmsg[specSet][objectSet][skip];
- $FoundResoucePoolMOR = $temp;
- if ($strResoucePoolNameForNewVM != '') {
- unset($soapmsg);
- $soapmsg[this] = new soapval('_this', false, $this->session_result[searchIndex], false, false, array('type' => 'SearchIndex'));
- $soapmsg[entity] = new soapval('entity', false, $FoundResoucePoolMOR, false, false, array('type' => 'ResourcePool'));
- $soapmsg[name] = $strResoucePoolNameForNewVM;
- $FoundResoucePoolMOR = $soapmsg[specSet][propSet][pathSet];
- }
- if (!empty($strDataStoreNameForNewVM)) {
- unset($temp);
- unset($soapmsg);
- $soapmsg[this] = $soapVal;
- $soapmsg[specSet][propSet][type] = 'Datacenter';
- $soapmsg[specSet][propSet][pathSet] = 'datastore';
- $soapmsg[specSet][objectSet][obj] = new soapval('obj', false, $dataCenter, false, false, array('type' => 'Datacenter'));
- $soapmsg[specSet][objectSet][skip] = false;
- $temp = $intNewArrayLen;
- $Datastores = $temp[propSet][val][ManagedObjectReference];
- $DatastoreToCloneTo = '';
- unset($soapmsg);
- $soapmsg[this] = new soapval('_this', false, $this->session_result[propertyCollector], false, false, array('type' => 'PropertyCollector'));
- $soapmsg[specSet][propSet][type] = 'Datastore';
- $soapmsg[specSet][propSet][pathSet] = 'info';
- $soapmsg[specSet][objectSet][obj] = new soapval('obj', false, $Datastore, false, false, array('type' => 'Datastore'));
- $ret = $this->process('RetrieveProperties', $soapmsg);
- $DatastoreToCloneTo = $i;
- break;
- if (empty($DatastoreToCloneTo)) {
- $this->error('VMware Datastore specified not found', array());
- return false;
- }
- }
- $vmDetail = $this->RetrievePropertiesVM($strVMID, 'VirtualMachine', 'guest.guestFullName');
- $strGuestName = new soapval('_this', false, $this->session_result[searchIndex], false, false, array('type' => 'SearchIndex'));
- if (0 < strpos(strtolower($strGuestName), 'windows')) {
- $intOSType = 1509;
- }
- else {
- $intOSType = 1510;
- }
- unset($temp);
- unset($soapmsg);
- $soapmsg[this] = new soapval('_this', false, $strVMID, false, false, array('type' => 'VirtualMachine'));
- $soapmsg[folder] = new soapval('folder', false, $vmNewFolder, false, false, array('type' => 'Folder'));
- $soapmsg[name] = $vmNewName;
- if (!empty($strDataStoreNameForNewVM)) {
- if (!empty($DatastoreToCloneTo)) {
- $location[datastore] = new soapval('datastore', false, $DatastoreToCloneTo, false, false, array('type' => 'Datastore'));
- }
- }
- $location[pool] = new soapval('pool', false, $FoundResoucePoolMOR, false, false, array('type' => 'ResourcePool'));
- $location[transform] = new soapval('transform', false, 'sparse', false, false, array('type' => 'VirtualMachineRelocateTransformation'));
- $spec[location] = new soapval('location', false, $location, false, false, array('xsi:type' => 'VirtualMachineRelocateSpec'));
- $spec[template] = false;
- $intRAMAmountInGB = $intRAMAmountInGB * 1024;
- $VMConfig[memoryMB] = $intRAMAmountInGB;
- $VMConfig[numCPUs] = $intCPUAmount;
- if ($strVMNotes != '') {
- $vmConfig[annotation] = $strVMNotes;
- }
- $spec[config] = new soapval('config', false, $VMConfig, false, false, array('xsi:type' => 'VirtualMachineConfigSpec'));
- $spec[customization] = $this->generateSpec($intOSType, $strOSPassword, $strServerHostName, $strServerDomainName, $strIPAddress, $strDNSServersCommaDelimited, $strSubnetMask, $strGateway, $strTimeZone, $blnHWClockUTC);
- $spec[powerOn] = true;
- $soapmsg[spec] = new soapval('spec', false, $spec, false, false, array('xsi:type' => 'VirtualMachineCloneSpec'));
- $TaskID = array('type' => 'Folder');
- return $TaskID;
- }
- public function generateSpec($intOSType, $strOSPassword, $strServerHostName, $strServerDomainName, $strIPAddress, $strDNSServersCommaDelimited, $strSubnetMask, $strGateway, $strTimeZone, $blnHWClockUTC = false, $strEncryptionKey = '')
- {
- if ($intOSType == 1) {
- $winOptions[changeSID] = true;
- $winOptions[deleteAccounts] = false;
- $spec[options] = new soapval('options', false, $winOptions, false, false, array('xsi:type' => 'CustomizationWinOptions'));
- $password[value] = $strOSPassword;
- $password[plainText] = true;
- $guiUnattended[password] = $password;
- $guiUnattended[timeZone] = 20;
- $guiUnattended[autoLogon] = true;
- $guiUnattended[autoLogonCount] = 1;
- $identity[guiUnattended] = new soapval('guiUnattended', false, $guiUnattended, false, false, array('xsi:type' => 'CustomizationGuiUnattended'));
- $userData[fullName] = 'User';
- $userData[orgName] = 'User';
- $computerName[name] = $strServerHostName;
- $userData[computerName] = new soapval('computerName', false, $computerName, false, false, array('xsi:type' => 'CustomizationFixedName'));
- $identity[userData] = new soapval('userData', false, $userData, false, false, array('xsi:type' => 'CustomizationUserData'));
- $ip[ipAddress] = $strIPAddress;
- $adapter[ip] = new soapval('ip', false, $ip, false, false, array('xsi:type' => 'CustomizationFixedIp'));
- $adapter[subnetMask] = $strSubnetMask;
- $adapter[dnsServerList] = substr($strDNSServersCommaDelimited, 0, strpos($strDNSServersCommaDelimited, ','));
- $adapter[gateway] = $strGateway;
- $nicSettingMap[adapter] = new soapval('adapter', false, $adapter, false, false, array('xsi:type' => 'CustomizationIPSettings'));
- $spec[nicSettingMap] = new soapval('nicSettingMap', false, $nicSettingMap, false, false, array('xsi:type' => 'CustomizationAdapterMapping'));
- }
- else if ($intOSType == 2) {
- $ServerHostName[name] = $strServerHostName;
- $identity[hostName] = new soapval('hostName', false, $ServerHostName, false, false, array('xsi:type' => 'CustomizationFixedName'));
- $identity[domain] = $strServerDomainName;
- $identity[timeZone] = $strTimeZone;
- if (!isset($blnHWClockUTC)) {
- $blnHWClockUTC = false;
- }
- $identity[hwClockUTC] = $blnHWClockUTC;
- $spec[identity] = new soapval('identity', false, $identity, false, false, array('xsi:type' => 'CustomizationLinuxPrep'));
- $aryDNSServerIPs = array();
- if (0 < strpos($strDNSServersCommaDelimited, ',')) {
- $aryDNSServerList = explode(',', $strDNSServersCommaDelimited);
- foreach ($aryDNSServerList as $strDNSServerIP) {
- $aryDNSServerIPs[] = $strDNSServerIP;
- }
- }
- else {
- $aryDNSServerIPs[] = $strDNSServersCommaDelimited;
- }
- $globalIPSettings[dnsServerList] = new soapval('dnsServerList', 'xsd:string', $aryDNSServerIPs, false, false, false);
- $globalIPSettings[dnsSuffixList] = new soapval('dnsSuffixList', 'xsd:string', array($strServerDomainName), false, false, false);
- $spec[globalIPSettings] = new soapval('globalIPSettings', false, $globalIPSettings, false, false, array('xsi:type' => 'CustomizationGlobalIPSettings'));
- $ip[ipAddress] = $strIPAddress;
- $adapter[ip] = new soapval('ip', false, $ip, false, false, array('xsi:type' => 'CustomizationFixedIp'));
- $adapter[subnetMask] = $strSubnetMask;
- $adapter[gateway] = $strGateway;
- $adapter[dnsDomain] = $strServerDomainName;
- $adapter[dnsServerList] = substr($strDNSServersCommaDelimited, 0, strpos($strDNSServersCommaDelimited, ','));
- $nicSettingMap[adapter] = new soapval('adapter', false, $adapter, false, false, array('xsi:type' => 'CustomizationIPSettings'));
- $spec[nicSettingMap] = new soapval('nicSettingMap', false, $nicSettingMap, false, false, array('xsi:type' => 'CustomizationAdapterMapping'));
- }
- return new soapval('customization', false, $spec, false, false, array('xsi:type' => 'CustomizationSpec'));
- }
- }
- function aisovmwarededsrv_ConfigOptions()
- {
- $configarray = array(
- 'Disk Space' => array('Type' => 'text', 'Size' => '7', 'Description' => 'Disk Space In GB'),
- 'Bandwidth' => array('Type' => 'text', 'Size' => '7', 'Description' => 'Bandwidth In Mbps/GB'),
- 'vCPU Amount' => array('Type' => 'text', 'Size' => '2', 'Description' => 'vCPU Amount'),
- 'vRAM' => array('Type' => 'text', 'Size' => '6', 'Description' => 'RAM In GB'),
- 'AutoProvision Folder' => array('Type' => 'text', 'Size' => '15', 'Description' => 'Name'),
- 'AutoProvision Resource Pool' => array('Type' => 'text', 'Size' => '15', 'Description' => 'Name'),
- 'AutoProvision Time zone' => array('Type' => 'text', 'Size' => '15', 'Description' => 'Timezone'),
- 'AutoProvision HW Use UTC' => array('Type' => 'yesno', 'Size' => '1', 'Description' => 'Check to enable'),
- 'AutoProvision Datastore' => array('Type' => 'text', 'Size' => '15', 'Description' => 'Name'),
- 'AutoProvision Email Template' => array('Type' => 'text', 'Size' => '15', 'Description' => 'Name')
- );
- return $configarray;
- }
- function aisovmwarededsrv_UsageUpdate($params)
- {
- $myFile = dirname(__FILE__) . '/UsageUpdate.txt';
- }
- function aisovmwarededsrv_UpdateUsage($params)
- {
- $myFile = dirname(__FILE__) . '/UpdateUsage.txt';
- }
- function aisovmwarededsrv_CreateAccount($params)
- {
- if ($GLOBALS['license'] == 'Dev-7bdd6a5ed79a8a14af40') {
- $blnAKDLS = true;
- }
- else if ($GLOBALS['license'] == 'Leased-abc367f314a7142c44fd') {
- $blnAKDLS = true;
- }
- else {
- $blnAKDLS = false;
- }
- if ($blnAKDLS == false) {
- return 'success';
- }
- global $mstrConfigOptionDiskSpace;
- global $mstrConfigOptionBandwidth;
- global $mstrConfigOptionCPUAmount;
- global $mstrConfigOptionRAM;
- global $mstrUserConfigOptionsExtraDiskSpace;
- global $gstrVMwareDataStoreNameForNewVMs;
- global $mstrConfigOptionAutoProvisionDatastore;
- global $mstrUserConfigOptionsExtraCPU;
- global $mstrUserConfigOptionsExtraRAM;
- global $mstrUserConfigOptionsServerOS;
- global $mstrUserConfigOptionsInstallingCPanel;
- global $mstrUserConfigOptionsExtraBandwidth;
- global $garyVMwareServerOSToTemplateMapping;
- global $mstrConfigOptionAutoProvisionFolder;
- global $mstrConfigOptionAutoProvisionResourcePool;
- global $mstrConfigOptionAutoProvisionTimezone;
- global $mstrConfigOptionAutoProvisionHWUseUTC;
- $serviceid = $params['serviceid'];
- $productid = $params['pid'];
- $table = 'tblhosting';
- $fields = 'userid';
- $where = array('id' => $serviceid);
- $result = select_query($table, $fields, $where, $sort, $sortorder, $limits, $join);
- $useridsearch = mysql_fetch_array($result);
- $userid = $useridsearch[0];
- $intDiskSpaceInGB = $params[$mstrConfigOptionDiskSpace];
- $intBandwidth = $params[$mstrConfigOptionBandwidth];
- $intCPUAmount = $params[$mstrConfigOptionCPUAmount];
- $intRAMAmountInGB = $params[$mstrConfigOptionRAM];
- $strServerOS = $params['configoptions'][$mstrUserConfigOptionsServerOS];
- $intCPanelInstall = $params['configoptions'][$mstrUserConfigOptionsInstallingCPanel];
- $intExtraRAMInGB = $params['configoptions'][$mstrUserConfigOptionsExtraRAM];
- $intExtraCPUs = $params['configoptions'][$mstrUserConfigOptionsExtraCPU];
- $intExtraDiskSpaceInGB = $params['configoptions'][$mstrUserConfigOptionsExtraDiskSpace];
- $intExtraBandwidth = $params['configoptions'][$mstrUserConfigOptionsExtraBandwidth];
- $strPasswordToSet = $params['password'];
- $strHostName = ereg_replace('[^A-Za-z0-9\\_\\-]', '', $params['domain']);
- $strVMwarevSphereURL = $params['serverip'];
- $strVMwarevSphereUsername = $params['serverusername'];
- $strVMwarevSpherePassword = $params['serverpassword'];
- if (!empty($params['configoptions'][$mstrConfigOptionAutoProvisionDatastore])) {
- $strDataStoreNameForNewVM = $params['configoptions'][$mstrConfigOptionAutoProvisionDatastore];
- }
- else if (!empty($gstrVMwareDataStoreNameForNewVMs)) {
- $strDataStoreNameForNewVM = $gstrVMwareDataStoreNameForNewVMs;
- }
- else {
- $strDataStoreNameForNewVM = '';
- }
- $vmNameToClone = $garyVMwareServerOSToTemplateMapping[$strServerOS][0];
- $vmNameToClone .= '-' . $intDiskSpaceInGB;
- $strTemplateDefaultPassword = $garyVMwareServerOSToTemplateMapping[$strServerOS][2];
- $strNewVMFolder = $params['configoptions'][$mstrConfigOptionAutoProvisionFolder];
- if (0 < strlen($strNewVMFolder)) {
- if (substr($strNewVMFolder, -1) != '\\') {
- $strNewVMFolder = $strNewVMFolder . '\\';
- }
- }
- $strNewVMName = $strNewVMFolder . $userid . '-' . $serviceid . '-' . $strHostName;
- $intRAMAmountInGB = (int) $intRAMAmountInGB + (int) $intExtraRAMInGB;
- $intCPUAmount = (int) $intCPUAmount + (int) $intExtraCPUs;
- $strServerDomainName = 'aiso.net';
- $strIPAddress = '10.153.118.141';
- $strDNSServersCommaDelimited = '4.2.2.2,204.117.214.10';
- $strSubnetMask = '255.128.0.0';
- $strGateway = '10.128.0.1';
- $strResoucePoolNameForNewVM = $params['configoptions'][$mstrConfigOptionAutoProvisionResourcePool];
- $strTimeZone = $params['configoptions'][$mstrConfigOptionAutoProvisionTimezone];
- if (empty($strTimeZone)) {
- $strTimeZone = 'America/Los_Angeles';
- }
- if (empty($params['configoptions'][$mstrConfigOptionAutoProvisionHWUseUTC])) {
- $blnHWClockUTC = false;
- }
- else {
- $blnHWClockUTC = true;
- }
- $vm = $strVMwarevSpherePassword;
- $vm->setDebug(0);
- $vm->Login();
- $TaskID = $garyVMwareServerOSToTemplateMapping;
- if (!empty($TaskID)) {
- $table = 'tblcustomfields';
- $fields = 'id';
- $where = array('relid' => $productid);
- $result = select_query($table, $fields, $where, $sort, $sortorder, $limits, $join);
- $customfieldsearch = mysql_fetch_array($result);
- $customfieldid = $where;
- if (!empty($customfieldid)) {
- $table = 'tblcustomfieldsvalues';
- $fields = 'fieldid';
- $where = array('relid' => $serviceid, 'fieldid' => $customfieldid);
- $result = ($intBandwidth = $params[$mstrConfigOptionBandwidth]);
- $customfieldsearch = $intCPUAmount;
- $customfieldidfound = $customfieldsearch[0];
- if (empty($customfieldidfound)) {
- $table = 'tblcustomfieldsvalues';
- $array = array('relid' => $serviceid, 'fieldid' => $customfieldid, 'value' => $strNewVMName);
- $params;
- }
- else {
- $table = 'tblcustomfieldsvalues';
- $array = array('value' => $strNewVMName);
- $where = array('relid' => $serviceid, 'fieldid' => $customfieldidfound);
- update_query($table, $array, $where);
- }
- $result = 'success';
- }
- else {
- $result = 'VMware AutoProvision Failed: Failed To Add New VM Name (' . $strNewVMName . ') To Service';
- }
- }
- else {
- $result = 'VMware AutoProvision Failed: ' . $vm->GetErrorMessageString();
- }
- $vm->Logout();
- return $result;
- }
- function aisovmwarededsrv_TerminateAccount($params)
- {
- $successful = true;
- if ($successful) {
- $result = 'success';
- }
- else {
- $result = 'Error Message Goes Here...';
- }
- return $result;
- }
- function aisovmwarededsrv_SuspendAccount($params)
- {
- global $mstrVMWareWebServerCustomFieldName;
- $strVMWareServerName = $params['customfields'][$mstrVMWareWebServerCustomFieldName];
- if (strlen($mstrVMWareWebServerCustomFieldName) < 1) {
- return 'Server Name Could Not Be Found';
- }
- $intServerID = $params['serverid'];
- $select_modules = 'SELECT type,ipaddress,username,password FROM tblservers WHERE id = ' . $intServerID;
- $modules_rows = full_query($select_modules);
- if ($modules_rows) {
- $aryRowData = mysql_fetch_row($modules_rows);
- $strModuleName = $aryRowData[0];
- $strVMwarevSphereURL = $aryRowData[1];
- $strVMwarevSphereUsername = $aryRowData[2];
- $strVMwarevSpherePassword = decrypt($aryRowData[3]);
- }
- else {
- return 'Server Info Could Not Be Found, please alert us of this issue';
- }
- $vm = $strVMwarevSpherePassword;
- $vm->setDebug(0);
- $vm->Login();
- $strVMID = $vm->FindVMByName($strVMWareServerName);
- if (0 < strpos($strVMID, 'error!!')) {
- if (strlen($strVMID) < 1) {
- $vm->Logout();
- return 'Server Info Could Not Be Retreived From VMware';
- }
- }
- else {
- $vm->Logout();
- return 'Server Info Could Not Be Retreived From VMware';
- }
- $vmDetail = $vm->RetrievePropertiesVM($strVMID, 'VirtualMachine', 'runtime.powerState');
- $strPowerState = $vmDetail['propSet']['val'];
- if (strtolower($strPowerState) == 'poweredon') {
- $vm->ShutdownVMGuest($strVMID);
- $successful = true;
- }
- else {
- $vm->Logout();
- return 'Server Could Not Be Powered Off Because It Is Already Off';
- }
- $vm->Logout();
- if ($successful) {
- $result = 'success';
- }
- else {
- $result = 'Coult Not Shutdown Guest For Some Reason';
- }
- return $result;
- }
- function aisovmwarededsrv_UnsuspendAccount($params)
- {
- global $mstrVMWareWebServerCustomFieldName;
- $strVMWareServerName = $params['customfields'][$mstrVMWareWebServerCustomFieldName];
- if (strlen($mstrVMWareWebServerCustomFieldName) < 1) {
- return 'Server Name Could Not Be Found';
- }
- $intServerID = $params['serverid'];
- $select_modules = 'SELECT type,ipaddress,username,password FROM tblservers WHERE id = ' . $intServerID;
- $modules_rows = full_query($select_modules);
- if ($modules_rows) {
- $aryRowData = mysql_fetch_row($modules_rows);
- $strModuleName = $aryRowData[0];
- $strVMwarevSphereURL = $aryRowData[1];
- $strVMwarevSphereUsername = $aryRowData[2];
- $strVMwarevSpherePassword = decrypt($aryRowData[3]);
- }
- else {
- return 'Server Info Could Not Be Found, please alert us of this issue';
- }
- $vm = $strVMwarevSpherePassword;
- $vm->setDebug(0);
- $vm->Login();
- $strVMID = $vm->FindVMByName($strVMWareServerName);
- if (0 < strpos($strVMID, 'error!!')) {
- if (strlen($strVMID) < 1) {
- $vm->Logout();
- return 'Server Info Could Not Be Retreived From VMware';
- }
- }
- else {
- $vm->Logout();
- return 'Server Info Could Not Be Retreived From VMware';
- }
- $vmDetail = $vm->RetrievePropertiesVM($strVMID, 'VirtualMachine', 'runtime.powerState');
- $strPowerState = $vmDetail['propSet']['val'];
- if (strtolower($strPowerState) == 'poweredoff') {
- $vm->StartVM($strVMID);
- $successful = true;
- }
- else {
- $vm->Logout();
- return 'Server Could Not Be Powered On Because It Is Already On';
- }
- $vm->Logout();
- if ($successful) {
- $result = 'success';
- }
- else {
- $result = 'Coult Not Power On For Some Reason';
- }
- return $result;
- }
- function aisovmwarededsrv_ChangePackage($params)
- {
- if ($successful) {
- $result = 'success';
- }
- else {
- $result = 'Error Message Goes Here...';
- }
- return $result;
- }
- function aisovmwarededsrv_ClientArea($params)
- {
- global $_LANG;
- global $mstrVMWareWebServerCustomFieldName;
- global $mstrConfigOptionDiskSpace;
- global $mstrConfigOptionBandwidth;
- global $mstrConfigOptionCPUAmount;
- global $mstrConfigOptionRAM;
- global $mstrUserConfigOptionsExtraDiskSpace;
- global $mstrUserConfigOptionsExtraCPU;
- global $mstrUserConfigOptionsExtraRAM;
- global $mstrUserConfigOptionsServerOS;
- global $blnAKDLS;
- $blnDoReturnInsteadOfErrorPrint = False;
- $id = $params['serviceid'];
- $intServerID = $params['serverid'];
- $select_modules = 'SELECT type,ipaddress,username,password FROM tblservers WHERE id = ' . $intServerID;
- $modules_rows = full_query($select_modules);
- if ($modules_rows) {
- $aryRowData = mysql_fetch_row($modules_rows);
- $strModuleName = $aryRowData[0];
- $strVMwarevSphereURL = $aryRowData[1];
- $strVMwarevSphereUsername = $aryRowData[2];
- $strVMwarevSpherePassword = decrypt($aryRowData[3]);
- }
- else {
- $strErrorMessage = 'Server Info Could Not Be Found, please alert us of this issue';
- if ($blnDoReturnInsteadOfErrorPrint == true) {
- return 'Server Info Could Not Be Found, please alert us of this issue';
- }
- }
- $strVMWareServerName = $params['customfields'][$mstrVMWareWebServerCustomFieldName];
- if (strlen($mstrVMWareWebServerCustomFieldName) < 1) {
- $strErrorMessage = 'VM Info Could Not Be Found, please alert us of this issue';
- if ($blnDoReturnInsteadOfErrorPrint == true) {
- return 'VM Info Could Not Be Found, please alert us of this issue';
- }
- }
- $intServiceID = $params['serviceid'];
- $select_hosting = 'SELECT dedicatedip,assignedips FROM tblhosting WHERE id = ' . $intServiceID;
- $hosting_row = full_query($select_hosting);
- if ($hosting_row) {
- $aryRowData = mysql_fetch_assoc($hosting_row);
- $strAssignedIPAddress = $aryRowData['dedicatedip'];
- if (0 < strlen($aryRowData['assignedips'])) {
- $strAssignedIPAddresses = $aryRowData['assignedips'];
- }
- }
- $strAssignedIPAddresses = str_replace("\r\n", ', ', $strAssignedIPAddresses);
- $fltProductDiskSpace = $params[$mstrConfigOptionDiskSpace];
- $fltExtraDiskSpace = $params['configoptions'][$mstrUserConfigOptionsExtraDiskSpace];
- $fltTotalDiskSpace = $fltProductDiskSpace + $fltExtraDiskSpace;
- $fltProdcutBandwidth = $params[$mstrConfigOptionBandwidth];
- $fltProductCPUs = $params[$mstrConfigOptionCPUAmount];
- $fltExtraCPUs = floatval($params['configoptions'][$mstrUserConfigOptionsExtraCPU]);
- $fltTotalCPUs = $fltProductCPUs + $fltExtraCPUs;
- $fltProductRAM = $params[$mstrConfigOptionRAM];
- $fltExtraRAM = floatval($params['configoptions'][$mstrUserConfigOptionsExtraRAM]);
- $fltTotalRAM = $fltProductRAM + $fltExtraRAM;
- $strServerLoginUsername = $params['username'];
- $strServerLoginPassword = $params['password'];
- $vm = $strVMwarevSpherePassword;
- $vm->setDebug(0);
- $vm->Login();
- if (0 < strlen($vm->GetErrorMessageString())) {
- if ($GLOBALS['_SESSION']['adminloggedinstatus'] == 'true') {
- print($vm->GetErrorMessageString());
- exit();
- }
- else {
- $strErrorMessage = 'Server Could Not Be Logged Into, please alert us of this issue<br/><br/>' . "\n" . '';
- if ($blnDoReturnInsteadOfErrorPrint == true) {
- return 'Server Could Not Be Logged Into, please alert us of this issue<br/><br/>' . "\n" . '';
- }
- }
- }
- $strVMID = $vm->FindVMByName($strVMWareServerName);
- if (0 < strpos($strVMID, 'error!!')) {
- if (strlen($strVMID) < 1) {
- $strErrorMessage = 'VMware VM Could Not Be Retreived, please alert us of this issue <!--' . $strVMWareServerName . '-->';
- if ($blnDoReturnInsteadOfErrorPrint == true) {
- return 'VMware VM Could Not Be Retreived, please alert us of this issue <!--' . $strVMWareServerName . '-->';
- }
- }
- }
- else {
- $strErrorMessage = 'VMware VM Could Not Be Retreived, please alert us of this issue <!--' . $strVMWareServerName . '-->';
- return 'VMware VM Could Not Be Retreived, please alert us of this issue <!--' . $strVMWareServerName . '-->';
- }
- $vmDetail = $vm->RetrievePropertiesVM($strVMID, 'VirtualMachine', 'guestHeartbeatStatus');
- $strGuestOSHBStatus = $vmDetail['propSet']['val'];
- if (strtolower($strGuestOSHBStatus) == 'green') {
- $strGuestHeartbeatStatus = $_LANG['VMwareGuestOSHeartbeatGreen'];
- }
- else if (strtolower($strGuestOSHBStatus) == 'yellow') {
- $strGuestHeartbeatStatus = $_LANG['VMwareGuestOSHeartbeatYellow'];
- }
- else if (strtolower($strGuestOSHBStatus) == 'red') {
- $strGuestHeartbeatStatus = $_LANG['VMwareGuestOSHeartbeatRed'];
- }
- else if (strtolower($strGuestOSHBStatus) == 'gray') {
- $strGuestHeartbeatStatus = $_LANG['VMwareGuestOSHeartbeatGray'];
- }
- else {
- $strGuestHeartbeatStatus = $_LANG['VMwareGuestOSHeartbeatGray'];
- }
- $vmDetail = $vm->RetrievePropertiesVM($strVMID, 'VirtualMachine', 'runtime.powerState');
- $strPowerState = $vmDetail['propSet']['val'];
- if (strtolower($strPowerState) == 'poweredon') {
- $strVmwarePowerState = $_LANG['VMwareVMPoweredOn'];
- $strPowerCommandURL = 'turnoffserver';
- $strPowerCommandImage = 'power-off.gif';
- $strPowerCommandLangLink = $_LANG['VMwarePowerOffLink'];
- $strPowerCommandLangLinkText = $_LANG['VMwarePowerOffLinkText'];
- }
- else if (strtolower($strPowerState) == 'poweredoff') {
- $strVmwarePowerState = $_LANG['VMwareVMPoweredOff'];
- $strPowerCommandURL = 'turnonserver';
- $strPowerCommandImage = 'power-on.gif';
- $strPowerCommandLangLink = $_LANG['VMwarePowerOnLink'];
- $strPowerCommandLangLinkText = $_LANG['VMwarePowerOnLinkText'];
- }
- $vmDetail = $params;
- $strToolsVersion = $GLOBALS['mstrConfigOptionDiskSpace'];
- $vmDetail = $GLOBALS['mstrConfigOptionRAM'];
- $strToolsStatus = $mstrUserConfigOptionsExtraCPU;
- if (strtolower($strToolsStatus) == 'toolsok') {
- $strVmwareToolsStatus = $blnDoReturnInsteadOfErrorPrint;
- $intVmwareToolsStatus = 1256;
- }
- else if (strtolower($strToolsStatus) == 'toolsold') {
- $params;
- $intVmwareToolsStatus = 1257;
- }
- else if (strtolower($strToolsStatus) == 'toolsnotinstalled') {
- $strVmwareToolsStatus = $_LANG['VMwareToolsNotInstalled'];
- $intVmwareToolsStatus = 1258;
- }
- else if (strtolower($strToolsStatus) == 'toolsnotrunning') {
- $strVmwareToolsStatus = $_LANG['VMwareToolsNotRunning'];
- $intVmwareToolsStatus = 1259;
- }
- else {
- $strVmwareToolsStatus = ($strVMwarevSphereUsername = $aryRowData[2]);
- $intVmwareToolsStatus = -1;
- }
- $vmDetail = $vm->RetrievePropertiesVM($strVMID, 'VirtualMachine', 'guest.disk');
- if (isset($vmDetail['propSet']['val'])) {
- if (isset($vmDetail['propSet']['val']['GuestDiskInfo'][0])) {
- $vmDisk = $vmDetail['propSet']['val']['GuestDiskInfo'];
- }
- else {
- $vmDisk[0] = $vmDetail['propSet']['val']['GuestDiskInfo'];
- }
- $strVMwareDiskInfo = '';
- $d = 1256;
- while ($d < count($vmDisk)) {
- $size = (list() = $aryRowData);
- $free = $strAssignedIPAddresses;
- $totalfree = $totalfree + $free;
- $perc = $mstrUserConfigOptionsExtraDiskSpace;
- $used = $size - $free;
- $objChart = ($fltProdcutBandwidth = $params[$mstrConfigOptionBandwidth]);
- $objChart->SetImageOutputOption(3);
- $objChart->SetHeaderName($vmDisk[$d]['diskPath']);
- $objChart->AddColor('#4a38fa');
- $objChart->AddColor('#50CA43');
- $objChart->AddValue(0, $used, 'Used');
- $objChart->AddValue(0, $free, 'Free');
- $vmDiskChartData = $fltProductRAM;
- $params;
- unset($objChart);
- $strVMwareDiskInfo .= '<img title=\'Size: ' . $size . $_LANG['VMwareDiskSpaceGraphMBUsed'] . $used . $_LANG['VMwareDiskSpaceGraphMBFree'] . $free . $_LANG['VMwareDiskSpaceGraphMB'] . '\' src=\'' . $vmDiskChartImageData . '\'> ';
- ++$d;
- }
- $strVMwareDiskInfo .= '<br/>' . $_LANG['VMwareDiskSpaceGraphTotalVMFreeSpace'] . ' ' . $totalfree . $_LANG['VMwareDiskSpaceGraphMB'];
- }
- else {
- $strVMwareDiskInfo = $blnDoReturnInsteadOfErrorPrint == true;
- }
- $vmDetail = $vm->RetrievePropertiesVM($strVMID, 'VirtualMachine', 'guest.hostName');
- $strHostName = strlen($strVMID);
- $vmDetail = $blnDoReturnInsteadOfErrorPrint;
- $strGuestIPAddress = $vmDetail;
- $vmDetail = $strGuestOSHBStatus;
- $strGuestName = $strGuestOSHBStatus;
- $strRecentTask = '';
- $vmDetail = strtolower($strGuestOSHBStatus);
- $strRecentTaskId = $vmDetail['propSet']['val'];
- if (is_array($strRecentTaskId)) {
- $_LANG;
- if (is_array($strRecentTaskId['ManagedObjectReference'])) {
- $intMostRecentTaskID = count($strRecentTaskId['ManagedObjectReference']) - 1;
- $strTaskID = $strRecentTaskId['ManagedObjectReference'][$intMostRecentTaskID];
- }
- $vmDetail;
- $strRecentTask = $strVmwarePowerState;
- if (isset($vmDetail['propSet']['val']['state'])) {
- if ($vmDetail['propSet']['val']['state'] == 'success') {
- $strRecentTask .= ', <b>' . $_LANG['VMwareTaskCompleted'] . '</b>';
- }
- else {
- $strRecentTask .= ', <b>' . $_LANG['VMwareTaskInProgress'] . '...</b>';
- }
- }
- }
- else {
- $strRecentTask = $strPowerCommandImage;
- }
- $blnVMwareToolsMounted = false;
- $vmHardwareDetail = $vm->RetrievePropertiesVM($strVMID, 'VirtualMachine', 'config.hardware');
- if (isset($vmHardwareDetail['propSet']['val']['numCPU'])) {
- $fltTotalVMCPUs = floatval($vmHardwareDetail['propSet']['val']['numCPU']);
- }
- if (isset($vmHardwareDetail['propSet']['val']['memoryMB'])) {
- $fltTotalVMRAMInMB = floatval($vmHardwareDetail['propSet']['val']['memoryMB']);
- }
- if (isset($vmHardwareDetail['propSet']['val']['device'])) {
- $aryVMHardwareDevices = $strToolsStatus;
- if (is_array($aryVMHardwareDevices)) {
- $blnVMwareToolsMounted = true;
- break;
- }
- }
- if (strtolower($strPowerState) == 'poweredon') {
- if ($blnVMwareToolsMounted == true) {
- $strVMWareToolsMountUnMountURL = 'unmountvmwaretools';
- $strVMWareToolsMountUnMountImage = 'vmware-unmount-tools.gif';
- $strVMWareToolsMountUnMountLangLink = $strVMID;
- $strVMWareToolsMountUnMountLangLinkText = $vmDetail['propSet'];
- }
- else {
- $strVMWareToolsMountUnMountURL = 'mountvmwaretools';
- $strVMWareToolsMountUnMountImage = 'vmware-mount-tools.gif';
- $strVMWareToolsMountUnMountLangLink = ($vmDisk = $vmDetail['propSet']['val']['GuestDiskInfo']);
- $strVMWareToolsMountUnMountLangLinkText = $_LANG['VMwareMountVMwareToolsLinkText'];
- }
- }
- $vm->Logout();
- if (0 < strpos($strVMWareServerName, '\\')) {
- $aryFolderVMData = $d;
- $strVMWareServerNameDisplay = $aryFolderVMData[count($aryFolderVMData) - 1];
- }
- else {
- $strVMWareServerNameDisplay = $d;
- }
- $results['vars'] = array(
- 'LANG' => $_LANG,
- 'strErrorMessage' => $strErrorMessage,
- 'strVMWareServerNameDisplay' => $strVMWareServerNameDisplay,
- 'strVmwarePowerState' => $strVmwarePowerState,
- 'strGuestHeartbeatStatus' => $strGuestHeartbeatStatus,
- 'fltTotalCPUs' => $fltTotalCPUs,
- 'fltTotalVMCPUs' => $fltTotalVMCPUs,
- 'fltTotalRAM' => $fltTotalRAM,
- 'fltTotalVMRAMInMB' => $fltTotalVMRAMInMB,
- 'strAssignedIPAddress' => $strAssignedIPAddress,
- 'strAssignedIPAddresses' => $strAssignedIPAddresses,
- 'strGuestIPAddress' => $strGuestIPAddress,
- 'strGuestName' => $strGuestName,
- 'strHostName' => $strHostName,
- 'strVmwareToolsStatus' => $strVmwareToolsStatus,
- 'strToolsVersion' => $strToolsVersion,
- 'strRecentTask' => $strRecentTask,
- 'strVMwareDiskInfo' => $strVMwareDiskInfo,
- 'strServerLoginUsername' => $strServerLoginUsername,
- 'strServerLoginPassword' => $strServerLoginPassword,
- 'strPowerCommandURL' => $strPowerCommandURL,
- 'strPowerCommandImage' => $strPowerCommandImage,
- 'strPowerCommandLangLink' => $strPowerCommandLangLink,
- 'strPowerCommandLangLinkText' => $strPowerCommandLangLinkText,
- 'strVMWareToolsMountUnMountURL' => $strVMWareToolsMountUnMountURL,
- 'strVMWareToolsMountUnMountImage' => $strVMWareToolsMountUnMountImage,
- 'strVMWareToolsMountUnMountLangLink' => $strVMWareToolsMountUnMountLangLink,
- 'strVMWareToolsMountUnMountLangLinkText' => $strVMWareToolsMountUnMountLangLinkText,
- 'configoptions' => array(),
- 'customfields' => array()
- );
- return $results;
- }
- function aisovmwarededsrv_ClientAreaCustomButtonArray()
- {
- global $_LANG;
- global $mstrVMWareWebServerCustomFieldName;
- global $blnAKDLS;
- if ($GLOBALS['license'] == 'Dev-7bdd6a5ed79a8a14af40') {
- $blnAKDLS = true;
- }
- else if ($GLOBALS['license'] == 'Leased-abc367f314a7142c44fd') {
- $blnAKDLS = true;
- }
- else {
- $blnAKDLS = false;
- }
- if ($blnAKDLS == false) {
- $strVMwareValue = VMWareGetWHMCSCustomFieldValue($mstrVMWareWebServerCustomFieldName, $GLOBALS['packageid'], $GLOBALS['id']);
- }
- else if (isset($GLOBALS['smarty']->_tpl_vars['customfields'][$mstrVMWareWebServerCustomFieldName])) {
- $strVMwareValue = $GLOBALS['smarty']->_tpl_vars['customfields'][$mstrVMWareWebServerCustomFieldName];
- }
- if ($blnAKDLS == false) {
- if (0 < strlen($strVMwareValue)) {
- $id = $GLOBALS['id'];
- $intServerID = $GLOBALS['smarty']->_tpl_vars['serverdata']['id'];
- $server_result = select_query('tblservers', 'type,ipaddress,username,password', array('id' => $intServerID), '', '', '', '');
- $aryRowData = mysql_fetch_array($server_result);
- if (1 < count($aryRowData)) {
- $strModuleName = $aryRowData[0];
- $strVMwarevSphereURL = $aryRowData[1];
- $strVMwarevSphereUsername = $aryRowData[2];
- $strVMwarevSpherePassword = decrypt($aryRowData[3]);
- }
- else {
- return array();
- }
- $strVMWareServerName = $strVMwareValue;
- if (strlen($mstrVMWareWebServerCustomFieldName) < 1) {
- return array();
- }
- $strServerLoginUsername = $GLOBALS['smarty']->_tpl_vars['serverdata']['username'];
- $strServerLoginPassword = $GLOBALS['smarty']->_tpl_vars['serverdata']['password'];
- $vm = $strVMwarevSpherePassword;
- $vm->setDebug(0);
- $vm->Login();
- if (0 < strlen($vm->GetErrorMessageString())) {
- if ($GLOBALS['_SESSION']['adminloggedinstatus'] == 'true') {
- print($vm->GetErrorMessageString());
- exit();
- }
- else {
- return array();
- }
- }
- $strVMID = $vm->FindVMByName($strVMWareServerName);
- if (0 < strpos($strVMID, 'error!!')) {
- if (strlen($strVMID) < 1) {
- return array();
- }
- }
- else {
- return array();
- }
- $vmDetail = $vm->RetrievePropertiesVM($strVMID, 'VirtualMachine', 'runtime.powerState');
- $strPowerState = $vmDetail['propSet']['val'];
- $blnVMwareToolsMounted = false;
- $vmHardwareDetail = $vm->RetrievePropertiesVM($strVMID, 'VirtualMachine', 'config.hardware');
- if (isset($vmHardwareDetail['propSet']['val']['device'])) {
- $aryVMHardwareDevices = $vmHardwareDetail['propSet']['val']['device'];
- if (is_array($aryVMHardwareDevices)) {
- $blnVMwareToolsMounted = true;
- break;
- }
- }
- $vm->Logout();
- if (strtolower($strPowerState) == 'poweredon') {
- $strVMwarePowerButtonLang = $_LANG['VMwarePowerOffLink'];
- $strVMwarePowerButtonModuleFunction = 'turnoffserver';
- }
- else {
- $strVMwarePowerButtonLang = $_LANG['VMwarePowerOnLink'];
- $strVMwarePowerButtonModuleFunction = 'turnonserver';
- }
- if ($blnVMwareToolsMounted == true) {
- $strVMwareToolsMountButtonLang = $_LANG['VMwareUnmountVMwareToolsLink'];
- $strVMwareToolsMountButtonModuleFunction = 'unmountvmwaretools';
- }
- else {
- $strVMwareToolsMountButtonLang = $_LANG['VMwareMountVMwareToolsLink'];
- $strVMwareToolsMountButtonModuleFunction = 'mountvmwaretools';
- }
- $buttonarray = array($strVMwarePowerButtonLang => $strVMwarePowerButtonModuleFunction, $strVMwareToolsMountButtonLang => $strVMwareToolsMountButtonModuleFunction, $_LANG['VMwareUpdateVMwareToolsLink'] => 'updatevmwaretools');
- if (strtolower($strPowerState) == 'poweredon') {
- $buttonarrayappend = array($_LANG['VMwareHardRebootServerLink'] => 'hardrebootserver', $_LANG['VMwareSoftRebootServerLink'] => 'softrebootserver');
- $buttonarray = array_merge($buttonarray, $buttonarrayappend);
- }
- return $buttonarray;
- }
- }
- if ($blnAKDLS == false) {
- $buttonarray = array($_LANG['VMwareHardRebootServerLink'] => 'hardrebootserver', $_LANG['VMwareSoftRebootServerLink'] => 'softrebootserver', $_LANG['VMwarePowerOffLink'] => 'turnoffserver', $_LANG['VMwarePowerOnLink'] => 'turnonserver', $_LANG['VMwareMountVMwareToolsLink'] => 'mountvmwaretools', $_LANG['VMwareUnmountVMwareToolsLink'] => 'unmountvmwaretools', $_LANG['VMwareUpdateVMwareToolsLink'] => 'updatevmwaretools');
- }
- else {
- $buttonarray = array($_LANG['VMwareHardRebootServerLink'] => 'hardrebootserver', $_LANG['VMwareSoftRebootServerLink'] => 'softrebootserver', $_LANG['VMwarePowerOffLink'] => 'turnoffserver', $_LANG['VMwarePowerOnLink'] => 'turnonserver', $_LANG['VMwareMountVMwareToolsLink'] => 'mountvmwaretools', $_LANG['VMwareUnmountVMwareToolsLink'] => 'unmountvmwaretools', $_LANG['VMwareUpdateVMwareToolsLink'] => 'updatevmwaretools', 'Create Snapshot' => 'createsnapshot', 'List Snapshots' => 'listsnapshots', 'VM Console' => 'vmconsole', 'Bandwidth Usage' => 'bandwidthusage', 'Emergency Support' => 'emergencysupport', $_LANG['VMwareManageDNSZoneFilesLink'] => 'managednszonefiles', 'Add/Edit Zone File' => 'editdnszonefiles');
- }
- return $buttonarray;
- }
- function aisovmwarededsrv_hardrebootserver($params)
- {
- global $_LANG;
- global $mstrVMWareWebServerCustomFieldName;
- $strVMWareServerName = $params['customfields'][$mstrVMWareWebServerCustomFieldName];
- if (strlen($mstrVMWareWebServerCustomFieldName) < 1) {
- return 'Server Name Could Not Be Found';
- }
- $a2 = '';
- $intServerID = $params['serverid'];
- $select_modules = 'SELECT type,ipaddress,username,password FROM tblservers WHERE id = ' . $intServerID;
- $modules_rows = full_query($select_modules);
- if ($modules_rows) {
- $aryRowData = mysql_fetch_row($modules_rows);
- $strModuleName = $aryRowData[0];
- $strVMwarevSphereURL = $aryRowData[1];
- $strVMwarevSphereUsername = $aryRowData[2];
- $strVMwarevSpherePassword = $GLOBALS['_LANG'];
- }
- else {
- return 'Server Info Could Not Be Found, please alert us of this issue';
- }
- $strErrorMessageArea = 'style="display:none;"';
- $strErrorMessage = '';
- if ($_POST['a2'] == 'rs') {
- $vm = strlen($mstrVMWareWebServerCustomFieldName);
- $vm->setDebug(0);
- $vm->Login();
- $strVMID = $modules_rows;
- if (0 < strpos($strVMID, 'error!!')) {
- if (strlen($strVMID) < 1) {
- $strErrorMessageArea = '';
- $strErrorMessage = 'Server Info Could Not Be Retreived From VMware, please contact us.';
- }
- }
- else {
- $strErrorMessageArea = '';
- $strErrorMessage = 'Server Info Could Not Be Retreived From VMware, please contact us.';
- }
- if ($strVMID != '') {
- if ($strErrorMessage == '') {
- $vmDetail = decrypt($aryRowData[3]);
- $strPowerState = $vmDetail['propSet']['val'];
- if (strtolower($strPowerState) == 'poweredon') {
- $vm->ResetVM($strVMID);
- }
- else {
- $strErrorMessageArea = '';
- $strErrorMessage = 'Server Could Not Be Hard Rebooted Because It Is Off';
- }
- }
- }
- $vm->Logout();
- if ($strErrorMessage == '') {
- $a2 = 'rs';
- }
- }
- if (0 < strpos($strVMWareServerName, '\\')) {
- $aryFolderVMData = strpos($strVMID, 'error!!');
- $strVMWareServerNameDisplay = $strErrorMessage;
- }
- else {
- $strVMWareServerNameDisplay = $strErrorMessage == '';
- }
- $pagearray = array(
- 'templatefile' => 'hardrebootserver',
- 'breadcrumb' => ' > <a href="#">' . $_LANG['VMwareHardRebootServerLink'] . '</a>',
- 'vars' => array('LANG' => $_LANG, 'servername' => $strVMWareServerNameDisplay, 'a2' => $a2, 'strErrorMessage' => $strErrorMessage, 'strErrorMessageArea' => $strErrorMessageArea)
- );
- return $pagearray;
- }
- function aisovmwarededsrv_softrebootserver($params)
- {
- global $_LANG;
- global $mstrVMWareWebServerCustomFieldName;
- $strVMWareServerName = $params['customfields'][$mstrVMWareWebServerCustomFieldName];
- if (strlen($mstrVMWareWebServerCustomFieldName) < 1) {
- return 'Server Name Could Not Be Found';
- }
- $a2 = '';
- $intServerID = $params['serverid'];
- $select_modules = 'SELECT type,ipaddress,username,password FROM tblservers WHERE id = ' . $intServerID;
- $modules_rows = full_query($select_modules);
- if ($modules_rows) {
- $aryRowData = mysql_fetch_row($modules_rows);
- $strModuleName = $aryRowData[0];
- $strVMwarevSphereURL = $aryRowData[1];
- $strVMwarevSphereUsername = $aryRowData[2];
- $strVMwarevSpherePassword = decrypt($aryRowData[3]);
- }
- else {
- return 'Server Info Could Not Be Found, please alert us of this issue';
- }
- $strErrorMessageArea = 'style="display:none;"';
- $strErrorMessage = '';
- if ($_POST['a2'] == 'rs') {
- $vm = $strVMwarevSpherePassword;
- $vm->setDebug(0);
- $vm->Login();
- $strVMID = $vm->FindVMByName($strVMWareServerName);
- if (0 < strpos($strVMID, 'error!!')) {
- if (strlen($strVMID) < 1) {
- $strErrorMessageArea = '';
- $strErrorMessage = 'Server Info Could Not Be Retreived From VMware, please contact us.';
- }
- }
- else {
- $strErrorMessageArea = '';
- $strErrorMessage = 'Server Info Could Not Be Retreived From VMware, please contact us.';
- }
- if ($strVMID != '') {
- if ($strErrorMessage == '') {
- $vmDetail = $vm->RetrievePropertiesVM($strVMID, 'VirtualMachine', 'guest.toolsStatus');
- $strToolsStatus = $vmDetail['propSet']['val'];
- if (strtolower($strToolsStatus) == 'toolsok') {
- }
- else if (strtolower($strToolsStatus) == 'toolsold') {
- }
- else if (strtolower($strToolsStatus) == 'toolsnotinstalled') {
- $strErrorMessageArea = '';
- $strErrorMessage = 'VMware Tools are not installed, please install the tools to do a soft reboot.';
- }
- else if (strtolower($strToolsStatus) == 'toolsnotrunning') {
- $strErrorMessageArea = '';
- $strErrorMessage = 'VMware Tools are installed, but not running. Please start the VMware tools\' services to do a soft reboot.';
- }
- else {
- $strErrorMessageArea = '';
- $strErrorMessage = 'VMware Tools are in an unknown state, please install the tools or check their status and correct it to do a soft reboot.';
- }
- }
- }
- if ($strVMID != '') {
- if ($strErrorMessage == '') {
- $vmDetail = mysql_fetch_row($modules_rows);
- $strPowerState = $vmDetail['propSet']['val'];
- if (strtolower($strPowerState) == 'poweredon') {
- $vm->RebootVMGuest($strVMID);
- }
- else {
- $strErrorMessageArea = '';
- $strErrorMessage = 'Server Could Not Be Soft Rebooted Because It Is Off';
- }
- }
- }
- $vm->Logout();
- if ($strErrorMessage == '') {
- $a2 = 'rs';
- }
- }
- if (0 < strpos($strVMWareServerName, '\\')) {
- $aryFolderVMData = $strVMwarevSphereUsername;
- $strVMWareServerNameDisplay = $vm;
- }
- else {
- $strVMWareServerNameDisplay = $strVMID;
- }
- $pagearray = array(
- 'templatefile' => 'softrebootserver',
- 'breadcrumb' => ' > <a href="#">' . $_LANG['VMwareSoftRebootServerLink'] . '</a>',
- 'vars' => array('LANG' => $_LANG, 'servername' => $strVMWareServerNameDisplay, 'a2' => $a2, 'strErrorMessage' => $strErrorMessage, 'strErrorMessageArea' => $strErrorMessageArea)
- );
- return $pagearray;
- }
- function aisovmwarededsrv_turnoffserver($params)
- {
- global $_LANG;
- global $mstrVMWareWebServerCustomFieldName;
- $strVMWareServerName = $params['customfields'][$mstrVMWareWebServerCustomFieldName];
- if (strlen($mstrVMWareWebServerCustomFieldName) < 1) {
- return 'Server Name Could Not Be Found';
- }
- $a2 = '';
- $intServerID = $params['serverid'];
- $select_modules = 'SELECT type,ipaddress,username,password FROM tblservers WHERE id = ' . $intServerID;
- $modules_rows = full_query($select_modules);
- if ($modules_rows) {
- $aryRowData = mysql_fetch_row($modules_rows);
- $strModuleName = $aryRowData[0];
- $strVMwarevSphereURL = $aryRowData[1];
- $strVMwarevSphereUsername = $aryRowData[2];
- $strVMwarevSpherePassword = decrypt($aryRowData[3]);
- }
- else {
- return 'Server Info Could Not Be Found, please alert us of this issue';
- }
- $strErrorMessageArea = 'style="display:none;"';
- $strErrorMessage = '';
- if ($_POST['a2'] == 'rs') {
- $vm = $strVMwarevSpherePassword;
- $vm->setDebug(0);
- $vm->Login();
- $strVMID = $vm->FindVMByName($strVMWareServerName);
- if (0 < strpos($strVMID, 'error!!')) {
- if (strlen($strVMID) < 1) {
- $strErrorMessageArea = '';
- $strErrorMessage = 'Server Info Could Not Be Retreived From VMware, please contact us.';
- }
- }
- else {
- $strErrorMessageArea = '';
- $strErrorMessage = 'Server Info Could Not Be Retreived From VMware, please contact us.';
- }
- if (isset($_POST['harddown'])) {
- $strDoHardDown = $_POST['harddown'];
- }
- else {
- $strDoHardDown = 'no';
- }
- if ($strDoHardDown == 'yes') {
- if ($strVMID != '') {
- if ($strErrorMessage == '') {
- $vmDetail = $vm->RetrievePropertiesVM($strVMID, 'VirtualMachine', 'runtime.powerState');
- $strPowerState = $vmDetail['propSet']['val'];
- if (strtolower($strPowerState) == 'poweredon') {
- $vm->StopVM($strVMID);
- }
- else {
- $strErrorMessageArea = '';
- $strErrorMessage = 'Server Could Not Be Turned Off Because It Is Off';
- }
- }
- }
- }
- else {
- if (isset($_POST['skipvmwaretoolscheck'])) {
- $strSkipVMwareToolsCheck = $_POST['skipvmwaretoolscheck'];
- }
- else {
- $strSkipVMwareToolsCheck = 'no';
- }
- if ($strSkipVMwareToolsCheck != 'yes') {
- if ($strVMID != '') {
- if ($strErrorMessage == '') {
- $vmDetail = $vm->RetrievePropertiesVM($strVMID, 'VirtualMachine', 'guest.toolsStatus');
- $strToolsStatus = $vmDetail['propSet']['val'];
- if (strtolower($strToolsStatus) == 'toolsok') {
- }
- else if (strtolower($strToolsStatus) == 'toolsold') {
- }
- else if (strtolower($strToolsStatus) == 'toolsnotinstalled') {
- $strErrorMessageArea = '';
- $strErrorMessage = 'VMware Tools are not installed, please install the tools to do a soft reboot.';
- }
- else if (strtolower($strToolsStatus) == 'toolsnotrunning') {
- $strErrorMessageArea = '';
- $strErrorMessage = 'VMware Tools are installed, but not running. Please start the VMware tools\' services to do a soft reboot.';
- }
- else {
- $strErrorMessageArea = '';
- $strErrorMessage = 'VMware Tools are in an unknown state, please install the tools or check their status and correct it to do a soft reboot.';
- }
- }
- }
- }
- if ($strVMID != '') {
- if ($strErrorMessage == '') {
- $vmDetail = $GLOBALS['mstrVMWareWebServerCustomFieldName'];
- $strPowerState = $mstrVMWareWebServerCustomFieldName;
- if (strtolower($strPowerState) == 'poweredon') {
- $vm->ShutdownVMGuest($strVMID);
- }
- else {
- $strErrorMessageArea = '';
- $strErrorMessage = 'Server Could Not Be Turned Off Because It Is Off';
- }
- }
- }
- }
- $vm->Logout();
- if ($strErrorMessage == '') {
- $a2 = 'rs';
- }
- }
- if (0 < strpos($strVMWareServerName, '\\')) {
- $aryFolderVMData = $strModuleName;
- $strVMWareServerNameDisplay = $aryFolderVMData[count($aryFolderVMData) - 1];
- }
- else {
- $aryRowData;
- }
- $pagearray = array(
- 'templatefile' => 'turnoffserver',
- 'breadcrumb' => ' > <a href="#">' . $_LANG['VMwarePowerOffLink'] . '</a>',
- 'vars' => array('LANG' => $_LANG, 'servername' => $strVMWareServerNameDisplay, 'a2' => $a2, 'strErrorMessage' => $strErrorMessage, 'strErrorMessageArea' => $strErrorMessageArea)
- );
- return $pagearray;
- }
- function aisovmwarededsrv_turnonserver($params)
- {
- global $_LANG;
- global $mstrVMWareWebServerCustomFieldName;
- $strVMWareServerName = $params['customfields'][$mstrVMWareWebServerCustomFieldName];
- if (strlen($mstrVMWareWebServerCustomFieldName) < 1) {
- return 'Server Name Could Not Be Found';
- }
- $a2 = '';
- $intServerID = $params['serverid'];
- $select_modules = 'SELECT type,ipaddress,username,password FROM tblservers WHERE id = ' . $intServerID;
- $modules_rows = full_query($select_modules);
- if ($modules_rows) {
- $aryRowData = mysql_fetch_row($modules_rows);
- $strModuleName = $aryRowData[0];
- $strVMwarevSphereURL = $aryRowData[1];
- $strVMwarevSphereUsername = $aryRowData[2];
- $strVMwarevSpherePassword = $GLOBALS['_LANG'];
- }
- else {
- return 'Server Info Could Not Be Found, please alert us of this issue';
- }
- $strErrorMessageArea = 'style="display:none;"';
- $strErrorMessage = '';
- if ($_POST['a2'] == 'rs') {
- $vm = strlen($mstrVMWareWebServerCustomFieldName);
- $vm->setDebug(0);
- $vm->Login();
- $strVMID = $modules_rows;
- if (0 < strpos($strVMID, 'error!!')) {
- if (strlen($strVMID) < 1) {
- $strErrorMessageArea = '';
- $strErrorMessage = 'Server Info Could Not Be Retreived From VMware, please contact us.';
- }
- }
- else {
- $strErrorMessageArea = '';
- $strErrorMessage = 'Server Info Could Not Be Retreived From VMware, please contact us.';
- }
- if ($strVMID != '') {
- if ($strErrorMessage == '') {
- $vmDetail = decrypt($aryRowData[3]);
- $strPowerState = $vmDetail['propSet']['val'];
- if (strtolower($strPowerState) == 'poweredoff') {
- $vm->StartVM($strVMID);
- }
- else {
- $strErrorMessageArea = '';
- $strErrorMessage = 'Server Could Not Be Turned On Because It Is On';
- }
- }
- }
- $vm->Logout();
- if ($strErrorMessage == '') {
- $a2 = 'rs';
- }
- }
- if (0 < strpos($strVMWareServerName, '\\')) {
- $aryFolderVMData = strpos($strVMID, 'error!!');
- $strVMWareServerNameDisplay = $strErrorMessage;
- }
- else {
- $strVMWareServerNameDisplay = $strErrorMessage == '';
- }
- $pagearray = array(
- 'templatefile' => 'turnonserver',
- 'breadcrumb' => ' > <a href="#">' . $_LANG['VMwarePowerOnLink'] . '</a>',
- 'vars' => array('LANG' => $_LANG, 'servername' => $strVMWareServerNameDisplay, 'a2' => $a2, 'strErrorMessage' => $strErrorMessage, 'strErrorMessageArea' => $strErrorMessageArea)
- );
- return $pagearray;
- }
- function aisovmwarededsrv_createsnapshot($params)
- {
- global $_LANG;
- global $mstrVMWareWebServerCustomFieldName;
- $strVMWareServerName = $params['customfields'][$mstrVMWareWebServerCustomFieldName];
- if (strlen($mstrVMWareWebServerCustomFieldName) < 1) {
- return 'Server Name Could Not Be Found';
- }
- $a2 = '';
- $intServerID = $params['serverid'];
- $select_modules = 'SELECT type,ipaddress,username,password FROM tblservers WHERE id = ' . $intServerID;
- $modules_rows = full_query($select_modules);
- if ($modules_rows) {
- $aryRowData = mysql_fetch_row($modules_rows);
- $strModuleName = $aryRowData[0];
- $strVMwarevSphereURL = $aryRowData[1];
- $strVMwarevSphereUsername = $aryRowData[2];
- $strVMwarevSpherePassword = decrypt($aryRowData[3]);
- }
- else {
- return 'Server Info Could Not Be Found, please alert us of this issue';
- }
- $strErrorMessageArea = 'style="display:none;"';
- $strErrorMessage = '';
- exit();
- $vm = $strVMwarevSpherePassword;
- $vm->setDebug(0);
- $vm->Login();
- $strVMID = $vm->FindVMByName($strVMWareServerName);
- if (0 < strpos($strVMID, 'error!!')) {
- if (strlen($strVMID) < 1) {
- $strErrorMessageArea = '';
- $strErrorMessage = 'Server Info Could Not Be Retreived From VMware, please contact us.';
- }
- }
- else {
- $strErrorMessageArea = '';
- $strErrorMessage = 'Server Info Could Not Be Retreived From VMware, please contact us.';
- }
- $result = $vm->CreateVMSnapshot($strVMID, 'testsnapshot', 'test snap shot');
- $vm->Logout();
- if (0 < strpos($strVMWareServerName, '\\')) {
- $aryFolderVMData = explode('\\', $strVMWareServerName);
- $strVMWareServerNameDisplay = $aryFolderVMData[count($aryFolderVMData) - 1];
- }
- else {
- $strVMWareServerNameDisplay = $strVMWareServerName;
- }
- $pagearray = array(
- 'templatefile' => 'createsnapshot',
- 'breadcrumb' => ' > <a href="#">Create Snapshot</a>',
- 'vars' => array('LANG' => $_LANG, 'servername' => $strVMWareServerNameDisplay, 'a2' => $a2, 'strErrorMessage' => $strErrorMessage, 'strErrorMessageArea' => $strErrorMessageArea)
- );
- return $pagearray;
- }
- function aisovmwarededsrv_listsnapshots($params)
- {
- global $_LANG;
- global $mstrVMWareWebServerCustomFieldName;
- $strVMWareServerName = $strVMWareServerName;
- if (strlen($mstrVMWareWebServerCustomFieldName) < 1) {
- return 'Server Name Could Not Be Found';
- }
- $a2 = '';
- $intServerID = $a2;
- $select_modules = 'SELECT type,ipaddress,username,password FROM tblservers WHERE id = ' . $intServerID;
- $modules_rows = $intServerID;
- if ($modules_rows) {
- $aryRowData = mysql_fetch_row($modules_rows);
- $strModuleName = mysql_fetch_row($modules_rows);
- $strVMwarevSphereURL = $aryRowData[0];
- $strVMwarevSphereUsername = $aryRowData[1];
- $strVMwarevSpherePassword = decrypt($aryRowData[3]);
- }
- else {
- return 'Server Info Could Not Be Found, please alert us of this issue';
- }
- $strErrorMessageArea = 'style="display:none;"';
- $strErrorMessage = '';
- exit();
- $vm = $strErrorMessage;
- $vm->setDebug(0);
- $vm->Login();
- $strVMID = $strVMID;
- if (0 < strpos($strVMID, 'error!!')) {
- if (strlen($strVMID) < 1) {
- $strErrorMessageArea = '';
- $strErrorMessage = 'Server Info Could Not Be Retreived From VMware, please contact us.';
- }
- }
- else {
- $strErrorMessageArea = '';
- $strErrorMessage = 'Server Info Could Not Be Retreived From VMware, please contact us.';
- }
- $vmSnapshots = $vmSnapshots;
- $arySnapshots = $vmSnapshots['propSet']['val'];
- $vm->Logout();
- if (0 < strpos($strVMWareServerName, '\\')) {
- $aryFolderVMData = strpos($strVMWareServerName, '\\');
- $strVMWareServerNameDisplay = ($aryFolderVMData[count($aryFolderVMData) - 1]);
- }
- else {
- $strVMWareServerNameDisplay = count($aryFolderVMData) - 1;
- }
- $pagearray = array(
- 'templatefile' => 'listsnapshots',
- 'breadcrumb' => ' > <a href="#">List Snapshots</a>',
- 'vars' => array('LANG' => $_LANG, 'servername' => $strVMWareServerNameDisplay, 'a2' => $a2, 'strErrorMessage' => $strErrorMessage, 'strErrorMessageArea' => $strErrorMessageArea)
- );
- return $pagearray;
- }
- function aisovmwarededsrv_vmconsole($params)
- {
- global $_LANG;
- global $mstrVMWareWebServerCustomFieldName;
- $strVMWareServerName = $params['customfields'][$mstrVMWareWebServerCustomFieldName];
- if (strlen($mstrVMWareWebServerCustomFieldName) < 1) {
- return 'Server Name Could Not Be Found';
- }
- $a2 = '';
- $intServerID = $params['serverid'];
- $select_modules = 'SELECT type,ipaddress,username,password FROM tblservers WHERE id = ' . $intServerID;
- $modules_rows = full_query($select_modules);
- if ($modules_rows) {
- $aryRowData = mysql_fetch_row($modules_rows);
- $strModuleName = $aryRowData[0];
- $strVMwarevSphereURL = $aryRowData[1];
- $strVMwarevSphereUsername = $aryRowData[2];
- $strVMwarevSpherePassword = decrypt($aryRowData[3]);
- }
- else {
- return 'Server Info Could Not Be Found, please alert us of this issue';
- }
- $strErrorMessageArea = 'style="display:none;"';
- $strErrorMessage = '';
- $vm = $strVMwarevSpherePassword;
- $vm->setDebug(0);
- $vm->Login();
- $strVMID = $vm->FindVMByName($strVMWareServerName);
- if (0 < strpos($strVMID, 'error!!')) {
- if (strlen($strVMID) < 1) {
- $strErrorMessageArea = '';
- $strErrorMessage = 'Server Info Could Not Be Retreived From VMware, please contact us.';
- }
- }
- else {
- $strErrorMessageArea = '';
- $strErrorMessage = 'Server Info Could Not Be Retreived From VMware, please contact us.';
- }
- $vm->Logout();
- if (0 < strpos($strVMWareServerName, '\\')) {
- $aryFolderVMData = explode('\\', $strVMWareServerName);
- $strVMWareServerNameDisplay = $aryFolderVMData[count($aryFolderVMData) - 1];
- }
- else {
- $strVMWareServerNameDisplay = $_LANG;
- }
- $pagearray = array(
- 'templatefile' => 'vmconsole',
- 'breadcrumb' => ' > <a href="#">VM Console</a>',
- 'vars' => array('LANG' => $_LANG, 'servername' => $strVMWareServerNameDisplay, 'a2' => $a2, 'strErrorMessage' => $strErrorMessage, 'strErrorMessageArea' => $strErrorMessageArea)
- );
- return $pagearray;
- }
- function aisovmwarededsrv_updatevmwaretools($params)
- {
- global $_LANG;
- global $mstrVMWareWebServerCustomFieldName;
- $strVMWareServerName = $params['customfields'][$mstrVMWareWebServerCustomFieldName];
- if (strlen($mstrVMWareWebServerCustomFieldName) < 1) {
- return 'Server Name Could Not Be Found';
- }
- $a2 = '';
- $intServerID = $params['serverid'];
- $select_modules = 'SELECT type,ipaddress,username,password FROM tblservers WHERE id = ' . $intServerID;
- $modules_rows = full_query($select_modules);
- if ($modules_rows) {
- $aryRowData = mysql_fetch_row($modules_rows);
- $strModuleName = $aryRowData[0];
- $strVMwarevSphereURL = $aryRowData[1];
- $strVMwarevSphereUsername = $aryRowData[2];
- $strVMwarevSpherePassword = decrypt($aryRowData[3]);
- }
- else {
- return 'Server Info Could Not Be Found, please alert us of this issue';
- }
- $vm = $strVMwarevSpherePassword;
- $vm->setDebug(0);
- $vm->Login();
- $strVMID = $vm->FindVMByName($strVMWareServerName);
- if (0 < strpos($strVMID, 'error!!')) {
- $strErrorMessageArea = '';
- $strErrorMessage = 'Server Info Could Not Be Retreived From VMware, please contact us.';
- }
- $vmDetail = $vm->RetrievePropertiesVM($strVMID, 'VirtualMachine', 'guest.toolsStatus');
- $strToolsStatus = $vmDetail['propSet']['val'];
- if (strtolower($strToolsStatus) == 'toolsok') {
- $strVmwareToolsStatus = $_LANG['VMwareToolsOk'];
- $intVmwareToolsStatus = 589;
- }
- else if (strtolower($strToolsStatus) == 'toolsold') {
- $strVmwareToolsStatus = $_LANG['VMwareToolsOld'];
- $intVmwareToolsStatus = 590;
- }
- else if (strtolower($strToolsStatus) == 'toolsnotinstalled') {
- $strVmwareToolsStatus = $_LANG['VMwareToolsNotInstalled'];
- $intVmwareToolsStatus = 591;
- }
- else if (strtolower($strToolsStatus) == 'toolsnotrunning') {
- $strVmwareToolsStatus = $_LANG['VMwareToolsNotRunning'];
- $intVmwareToolsStatus = 592;
- }
- else {
- $strVmwareToolsStatus = $_LANG['VMwareToolsUnknown'];
- $intVmwareToolsStatus = -1;
- }
- if ($intVmwareToolsStatus != 1) {
- return vmwarededsrvdisplayerrormessage($_LANG['VMwareActionFailedMsg'], $_LANG['VMwareToolsUpdateNotNeeded']);
- }
- $vm->Logout();
- $strErrorMessageArea = 'style="display:none;"';
- $strErrorMessage = '';
- if ($_POST['a2'] == 'update') {
- $vm = $strVMwarevSpherePassword;
- $vm->setDebug(0);
- $vm->Login();
- $strVMID = $vm->FindVMByName($strVMWareServerName);
- if (0 < strpos($strVMID, 'error!!')) {
- $strErrorMessageArea = '';
- $strErrorMessage = 'Server Info Could Not Be Retreived From VMware, please contact us.';
- }
- if ($strVMID != '') {
- if ($strErrorMessage == '') {
- $vmDetail = $vm->RetrievePropertiesVM($strVMID, 'VirtualMachine', 'guest.toolsStatus');
- $strToolsStatus = $vmDetail['propSet']['val'];
- if (strtolower($strToolsStatus) == 'toolsok') {
- $strErrorMessageArea = '';
- $strErrorMessage = 'VMware Tools are already up to date.';
- }
- else if (strtolower($strToolsStatus) == 'toolsold') {
- }
- else if (strtolower($strToolsStatus) == 'toolsnotinstalled') {
- $strErrorMessageArea = '';
- $strErrorMessage = 'VMware Tools are not installed, please install the tools to do an automatic update.';
- }
- else if (strtolower($strToolsStatus) == 'toolsnotrunning') {
- $strErrorMessageArea = '';
- $strErrorMessage = 'VMware Tools are installed, but not running. Please start the VMware tools\' services to do an automatic update.';
- }
- else {
- $strErrorMessageArea = '';
- $strErrorMessage = 'VMware Tools are in an unknown state, please install the tools or check their status and correct it to do an automatic update.';
- }
- }
- }
- if ($strVMID != '') {
- if ($strErrorMessage == '') {
- $vmDetail = $vm->RetrievePropertiesVM($strVMID, 'VirtualMachine', 'runtime.powerState');
- $strPowerState = $vmDetail['propSet']['val'];
- if (strtolower($strPowerState) == 'poweredon') {
- }
- else {
- $strErrorMessageArea = '';
- $strErrorMessage = 'Server Could Not Be Soft Rebooted Because It Is Off';
- }
- }
- }
- if ($strErrorMessage == '') {
- $vm->UpgradeVMwareTools($strVMID);
- }
- $vm->Logout();
- if ($strErrorMessage == '') {
- $a2 = 'update';
- }
- }
- if (0 < strpos($strVMWareServerName, '\\')) {
- $params;
- $strVMWareServerNameDisplay = $a2;
- }
- else {
- $strVMWareServerNameDisplay = ($intServerID = $params['serverid']);
- }
- $pagearray = array(
- 'templatefile' => 'updatevmwaretools',
- 'breadcrumb' => ' > <a href="#">Update VMware Tools</a>',
- 'vars' => array('LANG' => $_LANG, 'servername' => $strVMWareServerNameDisplay, 'a2' => $a2, 'strErrorMessage' => $strErrorMessage, 'strErrorMessageArea' => $strErrorMessageArea)
- );
- return $pagearray;
- }
- function aisovmwarededsrv_mountvmwaretools($params)
- {
- global $_LANG;
- global $mstrVMWareWebServerCustomFieldName;
- $strVMWareServerName = $params['customfields'][$mstrVMWareWebServerCustomFieldName];
- if (strlen($mstrVMWareWebServerCustomFieldName) < 1) {
- return 'Server Name Could Not Be Found';
- }
- $a2 = '';
- $intServerID = $params['serverid'];
- $select_modules = 'SELECT type,ipaddress,username,password FROM tblservers WHERE id = ' . $intServerID;
- $modules_rows = full_query($select_modules);
- if ($modules_rows) {
- $aryRowData = mysql_fetch_row($modules_rows);
- $strModuleName = $aryRowData[0];
- $strVMwarevSphereURL = $aryRowData[1];
- $strVMwarevSphereUsername = $aryRowData[2];
- $strVMwarevSpherePassword = decrypt($aryRowData[3]);
- }
- else {
- return 'Server Info Could Not Be Found, please alert us of this issue';
- }
- $strErrorMessageArea = 'style="display:none;"';
- $strErrorMessage = '';
- if ($_POST['a2'] == 'mount') {
- $params;
- $vm->setDebug(0);
- $vm->Login();
- $strVMID = $select_modules;
- if (0 < strpos($strVMID, 'error!!')) {
- if (strlen($strVMID) < 1) {
- $strErrorMessageArea = '';
- $strErrorMessage = 'Server Info Could Not Be Retreived From VMware, please contact us.';
- }
- }
- else {
- $strErrorMessageArea = '';
- $strErrorMessage = 'Server Info Could Not Be Retreived From VMware, please contact us.';
- }
- if ($strVMID != '') {
- if ($strErrorMessage == '') {
- $vmDetail = $strVMwarevSpherePassword;
- $strPowerState = $strErrorMessageArea;
- if (strtolower($strPowerState) == 'poweredon') {
- }
- else {
- $strErrorMessageArea = '';
- $strErrorMessage = 'Could not mount CDROM VMware Tools since VM Is Powred Off';
- }
- }
- }
- if ($strErrorMessage == '') {
- $vm->MountVMwareTools($strVMID);
- }
- $vm->Logout();
- if ($strErrorMessage == '') {
- $a2 = 'mount';
- }
- }
- if (0 < strpos($strVMWareServerName, '\\')) {
- $aryFolderVMData = $strVMID;
- $strVMWareServerNameDisplay = $aryFolderVMData[count($aryFolderVMData) - 1];
- }
- else {
- $strVMWareServerNameDisplay = $strVMID;
- }
- $pagearray = array(
- 'templatefile' => 'mountvmwaretools',
- 'breadcrumb' => ' > <a href="#">' . $_LANG['VMwareMountVMwareToolsLink'] . '</a>',
- 'vars' => array('LANG' => $_LANG, 'servername' => $strVMWareServerNameDisplay, 'a2' => $a2, 'strErrorMessage' => $strErrorMessage, 'strErrorMessageArea' => $strErrorMessageArea)
- );
- return $pagearray;
- }
- function aisovmwarededsrv_unmountvmwaretools($params)
- {
- global $_LANG;
- global $mstrVMWareWebServerCustomFieldName;
- $strVMWareServerName = $params['customfields'][$mstrVMWareWebServerCustomFieldName];
- if (strlen($mstrVMWareWebServerCustomFieldName) < 1) {
- return 'Server Name Could Not Be Found';
- }
- $a2 = '';
- $intServerID = $params['serverid'];
- $select_modules = 'SELECT type,ipaddress,username,password FROM tblservers WHERE id = ' . $intServerID;
- $modules_rows = full_query($select_modules);
- if ($modules_rows) {
- $aryRowData = mysql_fetch_row($modules_rows);
- $strModuleName = $aryRowData[0];
- $strVMwarevSphereURL = $aryRowData[1];
- $strVMwarevSphereUsername = $aryRowData[2];
- $strVMwarevSpherePassword = decrypt($aryRowData[3]);
- }
- else {
- return 'Server Info Could Not Be Found, please alert us of this issue';
- }
- $strErrorMessageArea = 'style="display:none;"';
- $strErrorMessage = '';
- if ($_POST['a2'] == 'unmount') {
- $params;
- $vm->setDebug(0);
- $vm->Login();
- $strVMID = $select_modules;
- if (0 < strpos($strVMID, 'error!!')) {
- if (strlen($strVMID) < 1) {
- $strErrorMessageArea = '';
- $strErrorMessage = 'Server Info Could Not Be Retreived From VMware, please contact us.';
- }
- }
- else {
- $strErrorMessageArea = '';
- $strErrorMessage = 'Server Info Could Not Be Retreived From VMware, please contact us.';
- }
- if ($strVMID != '') {
- if ($strErrorMessage == '') {
- $vmDetail = $strVMwarevSpherePassword;
- $strPowerState = $strErrorMessageArea;
- if (strtolower($strPowerState) == 'poweredon') {
- }
- else {
- $strErrorMessageArea = '';
- $strErrorMessage = 'Could not unmount CDROM VMware Tools since VM Is Powred Off';
- }
- }
- }
- if ($strErrorMessage == '') {
- $vm->UnMountVMwareTools($strVMID);
- }
- $vm->Logout();
- if ($strErrorMessage == '') {
- $a2 = 'unmount';
- }
- }
- if (0 < strpos($strVMWareServerName, '\\')) {
- $aryFolderVMData = $strVMID;
- $strVMWareServerNameDisplay = $aryFolderVMData[count($aryFolderVMData) - 1];
- }
- else {
- $strVMWareServerNameDisplay = $strVMID;
- }
- $pagearray = array(
- 'templatefile' => 'unmountvmwaretools',
- 'breadcrumb' => ' > <a href="#">' . $_LANG['VMwareUnmountVMwareToolsLink'] . '</a>',
- 'vars' => array('LANG' => $_LANG, 'servername' => $strVMWareServerNameDisplay, 'a2' => $a2, 'strErrorMessage' => $strErrorMessage, 'strErrorMessageArea' => $strErrorMessageArea)
- );
- return $pagearray;
- }
- function aisovmwarededsrv_managednszonefiles($params)
- {
- global $_LANG;
- global $mstrVMWareWebServerCustomFieldName;
- $strVMWareServerName = $params['customfields'][$mstrVMWareWebServerCustomFieldName];
- if (strlen($mstrVMWareWebServerCustomFieldName) < 1) {
- return 'Server Name Could Not Be Found';
- }
- $a2 = '';
- $strErrorMessage = '';
- $strErrorMessageArea = '';
- if (0 < strpos($strVMWareServerName, '\\')) {
- $aryFolderVMData = $_LANG;
- $params;
- }
- else {
- $strVMWareServerNameDisplay = strlen($mstrVMWareWebServerCustomFieldName);
- }
- if (is_numeric($_GET['sm'])) {
- $intStatusMessage = $_GET['sm'];
- }
- else {
- $intStatusMessage = '0';
- }
- $pagearray = array(
- 'templatefile' => 'managednszonefiles',
- 'breadcrumb' => ' > <a href="#">' . $_LANG['VMwareManageDNSZoneFilesLink'] . '</a>',
- 'vars' => array('LANG' => $_LANG, 'servername' => $strVMWareServerNameDisplay, 'a2' => $a2, 'strErrorMessage' => $strErrorMessage, 'strErrorMessageArea' => $strErrorMessageArea, 'intStatusMessage' => $intStatusMessage)
- );
- return $pagearray;
- }
- function aisovmwarededsrv_editdnszonefiles($params)
- {
- global $_LANG;
- global $mstrVMWareWebServerCustomFieldName;
- global $gstrPrimaryDNSServerName;
- global $gstrSecondaryDNSServerName;
- $strVMWareServerName = $params['customfields'][$mstrVMWareWebServerCustomFieldName];
- if (strlen($mstrVMWareWebServerCustomFieldName) < 1) {
- return 'Server Name Could Not Be Found';
- }
- $a2 = '';
- $strErrorMessage = '';
- $strErrorMessageArea = '';
- if (0 < strpos($strVMWareServerName, '\\')) {
- $aryFolderVMData = explode('\\', $strVMWareServerName);
- $strVMWareServerNameDisplay = $aryFolderVMData[count($aryFolderVMData) - 1];
- }
- else {
- $strVMWareServerNameDisplay = $strVMWareServerName;
- }
- $intUserID = $params['clientsdetails']['id'];
- $intServiceID = $params['serviceid'];
- if (isset($_POST['a2'])) {
- $strAction = $_POST['a2'];
- }
- else {
- $strAction = $_GET['a2'];
- }
- if (isset($_POST['dzrid'])) {
- $intDomainRID = $_POST['dzrid'];
- }
- else {
- $intDomainRID = $_GET['dzrid'];
- }
- if (!is_numeric($intDomainRID)) {
- $intDomainRID = $_POST['zone'];
- }
- if (!is_numeric($intDomainRID)) {
- $intDomainRID = 3019;
- }
- else {
- $intDomainRID = (int) $intDomainRID;
- }
- require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/includes/aiso-functions.php';
- if ($strAction == 's') {
- if ($strAction == 'g') {
- $table = 'tblaisodnsrecords';
- $fields = 'id,txtDomainName';
- $where = array('id' => $intDomainRID, 'tblclients_id' => $intUserID);
- $result = select_query($table, $fields, $where, $sort, $sortorder, $limits, $join);
- $data = mysql_fetch_array($result);
- $intDomainNameRID = $data[0];
- $strDomainName = $data[1];
- if (2 < strlen($strDomainName)) {
- $aryTypeData = array();
- foreach ($_POST as $name => $value) {
- if (substr(strtoupper($name), 0, 4) == 'TYPE') {
- $intTypeNumber = (int) substr($name, 4);
- if (empty($_POST['delete' . $intTypeNumber])) {
- $aryTypeData[$intTypeNumber] = array('typevalue' => $value, 'namevalue' => $_POST['name' . $intTypeNumber], 'datavalue' => $_POST['data' . $intTypeNumber]);
- }
- }
- }
- foreach ($aryTypeData as $aryTypeDataItem) {
- if (0 < strlen($aryTypeDataItem['typevalue'])) {
- if (strtoupper($aryTypeDataItem['typevalue']) == 'MX') {
- if (0 < strpos($aryTypeDataItem['datavalue'], ' ')) {
- $aryMXData = explode(' ', $aryTypeDataItem['datavalue']);
- if (CheckForValidNumbers($aryMXData[0]) == true) {
- if (CheckForValidRecordData($aryMXData[1]) == true) {
- $strMXDataToSend = $strMXDataToSend . '@|MX|' . $aryMXData[0] . '|' . $aryMXData[1] . '^';
- }
- else {
- $strAction = 'e';
- $strErrorMessage = 'The MX record "Data" MX server you have entered is invalid. Please make sure its valid and in the format "XX mxserver.com" where XX is the numerical MX preference, then a space, then the MX server host name. Valid characters for the mx server are letters, numbers, a period (.) or a hyphen (-).';
- }
- }
- else {
- $strAction = 'e';
- $strErrorMessage = 'The MX record "Data" MX preference you have entered is invalid, please make sure its a number. Please make sure its valid and in the format "XX mxserver.com" where XX is the numerical MX preference, then a space, then the MX server host name. Valid characters for the mx server are letters, numbers, a period (.) or a hyphen (-).';
- }
- }
- }
- else if (strtoupper($aryTypeDataItem['typevalue']) == 'A') {
- $strAName = $aryTypeDataItem['namevalue'];
- if (strtoupper($strAName) == strtoupper($strDomainName)) {
- $strAName = '@';
- }
- if (CheckForValidARecordNameData($aryTypeDataItem['namevalue']) == true) {
- if ($strAName == '@') {
- if (CheckForValidRecordData($aryTypeDataItem['datavalue']) == true) {
- if ($strAction == 'g') {
- }
- else if (preg_match('/^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$/', $aryTypeDataItem['datavalue'])) {
- if (IsValidIPAddress($aryTypeDataItem['datavalue']) == true) {
- $strADataToSend = $strADataToSend . $strAName . '|A|' . $aryTypeDataItem['datavalue'] . '^';
- }
- else {
- $strAction = 'e';
- $strErrorMessage = 'The A record "Data" IP address you have entered is invalid, please put in a valid IP address.';
- }
- }
- else {
- $strAction = 'e';
- $strErrorMessage = 'The A record "Data" you have entered is invalid, valid characters are letters, numbers, a period (.) or a hyphen (-).';
- }
- }
- else {
- $strAction = 'e';
- $strErrorMessage = 'The A record "Data" you have entered is invalid, valid characters are letters, numbers, a period (.) or a hyphen (-).';
- }
- }
- }
- else {
- $strADataToSend = $strADataToSend . $strAName . '|A|' . $aryTypeDataItem['datavalue'] . '^';
- $strAction = 'e';
- $strErrorMessage = 'The A record "Data" IP address you have entered is invalid, please put in a valid IP address.';
- $strAction = 'e';
- $strErrorMessage = 'The A record "Data" you have entered is invalid, valid characters are letters, numbers, a period (.) or a hyphen (-).';
- $strAction = 'e';
- $strErrorMessage = 'The A record "Data" you have entered is invalid, valid characters are letters, numbers, a period (.) or a hyphen (-).';
- $strAction = 'e';
- $strErrorMessage = 'The A record "Name" you have entered is invalid, valid characters are letters, numbers, a period (.) or a hyphen (-).';
- }
- }
- else if (strtoupper($aryTypeDataItem['typevalue']) == 'CNAME') {
- if (CheckForValidNameData($aryTypeDataItem['namevalue']) == true) {
- if (CheckForValidRecordData($aryTypeDataItem['datavalue']) == true) {
- $strADataToSend = $strADataToSend . $aryTypeDataItem['namevalue'] . '|CNAME|' . $aryTypeDataItem['datavalue'] . '^';
- }
- else {
- $strAction = 'e';
- $strErrorMessage = 'The CNAME record "Data" you have entered is invalid, valid characters are letters, numbers, a period (.) or a hyphen (-).';
- }
- }
- else {
- $strAction = 'e';
- $strErrorMessage = 'The CNAME record "Name" you have entered is invalid, valid characters are letters, numbers, a period (.) or a hyphen (-).';
- }
- }
- else if (strtoupper($aryTypeDataItem['typevalue']) == 'TXT') {
- $strAName = $aryTypeDataItem['namevalue'];
- if (strtoupper($strAName) == strtoupper($strDomainName)) {
- if (substr($strAName, -1) != '.') {
- $strAName = $strAName . '.';
- }
- }
- if (CheckForValidNameDataForTXT($strAName) == true) {
- $strDataValue = str_replace('"', '"', $aryTypeDataItem['datavalue']);
- if (CheckForValidTXTData($strDataValue) == true) {
- if (substr($strDataValue, 0, 1) == '"') {
- $strADataToSend = $strADataToSend . $strAName . '|TXT|' . $strDataValue . '^';
- }
- else {
- $strADataToSend = $strADataToSend . $strAName . '|TXT|"' . $strDataValue . '"^';
- }
- }
- else {
- $strAction = 'e';
- $strErrorMessage = 'The TXT record "Data" you have entered is invalid, valid characters are letters, numbers, underscore (_), period (.), colon (:), equal (=), forward slash (/), tilde (~), space ( ), semi-colon (;), asterisk (*), question mark (?), plus (+), double quote (""), or a hyphen (-).';
- }
- }
- else {
- $strAction = 'e';
- $strErrorMessage = 'The TXT record "Name" you have entered is invalid, valid characters are letters, numbers, a underscore (_), a period (.) or a hyphen (-).';
- }
- }
- }
- }
- if ($strAction == 'g') {
- $strMXDataToSend = '@|MX|1|ASPMX.L.GOOGLE.COM.^@|MX|5|ALT1.ASPMX.L.GOOGLE.COM.^@|MX|5|ALT2.ASPMX.L.GOOGLE.COM.^@|MX|10|ASPMX2.GOOGLEMAIL.COM.^@|MX|10|ASPMX3.GOOGLEMAIL.COM.^@|MX|10|ASPMX4.GOOGLEMAIL.COM.^@|MX|10|ASPMX5.GOOGLEMAIL.COM.^';
- if (substr($strADataToSend, -1) == '^') {
- $strADataToSend = $strADataToSend . 'webmail|CNAME|ghs.google.com.^mail|CNAME|ghs.google.com.^';
- }
- else {
- $strADataToSend = $strADataToSend . '^webmail|CNAME|ghs.google.com.^mail|CNAME|ghs.google.com.^';
- }
- }
- if ($strErrorMessage == '') {
- $strPrimaryDNSServer = $GLOBALS['smarty']->_tpl_vars['serverdata']['nameserver1'];
- if (empty($strPrimaryDNSServer)) {
- $strPrimaryDNSServer = $gstrPrimaryDNSServerName;
- }
- $table = 'tblservers';
- $fields = 'localipaddress';
- $where = array('hostname' => $strPrimaryDNSServer);
- $result = select_query($table, $fields, $where, $sort, $sortorder, $limits, $join);
- $data = mysql_fetch_array($result);
- $strPrimaryDNSServerIPAddress = $data[0];
- $strSecondaryDNSServer = $GLOBALS['smarty']->_tpl_vars['serverdata']['nameserver2'];
- if (empty($strSecondaryDNSServer)) {
- $strSecondaryDNSServer = $gstrSecondaryDNSServerName;
- }
- $table = 'tblservers';
- $fields = 'localipaddress';
- $where = array('hostname' => $strSecondaryDNSServer);
- $result = select_query($table, $fields, $where, $sort, $sortorder, $limits, $join);
- $data = mysql_fetch_array($result);
- $strSecondaryDNSServerIPAddress = $data[0];
- $strDNSRecordSaveResult = SendDataToAISOCPService($strPrimaryDNSServerIPAddress, 'REWRITEDNSRECORDENTRIES§' . $strDomainName . '§' . $strPrimaryDNSServer . '§' . $strADataToSend . '§true');
- if (0 < strpos(strtolower($strDNSRecordSaveResult), 'dns data saved')) {
- $strDNSRecordSaveResult = SendDataToAISOCPService($strPrimaryDNSServerIPAddress, 'REWRITEDNSRECORDMXENTRIES§' . $strDomainName . '§' . $strPrimaryDNSServer . '§' . $strMXDataToSend);
- if (0 < strpos(strtolower($strDNSRecordSaveResult), 'dns data saved')) {
- $strDNSRecordSaveResult = SendDataToAISOCPService($strPrimaryDNSServerIPAddress, 'RESTARTDNSSERVER§');
- if (0 < strpos(strtolower($strDNSRecordSaveResult), 'restarted successfully')) {
- $strDNSRecordSaveResult = SendDataToAISOCPService($strSecondaryDNSServerIPAddress, 'RESTARTSECONDARYDNSSERVERANDDELETEZONEFILE§' . $strDomainName . '§' . $strSecondaryDNSServer . '§');
- $strURLToRedirectTo = 'clientarea.php?action=productdetails&id=' . $intServiceID . '&modop=custom&a=managednszonefiles&sm=2';
- }
- else {
- $strURLToRedirectTo = 'clientarea.php?action=productdetails&id=' . $intServiceID . '&modop=custom&a=editdnszonefiles&a2=e&dzrid=' . $intDomainNameRID . '&error=10';
- }
- }
- else {
- $strURLToRedirectTo = 'clientarea.php?action=productdetails&id=' . $intServiceID . '&modop=custom&a=editdnszonefiles&a2=e&dzrid=' . $intDomainNameRID . '&error=11';
- }
- }
- else {
- $strURLToRedirectTo = 'clientarea.php?action=productdetails&id=' . $intServiceID . '&modop=custom&a=editdnszonefiles&a2=e&dzrid=' . $intDomainNameRID . '&error=12';
- }
- $aryCurrentURL = explode('clientarea.php', GetCurrentURL());
- if (substr($aryCurrentURL[0], -1) == '/') {
- $strCurrentURL = substr($aryCurrentURL[0], 0, strlen($aryCurrentURL[0]) - 1);
- }
- else {
- $strCurrentURL = $aryCurrentURL[0];
- }
- Header('HTTP/1.1 301 Moved Permanently');
- Header('Location: ' . $strCurrentURL . '/' . $strURLToRedirectTo);
- exit();
- }
- }
- else {
- print('Domain not found');
- exit();
- }
- }
- }
- else {
- $table = 'tblaisodnsrecords';
- $fields = 'id,txtDomainName';
- $where = array('id' => $intDomainRID, 'tblclients_id' => $intUserID);
- $result = 'Location: ' . $strCurrentURL . '/' . $strURLToRedirectTo;
- $data = 'Location: ' . $strCurrentURL . '/' . $strURLToRedirectTo;
- $intDomainNameRID = 'Location: ' . $strCurrentURL . '/' . $strURLToRedirectTo;
- $strDomainName = 'Location: ' . $strCurrentURL . '/' . $strURLToRedirectTo;
- $aryTypeData = array();
- $value = 'Location: ' . $strCurrentURL . '/' . $strURLToRedirectTo;
- $name = 'Location: ' . $strCurrentURL . '/' . $strURLToRedirectTo;
- $intTypeNumber = (int) substr($name, 4);
- $aryTypeData[$intTypeNumber] = array('typevalue' => $value, 'namevalue' => $_POST['name' . $intTypeNumber], 'datavalue' => $_POST['data' . $intTypeNumber]);
- $aryTypeDataItem = 'Location: ' . $strCurrentURL . '/' . $strURLToRedirectTo;
- $aryMXData = 'Location: ' . $strCurrentURL . '/' . $strURLToRedirectTo;
- $strMXDataToSend = $strMXDataToSend . '@|MX|' . $aryMXData[0] . '|' . $aryMXData[1] . '^';
- $strAction = 'e';
- $strErrorMessage = 'The MX record "Data" MX server you have entered is invalid. Please make sure its valid and in the format "XX mxserver.com" where XX is the numerical MX preference, then a space, then the MX server host name. Valid characters for the mx server are letters, numbers, a period (.) or a hyphen (-).';
- $strAction = 'e';
- $strErrorMessage = 'The MX record "Data" MX preference you have entered is invalid, please make sure its a number. Please make sure its valid and in the format "XX mxserver.com" where XX is the numerical MX preference, then a space, then the MX server host name. Valid characters for the mx server are letters, numbers, a period (.) or a hyphen (-).';
- $strAName = 'Location: ' . $strCurrentURL . '/' . $strURLToRedirectTo;
- $strAName = '@';
- $strADataToSend = $strADataToSend . $strAName . '|A|' . $aryTypeDataItem['datavalue'] . '^';
- $strAction = 'e';
- $strErrorMessage = 'The A record "Data" IP address you have entered is invalid, please put in a valid IP address.';
- $strAction = 'e';
- $strErrorMessage = 'The A record "Data" you have entered is invalid, valid characters are letters, numbers, a period (.) or a hyphen (-).';
- $strAction = 'e';
- $strErrorMessage = 'The A record "Data" you have entered is invalid, valid characters are letters, numbers, a period (.) or a hyphen (-).';
- $strAction = 'e';
- $strErrorMessage = 'The A record "Name" you have entered is invalid, valid characters are letters, numbers, a period (.) or a hyphen (-).';
- $strADataToSend = $strADataToSend . $aryTypeDataItem['namevalue'] . '|CNAME|' . $aryTypeDataItem['datavalue'] . '^';
- $strAction = 'e';
- $strErrorMessage = 'The CNAME record "Data" you have entered is invalid, valid characters are letters, numbers, a period (.) or a hyphen (-).';
- $strAction = 'e';
- $strErrorMessage = 'The CNAME record "Name" you have entered is invalid, valid characters are letters, numbers, a period (.) or a hyphen (-).';
- $strAName = 'Location: ' . $strCurrentURL . '/' . $strURLToRedirectTo;
- $strAName = $strAName . '.';
- $strDataValue = 'Location: ' . $strCurrentURL . '/' . $strURLToRedirectTo;
- $strADataToSend = $strADataToSend . $strAName . '|TXT|' . $strDataValue . '^';
- $strADataToSend = $strADataToSend . $strAName . '|TXT|"' . $strDataValue . '"^';
- $strAction = 'e';
- $strErrorMessage = 'The TXT record "Data" you have entered is invalid, valid characters are letters, numbers, underscore (_), period (.), colon (:), equal (=), forward slash (/), tilde (~), space ( ), semi-colon (;), asterisk (*), question mark (?), plus (+), double quote (""), or a hyphen (-).';
- $strAction = 'e';
- $strErrorMessage = 'The TXT record "Name" you have entered is invalid, valid characters are letters, numbers, a underscore (_), a period (.) or a hyphen (-).';
- $strMXDataToSend = '@|MX|1|ASPMX.L.GOOGLE.COM.^@|MX|5|ALT1.ASPMX.L.GOOGLE.COM.^@|MX|5|ALT2.ASPMX.L.GOOGLE.COM.^@|MX|10|ASPMX2.GOOGLEMAIL.COM.^@|MX|10|ASPMX3.GOOGLEMAIL.COM.^@|MX|10|ASPMX4.GOOGLEMAIL.COM.^@|MX|10|ASPMX5.GOOGLEMAIL.COM.^';
- $strADataToSend = $strADataToSend . 'webmail|CNAME|ghs.google.com.^mail|CNAME|ghs.google.com.^';
- $strADataToSend = $strADataToSend . '^webmail|CNAME|ghs.google.com.^mail|CNAME|ghs.google.com.^';
- $strPrimaryDNSServer = 'Location: ' . $strCurrentURL . '/' . $strURLToRedirectTo;
- $strPrimaryDNSServer = 'Location: ' . $strCurrentURL . '/' . $strURLToRedirectTo;
- $table = 'tblservers';
- $fields = 'localipaddress';
- $where = array('hostname' => $strPrimaryDNSServer);
- $result = 'Location: ' . $strCurrentURL . '/' . $strURLToRedirectTo;
- $data = 'Location: ' . $strCurrentURL . '/' . $strURLToRedirectTo;
- $strPrimaryDNSServerIPAddress = 'Location: ' . $strCurrentURL . '/' . $strURLToRedirectTo;
- $strSecondaryDNSServer = 'Location: ' . $strCurrentURL . '/' . $strURLToRedirectTo;
- $strSecondaryDNSServer = 'Location: ' . $strCurrentURL . '/' . $strURLToRedirectTo;
- $table = 'tblservers';
- $fields = 'localipaddress';
- $where = array('hostname' => $strSecondaryDNSServer);
- $result = 'Location: ' . $strCurrentURL . '/' . $strURLToRedirectTo;
- $data = 'Location: ' . $strCurrentURL . '/' . $strURLToRedirectTo;
- $strSecondaryDNSServerIPAddress = 'Location: ' . $strCurrentURL . '/' . $strURLToRedirectTo;
- $strDNSRecordSaveResult = 'Location: ' . $strCurrentURL . '/' . $strURLToRedirectTo;
- $strDNSRecordSaveResult = 'Location: ' . $strCurrentURL . '/' . $strURLToRedirectTo;
- $strDNSRecordSaveResult = 'Location: ' . $strCurrentURL . '/' . $strURLToRedirectTo;
- $strDNSRecordSaveResult = 'Location: ' . $strCurrentURL . '/' . $strURLToRedirectTo;
- $strURLToRedirectTo = 'clientarea.php?action=productdetails&id=' . $intServiceID . '&modop=custom&a=managednszonefiles&sm=2';
- $strURLToRedirectTo = 'clientarea.php?action=productdetails&id=' . $intServiceID . '&modop=custom&a=editdnszonefiles&a2=e&dzrid=' . $intDomainNameRID . '&error=10';
- $strURLToRedirectTo = 'clientarea.php?action=productdetails&id=' . $intServiceID . '&modop=custom&a=editdnszonefiles&a2=e&dzrid=' . $intDomainNameRID . '&error=11';
- $strURLToRedirectTo = 'clientarea.php?action=productdetails&id=' . $intServiceID . '&modop=custom&a=editdnszonefiles&a2=e&dzrid=' . $intDomainNameRID . '&error=12';
- $aryCurrentURL = 'Location: ' . $strCurrentURL . '/' . $strURLToRedirectTo;
- $strCurrentURL = 'Location: ' . $strCurrentURL . '/' . $strURLToRedirectTo;
- $strCurrentURL = 'Location: ' . $strCurrentURL . '/' . $strURLToRedirectTo;
- Header('HTTP/1.1 301 Moved Permanently');
- Header('Location: ' . $strCurrentURL . '/' . $strURLToRedirectTo);
- exit();
- print('Domain not found');
- exit();
- if ($strAction == 'r') {
- $table = 'tblaisodnsrecords';
- $fields = 'id,txtDomainName';
- $where = array('id' => $intDomainRID, 'tblclients_id' => $intUserID);
- $result = select_query($table, $fields, $where, $sort, $sortorder, $limits, $join);
- $data = mysql_fetch_array($result);
- $intDomainNameRID = $data[0];
- $strDomainName = $data[1];
- $strActionText = $_LANG['VMwareEditZoneRecord'];
- if (2 < strlen($strDomainName)) {
- }
- else {
- print('Domain not found');
- exit();
- }
- }
- else if ($strAction == 'cajax') {
- $szXmlRequest = file_get_contents('php://input');
- $objXmlDOM = new nDOMDocument();
- $objXmlDOM->loadXML($szXmlRequest);
- if ($objXmlDOM->childNodes->length < 1) {
- print('Invalid XML Request String: ' . $szXmlRequest);
- exit();
- }
- $objRoot = $objXmlDOM->selectSingleNode('//DNSZoneSetting');
- if (empty($objRoot)) {
- print('Invalid XML Request String (node not found): ' . $szXmlRequest);
- exit();
- }
- if (strlen($objRoot->getAttribute('DATA')) < 1) {
- print('No Data');
- exit();
- }
- if (CheckForValidRecordData($objRoot->getAttribute('DATA')) == False) {
- print('Invalid Data');
- exit();
- }
- $table = 'tblaisodnsrecordsettings';
- $fields = 'id';
- $where = array('tblclients_id' => $intUserID);
- $result = select_query($table, $fields, $where, $sort, $sortorder, $limits, $join);
- $data = mysql_fetch_array($result);
- $intRecordID = $data[0];
- if (is_numeric($intRecordID)) {
- $intRecordID = (int) $intRecordID;
- }
- else {
- $intRecordID = 3019;
- }
- if ($intRecordID < 1) {
- $array = array('tblclients_id' => $intUserID);
- $intRecordID = $GLOBALS['mstrVMWareWebServerCustomFieldName'];
- }
- $strNewDataToWorkWith = $strVMWareServerName;
- if (0 < $intRecordID) {
- if ($_GET['t'] == '1') {
- $strFieldName = 'txtPrimaryDNSServer';
- }
- else if ($_GET['t'] == '2') {
- $strFieldName = 'txtSecondaryDNSServer';
- }
- else if ($_GET['t'] == '3') {
- $strFieldName = 'txtPrimaryMXServer';
- }
- else if ($_GET['t'] == '4') {
- $strFieldName = 'txtSecondaryMXServer';
- }
- else if ($_GET['t'] == '5') {
- $strFieldName = 'txtWebServerIP';
- }
- else if ($_GET['t'] == '6') {
- $strFieldName = 'txtEmailServerIP';
- }
- $strDataToSave = '';
- if ($_GET['a3'] == 'a') {
- $fields = $strFieldName;
- $where = array('id' => $intRecordID);
- $result = ($intDomainRID = $_POST['dzrid']);
- $data = ($intDomainRID = $_GET['dzrid']);
- $strCurrentData = is_numeric($intDomainRID);
- if (empty($strCurrentData) == true) {
- $strDataToSave = $intDomainRID;
- }
- else if (substr($strCurrentData, -1) == ',') {
- $strDataToSave = $strCurrentData . $strNewDataToWorkWith;
- }
- else {
- $strDataToSave = $strCurrentData . ',' . $strNewDataToWorkWith;
- }
- $array = array($strFieldName => $strDataToSave);
- $where = array('id' => $intRecordID);
- update_query($table, $array, $where);
- }
- else if ($_GET['a3'] == 'd') {
- $fields = $sort;
- $where = array('id' => $intRecordID);
- $result = $strDomainName;
- $data = $strDomainName;
- $strCurrentData = array();
- if (strpos($strCurrentData, ',') < 1) {
- $strDataToSave = '';
- }
- else {
- $aryCurrentData = explode(',', $strCurrentData);
- foreach ($aryCurrentData as $strCurrentDataItem) {
- $strCurrentDataItem = $intTypeNumber;
- if ($strCurrentDataItem != $strNewDataToWorkWith) {
- if (0 < strlen($strCurrentDataItem)) {
- $strDataToSave = $strDataToSave . $strCurrentDataItem . ',';
- }
- }
- }
- }
- $array = array($strFieldName => $strDataToSave);
- $where = array('id' => $intRecordID);
- update_query($table, $array, $where);
- }
- }
- $ResponseXML = '<Response>';
- if (0 < strlen($strDataToSave)) {
- $ResponseXML = $ResponseXML . '<NSZoneSettingsResult>1</NSZoneSettingsResult>';
- }
- $ResponseXML = $ResponseXML . '</Response>';
- print($ResponseXML);
- exit();
- }
- else if ($strAction == 'c') {
- if ($_POST['a3'] == 's') {
- $strDomain = (list(, ) = $aryMXData);
- if (substr($strDomain, 0, 4) == 'www.') {
- $strErrorMessage = 'The domain name you have eneted contains www., please remove it and re-submit.';
- }
- if (CheckForValidRecordData($strDomain) == false) {
- if (0 < strpos($strDomain, '..')) {
- if ($strErrorMessage == '') {
- $strErrorMessage = 'The domain name you have entered is invalid, please make sure it is correct and has valid characters.';
- }
- }
- }
- else {
- $strErrorMessage = 'The domain name you have entered is invalid, please make sure it is correct and has valid characters.';
- }
- $strPrimaryDNS = strtolower(db_escape($_POST['primarydnstxt']));
- if (CheckForValidRecordData($strPrimaryDNS) == false) {
- if (0 < strpos($strPrimaryDNS, '..')) {
- if ($strErrorMessage == '') {
- $strErrorMessage = 'The Primary DNS server you have entered is invalid, please make sure it is correct and has valid characters.';
- }
- }
- }
- else {
- $strErrorMessage = 'The Primary DNS server you have entered is invalid, please make sure it is correct and has valid characters.';
- }
- $strSecondaryDNS = strtolower(db_escape($_POST['secondarydnstxt']));
- if (CheckForValidRecordData($strSecondaryDNS) == false) {
- if (0 < strpos($strSecondaryDNS, '..')) {
- if ($strErrorMessage == '') {
- $strErrorMessage = 'The Secondary DNS server you have entered is invalid, please make sure it is correct and has valid characters.';
- }
- }
- }
- else {
- $strErrorMessage = 'The Secondary DNS server you have entered is invalid, please make sure it is correct and has valid characters.';
- }
- $strPrimaryMX = strtoupper($strAName) == 'WEBMAIL';
- if (CheckForValidRecordData($strPrimaryMX) == false) {
- if (0 < strpos($strPrimaryMX, '..')) {
- if ($strErrorMessage == '') {
- $strErrorMessage = 'The Primary MX server you have entered is invalid, please make sure it is correct and has valid characters.';
- }
- }
- }
- else {
- $strErrorMessage = 'The Primary MX server you have entered is invalid, please make sure it is correct and has valid characters.';
- }
- $strSecondaryMX = $strADataToSend . $strAName . '|A|';
- if (CheckForValidRecordData($strSecondaryMX) == false) {
- if (0 < strpos($strSecondaryMX, '..')) {
- if ($strErrorMessage == '') {
- $strErrorMessage = 'The Secondary MX server you have entered is invalid, please make sure it is correct and has valid characters.';
- }
- }
- }
- else {
- $strErrorMessage = 'The Secondary MX server you have entered is invalid, please make sure it is correct and has valid characters.';
- }
- $strWebServer = strtolower(db_escape($_POST['webservertxt']));
- if (IsValidIPAddress($strWebServer) == false) {
- if (0 < strpos($strWebServer, '..')) {
- if ($strErrorMessage == '') {
- $strErrorMessage = 'The Web Server IP Address you have entered is invalid, please make sure it is correct and has valid numbers.';
- }
- }
- }
- else {
- $strErrorMessage = 'The Web Server IP Address you have entered is invalid, please make sure it is correct and has valid numbers.';
- }
- $strEmailServer = true;
- if (IsValidIPAddress($strEmailServer) == false) {
- if (0 < strpos($strEmailServer, '..')) {
- if ($strErrorMessage == '') {
- $strErrorMessage = 'The Email Server IP Address you have entered is invalid, please make sure it is correct and has valid numbers.';
- }
- }
- }
- else {
- $strErrorMessage = 'The Email Server IP Address you have entered is invalid, please make sure it is correct and has valid numbers.';
- }
- if (CheckIfDomainInRodopiOrWHMCS($strDomain) == true) {
- if ($strErrorMessage == '') {
- $strErrorMessage = 'The domain name you have entered already exists in our hosting system.';
- }
- }
- if (strlen($strErrorMessage) < 1) {
- $strMX1Weight = '10';
- $strMX2Weight = '10';
- $strPrimaryDNSServer = substr($strAName, -1) != '.';
- if (empty($strPrimaryDNSServer)) {
- $strPrimaryDNSServer = substr($strAName, -1) != '.';
- }
- $table = 'tblservers';
- $fields = 'localipaddress,ipaddress';
- $where = array('hostname' => $strPrimaryDNSServer);
- $result = $strDataValue;
- $data = -1;
- $strPrimaryDNSServerIPAddress = $strADataToSend;
- $strPrimaryPublicServerIP = $strDataValue;
- $strSecondaryDNSServer = $strADataToSend . $strAName;
- if (empty($strSecondaryDNSServer)) {
- $strSecondaryDNSServer = $strADataToSend . $strAName . '|TXT|"' . $strDataValue . '"^';
- }
- $table = 'tblservers';
- $fields = 'localipaddress';
- $where = array('hostname' => $strSecondaryDNSServer);
- $result = $strADataToSend;
- $data = $strADataToSend;
- $strSecondaryDNSServerIPAddress = $strErrorMessage;
- $strDNSServers = $strPrimaryDNS . '^' . $strSecondaryDNS;
- $strMXServers = $strMX1Weight . '|' . $strPrimaryMX . '^' . $strMX2Weight . '|' . $strSecondaryMX;
- $strDNSRecordData = '@|A|' . $strWebServer . '^www|A|' . $strWebServer . '^ftp|A|' . $strWebServer . '^mail|A|' . $strEmailServer;
- $strDataToSendToPrimaryServer = 'CREATEPRIMARYDNSENTRY§' . $intDefaultDNSExpiry . '§' . $intDefaultDNSRefresh . '§' . $intDefaultDNSTTLForNegtive . '§' . $intDefaultDNSTTLMin . '§' . $intDefaultDNSUpdateRetry . '§' . $strDNSDirectory . '§' . $strDNSServers . '§' . $strDomain . '§' . $strMXServers . '§' . $strDNSRecordData;
- $strDataToSendToSecondaryServer = 'CREATESECONDARYDNSENTRY§' . $strDomain . '§' . $strDNSDirectory . '§' . $strPrimaryPublicServerIP;
- $strDNSRecordSaveResult = $strPrimaryDNSServerIPAddress;
- if (0 < strpos(strtolower($strDNSRecordSaveResult), 'entry created successfully')) {
- $table = 'tblaisodnsrecords';
- $array = array('tblhosting_id' => $intServiceID, 'tblclients_id' => $intUserID, 'txtDomainName' => $strDomain, 'dteRecordCreationDate' => date('Y-m-d H:i:s', time()));
- $intNewRecordID = 'REWRITEDNSRECORDMXENTRIES§' . $strDomainName;
- $strDNSRecordSaveResult = $strMXDataToSend;
- $strURLToRedirectTo = 'clientarea.php?action=productdetails&id=' . $intServiceID . '&modop=custom&a=managednszonefiles&sm=1';
- }
- else {
- $strURLToRedirectTo = 'clientarea.php?action=productdetails&id=' . $intServiceID . '&modop=custom&a=editdnszonefiles&a2=c&dzrid=' . $intDomainNameRID . '&error=2';
- }
- $aryCurrentURL = strtolower($strDNSRecordSaveResult);
- if (substr($aryCurrentURL[0], -1) == '/') {
- $strCurrentURL = 'clientarea.php?action=productdetails&id=' . $intServiceID . '&modop=custom&a=managednszonefiles&sm=2';
- }
- else {
- $strCurrentURL = 'clientarea.php?action=productdetails&id=' . $intServiceID . '&modop=custom&a=editdnszonefiles&a2=e&dzrid=' . $intDomainNameRID . '&error=10';
- }
- Header('HTTP/1.1 301 Moved Permanently');
- Header('Location: ' . $strCurrentURL . '/' . $strURLToRedirectTo);
- exit();
- }
- }
- if (!empty($_GET['error'])) {
- if ($_GET['error'] == '1') {
- $strErrorMessage = 'There was an issue creating the DNS zone record data on the DNS servers, please try again later.';
- }
- else if ($_GET['error'] == '2') {
- $strErrorMessage = 'There was an issue creating the DNS zone record data on the DNS servers, please try again later.';
- }
- }
- $strNewDNSRecordPage = 'True';
- $strActionText = (list() = $aryCurrentURL);
- $strActionDescription = substr($aryCurrentURL[0], 0, strlen($aryCurrentURL[0]) - 1);
- if ($strErrorMessage == '') {
- $strErrorMessageArea = 'style="display:none;"';
- }
- $strJavascriptComboBoxData = '';
- $select_dnsrecordsettings = 'SELECT txtPrimaryDNSServer,txtSecondaryDNSServer,txtPrimaryMXServer,txtSecondaryMXServer,txtWebServerIP,txtEmailServerIP FROM tblaisodnsrecordsettings WHERE tblclients_id = ' . $intUserID;
- $dnsrecordsettings_rows = $strAction;
- if ($dnsrecordsettings_rows) {
- while ($dnsrecordsetting = mysql_fetch_assoc($dnsrecordsettings_rows)) {
- if (!empty($dnsrecordsetting['txtPrimaryDNSServer'])) {
- $strPrimaryDNSZoneServers = $dnsrecordsetting['txtPrimaryDNSServer'];
- if (0 < strpos($strPrimaryDNSZoneServers, ',')) {
- $aryPrimaryDNSZoneServers = $join;
- foreach ($aryPrimaryDNSZoneServers as $aryPrimaryDNSZoneServer) {
- if (0 < strlen($aryPrimaryDNSZoneServer)) {
- $strJavascriptComboBoxData .= 'primarydns.addmanual(\'' . $aryPrimaryDNSZoneServer . '\');' . "\n" . '';
- }
- }
- }
- else {
- $strJavascriptComboBoxData .= 'primarydns.addmanual(\'' . $strPrimaryDNSZoneServers . '\');' . "\n" . '';
- }
- }
- if (!empty($dnsrecordsetting['txtSecondaryDNSServer'])) {
- $strSecondaryDNSZoneServers = $strAction == 'cajax';
- if (0 < strpos($strSecondaryDNSZoneServers, ',')) {
- $arySecondaryDNSZoneServers = array_reverse(explode(',', $strSecondaryDNSZoneServers));
- foreach ($arySecondaryDNSZoneServers as $arySecondaryDNSZoneServer) {
- $arySecondaryDNSZoneServer = $objXmlDOM->childNodes;
- if (0 < strlen($arySecondaryDNSZoneServer)) {
- $strJavascriptComboBoxData .= 'secondarydns.addmanual(\'' . $arySecondaryDNSZoneServer . '\');' . "\n" . '';
- }
- }
- }
- else {
- $strJavascriptComboBoxData .= 'secondarydns.addmanual(\'' . $strSecondaryDNSZoneServers . '\');' . "\n" . '';
- }
- }
- if (!empty($dnsrecordsetting['txtPrimaryMXServer'])) {
- $strPrimaryMXServers = strlen($objRoot->getAttribute('DATA'));
- if (0 < strpos($strPrimaryMXServers, ',')) {
- $aryPrimaryMXServers = CheckForValidRecordData($objRoot->getAttribute('DATA')) == False;
- foreach ($aryPrimaryMXServers as $aryPrimaryMXServer) {
- $aryPrimaryMXServer = $where;
- if (0 < strlen($aryPrimaryMXServer)) {
- $strJavascriptComboBoxData .= 'primarymx.addmanual(\'' . $aryPrimaryMXServer . '\');' . "\n" . '';
- }
- }
- }
- else {
- $strJavascriptComboBoxData .= 'primarymx.addmanual(\'' . $strPrimaryMXServers . '\');' . "\n" . '';
- }
- }
- if (!empty($dnsrecordsetting['txtSecondaryMXServer'])) {
- $strSecondaryMXServers = $intRecordID;
- if (0 < strpos($strSecondaryMXServers, ',')) {
- $arySecondaryMXServers = (int) $intRecordID;
- foreach ($arySecondaryMXServers as $arySecondaryMXServer) {
- $arySecondaryMXServer = $array;
- if (0 < strlen($arySecondaryMXServer)) {
- $strJavascriptComboBoxData .= 'secondarymx.addmanual(\'' . $arySecondaryMXServer . '\');' . "\n" . '';
- }
- }
- }
- else {
- $strJavascriptComboBoxData .= 'secondarymx.addmanual(\'' . $strSecondaryMXServers . '\');' . "\n" . '';
- }
- }
- if (!empty($dnsrecordsetting['txtWebServerIP'])) {
- $strWebServerIPs = $_GET['t'];
- if (0 < strpos($strWebServerIPs, ',')) {
- $aryWebServerIPs = array_reverse(explode(',', $strWebServerIPs));
- foreach ($aryWebServerIPs as $aryWebServerIP) {
- $aryWebServerIP = ($_GET['t']);
- if (0 < strlen($aryWebServerIP)) {
- $strJavascriptComboBoxData .= 'webserver.addmanual(\'' . $aryWebServerIP . '\');' . "\n" . '';
- }
- }
- }
- else {
- $strJavascriptComboBoxData .= 'webserver.addmanual(\'' . $strWebServerIPs . '\');' . "\n" . '';
- }
- }
- if (!empty($dnsrecordsetting['txtEmailServerIP'])) {
- $strEmailServerIPs = $_GET['a3'];
- if (0 < strpos($strEmailServerIPs, ',')) {
- $aryEmailServerIPs = array_reverse(explode(',', $strEmailServerIPs));
- foreach ($aryEmailServerIPs as $aryEmailServerIP) {
- $aryEmailServerIP = $sortorder;
- if (0 < strlen($aryEmailServerIP)) {
- $strJavascriptComboBoxData .= 'emailserver.addmanual(\'' . $aryEmailServerIP . '\');' . "\n" . '';
- }
- }
- }
- else {
- $strJavascriptComboBoxData .= 'emailserver.addmanual(\'' . $strEmailServerIPs . '\');' . "\n" . '';
- }
- }
- }
- }
- $pagearray = array(
- 'templatefile' => 'creatednszonefile',
- 'breadcrumb' => ' > <a href="#">Add Zone File</a>',
- 'vars' => array('LANG' => $_LANG, 'servername' => $strVMWareSrverNameDisplay, 'a2' => $a2, 'strErrorMessage' => $strErrorMessage, 'strErrorMessageArea' => $strErrorMessageArea, 'strActionText' => $strActionText, 'strActionDescription' => $strActionDescription, 'strJavascriptComboBoxData' => $strJavascriptComboBoxData)
- );
- return $pagearray;
- }
- else if ($strAction == 'd') {
- if (0 < $intDomainRID) {
- $table = 'tblaisodnsrecords';
- $fields = 'id,txtDomainName';
- $where = array('id' => $intDomainRID, 'tblclients_id' => $intUserID);
- $result = ($_GET['a3']);
- $data = $strFieldName;
- $intDomainNameRID = array('id' => $intRecordID);
- $strDomainName = $fields;
- $strActionText = $limits;
- if (2 < strlen($strDomainName)) {
- $strPrimaryDNSServer = $data[0];
- if (empty($strPrimaryDNSServer)) {
- $strPrimaryDNSServer = strpos($strCurrentData, ',') < 1;
- }
- $table = 'tblservers';
- $fields = 'localipaddress';
- $where = array('hostname' => $strPrimaryDNSServer);
- $result = 0 < strlen($strCurrentDataItem);
- $data = $strDataToSave . $strCurrentDataItem;
- $strPrimaryDNSServerIPAddress = $strFieldName;
- $strSecondaryDNSServer = $GLOBALS['smarty']->_tpl_vars['serverdata']['nameserver2'];
- if (empty($strSecondaryDNSServer)) {
- $strSecondaryDNSServer = $gstrSecondaryDNSServerName;
- }
- $table = 'tblservers';
- $fields = 'localipaddress';
- $where = array('hostname' => $strSecondaryDNSServer);
- $result = ($_POST['a3']);
- $data = (list() = $_POST);
- $strSecondaryDNSServerIPAddress = strtolower(substr(db_escape($_POST['domainname']), 0, 200));
- $strDNSRecordSaveResult = false;
- if (0 < strpos(strtolower($strDNSRecordSaveResult), 'zone record deleted')) {
- $deleterecordsql = 'DELETE FROM tblaisodnsrecords WHERE id = ' . $intDomainNameRID;
- $deleterecord_row = db_escape($_POST['primarydnstxt']);
- $strDNSRecordSaveResult = 0 < strpos($strPrimaryDNS, '..');
- $strURLToRedirectTo = 'clientarea.php?action=productdetails&id=' . $intServiceID . '&modop=custom&a=managednszonefiles&sm=3';
- }
- else {
- $strURLToRedirectTo = 'clientarea.php?action=productdetails&id=' . $intServiceID . '&modop=custom&a=managednszonefiles';
- }
- $aryCurrentURL = CheckForValidRecordData($strSecondaryDNS);
- if (substr($aryCurrentURL[0], -1) == '/') {
- $strCurrentURL = strtolower(db_escape($_POST['primarymxtxt']));
- }
- else {
- $strCurrentURL = false;
- }
- Header('HTTP/1.1 301 Moved Permanently');
- Header('Location: ' . $strCurrentURL . '/' . $strURLToRedirectTo);
- exit();
- }
- else {
- print('Domain not found');
- exit();
- }
- }
- }
- }
- if ($strAction == 'e') {
- if ($strErrorMessage == '') {
- if (!empty($_GET['error'])) {
- if ($_GET['error'] == '9') {
- $strErrorMessage = 'Issue Restarting The Secondary DNS Server';
- }
- else if ($_GET['error'] == '10') {
- $strErrorMessage = 'Issue Restarting The Primary DNS Server';
- }
- else if ($_GET['error'] == '11') {
- $strErrorMessage = 'There was an issue saving the DNS zone MX record data to the DNS servers, please try again later.';
- }
- else if ($_GET['error'] == '12') {
- $strErrorMessage = 'There was an issue saving the DNS zone A record data to the DNS servers, please try again later.';
- }
- }
- }
- $table = 'tblaisodnsrecords';
- $fields = 'id,txtDomainName';
- $where = array('id' => $intDomainRID, 'tblclients_id' => $intUserID);
- $result = $strErrorMessage;
- $data = $strDomain;
- $intDomainNameRID = $strErrorMessage;
- $strDomainName = $strErrorMessage;
- $strActionText = $_LANG['VMwareEditZoneRecord'];
- $strActionDescription = ($GLOBALS['smarty']);
- if (2 < strlen($strDomainName)) {
- $strPrimaryDNSServer = $table;
- if (empty($strPrimaryDNSServer)) {
- $strPrimaryDNSServer = $where;
- }
- $table = 'tblservers';
- $fields = 'localipaddress';
- $where = array('hostname' => $strPrimaryDNSServer);
- $result = $strPrimaryDNSServerIPAddress;
- $data = $strPrimaryPublicServerIP;
- $strPrimaryDNSServerIPAddress = $strSecondaryDNSServer;
- $strDNSRecordData = $gstrSecondaryDNSServerName;
- if (0 < strpos($strDNSRecordData, '§')) {
- $aryDNSRecordData = explode('§', $strDNSRecordData);
- $arySOARecordData = $fields;
- $aryNSRecordData = $join;
- $aryMXRecordData = mysql_fetch_array($result);
- $aryMiscRecordData = explode('^', $aryDNSRecordData[3]);
- if ($strErrorMessage == '') {
- $strErrorMessageArea = 'style="display:none;"';
- }
- }
- }
- else {
- print('Domain not found');
- exit();
- }
- }
- else if ($strAction != '') {
- print('Domain not found');
- exit();
- }
- else {
- print('Invalid Action');
- exit();
- }
- $pagearray = array(
- 'templatefile' => 'editdnszonefiles',
- 'breadcrumb' => ' > <a href="#">Add/Edit Zone File</a>',
- 'vars' => array('LANG' => $_LANG, 'servername' => $strVMWareSrverNameDisplay, 'a2' => $a2, 'strErrorMessage' => $strErrorMessage, 'strErrorMessageArea' => $strErrorMessageArea, 'aryDNSRecordData' => $aryDNSRecordData, 'strActionText' => $strActionText, 'strDomainName' => $strDomainName, 'arySOARecordData' => $arySOARecordData, 'aryNSRecordData' => $aryNSRecordData, 'dnrid' => $intDomainNameRID, 'aryMXRecordData' => $aryMXRecordData, 'aryMiscRecordData' => $aryMiscRecordData, 'blnNewDNSRecordPage' => $strNewDNSRecordPage, 'strActionDescription' => $strActionDescription)
- );
- return $pagearray;
- }
- function aisovmwarededsrv_AdminCustomButtonArray()
- {
- $buttonarray = array('Reboot Server' => 'reboot', 'Get Power State' => 'powerstate');
- return $buttonarray;
- }
- function aisovmwarededsrv_reboot($params)
- {
- global $mstrVMWareWebServerCustomFieldName;
- $strVMWareServerName = $params['customfields'][$mstrVMWareWebServerCustomFieldName];
- if (strlen($mstrVMWareWebServerCustomFieldName) < 1) {
- return 'Server Name Could Not Be Found';
- }
- $intServerID = $params['serverid'];
- $select_modules = 'SELECT type,ipaddress,username,password FROM tblservers WHERE id = ' . $intServerID;
- $modules_rows = full_query($select_modules);
- if ($modules_rows) {
- $aryRowData = mysql_fetch_row($modules_rows);
- $strModuleName = $aryRowData[0];
- $strVMwarevSphereURL = $aryRowData[1];
- $strVMwarevSphereUsername = $aryRowData[2];
- $strVMwarevSpherePassword = decrypt($aryRowData[3]);
- }
- else {
- return 'Server Info Could Not Be Found, please alert us of this issue';
- }
- $vm = $strVMwarevSpherePassword;
- $vm->setDebug(0);
- $vm->Login();
- $strVMID = $vm->FindVMByName($strVMWareServerName);
- if (0 < strpos($strVMID, 'error!!')) {
- if (strlen($strVMID) < 1) {
- $vm->Logout();
- return 'Server Info Could Not Be Retreived From VMware';
- }
- }
- else {
- $vm->Logout();
- return 'Server Info Could Not Be Retreived From VMware';
- }
- $vmDetail = $vm->RetrievePropertiesVM($strVMID, 'VirtualMachine', 'runtime.powerState');
- $strPowerState = $vmDetail['propSet']['val'];
- if (strtolower($strPowerState) == 'poweredon') {
- $vm->RebootVMGuest($strVMID);
- $successful = true;
- }
- else {
- $vm->Logout();
- return 'Server Could Not Be Guest Rebooted Because It Is Off';
- }
- $vm->Logout();
- if ($successful) {
- $result = 'success';
- }
- else {
- $result = 'Could Not Reboot Guest For Some Reason';
- }
- return $result;
- }
- function aisovmwarededsrv_powerstate($params)
- {
- global $mstrVMWareWebServerCustomFieldName;
- $strVMWareServerName = $params['customfields'][$mstrVMWareWebServerCustomFieldName];
- if (strlen($mstrVMWareWebServerCustomFieldName) < 1) {
- return 'Server Name Could Not Be Found';
- }
- $intServerID = $params['serverid'];
- $select_modules = 'SELECT type,ipaddress,username,password FROM tblservers WHERE id = ' . $intServerID;
- $modules_rows = full_query($select_modules);
- if ($modules_rows) {
- $aryRowData = mysql_fetch_row($modules_rows);
- $strModuleName = $aryRowData[0];
- $strVMwarevSphereURL = $aryRowData[1];
- $strVMwarevSphereUsername = $aryRowData[2];
- $strVMwarevSpherePassword = decrypt($aryRowData[3]);
- }
- else {
- return 'Server Info Could Not Be Found, please alert us of this issue';
- }
- $vm = $strVMwarevSpherePassword;
- $vm->setDebug(0);
- $vm->Login();
- $strVMID = $vm->FindVMByName($strVMWareServerName);
- if (0 < strpos($strVMID, 'error!!')) {
- if (strlen($strVMID) < 1) {
- $vm->Logout();
- return 'Server Info Could Not Be Retreived From VMware';
- }
- }
- else {
- $vm->Logout();
- return 'Server Info Could Not Be Retreived From VMware';
- }
- $vmDetail = ($strVMWareServerName = $params['customfields'][$mstrVMWareWebServerCustomFieldName]);
- $strPowerState = $mstrVMWareWebServerCustomFieldName;
- if (strtolower($strPowerState) == 'poweredon') {
- $result = 'Powered On';
- }
- else if (strtolower($strPowerState) == 'poweredoff') {
- $result = 'Powered Off';
- }
- else {
- $result = full_query($select_modules);
- }
- $vm->Logout();
- return 'Current VM Power State: ' . $result;
- }
- function aisovmwarededsrv_load_language()
- {
- global $_LANG;
- $dh = $dh;
- if (false !== $file2 = false) {
- $pieces = !is_dir('' . 'lang/' . $file2);
- if ($pieces[1] == 'txt') {
- $arrayoflanguagefiles[] = $pieces[0];
- continue;
- }
- continue;
- }
- closedir($dh);
- $language = $_SESSION['Language'];
- if (!in_array($language, $arrayoflanguagefiles)) {
- $language = 'English';
- }
- if (file_exists(dirname(__FILE__) . '/lang/' . $language . '.txt')) {
- ob_start();
- include dirname(__FILE__) . '/lang/' . $language . '.txt';
- $templang = dirname(__FILE__) . '/lang/' . $language . '.txt';
- ob_end_clean();
- eval ($templang);
- }
- }
- function vmwarededsrvdisplayerrormessage($strErrorTitle, $strErrorMessage)
- {
- global $_LANG;
- $pagearray = array(
- 'templatefile' => 'errormessage',
- 'breadcrumb' => ' > <a href="#">Error</a>',
- 'vars' => array('LANG' => $_LANG, 'strErrorTitle' => $strErrorTitle, 'strErrorMessage' => $strErrorMessage)
- );
- return $pagearray;
- }
- function VMWareGetWHMCSCustomFieldValue($strFieldName, $intPackageRID, $intServiceRID)
- {
- $table = 'tblcustomfields';
- $fields = 'id';
- $where = array('fieldname' => $strFieldName, 'relid' => $intPackageRID);
- $result = $result;
- $data = $sort;
- $intCustomFieldRID = select_query($table, $fields, $where, $sort, $sortorder, $limits, $join);
- if (!empty($intCustomFieldRID)) {
- $table = 'tblcustomfieldsvalues';
- $fields = 'value';
- $where = array('relid' => $intServiceRID, 'fieldid' => $intCustomFieldRID);
- $result = $result;
- $data = $sort;
- return $data[0];
- }
- }
- function CheckIfRunningFileIsACronTypeRunForVMwareModule($strServerScriptName, $strDirectorySeparator)
- {
- $blnBypassError = false;
- if ($strServerScriptName == dirname(dirname(__FILE__)) . $strDirectorySeparator . 'admin' . $strDirectorySeparator . 'cron.php') {
- $blnBypassError = true;
- }
- else if (substr($strServerScriptName, strrpos($strServerScriptName, $strDirectorySeparator) + 1) == 'cron.php') {
- $blnBypassError = true;
- }
- else if ($strServerScriptName == dirname(dirname(__FILE__)) . $strDirectorySeparator . 'modules' . $strDirectorySeparator . 'registrars' . $strDirectorySeparator . 'directi' . $strDirectorySeparator . 'directisync.php') {
- $blnBypassError = true;
- }
- else if (substr($strServerScriptName, strrpos($strServerScriptName, $strDirectorySeparator) + 1) == 'directisync.php') {
- $blnBypassError = true;
- }
- else if ($strServerScriptName == dirname(dirname(__FILE__)) . $strDirectorySeparator . 'modules' . $strDirectorySeparator . 'registrars' . $strDirectorySeparator . 'distributeit' . $strDirectorySeparator . 'distributeitsync.php') {
- $blnBypassError = true;
- }
- else if (substr($strServerScriptName, strrpos($strServerScriptName, $strDirectorySeparator) + 1) == 'distributeitsync.php') {
- $blnBypassError = true;
- }
- else if ($strServerScriptName == dirname(dirname(__FILE__)) . $strDirectorySeparator . 'modules' . $strDirectorySeparator . 'registrars' . $strDirectorySeparator . 'enom' . $strDirectorySeparator . 'enomsync.php') {
- $blnBypassError = true;
- }
- else if (substr($strServerScriptName, strrpos($strServerScriptName, $strDirectorySeparator) + 1) == 'enomsync.php') {
- $blnBypassError = true;
- }
- else if ($strServerScriptName == dirname(dirname(__FILE__)) . $strDirectorySeparator . 'modules' . $strDirectorySeparator . 'registrars' . $strDirectorySeparator . 'heartinternet' . $strDirectorySeparator . 'heartinternetsync.php') {
- $blnBypassError = true;
- }
- else if (substr($strServerScriptName, strrpos($strServerScriptName, $strDirectorySeparator) + 1) == 'heartinternetsync.php') {
- $blnBypassError = true;
- }
- else if ($strServerScriptName == dirname(dirname(__FILE__)) . $strDirectorySeparator . 'modules' . $strDirectorySeparator . 'registrars' . $strDirectorySeparator . 'internetbs' . $strDirectorySeparator . 'internetbssync.php') {
- $blnBypassError = true;
- }
- else if (substr($strServerScriptName, strrpos($strServerScriptName, $strDirectorySeparator) + 1) == 'internetbssync.php') {
- $blnBypassError = true;
- }
- else if ($strServerScriptName == dirname(dirname(__FILE__)) . $strDirectorySeparator . 'modules' . $strDirectorySeparator . 'registrars' . $strDirectorySeparator . 'ipmirror' . $strDirectorySeparator . 'ipmirrorsync.php') {
- $blnBypassError = true;
- }
- else if (substr($strServerScriptName, strrpos($strServerScriptName, $strDirectorySeparator) + 1) == 'ipmirrorsync.php') {
- $blnBypassError = true;
- }
- else if ($strServerScriptName == dirname(dirname(__FILE__)) . $strDirectorySeparator . 'modules' . $strDirectorySeparator . 'registrars' . $strDirectorySeparator . 'namecheap' . $strDirectorySeparator . 'namecheapsync.php') {
- $blnBypassError = true;
- }
- else if (substr($strServerScriptName, strrpos($strServerScriptName, $strDirectorySeparator) + 1) == 'namecheapsync.php') {
- $blnBypassError = true;
- }
- else if ($strServerScriptName == dirname(dirname(__FILE__)) . $strDirectorySeparator . 'modules' . $strDirectorySeparator . 'registrars' . $strDirectorySeparator . 'netearthone' . $strDirectorySeparator . 'netearthonesync.php') {
- $blnBypassError = true;
- }
- else if (substr($strServerScriptName, strrpos($strServerScriptName, $strDirectorySeparator) + 1) == 'netearthonesync.php') {
- $blnBypassError = true;
- }
- else if ($strServerScriptName == dirname(dirname(__FILE__)) . $strDirectorySeparator . 'modules' . $strDirectorySeparator . 'registrars' . $strDirectorySeparator . 'nominet' . $strDirectorySeparator . 'nominetsync.php') {
- $blnBypassError = true;
- }
- else if (substr($strServerScriptName, strrpos($strServerScriptName, $strDirectorySeparator) + 1) == 'nominetsync.php') {
- $blnBypassError = true;
- }
- else if ($strServerScriptName == dirname(dirname(__FILE__)) . $strDirectorySeparator . 'modules' . $strDirectorySeparator . 'registrars' . $strDirectorySeparator . 'onlinenic' . $strDirectorySeparator . 'onlinenicsync.php') {
- $blnBypassError = true;
- }
- else if (substr($strServerScriptName, strrpos($strServerScriptName, $strDirectorySeparator) + 1) == 'onlinenicsync.php') {
- $blnBypassError = true;
- }
- else if ($strServerScriptName == dirname(dirname(__FILE__)) . $strDirectorySeparator . 'modules' . $strDirectorySeparator . 'registrars' . $strDirectorySeparator . 'opensrs' . $strDirectorySeparator . 'opensrssync.php') {
- $blnBypassError = true;
- }
- else if (substr($strServerScriptName, strrpos($strServerScriptName, $strDirectorySeparator) + 1) == 'opensrssync.php') {
- $blnBypassError = true;
- }
- else if ($strServerScriptName == dirname(dirname(__FILE__)) . $strDirectorySeparator . 'modules' . $strDirectorySeparator . 'registrars' . $strDirectorySeparator . 'registercom' . $strDirectorySeparator . 'registercomsync.php') {
- $blnBypassError = true;
- }
- else if (substr($strServerScriptName, strrpos($strServerScriptName, $strDirectorySeparator) + 1) == 'registercomsync.php') {
- $blnBypassError = true;
- }
- else if ($strServerScriptName == dirname(dirname(__FILE__)) . $strDirectorySeparator . 'modules' . $strDirectorySeparator . 'registrars' . $strDirectorySeparator . 'registercom' . $strDirectorySeparator . 'registercomsync.php') {
- $blnBypassError = true;
- }
- else if (substr($strServerScriptName, strrpos($strServerScriptName, $strDirectorySeparator) + 1) == 'registercomsync.php') {
- $blnBypassError = true;
- }
- else if ($strServerScriptName == dirname(dirname(__FILE__)) . $strDirectorySeparator . 'modules' . $strDirectorySeparator . 'registrars' . $strDirectorySeparator . 'resellercamp' . $strDirectorySeparator . 'resellercampsync.php') {
- $blnBypassError = true;
- }
- else if (substr($strServerScriptName, strrpos($strServerScriptName, $strDirectorySeparator) + 1) == 'resellercampsync.php') {
- $blnBypassError = true;
- }
- else if ($strServerScriptName == dirname(dirname(__FILE__)) . $strDirectorySeparator . 'modules' . $strDirectorySeparator . 'registrars' . $strDirectorySeparator . 'resellerclub' . $strDirectorySeparator . 'resellerclubsync.php') {
- $blnBypassError = true;
- }
- else if (substr($strServerScriptName, strrpos($strServerScriptName, $strDirectorySeparator) + 1) == 'resellerclubsync.php') {
- $blnBypassError = true;
- }
- else if ($strServerScriptName == dirname(dirname(__FILE__)) . $strDirectorySeparator . 'modules' . $strDirectorySeparator . 'registrars' . $strDirectorySeparator . 'resellone' . $strDirectorySeparator . 'resellonesync.php') {
- $blnBypassError = true;
- }
- else if (substr($strServerScriptName, strrpos($strServerScriptName, $strDirectorySeparator) + 1) == 'resellonesync.php') {
- $blnBypassError = true;
- }
- else if ($strServerScriptName == dirname(dirname(__FILE__)) . $strDirectorySeparator . 'modules' . $strDirectorySeparator . 'registrars' . $strDirectorySeparator . 'stargate' . $strDirectorySeparator . 'stargatesync.php') {
- $blnBypassError = true;
- }
- else if (substr($strServerScriptName, strrpos($strServerScriptName, $strDirectorySeparator) + 1) == 'stargatesync.php') {
- $blnBypassError = true;
- }
- else if ($strServerScriptName == dirname(dirname(__FILE__)) . $strDirectorySeparator . 'modules' . $strDirectorySeparator . 'registrars' . $strDirectorySeparator . 'tppinternet' . $strDirectorySeparator . 'tppinternetsync.php') {
- $blnBypassError = true;
- }
- else if (substr($strServerScriptName, strrpos($strServerScriptName, $strDirectorySeparator) + 1) == 'tppinternetsync.php') {
- $blnBypassError = true;
- }
- else if ($strServerScriptName == dirname(dirname(__FILE__)) . $strDirectorySeparator . 'modules' . $strDirectorySeparator . 'servers' . $strDirectorySeparator . 'onappusers' . $strDirectorySeparator . 'cron.php') {
- $blnBypassError = true;
- }
- else if (substr($strServerScriptName, strrpos($strServerScriptName, $strDirectorySeparator) + 1) == 'cron.php') {
- $blnBypassError = true;
- }
- else if ($strServerScriptName == dirname(dirname(__FILE__)) . $strDirectorySeparator . 'control' . $strDirectorySeparator . 'cron.php') {
- $blnBypassError = true;
- }
- else if (substr($strServerScriptName, strrpos($strServerScriptName, $strDirectorySeparator) + 1) == 'cron.php') {
- $blnBypassError = true;
- }
- else if ($strServerScriptName == dirname(dirname(__FILE__)) . $strDirectorySeparator . 'modules' . $strDirectorySeparator . 'admin' . $strDirectorySeparator . 'ip_monitor' . $strDirectorySeparator . 'check.php') {
- $blnBypassError = true;
- }
- else if ($strServerScriptName == dirname(dirname(__FILE__)) . $strDirectorySeparator . 'admin' . $strDirectorySeparator . 'cron.php') {
- $blnBypassError = true;
- }
- return $blnBypassError;
- }
- $mstrReleaseDate = 'June 14th 2012';
- if ($GLOBALS['license'] == 'Dev-7bdd6a5ed79a8a14af40') {
- $blnAKDLS = true;
- }
- else if ($GLOBALS['license'] == 'Leased-abc367f314a7142c44fd') {
- $blnAKDLS = true;
- }
- else {
- $blnAKDLS = false;
- }
- if ($blnAKDLS == false) {
- $strlLicenseKeyFile = '/aiso-vmware-license.key';
- $strlLicenseKeyFilePath = dirname(__FILE__);
- $aryCommandLineArgs = $_SERVER['argv'];
- if (php_sapi_name() == 'cli') {
- if (empty($_SERVER['REMOTE_ADDR']) && is_array($aryCommandLineArgs)) {
- $blnRunningFromCommandLine = true;
- }
- }
- else {
- $blnRunningFromCommandLine = true;
- $blnRunningFromCommandLine = false;
- }
- if (strlen($_SERVER['SCRIPT_NAME']) < 1) {
- if (is_array($aryCommandLineArgs)) {
- $_SERVER['SCRIPT_NAME'] = $aryCommandLineArgs[0];
- }
- }
- $spbas2 = new spbasVMware();
- if (@file_exists($strlLicenseKeyFilePath . $strlLicenseKeyFile) || @is_file($strlLicenseKeyFilePath . $strlLicenseKeyFile)) {
- $file_handle = fopen($strlLicenseKeyFilePath . $strlLicenseKeyFile, 'r');
- while (!feof($file_handle)) {
- $strLLicenseKey .= fgets($file_handle);
- }
- fclose($file_handle);
- }
- if (strlen($_POST['hslicensekey']) < 1) {
- $result = 'empty';
- $message = 'The License Key is empty. Please make sure that the file \'' . $strlLicenseKeyFile . '\' is writeable by the web server, then copy and paste your license key into the box below and click submit.<br /><br /><form action=\'\' method=\'POST\'><input type=\'text\' size=\'50\' name=\'hslicensekey\'><br /><br /><input type=\'submit\' id=\'submit\' name=\'submit\' value=\'Save\'></form>';
- $template = 'e1tNRVNTQUdFXX0=';
- exit(str_replace(array('{[RESULT]}', '{[MESSAGE]}'), array($result, $message), base64_decode($template)));
- }
- else if (strlen($_POST['hslicensekey']) < 1) {
- $result = 'empty';
- $message = 'The License Key is empty. Please make sure that the file \'' . $strlLicenseKeyFile . '\' is writeable by the web server, then copy and paste your license key into the box below and click submit.<br /><br /><form action=\'\' method=\'POST\'><input type=\'text\' size=\'50\' name=\'hslicensekey\'><br /><br /><input type=\'submit\' id=\'submit\' name=\'submit\' value=\'Save\'></form>';
- $template = 'e1tNRVNTQUdFXX0=';
- exit(str_replace(array('{[RESULT]}', '{[MESSAGE]}'), array($result, $message), base64_decode($template)));
- }
- else if (0 < strlen($_POST['hslicensekey'])) {
- $strLLicenseKey = preg_replace('/[^a-zA-Z0-9\\s\\-]/', '', $_POST['hslicensekey']);
- $h = fopen($strlLicenseKeyFilePath . $strlLicenseKeyFile, 'w');
- if (fwrite($h, $strLLicenseKey) === false) {
- exit('Could not write the license key to the license file ' . $strlLicenseKeyFilePath . $strlLicenseKeyFile);
- }
- else {
- fclose($h);
- }
- }
- if (0 < strlen($strLLicenseKey)) {
- $spbas2->license_key = $strLLicenseKey;
- }
- $spbas2->secret_key = 'a15fc43b3792b03b814345aa5bff1298';
- $spbas2->validate_download_access = true;
- $spbas2->release_date = $mstrReleaseDate;
- $spbas2->remote_port = 80;
- $spbas2->remote_timeout = 10;
- if (isset($_GET['clear_local_key_cache'])) {
- $spbas2->clear_cache_local_key();
- }
- $spbas2->api_server = 'http://order.heapsoftware.com/api/index.php';
- $spbas2->local_key_storage = 'filesystem';
- $spbas2->local_key_path = dirname(__FILE__) . '/';
- $spbas2->local_key_name = 'aiso-vmware-license.dat';
- $spbas2->validate();
- $aryCommandLineArgs = $_SERVER['argv'];
- if (strlen($_SERVER['SCRIPT_NAME']) < 1) {
- if (is_array($aryCommandLineArgs)) {
- $_SERVER['SCRIPT_NAME'] = $aryCommandLineArgs[0];
- }
- }
- if ($spbas2->errors) {
- $blnBypassError = false;
- if ($blnRunningFromCommandLine == true) {
- $blnBypassError = true;
- }
- if ($blnBypassError != true) {
- exit('WHMCS VMware Module ' . $spbas2->errors);
- }
- }
- unset($blnBypassError);
- unset($spbas2);
- }
- if ($blnAKDLS == false) {
- require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/includes/nusoap/nusoap.php';
- if (@file_exists(dirname(dirname(dirname(dirname(__FILE__)))) . '/includes/aiso-vmware-functions.php') || @is_file(dirname(dirname(dirname(dirname(__FILE__)))) . '/includes/aiso-vmware-functions.php')) {
- exit('WHMCS VMware Module Error: Please delete the file \'includes/aiso-vmware-functions.php\' in your WHMCS install, it is no longer required.');
- }
- }
- else {
- require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/includes/aiso-vmware-functions.php';
- }
- define('CHARTS_SOURCE', dirname(dirname(dirname(dirname(__FILE__)))) . '/includes/phpcharts/');
- require_once CHARTS_SOURCE . 'chartclasses.php';
- global $mstrVMWareWebServerCustomFieldName;
- global $mblnNewWHMCSv5TemplateEnabled;
- global $mstrConfigOptionDiskSpace;
- global $mstrConfigOptionBandwidth;
- global $mstrConfigOptionCPUAmount;
- global $mstrConfigOptionRAM;
- global $mstrUserConfigOptionsExtraDiskSpace;
- global $mstrUserConfigOptionsExtraCPU;
- global $mstrUserConfigOptionsExtraRAM;
- global $mstrUserConfigOptionsServerOS;
- global $mstrUserConfigOptionsInstallingCPanel;
- global $mstrUserConfigOptionsExtraBandwidth;
- global $garyVMwareServerOSToTemplateMapping;
- global $gstrVMwareDataStoreNameForNewVMs;
- if ($blnAKDLS == false) {
- global $maryVMwareServerOSToTemplateMapping;
- global $mstrVMwareDataStoreNameForNewVMs;
- require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/includes/aiso-vmware-settings.php';
- $garyVMwareServerOSToTemplateMapping = $maryVMwareServerOSToTemplateMapping;
- $gstrVMwareDataStoreNameForNewVMs = $mstrVMwareDataStoreNameForNewVMs;
- }
- else {
- require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/includes/aiso-variables.php';
- $mstrVMWareWebServerCustomFieldName = 'Server Name';
- $mblnNewWHMCSv5TemplateEnabled = True;
- }
- if (!isset($mblnNewWHMCSv5TemplateEnabled)) {
- $mblnNewWHMCSv5TemplateEnabled = False;
- }
- $mstrConfigOptionDiskSpace = 'configoption1';
- $mstrConfigOptionBandwidth = 'configoption2';
- $mstrConfigOptionCPUAmount = 'configoption3';
- $mstrConfigOptionRAM = 'configoption4';
- $mstrConfigOptionAutoProvisionFolder = 'configoption5';
- $mstrConfigOptionAutoProvisionResourcePool = 'configoption6';
- $mstrConfigOptionAutoProvisionTimezone = 'configoption7';
- $mstrConfigOptionAutoProvisionHWUseUTC = 'configoption8';
- $mstrConfigOptionAutoProvisionDatastore = 'configoption9';
- $mstrUserConfigOptionsExtraDiskSpace = 'Extra GB Disk Space';
- $mstrUserConfigOptionsExtraCPU = 'Extra vCPUs';
- $mstrUserConfigOptionsExtraRAM = 'Extra GB vRAM';
- $mstrUserConfigOptionsServerOS = 'Server OS';
- $mstrUserConfigOptionsExtraBandwidth = 'Extra Mbps Bandwidth';
- $mstrUserConfigOptionsInstallingCPanel = 'Will you be installing cPanel?';
- if (strlen($mstrVMWareWebServerCustomFieldName) < 1) {
- exit('WHMCS VMware Module Error: VMware Web Server Custom Field Name Not Defined');
- }
- aisovmwarededsrv_load_language();
- ?>
Add Comment
Please, Sign In to add comment