در قسمتCustom Fields
Field Name را
vpsid
Field Type را text box
Description را vps id
وارد کنید
احتمالا در محصولات گزینه بالا انجام ندادید
در قسمتCustom Fields
Field Name را
vpsid
Field Type را text box
Description را vps id
وارد کنید
احتمالا در محصولات گزینه بالا انجام ندادید
ویرایش توسط i-whost : January 1st, 2014 در ساعت 12:02
دوستانی که از این ماژول استفاده میکنن بعد از این که نصب کردنش این فایل رو ویرایش کنید به آدرس سایت خودتون.
virtualizor.php
این رو ادیت کنید
فدا کاری که قرار داده یادش رفت که این رو ویرایش کنه.
<?php
include('SSH2.php');
$vm_all_array = null;
function virtualizor_ConfigOptions() {
# Should return an array of the module options for each xproduct - maimum of 24
$configarray = array(
"Type" => array( "Type" => "dropdown", "Options" => "ESXI,ESX"),
);
return $configarray;
}
//-----xxx
function virtualizor_AdminServicesTabFields($params) {
$values=array( );
$values= getAllVmInfo($params);
$ret= "<option value=''> NO SELECTED </option>" ;
$x=0;
foreach($values as $key=>$value){
$ret.=
"<option value='".$values[$x]['vmid']."'".
($params["customfields"]['vpsid']!=null?($params["customfields"]['vpsid']==$values[$x]['vmid']?' selected':''):'').
">{$values[$x]['name']}</option>"
;
++$x;
}
$virt_resp =getImportantInfo( $params['customfields']['vpsid'] ,$params );
$fieldsarray = array(
'select vps' => '<select name="modulefields[0]">'.$ret.'</select>',
'summery' => $theme = virt_performance($params),
// $virt_resp['vmPathName'] , # Info Output Only
);
return $fieldsarray;
}
function virtualizor_AdminServicesTabFieldsSave($params) {
//yyy
$serviceid = $params["serviceid"];
$pid = $params["pid"];
$query = mysql_query("SELECT `id` FROM `tblcustomfields` WHERE `relid` = '$pid' AND `fieldname` = 'vpsid'");
$res = mysql_fetch_array($query);
mysql_query("UPDATE `tblcustomfieldsvalues` SET `value` = '".$_POST['modulefields'][0]."' WHERE `relid` = '$serviceid' AND `fieldid` = '$res[id]'") ;
}
//---------
function virtualizor_CreateAccount($params) {
# ** The variables listed below are passed into all module functions **
$serviceid = $params["serviceid"]; # Unique ID of the product/service in the WHMCS Database
$pid = $params["pid"]; # Product/Service ID
$producttype = $params["producttype"]; # Product Type: hostingaccount, reselleraccount, server or other
$domain = $params["domain"];
$username = $params["username"];
$password = $params["password"];
$clientsdetails = $params["clientsdetails"]; # Array of clients details - firstname, lastname, email, country, etc...
$customfields = $params["customfields"]; # Array of custom field values for the product
$configoptions = $params["configoptions"]; # Array of configurable option values for the product
if(!empty($params["customfields"]['vpsid'])){
return 'The VPS exists';
}
# Additional variables if the product/service is linked to a server
$server = $params["server"]; # True if linked to a server
$serverid = $params["serverid"];
$serverip = $params["serverip"];
$serverusername = $params["serverusername"];
$serverpassword = $params["serverpassword"];
$serveraccesshash = $params["serveraccesshash"];
$serversecure = $params["serversecure"]; # If set, SSL Mode is enabled in the server config
$virttype = (preg_match('/xen/is', $params['configoption1']) ? 'xen' : strtolower($params['configoption1']));
$hvm = (preg_match('/hvm/is', $params['configoption1']) ? 1 : 0);
$numips = (int) $params['configoption13'];
// Get the Data
$data = Virtualizor_Curl::make_api_call($params["serverip"], $params["serverpassword"], 'index.php?act=addvs');
if(empty($data)){
return 'Could not load the server data.'.Virtualizor_Curl::error($params["serverip"]);
}
// echo "<pre>";print_r($params);echo "</pre>";
// echo "<pre>";print_r($data);echo "</pre>";
$cookies = array();
// Is there a Slave server ?
if(!empty($params['configoption15']) && $params['configoption15'] != 'localhost'){
// Do we have to Auto Select
if($params['configoption15'] == 'auto'){
foreach($data['servers'] as $k => $v){
// Master servers cannot be here
if(empty($k)) continue;
// Only the Same type of Virtualization is supported
if($virttype != $v['virt']){
continue;
}
// Xen HVM additional check
if(!empty($hvm) && empty($v['hvm'])){
continue;
}
$tmpsort[$k] = $v['numvps'];
}
// Did we get a list of Slave Servers
if(empty($tmpsort)){
return 'No server present in the Cluster which is of the Virtualization Type : '.$params['configoption1'];
}
asort($tmpsort);
$newserid = key($tmpsort);
//return 'Tests'.$newserid.var_export($tmpsort, 1);
}else{
foreach($data['servers'] as $k => $v){
if(trim(strtolower($v['server_name'])) == trim(strtolower($params['configoption15']))){
$newserid = $k;
}
}
}
// Is there a valid slave server ?
if(empty($newserid)){
return 'There is no slave server - '.$params['configoption15'].'. Please correct the <b>Product / Service</b> with the right slave server name.';
}
// Is there a Server Group ?
}elseif(!empty($params['configoption16'])){
foreach($data['servergroups'] as $k => $v){
// Match the Server Group
if(trim(strtolower($v['sg_name'])) == trim(strtolower($params['configoption16']))){
$sgid = $k;
}
}
// OH SHIT ! We didnt find anything
if(!isset($sgid)){
return 'Could not find the server group - '.$params['configoption16'].'. Please correct the <b>Product / Service</b> with the right slave server name.';
}
// Make an array of available servers in this group
foreach($data['servers'] as $k => $v){
// Do you belong to this group
if($v['sgid'] != $sgid){
continue;
}
// Only the Same type of Virtualization is supported
if($virttype != $v['virt']){
continue;
}
// Xen HVM additional check
if(!empty($hvm) && empty($v['hvm'])){
continue;
}
$tmpsort[$k] = $v['numvps'];
}
asort($tmpsort);
// Is there a valid slave server ?
if(empty($tmpsort)){
return 'No server present in the Server Group which is of the Virtualization Type : '.$params['configoption1'].'. Please correct the <b>Product / Service</b> with the right slave server name.';
}
$newserid = key($tmpsort);
}
// If a new server ID was found. Even if its 0 (Zero) then there is no need to reload data as the DATA is by default of 0
if(!empty($newserid)){
$cookies[$data['globals']['cookie_name'].'_server'] = $newserid;
$data = Virtualizor_Curl::make_api_call($params["serverip"], $params["serverpassword"], 'index.php?act=addvs', array(), array(), $cookies);
if(empty($data)){
return 'Could not load the slave server data';
}
}
$post = array();
// Search does the user exist
foreach($data['users'] as $k => $v){
if(strtolower($v['email']) == strtolower($params["clientsdetails"]['email'])){
$post['uid'] = $v['uid'];
}
}
// Was the user there ?
if(empty($post['uid'])){
$post['user_email'] = $params["clientsdetails"]['email'];
$post['user_pass'] = $params["password"];
}
// Search the OS ID
foreach($data['oslist'][$virttype] as $k => $v){
foreach($v as $kk => $vv){
// Xen Stuff!
if($virttype == 'xen'){
// Xen HVM templates
if(!empty($hvm) && empty($vv['hvm'])){
continue;
// Xen PV templates
}elseif(empty($hvm) && !empty($vv['hvm'])){
continue;
}
}
//echo $vv['name'].' - '.$params["customfields"]['OS'].'<br>';
// Does the String match ?
if(strtolower($vv['name']) == strtolower(trim($params["customfields"]['OS']))){
$post['osid'] = $kk;
}
}
}
// No emails
if(!empty($params["customfields"]['noemail'])){
$post['noemail'] = 1;
}
// Is the OS template there
if(empty($post['osid'])){
return 'Could not find the OS Template '.$params["customfields"]['OS'];
}
// Assign the IPs
foreach($data['ips'] as $k => $v){
$i = $numips;
$_ips[] = $v['ip'];
if($i == count($_ips)){
break;
}
}
// Were there enough IPs
if(empty($_ips) || count($_ips) < $numips){
return 'There are insufficient IPs on the server';
}
$post['hostname'] = $params['domain'];
$post['rootpass'] = $params['password'];
$post['space'] = $params['configoption2'];
$post['ram'] = $params['configoption4'];
$post['bandwidth'] = $params['configoption7'];
$post['cores'] = $params['configoption9'];
$post['network_speed'] = $params['configoption14'];
$post['addvps'] = 1;
// Is is OpenVZ
if($virttype == 'openvz'){
$post['inodes'] = $params['configoption3'];
$post['burst'] = $params['configoption5'];
$post['cpu_percent'] = $params['configoption10'];
$post['cpu'] = $params['configoption8'];
$post['priority'] = $params['configoption11'];
// Is it Xen PV?
}elseif($virttype == 'xen' && empty($hvm)){
$post['swapram'] = $params['configoption6'];
$post['cpu_percent'] = $params['configoption10'];
$post['cpu'] = $params['configoption8'];
if($params['configoption12'] == 'yes' || $params['configoption12'] == 'on'){
$post['vnc'] = 1;
$post['vncpass'] = generateRandStr(8);
}
// Is it Xen HVM?
}elseif($virttype == 'xen' && !empty($hvm)){
$post['hvm'] = 1;
$post['shadow'] = 8;
$post['swapram'] = $params['configoption6'];
$post['cpu_percent'] = $params['configoption10'];
$post['cpu'] = $params['configoption8'];
if($params['configoption12'] == 'yes' || $params['configoption12'] == 'on'){
$post['vnc'] = 1;
$post['vncpass'] = generateRandStr(8);
}
// Is it KVM ?
}elseif($virttype == 'kvm'){
$post['swapram'] = $params['configoption6'];
if($params['configoption12'] == 'yes' || $params['configoption12'] == 'on'){
$post['vnc'] = 1;
$post['vncpass'] = generateRandStr(8);
}
}
// Suspend on bandwidth
//$post['band_suspend'] = 1;
// Add the IPs
$post['ips'] = $_ips;
// Are there any configurable options
if(!empty($params['configoptions'])){
foreach($params['configoptions'] as $k => $v){
if(!isset($post[$k])){
$post[$k] = $v;
}
}
}
//echo "<pre>";print_r($cookies);echo "</pre>";
//echo "<pre>";print_r($post);echo "</pre>";
// return 'TEST'.var_export($params, 1);
$ret = Virtualizor_Curl::make_api_call($params["serverip"], $params["serverpassword"], 'index.php?act=addvs', array(), $post, $cookies);
// echo "<pre>";print_r($ret);echo "</pre>";
// Was the VPS Inserted
if(!empty($ret['newvs']['vpsid'])){
// vpsid of virtualizor
$query = mysql_query("SELECT `id` FROM `tblcustomfields` WHERE `relid` = '$pid' AND `fieldname` = 'vpsid'");
$res = mysql_fetch_array($query);
mysql_query("UPDATE `tblcustomfieldsvalues` SET `value` = '".$ret['newvs']['vpsid']."' WHERE `relid` = '$serviceid' AND `fieldid` = '$res[id]'") or mysql_error();
// Change the Username to the email
mysql_query("UPDATE `tblhosting` SET `username` = '".$params['clientsdetails']['email']."' WHERE `id` = '$serviceid';");
// The Dedicated IP
mysql_query("UPDATE `tblhosting` SET `dedicatedip` = '".$_ips[0]."' WHERE `id` = '$serviceid'");
// Extra IPs
if(count($_ips) > 1){
$tmp = $_ips;
unset($tmp[0]);
mysql_query("UPDATE `tblhosting` SET `assignedips` = '".implode("\n", $tmp)."' WHERE `id` = '$serviceid'");
}
// Did it start ?
if(!empty($ret['done'])){
return 'success';
}else{
return 'Errors : '.implode('<br>', $ret['error']);
}
} else {
return 'Errors : '.implode('<br>', $ret['error']);
}
}
function virtualizor_TerminateAccount($params) {
$data = Virtualizor_Curl::make_api_call($params["serverip"], $params["serverpassword"], 'index.php?act=vs&delete='.$params['customfields']['vpsid']);
if(empty($data)){
return 'Could not load the server data.'.Virtualizor_Curl::error($params["serverip"]);
}
// echo "<pre>";print_r($params);echo "</pre>";
// echo "<pre>";print_r($data);echo "</pre>";
// If the VPS has been deleted
if ($data['done']) {
// vpsid of virtualizor
$query = mysql_query("SELECT `id` FROM `tblcustomfields` WHERE `relid` = '".$params["pid"]."' AND `fieldname` = 'vpsid'");
$res = mysql_fetch_array($query);
mysql_query("UPDATE `tblcustomfieldsvalues` SET `value` = '' WHERE `relid` = '".$params["serviceid"]."' AND `fieldid` = '$res[id]'") or mysql_error();
// The Dedicated IP
mysql_query("UPDATE `tblhosting` SET `dedicatedip` = '' WHERE `id` = '".$params["serviceid"]."'");
mysql_query("UPDATE `tblhosting` SET `assignedips` = '' WHERE `id` = '".$params["serviceid"]."'");
$result = "success";
} else {
$result = "There was some error deleting the VPS";
}
return $result;
}
function virtualizor_SuspendAccount($params) {
global $virt_action_display, $virt_errors;
$virt_resp =runcommand( 'vim-cmd vmsvc/power.suspend '.$params['customfields']['vpsid'] ,$params);
if ( !stripos( $virt_resp, 'failed' ) === false ){
$virt_action_display = 'The VPS failed to suspend';
return $virt_action_display;
}
// Started it
$virt_action_display = 'The VPS has been started';
return 'success';
}
function virtualizor_UnsuspendAccount($params) {
global $virt_action_display, $virt_errors;
$virt_resp =runcommand( 'vim-cmd vmsvc/power.on '.$params['customfields']['vpsid'] ,$params);
if ( !stripos( $virt_resp, 'failed' ) === false ){
$virt_action_display = 'The VPS failed to start';
return $virt_action_display;
}
// Started it
$virt_action_display = 'The VPS has been unsuspend';
return 'success';
}
function virtualizor_ChangePassword($params) {
# Code to perform action goes here...
if ($successful) {
$result = "success";
} else {
$result = "Error Message Goes Here...";
}
return $result;
}
function virtualizor_ChangePackage($params) {
# Code to perform action goes here...
if ($successful) {
$result = "success";
} else {
$result = "Error Message Goes Here...";
}
return $result;
}
function virtualizor_AdminLink($params) {
$code = '';
return $code;
}
function virtualizor_LoginLink($params) {
echo "";
}
function virtualizor_AdminCustomButtonArray() {
# This function can define additional functions your module supports, the example here is a reboot button and then the reboot function is defined below
$buttonarray = array(
"Poweron VPS" => "start",
"Reboot VPS" => "reboot",
"OS Reboot"=> "stop",
"Poweroff VPS"=> "poweroff",
"Launch VNC"=> "vnc"
);
return $buttonarray;
}
function virtualizor_ClientAreaCustomButtonArray() {
# This function can define additional functions your module supports, the example here is a reboot button and then the reboot function is defined below
$buttonarray = array(
"Poweron VPS" => "start",
"Reboot VPS" => "reboot",
"OS Reboot"=> "stop",
"Poweroff VPS"=> "poweroff",
"Launch VNC"=> "vnc"
);
return $buttonarray;
}
class Virtualizor_Curl {
function error($ip = ''){
$err = '';
if(!empty($GLOBALS['virt_curl_err'])){
$err .= ' Curl Error: '.$GLOBALS['virt_curl_err'];
}
if(!empty($ip)){
$err .= ' (Server IP : '.$ip.')';
}
return $err;
}
function make_api_call($ip, $pass, $path, $data = array(), $post = array(), $cookies = array()){
$key = generateRandStr(8);
$apikey = make_apikey($key, $pass);
$url = 'https://'.$ip.':4085/'.$path;
$url .= (strstr($url, '?') ? '' : '?');
$url .= '&api=serialize&apikey='.rawurlencode($apikey);
// Pass some data if there
if(!empty($data)){
$url .= '&apidata='.rawurlencode(base64_encode(serialize($ data)));
}
// Set the curl parameters.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
// Time OUT
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
// Turn off the server and peer verification (TrustManager Concept).
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
// UserAgent
curl_setopt($ch, CURLOPT_USERAGENT, 'Softaculous');
// Cookies
if(!empty($cookies)){
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt($ch, CURLOPT_COOKIE, http_build_query($cookies, '', '; '));
}
if(!empty($post)){
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// Get response from the server.
$resp = curl_exec($ch);
if(empty($resp)){
$GLOBALS['virt_curl_err'] = curl_error($ch);
}
curl_close($ch);
// The following line is a method to test
//if(preg_match('/sync/is', $url)) echo $resp;
if(empty($resp)){
return false;
}
$r = _unserialize($resp);
if(empty($r)){
return false;
}
return $r;
}
function e_make_api_call($ip, $pass, $vid, $path, $post = array()){
$key = generateRandStr(8);
$apikey = make_apikey($key, $pass);
$url = 'https://'.$ip.':4083/'.$path;
$url .= (strstr($url, '?') ? '' : '?');
$url .= '&svs='.$vid.'&api=serialize&apikey='.rawurlencode ($apikey);
// Set the curl parameters.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
// Time OUT
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
// Turn off the server and peer verification (TrustManager Concept).
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
// UserAgent and Cookies
curl_setopt($ch, CURLOPT_USERAGENT, 'Softaculous');
if(!empty($post)){
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// Get response from the server.
$resp = curl_exec($ch);
curl_close($ch);
// The following line is a method to test
//if(preg_match('/os/is', $url)) echo $resp;
if(empty($resp)){
return false;
}
$r = _unserialize($resp);
if(empty($r)){
return false;
}
return $r;
}
function action($params, $action, $post = array()){
global $virt_verify, $virt_errors;
/*// Verify its this user
if(empty($virt_verify)){
$virt_verify = Virtualizor_Curl::make_api_call($params["serverip"], $params["serverpassword"], 'index.php?act=addvs');
}*/
// Make the call yaserf
$response = Virtualizor_Curl::e_make_api_call($params["serverip"], $params["serverpassword"], $params['customfields']['vpsid'], 'index.php?'.$action, $post);
if(empty($response)){
$virt_errors[] = '1The action could not be completed as no response was received.';
return false;
}
return $response;
} // function virt_curl_action ends
function actionchangevnc($params, $action, $post = array()){
global $virt_verify, $virt_errors;
$virt_resp =getImportantInfo( $params['customfields']['vpsid'] ,$params );
$filename ="/vmfs/volumes/".substr_replace($virt_resp['vmPathName'],"/",strpos($virt_resp['vmPathName'], " "),1);
/*// Verify its this user
if(empty($virt_verify)){
$virt_verify = Virtualizor_Curl::make_api_call($params["serverip"], $params["serverpassword"], 'index.php?act=addvs');
}*/
// Make the call ttt
$a='sed -i "s/\(remoteDisplay.vnc.password *= *\).*/\1'.$post['newpass'].'/" '.'"'.$filename.'"';
$response = runcommand($a,$params );
if(!empty($response)){
$virt_errors[] = 'The action could not be completed as no response was received.';
return false;
}
$response ="true";
return $response;
} // function virt_curl_action ends
} // class virtualizor_curl ends
function virtualizor_ClientArea($params) {
global $virt_action_display, $virt_errors, $virt_resp;
$GLOBALS['virt_img_url'] = 'modules/servers/virtualizor/images/';
$code = '
<table width="550" align="center"><tr><td align="center">
<h4 class="auto-style1">برای انجام عملیات بر روی آیکن کلیک کنید</h4>
<table cellpadding="0" dir="rtl" cellspacing="0"><tr><td align="center"><img src="'.$GLOBALS['virt_img_url'].'start.gif" width="80" height="65" title="Poweron VPS" alt="Start VPS" onMouseOver="this.style.cursor=\'pointer\'" onClick="window.location=\'clientarea.php?action=p roductdetails&id=' . $params['serviceid'] . '&modop=custom&a=start\'" /></img><br /></td>
<td align="center" ><img src="'.$GLOBALS['virt_img_url'].'stop.gif" width="80" height="65" title="Reboot VPS" alt="Reboot VPS" onMouseOver="this.style.cursor=\'pointer\'" onClick="window.location=\'clientarea.php?action=p roductdetails&id=' . $params['serviceid'] . '&modop=custom&a=reboot\'" /></img><br /></td>
<td align="center" ><img src="'.$GLOBALS['virt_img_url'].'poweroff.gif" width="80" height="65" title="Power off VPS" alt="Power off VPS" onMouseOver="this.style.cursor=\'pointer\'" onClick="window.location=\'clientarea.php?action=p roductdetails&id=' . $params['serviceid'] . '&modop=custom&a=poweroff\'" /></img><br /></td>
<td align="center"><img src="'.$GLOBALS['virt_img_url'].'performancedp.gif" width="80" height="65" title="Performance" alt="Performance" onMouseOver="this.style.cursor=\'pointer\'" onClick="window.location=\'clientarea.php?action=p roductdetails&id=' . $params['serviceid'] . '&modop=custom&b=performance\'" /></img><br /></td>
<tr>
<td align="center" ><img src="'.$GLOBALS['virt_img_url'].'vncpass.gif" width="80" height="65" title="Change VNC Password" alt="Change VNC Password" onMouseOver="this.style.cursor=\'pointer\'" onClick="window.location=\'clientarea.php?action=p roductdetails&id=' . $params['serviceid'] . '&modop=custom&b=changeVncPass\'" /></img></td>
<td align="center" ><img src="'.$GLOBALS['virt_img_url'].'vnc.gif" width="80" height="65" title="VNC console" alt="VNC console" onMouseOver="this.style.cursor=\'pointer\'" onClick="window.location=\'clientarea.php?action=p roductdetails&id=' . $params['serviceid'] . '&modop=custom&b=ram\'" /></img></td>
<td align="center" ><img src="'.$GLOBALS['virt_img_url'].'ostemp.gif" width="80" height="65" title="install Vmware tools" alt="install Vmware tools" onMouseOver="this.style.cursor=\'pointer\'" onClick="window.location=\'clientarea.php?action=p roductdetails&id=' . $params['serviceid'] . '&modop=custom&b=osreinstall\'" /></img><br /></td>
<td align="center" ><img src="'.$GLOBALS['virt_img_url'].'restart.gif" width="80" height="65" title="OS Reboot VPS" alt="OS Reboot" onMouseOver="this.style.cursor=\'pointer\'" onClick="window.location=\'clientarea.php?action=p roductdetails&id=' . $params['serviceid'] . '&modop=custom&a=stop\'" /></img><br /></td>
</tr>
</table><br /><br />
';
if($_GET['b'] == 'hostname'){
$theme = virt_hostname($params);
}
if($_GET['b'] == 'changeRootPass'){
$theme = virt_changeRootPass($params);
}
if($_GET['b'] == 'changeVncPass'){
$theme = virt_changeVncPass($params);
}
if($_GET['b'] == 'osreinstall'){
$theme = virt_osreinstall($params);
}
if($_GET['b'] == 'controlpanel'){
$theme = virt_controlpanel($params);
}
if($_GET['b'] == 'cpu'){
$theme = virt_cpu($params);
}
if($_GET['b'] == 'ram'){
$theme = virt_ram($params);
}
if($_GET['b'] == 'disk'){
$theme = virt_disk($params);
}
if($_GET['b'] == 'bandwidth'){
$theme = virt_bandwidth($params);
}
if($_GET['b'] == 'performance'){
$theme = virt_performance($params);
}
if($_GET['b'] == 'processes'){
$theme = virt_processes($params);
}
if($_GET['b'] == 'services'){
$theme = virt_services($params);
}
if($_GET['b'] == ''){
$theme = virt_performance($params);
}
// Any errors
if(!empty($virt_errors)){
$code .= virt_error($virt_errors);
}
// Show a Done message
if(!empty($virt_action_display)){
$code .= virt_done($virt_action_display);
}
// Show a Form
if(!empty($theme)){
$code .= $theme;
}
$code .= '<br /><br /></td></tr></table>';
return $code;
}
function virt_error($error, $table_width = '500', $center = true, $ret = true){
$str = '';
//on error call the form
if(!empty($error)){
$str = '<table width="'.$table_width.'" cellpadding="2" cellspacing="1" style="background-color: rgb(230, 230, 230);" '.(($center) ? 'align="center"' : '' ).'>
<tr>
<td>
The following errors occured :
<ul type="square">';
foreach($error as $ek => $ev){
$str .= '<li>'.$ev.'</li>';
}
$str .= '</ul>
</td>
</tr>
</table>'.(($center) ? '</center>' : '' ).'
<br />';
if(empty($ret)){
echo $str;
}else{
return $str;
}
}
}
function virt_done($done){
return '<div style="background-color: #FAFBD9; font-size:13px; padding:8px; text-align:center; margin-bottom: 20px; width: 500px"><img src="'.$GLOBALS['virt_img_url'].'notice.gif" /> '.$done.'</div>';
}
function virt_controlpanel($params) {
$theme = '<h2>Control Panel Installation</h2>';
$ins = @array_keys($_POST['ins']);
if(!empty($ins)){
$fields = array(
'ins' => $_POST['ins']
);
$virt_resp = Virtualizor_Curl::action($params, 'act=controlpanel&',$fields);
if(isset($virt_resp['done'])){
$theme .= virt_done('Control Panel Installation has been Started');
} elseif(isset($virt_resp['onboot'])) {
$theme .= virt_done('Please stop and start the VPS after which the control panel installtion will start');
} else {
$virt_errors[] = 'There was an error while reinstalling the Control Panel';
$theme .= virt_error($virt_errors);
}
}
$theme .= '
<script language="javascript" type="text/javascript">
function confirmpanel(){
if(confirm("Are you sure you want to install this panel ? Data on the server will be altered significantly.")){
return true;
}else{
return false;
}
}
</script>
<STYLE TYPE="text/css">
.mycss { width: 50px; height: 50px; }
</STYLE>
<form method="post" action="">
<table cellpadding="8" cellspacing="1">
<tr>
<td align="center">
<input type="image" name="ins[cpanel]" onclick="return confirmpanel()" src="'.$GLOBALS['virt_img_url'].'cpanel.gif" class="mycss" /><br />cPanel
</td>
<td align="center">
<input type="image" name="ins[plesk]" onclick="return confirmpanel()" src="'.$GLOBALS['virt_img_url'].'plesk.gif" class="mycss"/><br />Plesk
</td>
<td align="center">
<input type="image" name="ins[webuzo]" onclick="return confirmpanel()" src="'.$GLOBALS['virt_img_url'].'webuzo.gif" class="mycss"/><br />Webuzo
</td>
</tr>
<tr>
<td align="center">
<input type="image" name="ins[kloxo]" onclick="return confirmpanel()" src="'.$GLOBALS['virt_img_url'].'kloxo.gif" class="mycss" /><br />Kloxo
</td>
<td align="center">
<input type="image" name="ins[webmin]" onclick="return confirmpanel()" src="'.$GLOBALS['virt_img_url'].'webmin.gif" class="mycss" /><br />Webmin
</td>
<td> </td>
</tr>
</table>
</form><br />';
return $theme;
}
function virtualizor_start($params) {
global $virt_action_display, $virt_errors;
$virt_resp =runcommand( 'vim-cmd vmsvc/power.on '.$params['customfields']['vpsid'] ,$params);
if ( !stripos( $virt_resp, 'failed' ) === false ){
$virt_action_display = 'The VPS failed to start';
return $virt_action_display;
}
// Started it
$virt_action_display = 'The VPS has been started';
return 'success';
}
function virtualizor_stop($params) {
global $virt_action_display, $virt_errors;
$virt_resp =runcommand( 'vim-cmd vmsvc/power.reboot '.$params['customfields']['vpsid'] ,$params);
if ( !stripos( $virt_resp, 'Invalid' ) === false ){
$virt_action_display = 'The VPS failed to os reboot (InvalidPowerState)';
return $virt_action_display;
}
// Started it
$virt_action_display = 'The VPS has been restart os';
return 'success';
}
function virtualizor_reboot($params) {
global $virt_action_display, $virt_errors;
$virt_resp =runcommand( 'vim-cmd vmsvc/power.reset '.$params['customfields']['vpsid'] ,$params);
if ( !stripos( $virt_resp, 'failed' ) === false ){
$virt_action_display = 'The VPS failed to reset';
return $virt_action_display;
}
// Started it
$virt_action_display = ' The VPS has been restarted ';
return 'success';
}
function virtualizor_poweroff($params) {
global $virt_action_display, $virt_errors;
$virt_resp =runcommand( 'vim-cmd vmsvc/power.off '.$params['customfields']['vpsid'] ,$params);
if ( !stripos( $virt_resp, 'failed' ) === false ){
$virt_action_display = 'The VPS failed to poweroff';
return $virt_action_display;
}
// Started it
$virt_action_display = 'The VPS has been Power off';
return 'success';
}
function virtualizor_vnc($params){
global $virt_action_display, $virt_errors;
//xxxx
$theme = '<h2>.:VNC INFORMATION :.</h2>';
// $virt_resp=array( )
$virt_resp =getImportantInfo( $params['customfields']['vpsid'] ,$params );
$filename ="/vmfs/volumes/".substr_replace($virt_resp['vmPathName'],"/",strpos($virt_resp['vmPathName'], " "),1);
$searchfor = 'remoteDisplay.vnc.enabled';
$searchfor = 'remoteDisplay.vnc.enabled';
$searchfor = 'remoteDisplay.vnc.enabled';
$file = file_get_contents($filename);
if(strpos($file, $searchfor))
{
}
if(empty($virt_resp)){
$virt_errors[] = 'There was an error while fetching the Details';
$theme .= virt_error($virt_errors);
}else{
}
$theme .= '<table cellpadding="8" cellspacing="1">
<tr>
<td>Status : </td>
<td>'.(preg_match('/xen|kvm/is', $params['configoption1']) ? '<i>No Info</i>' : $virt_resp['vmPathName'].' *').'</td>
</tr>
</table><br />';
// $virt_action_display = "/vmfs/volumes/".substr_replace($virt_resp['vmPathName'],"/",strpos($virt_resp['vmPathName'], " "),1);
return $theme;
//xvnc
}
function virt_cpu($params){
$theme = '<h2>CPU Information</h2>';
$virt_resp =getImportantInfo( $params['customfields']['vpsid'] ,$params );
if(empty($virt_resp)){
$virt_errors[] = 'There was an error while fetching the Details';
$theme .= virt_error($virt_errors);
}else{
$theme .= '<table cellpadding="8" cellspacing="1">
<tr>
<td>MAX CPU : </td>
<td>'.$virt_resp['cpuMax'].' MHZ</td>
</tr>
<tr>
<td>CpuUsage : </td>
<td>'.(preg_match('/xen|kvm/is', $params['configoption1']) ? '<i>No Info</i>' : $virt_resp['cpuUsage'].' MHZ').'</td>
</tr>
</table><br />';
}
return $theme;
}
function virt_ram($params){
//xxxx
$theme = '<h2>.:VNC INFORMATION :.</h2>';
// $virt_resp=array( )
$virt_resp =getImportantInfo( $params['customfields']['vpsid'] ,$params );
$filename ="/vmfs/volumes/".substr_replace($virt_resp['vmPathName'],"/",strpos($virt_resp['vmPathName'], " "),1);
$a='grep -q "remoteDisplay.vnc.enabled =true" '.'"'.$filename.'"'.'|| echo "remoteDisplay.vnc.enabled =true" >>'.'"'.$filename.'"';
$response = runcommand($a,$params );
$a='grep -q "remoteDisplay.vnc.port ='.'60'.$params['customfields']['vpsid'] .'" '.'"'.$filename.'"'.' || echo "remoteDisplay.vnc.port ='.'60'.$params['customfields']['vpsid'].'" >> '.'"'.$filename.'"';
$response = runcommand($a,$params );
$a='grep -q "remoteDisplay.vnc.password =" '.'"'.$filename.'"'.'|| echo "remoteDisplay.vnc.password =484815" >>'.'"'.$filename.'"';
$response = runcommand($a,$params );
$vncpasword=generateRandStr(8);
$a='sed -i "s/\(remoteDisplay.vnc.password *= *\).*/\1'.$vncpasword.'/" '.'"'.$filename.'"';
$response = runcommand($a,$params );
$file = file_get_contents($filename);
if(strpos($file, $searchfor))
{
}
if(empty($virt_resp)){
$virt_errors[] = 'There was an error while fetching the Details';
$theme .= virt_error($virt_errors);
}else{
}
$theme .= '<table dir="ltr" cellpadding="8" cellspacing="1">
<tr>
<td >Server Address(ip:port) :</td>
<td >'.$params["serverip"].':60'.$params['customfields']['vpsid'].'</td>
</tr>
<tr>
<td style="width: 8px">Password :</td>
<td style="width: 8px">'.$vncpasword.'</td>
</tr>
<tr>
<td colspan="2" align="center">
<a href="http://paraserver.net/vncviewer.zip">Download vnc viewer 89Kb</a></td>
</tr>
<tr>
<td colspan="2" align="center">
<a href="http://paraserver.net/knowledgebase.php?action=displayarticle&id=39h ttp://paraserver.net/knowledgebase.php?action=displayarticle&id=39 </a>">آموزش فعال سازی کنسول وی ان سی</a></td>
</tr>
</table><br />';
return $theme;
}
function virt_disk($params){
$theme = '<h2>Disk Information</h2>';
$virt_resp =getImportantInfo( $params['customfields']['vpsid'] ,$params );
if(empty($virt_resp)){
$virt_errors[] = 'There was an error while fetching the Details';
$theme .= virt_error($virt_errors);
}else{
$theme .= '<table cellpadding="8" cellspacing="1">
<tr>
<td>Disk Space : </td>
<td>'.$virt_resp['hd'].' GB</td>
</tr>
<tr>
<td>Utilization : </td>
<td>'.(preg_match('/xen|kvm/is', $params['configoption1']) ? '<i>No Info</i>' : '<i>No Info</i>'.' GB').'</td>
</tr>
</table><br />';
}
return $theme;
}
function virt_bandwidth($params){
$theme = '<h2>Bandwidth Information</h2>';
$virt_resp = Virtualizor_Curl::action($params, 'act=bandwidth&');
if(empty($virt_resp)){
$virt_errors[] = 'There was an error while fetching the Details';
$theme .= virt_error($virt_errors);
}else{
$theme .= '<table cellpadding="8" cellspacing="1">
<tr>
<td>Allowed Limit : </td>
<td>'.$virt_resp['bandwidth']['limit_gb'].' GB</td>
</tr>
<tr>
<td>Utilization : </td>
<td>'.$virt_resp['bandwidth']['used_gb'].' GB'.'</td>
</tr>
</table><br />';
}
return $theme;
}
//yass
function virt_performance($params){
$theme = '<h2>VPS Performance</h2>';
// $virt_resp=array( )
$virt_resp =getImportantInfo( $params['customfields']['vpsid'] ,$params );
if(empty($virt_resp)){
$virt_errors[] = 'There was an error while fetching the Details';
$theme .= virt_error($virt_errors);
}else{
//1yaser
//ram bar
$rambar=round(($virt_resp['memoryUsage']*100)/$virt_resp['memorySize']);
$cpubar=round(($virt_resp['cpuUsage']*100)/$virt_resp['cpuMax']);
//status
if($virt_resp['powerState']=="poweredon"){
$statuspic='<img src="../modules/servers/virtualizor/images/on.gif" width="34" height="34" title="Power on" /img> ';
}
if($virt_resp['powerState']=="suspended"){
$statuspic='<img src="../modules/servers/virtualizor/images/off.gif" width="34" height="34" title="Suspend" /img>';
}
if($virt_resp['powerState']=="poweredoff"){
$statuspic='<img src="../modules/servers/virtualizor/images/off.gif" width="34" height="34" title="Power off" /img>';
}
$theme .= '<table dir="ltr" cellpadding="8" cellspacing="1">
<tr>
<td>Status : </td>
<td>'.(preg_match('/xen|kvm/is', $params['configoption1']) ? '<i>No Info</i>' :
$statuspic)
.'</td>
</tr>
<tr>
<td>CPU Used : </td>
<td>'.(preg_match('/xen|kvm/is', $params['configoption1']) ? '<i>No Info</i>' :'<img src="../modules/servers/virtualizor/images/redbar.png" width="'.($cpubar*2).'" height="20" title="'.$cpubar."% CPU used".$virt_resp['cpuUsage'].' OF '.$virt_resp['cpuMax'].'" /img><img src="../modules/servers/virtualizor/images/green_bar_fade.png" width="'.((100-$cpubar)*2).'" height="20" title="'.$cpubar."% CPU used -".$virt_resp['cpuUsage'].' OF '.$virt_resp['cpuMax'].'" /img>' ).'</td>
</tr>
<tr>
<td>RAM Used : </td>
<td>'.(preg_match('/xen|kvm/is', $params['configoption1']) ? '<i>No Info</i>' :'<img src="../modules/servers/virtualizor/images/redbar.png" width="'.($rambar*2).'" height="20" title="'.$rambar."% ram used -".$virt_resp['memoryUsage'].' OF '.$virt_resp['memorySize'].'" /img><img src="../modules/servers/virtualizor/images/green_bar_fade.png" width="'.((100-$rambar)*2).'" height="20" title="'.$rambar."% ram used -".$virt_resp['memoryUsage'].' OF '.$virt_resp['memorySize'].'" /img>' ).'</td>
</tr>
<tr>
<td>Disk Space : </td>
<td>'.$virt_resp['hd'].' GB</td>
</tr>
<tr>
<td>Operition system : </td>
<td>'.$virt_resp['osFullName'].'</td>
</tr>
<tr>
<td>Host name : </td>
<td>'.$virt_resp['hostname'].' </td>
</tr>
<tr>
<td>Boot time : </td>
<td>'.$virt_resp['bootTime'].' </td>
</tr>
</table><br />';
}
return $theme;
}
function virt_processes($params){
$theme = '<h2>VPS Processes</h2>';
$virt_resp = Virtualizor_Curl::action($params, 'act=processes&');
if(empty($virt_resp)){
$virt_errors[] = 'There was an error while fetching the Details';
$theme .= virt_error($virt_errors);
}else{
if(preg_match('/xen|kvm/is', $params['configoption1'])){
$theme .= virt_done('This feature is not available');
}else{
$processes = $virt_resp['processes'];
$theme .= '<table class="summaryBlock" align="center" cellpadding="6" cellspacing="2" border="0" width="100%">
<tr>';
$keys = array_keys(current($processes));
foreach($keys as $k => $v){
$theme .= '<td align="center" class="summaryTitle">'.$v.'</td>';
}
//r_print($processes);
foreach($processes as $k=>$v){
$theme .= '<tr>';
foreach($v as $vv){
$theme .= '<td align="center">'.$vv.'</td>';
}
$theme .= '</tr>';
}
$theme .= '</table>';
}
}
return $theme;
}
function virt_services($params){
$theme = '<h2>VPS Services</h2>';
$virt_resp = Virtualizor_Curl::action($params, 'act=services&');
if(empty($virt_resp)){
$virt_errors[] = 'There was an error while fetching the Details';
$theme .= virt_error($virt_errors);
}else{
if(preg_match('/xen|kvm/is', $params['configoption1'])){
$theme .= virt_done('This feature is not available');
}else{
$services = $virt_resp['services'];
$autostart = $virt_resp['autostart'];
$running = $virt_resp['running'];
$theme .= '<table align="center" cellpadding="5" cellspacing="2" border="0" width="100%" class="summaryBlock">
<tr>
<td class="summaryTitle" align="center">Services</td>
<td align="center" class="summaryTitle">Status</td>
<td align="center" class="summaryTitle">Auto Start</td>
</tr>';
foreach($services as $k=>$v){
$theme .= '<tr>
<td>'.$v.'</td>
<td align="center">'.(in_array($v, $running) ? ' Running': ' OFF').'</td>
<td align="center">'.(in_array($v, $autostart) ? ' ON' : ' OF').'</td>
</tr>';
}
$theme .= '</table>';
}
}
return $theme;
}
// Show the Hostname Form
function virt_hostname($params){
$theme = '<h2>Change Hostname</h2>';
if(isset($_POST['virt_changehostname'])){
$fields = array(
'newhost' => $_POST['virt_newhostname'],
'changehost' => 'Change Hostname'
);
$virt_resp = Virtualizor_Curl::action($params, 'act=hostname&', $fields);
if(empty($virt_resp['done'])){
$virt_errors[] = 'There was an error changing the Hostname';
$theme .= virt_error($virt_errors);
}else{
$theme .= virt_done('The Hostname was changed successfully');
// Change the Hostname
mysql_query("UPDATE `tblhosting` SET `domain` = '".$_POST['virt_newhostname']."' WHERE `id` = '".$params['serviceid']."';");
}
}else{
$virt_resp = Virtualizor_Curl::action($params, 'act=hostname&');
}
$theme .= '<form method="post" action="">
<table cellpadding="8" cellspacing="1">
<tr>
<td>Hostname : </td>
<td>'.$virt_resp['current'].'</td>
</tr>
<tr>
<td>New Hostname : </td>
<td><input type="text" name="virt_newhostname" id="virt_newhostname" value="" /></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="Submit" name="virt_changehostname" />
</td>
</table>
</form><br />';
return $theme;
}
function virt_changeRootPass($params) {
$theme = '<h2>Change Root Password</h2>';
if(isset($_POST['virt_changepassword'])){
$fields = array(
'newpass' => $_POST['virt_newpassword'],
'conf' => $_POST['virt_newpasswordconf'],
'changepass' => 'Change Password'
);
$virt_resp = Virtualizor_Curl::action($params, 'act=changepassword&', $fields);
if(isset($virt_resp['onboot'])){
$theme .= virt_done('The Password will be changed when it is booted again');
}elseif(isset($virt_resp['done'])){
$theme .= virt_done('The Password was changed successfully');
}else{
$virt_errors[] = 'There was an error changing the Password';
$theme .= virt_error($virt_errors);
}
// Change the Password
if(empty($virt_errors)){
mysql_query("UPDATE `tblhosting` SET `password` = '".encrypt($_POST['virt_newpassword'])."' WHERE `id` = '".$params['serviceid']."';");
}
}
$theme .= '<form method="post" action="">
<table cellpadding="8" cellspacing="1">
<tr>
<td>New Password : </td>
<td><input type="password" name="virt_newpassword" value="" /></td>
</tr>
<tr>
<td>Confirm Password : </td>
<td><input type="password" name="virt_newpasswordconf" value="" /></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="Submit" name="virt_changepassword" />
</td>
</table>
</form><br />';
return $theme;
}
function virt_changeVncPass($params) {
$theme = '<h2>Change VNC Password</h2>';
if(isset($_POST['virt_vncpass'])){
$fields = array(
'newpass' => $_POST['virt_newvncpass'],
'vncpass' => 'Change Password'
);
$virt_resp = Virtualizor_Curl::actionchangevnc($params, 'act=vncpass&', $fields);
if(isset($virt_resp['done'])){
$theme .= virt_done('The Password was changed successfully. The changes will take effect when the VPS is power off and power on again. ip and port is:'.$params["serverip"].':60'.$params['customfields']['vpsid']);
}else{
$virt_errors[] = 'There was an error changing the Password';
$theme .= virt_error($virt_errors);
}
}
$theme .= '<form method="post" action="">
<table dir="ltr" cellpadding="8" cellspacing="1">
<tr>
<td>New Password : </td>
<td><input type="password" name="virt_newvncpass" value="" /></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="Submit" name="virt_vncpass" />
</td>
</table>
</form><br />';
return $theme;
}
function virt_osreinstall($params) {
global $virt_action_display, $virt_errors;
$virt_resp =runcommand( 'vim-cmd vmsvc/tools.install '.$params['customfields']['vpsid'] ,$params);
// Started it
$virt_action_display = 'VMware tools installetion active now';
return 'success';
}
function make_apikey($key, $pass){
return $key.md5($pass.$key);
}
function _unserialize($str){
$var = @unserialize($str);
if(empty($var)){
$str = preg_replace('!s\d+):"(.*?)";!se', "'s:'._strlen('$2').':\"$2\";'", $str);
$var = @unserialize($str);
}
//If it is still empty false
if(empty($var)){
return false;
}else{
return $var;
}
}
//generates random strings
function generateRandStr($length){
$randstr = "";
for($i = 0; $i < $length; $i++){
$randnum = mt_rand(0,61);
if($randnum < 10){
$randstr .= chr($randnum+48);
}elseif($randnum < 36){
$randstr .= chr($randnum+55);
}else{
$randstr .= chr($randnum+61);
}
}
return strtolower($randstr);
}
// function exec( $cmd,$params ) {
function runcommand($cmd,$params){
$sshcon = new Net_SSH2($params["serverip"]);
if (!$sshcon->login($params["serverusername"], $params["serverpassword"])) {
return ('Login failed');
}
return $sshcon->exec($cmd);
/*
$sshcon = new Net_SSH2('5.9.7.143');
if (!$sshcon->login('root', 'yaserheydari2285ESXI')) {
return ('Login failed');
}
return $sshcon->exec('vim-cmd vmsvc/power.on 105');
*/
}
function getGuestInfo($vmid,$params)
{
// $this->vm_info_array = null;
$response = runcommand('vim-cmd vmsvc/get.guest '.$vmid,$params );
return parsInfo( $response );
}
function getSummaryInfo($vmid,$params){
// vm_info_array = null;
$response = runcommand('vim-cmd vmsvc/get.summary '.$vmid,$params );
return parsInfo( $response );
}
function parsInfo( $response )
{
$response = preg_replace( "@\\(vim.*\\)@", "", $response );
$response = preg_replace( "@([^ ]*) =@", "\"\$1\" =>", $response );
$search = array( "<unset>", "(string)", "{", "}", "[", "]", "Listsummary:", "Guest information:" );
$replace = array( "null", "", "array(", ")", "", "", "", "" );
$response = str_replace( $search, $replace, $response );
$response = addcslashes( $response, "\\" );
@eval( "\$arr = ".$response.";" );
if ( $arr == null )
{
return false;
}
return $arr;
}
function getImportantInfo( $vmid,$params )
{
$vminfoArr = getSummaryInfo( $vmid,$params );
if ( $vminfoArr === false )
{
return false;
}
$info = array( );
$info['vmid'] = $vmid;
$info['memorySize'] = intval( $vminfoArr['config']['memorySizeMB'] );
$info['memoryUsage'] = intval( $vminfoArr['quickStats']['hostMemoryUsage'] );
$info['cpuMax'] = intval( $vminfoArr['runtime']['maxCpuUsage'] );
$info['bootTime'] = str_replace( "T", " ", $vminfoArr['runtime']['bootTime'] );
$os = strtolower( trim( $vminfoArr['guest']['guestId'] ) );
if ( stripos( $os, "win" ) !== false )
{
$os = "WIN";
}
else if ( stripos( $os, "linux" ) !== false )
{
$os = "LINUX";
}
else
{
$os = "OTHER";
}
$info['os'] = $os;
$info['vmPathName'] = $vminfoArr['config']['vmPathName'];;
$info['osFullName'] = trim( $vminfoArr['guest']['guestFullName'] );
$info['hostname'] = $vminfoArr['guest']['hostName'];
$info['ip'] = $vminfoArr['guest']['ipAddress'];
$info['powerState'] = strtolower( trim( $vminfoArr['runtime']['powerState'] ) );
$info['cpuUsage'] = intval( $vminfoArr['quickStats']['overallCpuUsage'] );
$info['uptime'] = intval( $vminfoArr['quickStats']['uptimeSeconds'] );
$guest = getGuestInfo( $vmid,$params );
$info['hd'] = round( abs( $guest['disk']['capacity'] ) / ( 1024 * 1024 * 1024 ), 2 );
return $info;
}
function getAllVmInfo( $params )
{
$vm_all_array=array();
$response = runcommand( "vim-cmd vmsvc/getallvms" ,$params);
$vm_all_array = parsAllVmInfo( $response );
return $vm_all_array;
}
function parsAllVmInfo( $response )
{
if ( preg_match_all( "@^(\\d+) {2,}([^\\[\\]]+)\\[.*\\].*/(.*\\.vmx) {2,}([a-zA-Z]+)@m", $response, $matches ) )
{
$total = count( $matches[1] );
$parsed_array = array( );
$i = 0;
while ( $i < $total )
{
$vm_arr = array( );
$vm_arr['vmid'] = trim( $matches[1][$i] );
$vm_arr['name'] = trim( $matches[2][$i] );
$vm_arr['filename'] = trim( $matches[3][$i] );
$os = strtolower( trim( $matches[4][$i] ) );
if ( stripos( $os, "win" ) !== false )
{
$os = "WIN";
}
else if ( stripos( $os, "linux" ) !== false )
{
$os = "LINUX";
}
else
{
$os = "OTHER";
}
$vm_arr['os'] = $os;
$parsed_array[] = $vm_arr;
++$i;
}
$total_vm = $total;
return $parsed_array;
}
return false;
}
/*
function died(){
print_r(error_get_last());
}
register_shutdown_function('died');*/
?>
شما این کارو انجام بدین.
سلام
مرسی دوست عزیز
میشه دوستان برای دانلود قر ار بدهند لینکش خرابه
لینک همیشگی
http://shidserver.com/modules.zip
shidserver.com
@shidserver
برای فعال سازی vnc تنظیمات گفته شده بدرستی انجام شده و این گزینه در قسمت configration اومده ولی متاسفانه موقع استفاده کار نمیکنه و ارور میده
ایا چیز دیگه ای هم لازمه روی سرور فعال باشه؟
سرور مجازی با بالاترین کیفیت از المان و امریکا
دارای نماد اعتماد الکترونیک از وزارت صنعت معدن و تجارت
TEL : 09355971597 site : abarserver.net
با احترام تمامی تنظیمات به درستی انجام شده و وی ان سی هم فعال شده از طریق فایروال اما مشکلی که دارم اینه که زمانی که کاربر روی وی ان سی میزنه ای پی و پورت را میزنه و پسورد وقتی وارد برنامه می کنم ارتباط برقرار نمی شود ایا پورت یا گزینه دیگری باید فعال باشد دقیقا مشکل دوست عزیز را دارم da6276
بردارد محترم عزیز الان من منتظرم اخه مهندس من تمامی تنظیمات را به درستی انجام دادم همه چیز به درستی کار می کند به غیر از وی ان سی درضمن وی ان سی با توجه به تنظیمات شما اعمال شده است اما یکی از دوستان گفتند باید پورت 33 و ای پی وی ام ور در هاست باز باشید که این مورد هم انجام شد اما هنوز مشکل دارم تو رو خدا راهنمایی کنید که بتوانیم استفاده کنم انشاالله امروز جواب بگیرم
راه حل مشکل رو پیدا کردم
بعد از دریافت آی پی و پورت و پسورد
سرور رو از طریق پنل ربستارت بدید و بعد می تونید کانکت شیم
یعنی بعد از دریافت اطلاعات سرور رو باید یبار ریست بدید
تمام
در حال حاضر 1 کاربر در حال مشاهده این موضوع است. (0 کاربران و 1 مهمان ها)