Commit 286803ad authored by Kelvin Mwiti's avatar Kelvin Mwiti

Initial Commit

parents
Pipeline #2 failed with stages
<?php
/*
* This file is part of the CloudStack PHP Client.
*
* (c) Quentin Pleplé <quentin.pleple@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require_once dirname(__FILE__) . "/CloudStackClientException.php";
class BaseCloudStackClient {
public $apiKey;
public $secretKey;
public $endpoint; // Does not ends with a "/"
public function __construct($endpoint, $apiKey, $secretKey) {
// API endpoint
if (empty($endpoint)) {
throw new CloudStackClientException(ENDPOINT_EMPTY_MSG, ENDPOINT_EMPTY);
}
if (!preg_match("|^http://.*$|", $endpoint)) {
throw new CloudStackClientException(sprintf(ENDPOINT_NOT_URL_MSG, $endpoint), ENDPOINT_NOT_URL);
}
// $endpoint does not ends with a "/"
$this->endpoint = substr($endpoint, -1) == "/" ? substr($endpoint, 0, -1) : $endpoint;
// API key
if (empty($apiKey)) {
throw new CloudStackClientException(APIKEY_EMPTY_MSG, APIKEY_EMPTY);
}
$this->apiKey = $apiKey;
// API secret
if (empty($secretKey)) {
throw new CloudStackClientException(SECRETKEY_EMPTY_MSG, SECRETKEY_EMPTY);
}
$this->secretKey = $secretKey;
}
public function getSignature($queryString) {
if (empty($queryString)) {
throw new CloudStackClientException(STRTOSIGN_EMPTY_MSG, STRTOSIGN_EMPTY);
}
$hash = @hash_hmac("SHA1", $queryString, $this->secretKey, true);
$base64encoded = base64_encode($hash);
return urlencode($base64encoded);
}
public function request($command, $args = array()) {
if (empty($command)) {
throw new CloudStackClientException(NO_COMMAND_MSG, NO_COMMAND);
}
if (!is_array($args)) {
throw new CloudStackClientException(sprintf(WRONG_REQUEST_ARGS_MSG, $args), WRONG_REQUEST_ARGS);
}
foreach ($args as $key => $value) {
if ($value == "") {
unset($args[$key]);
}
}
// Building the query
$args['apikey'] = $this->apiKey;
$args['command'] = $command;
$args['response'] = "json";
ksort($args);
$query = http_build_query($args);
$query = str_replace("+", "%20", $query);
$query .= "&signature=" . $this->getSignature(strtolower($query));
$url = $this->endpoint . "?" . $query;
//$json = file_get_contents($url);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, '300');
$json = curl_exec($ch);
if (curl_errno($ch)) {
$json = json_encode(array($command => array('errortext' => curl_error($ch))));
}
curl_close($ch);
$response = json_decode($json);
return $response;
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
<?php //00507
// 10.2 72
if(!extension_loaded('ionCube Loader')){$__oc=strtolower(substr(php_uname(),0,3));$__ln='ioncube_loader_'.$__oc.'_'.substr(phpversion(),0,3).(($__oc=='win')?'.dll':'.so');if(function_exists('dl')){@dl($__ln);}if(function_exists('_il_exec')){return _il_exec();}$__ln='/ioncube/'.$__ln;$__oid=$__id=realpath(ini_get('extension_dir'));$__here=dirname(__FILE__);if(strlen($__id)>1&&$__id[1]==':'){$__id=str_replace('\\','/',substr($__id,2));$__here=str_replace('\\','/',substr($__here,2));}$__rd=str_repeat('/..',substr_count($__id,'/')).$__here.'/';$__i=strlen($__rd);while($__i--){if($__rd[$__i]=='/'){$__lp=substr($__rd,0,$__i).$__ln;if(file_exists($__oid.$__lp)){$__ln=$__lp;break;}}}if(function_exists('dl')){@dl($__ln);}}else{die('The file '.__FILE__." is corrupted.\n");}if(function_exists('_il_exec')){return _il_exec();}echo("Site error: the ".(php_sapi_name()=='cli'?'ionCube':'<a href="http://www.ioncube.com">ionCube</a>')." PHP Loader needs to be installed. This is a widely used PHP extension for running ionCube protected PHP code, website security and malware blocking.\n\nPlease visit ".(php_sapi_name()=='cli'?'get-loader.ioncube.com':'<a href="http://get-loader.ioncube.com">get-loader.ioncube.com</a>')." for install assistance.\n\n");exit(199);
?>
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
mSq+rW==
\ No newline at end of file
<div class="text-center module-client-area">
<link href="modules/servers/cloudstack/css/style.css" rel="stylesheet" type="text/css">
<div id="wrapper">
<section class="manage_content"><!-- maincontent starts -->
<div class="row"><!-- row starts -->
<div class="clearfix"></div>
<div class="col-lg-12 col-md-12 col-sm-12"><!-- col-12 starts -->
<div id="custon_tab_container"><h2>{$message}</h2></div>
<div class="manage_tab_sec">
{if !isset($smarty.get.page)}
{assign var=select value="style='background: #006687;transition: all 0.4s ease 0s;color: white;'"}
{/if}
{if $smarty.get.page=='actions'}
{assign var=select1 value="style='background: #006687;transition: all 0.4s ease 0s;color: white;'"}
{/if}
{if $smarty.get.page=='logs'}
{assign var=select2 value="style='background: #006687;transition: all 0.4s ease 0s;color: white;'"}
{/if}
<ul class="manage_tab_menu">
<li >
<a {$select} href="clientarea.php?action=productdetails&id={$smarty.get.id}"><i class="fa fa-info-circle" aria-hidden="true"></i>
<p>Details</p>
</a>
</li>
<li >
<a {$select1} href="clientarea.php?action=productdetails&page=actions&id={$smarty.get.id}"><i class="fa fa-microchip" aria-hidden="true"></i>
<p>Actions</p>
</a>
</li>
<li>
<a href="clientarea.php?action=productdetails&page=rebuild&id={$smarty.get.id}"><i class="fa fa-code" aria-hidden="true"></i>
<p>Rebuild</p>
</a>
</li>
<li>
<a href="clientarea.php?action=productdetails&page=snapshot&id={$smarty.get.id}"><i class="fa fa-code" aria-hidden="true"></i>
<p>SnapShot</p>
</a>
</li>
<li >
<a {$select2} href="clientarea.php?action=productdetails&page=logs&id={$smarty.get.id}" ><i class="fa fa-line-chart" aria-hidden="true"></i>
<p>Logs</p>
</a>
</li>
<li>
<a href="clientarea.php?action=productdetails&page=updatevm&id={$smarty.get.id}"><i class="fa fa-code" aria-hidden="true"></i>
<p>Update VM</p>
</a>
</li>
<li>
<a href="clientarea.php?action=productdetails&page=networking&id={$smarty.get.id}"><i class="fa fa-code" aria-hidden="true"></i>
<p>Networking</p>
</a>
</li>
<li>
<a href="clientarea.php?action=productdetails&page=resize&id={$smarty.get.id}"><i class="fa fa-code" aria-hidden="true"></i>
<p>Resize</p>
</a>
</li>
</ul>
<div class="clearfix"></div>
<!-- if vm in not available or not created condition end -->
<div id="details">
{if $smarty.get.page=='logs'}
<table class='table'>
<tr>
<td>Command</td><td>Date</td><td>Status</td>
</tr>
{foreach from=$logs item=log}
{assign var=cmd value="."|explode:$log->cmd}
{if $log->jobinstanceid==$vmid || $log->jobresult->vmsnapshot->virtualmachineid==$vmid || $log->jobresult->virtualmachine->id==$vmid}
<tr>
<td>{($cmd|@end)|replace:'CmdByAdmin':''}</td><td>{$log->created}</td><td>{$log->jobresult->errortext}</td>
</tr>
{/if}
{/foreach}
</table>
{elseif $smarty.get.page=='actions'}
<div style='float:left;'>
<br><br><br>
<a type="button" href="clientarea.php?action=productdetails&modop=custom&a=start&id={$smarty.get.id}" class="btn">Start</a>
&nbsp;&nbsp;&nbsp;&nbsp;
<a type="button" href="clientarea.php?action=productdetails&modop=custom&a=shutdown&id={$smarty.get.id}" class="btn btn-default">Stop</a>
&nbsp;&nbsp;&nbsp;&nbsp;
<a type="button" href="clientarea.php?action=productdetails&modop=custom&a=reboot&id={$smarty.get.id}" class="btn btn-primary">Restart</a>
</tr>
</div>
{elseif $smarty.get.page=='snapshot'}
{if $smarty.get.subpage=='createsnap'}
<form method="post" action="clientarea.php?action=productdetails&page=snapshot&id={$serviceid}">
<input type="hidden" name="createsnapshot" value="createsnapshot"/>
<table style="width:100%;" class="table">
<tr>
<td>Description</td><td><textarea name="description"></textarea></td>
</tr>
<tr>
<td>Name</td><td><input type="text" value="" class="form-control" name="name"/></td>
</tr>
<tr>
<td>Quiescevm</td><td><input type='checkbox' value="true" name="quiescevm"/></td>
</tr>
<tr>
<td>Snapshotmemory</td><td><input type='checkbox' value="true" name="snapshotmemory"/></td>
</tr>
<tr>
<td></td><td><input type='submit' value="Submit" name="submit"/></td>
</tr>
</table>
</form>
{else}
<a href="clientarea.php?action=productdetails&page=snapshot&subpage=createsnap&id={$serviceid}">Create Snapshot</a>
<form method="post" action="clientarea.php?action=productdetails&id={$serviceid}">
<table style="width:100%;" class="table">
<tr>
<td>Created</td>
<td>Description</td>
<td>Displayname</td>
<td>Type</td>
<td>State</td>
<td>Domain</td>
<td>Action</td>
</tr>
{foreach from=$snapshot->listvmsnapshotresponse->vmSnapshot item=$snaps}
<tr>
<td>{$snaps->created|date_format:"%D"}</td>
<td>{$snaps->description}</td>
<td>{$snaps->displayname}</td>
<td>{$snaps->type}</td>
<td>{$snaps->state}</td>
<td>{$snaps->domain}</td>
<td><a href="clientarea.php?action=productdetails&page=snapshot&id={$smarty.get.id}&snapdelete={$snaps->id}">Delete</a></td>
</tr>
{/foreach}
</table>
</form>
{/if}
{elseif $smarty.get.page=='updatevm'}<br>
<form method="post" action="clientarea.php?action=productdetails&id={$serviceid}">
<table style="width:100%;">
<tr>
<td>VM Name:</td><td><input type="text" name="displayname" value="{$virtualmachine->displayname}" class="form-control"></td>
</tr>
<tr>
<td></td><td><input type="submit" name="submit" value="Submit"/></td>
</tr>
</table>
{elseif $smarty.get.page=='rebuild'}
<form method="post" action="clientarea.php?action=productdetails&id={$serviceid}">
{$response}
<br><br>
<input type="hidden" name="rebuild" value="rebuild" />
<table style="width:100%;">
{* <tr>
<td>Zone:</td><td> <select name="zone" class="form-control">
{$zone}
</select></td>
</tr>*}
<tr>
<td>Template:</td><td> <select name="template" class="form-control">
{$template}
</select></td>
</tr>
{* <tr>
<td>Server Name :</td><td><input type="text" class="form-control" name="prefix" placeholder="Example: EXAMPLE"></td>
</tr>*}
<tr>
<td></td><td> <input type="submit" name="submit" class="btn btn-default" value="Build VM!"> </td>
</tr>
</table>
</form>
{elseif $smarty.get.page=='resize'}
<form method="post" action="clientarea.php?action=productdetails&id={$serviceid}">
{$response}
<br><br>
<input type="hidden" name="resize" value="resize" />
<table style="width:100%;">
<tr>
<td>Select Size:</td><td> <select name="serviceoffer" class="form-control">
{$serviceoffer}
</select></td>
</tr>
<tr>
<td></td><td> <br><input type="submit" name="submit" class="btn btn-default" value="Resize VM!"> </td>
</tr>
</table>
</form>
{elseif $smarty.get.page=='networking'}
{if $smarty.get.subpage=='add'}
<form method="post" action="">
<input type="hidden" name="networkcreate" value="networkcreate"/>
<table style="width:100%;" class="table">
<tr>
<td>Name :</td><td><input type="text" name="displaytext" class="form-control" required=""/></td>
</tr>
<tr>
<td>IP Start :</td><td><input type="text" name="ipstart" class="form-control" required=""/></td>
</tr>
<tr>
<td>IP End: </td><td><input type="text" name="ipend" class="form-control" required=""/></td>
</tr>
<tr>
<td>Gateway: </td><td><input type="text" name="gateway" class="form-control" required=""/></td>
</tr>
<tr>
<td>Netmask: </td><td><input type="text" name="netmask" class="form-control" required=""/></td>
</tr>
<tr>
<td>Is Default: </td><td><input type="checkbox" class="form-control" value="1" name="isdefault" /></td>
</tr>
<tr>
<td> </td><td><input type="submit" name="submit" value="Add"/></td>
</tr>
</table>
</form>
{else}
<a href="clientarea.php?action=productdetails&page=networking&id={$smarty.get.id}&subpage=add">Add Network</a>
{*<table style="width:100%;" class="table">
<tr>
<td>Name :</td><td>{$virtualmachine->displayname}</td>
</tr>
<tr>
<td>Username: </td><td>{$virtualmachine->username}</td>
</tr>
</table>*}
{/if}
{else}
<table style="width:100%;" class="table">
<tr>
<td>Name :</td><td>{$virtualmachine->displayname}</td>
</tr>
<tr>
<td>Username: </td><td>{$virtualmachine->username}</td>
</tr>
<tr>
<td>Status:</td><td>{$virtualmachine->state}</td>
</tr>
<tr>
<td>Template Name:</td><td>{$virtualmachine->templatename}</td>
</tr>
<tr>
<td>Disk:</td><td>{$virtualmachine->diskofferingname}</td>
</tr>
<tr>
<td>Password:</td><td>{$virtualmachine->details->password}</td>
</tr>
<tr>
<td>Memory</td><td>{$virtualmachine->memory} MB</td>
</tr>
<tr>
<td colspan="2">Network</td>
</tr>
{foreach from=$virtualmachine->nic key=k item=val}
<tr>
<td>NetMask </td>
<td>{$val->netmask}</td>
</tr>
<tr>
<td>IP Address</td><td>{$val->ipaddress}</td>
</tr>
<tr>
<td>Gateway</td><td>{$val->gateway}</td>
</tr>
{/foreach}
</table>
{/if}
</div>
</div><!-- manage_tab_sec -->
</div><!-- col-12 end -->
</div><!-- row end -->
</section></div><!-- wrapper-->
</div>
<?php
use WHMCS\Database\Capsule;
//ini_set('display_errors',true);
//error_reporting(E_ALL);
function cloudstack_ConfigOptions() {
$id = (int) $_REQUEST["id"];
$query = Capsule::table("tblcustomfields")->where('relid', $id)->where('fieldname', 'domainid')->where('type', 'product')->get();
if (!$query) {
Capsule::table("tblcustomfields")->insert(
[
"type" => "product",
"relid" => $id,
"fieldname" => "domainid",
"fieldtype" => "text",
"adminonly" => "on"
]
);
}
$query = Capsule::table("tblcustomfields")->where('relid', $id)->where('fieldname', 'cloudstackvmid')->where('type', 'product')->get();
if (!$query) {
Capsule::table("tblcustomfields")->insert(
[
"type" => "product",
"relid" => $id,
"fieldname" => "cloudstackvmid",
"fieldtype" => "text",
"adminonly" => "on"
]
);
}
$query = Capsule::table("tblcustomfields")->where('relid', $id)->where('fieldname', 'cloudstackaccountid')->where('type', 'product')->get();
if (!$query) {
Capsule::table("tblcustomfields")->insert(
[
"type" => "product",
"relid" => $id,
"fieldname" => "cloudstackaccountid",
"fieldtype" => "text",
"adminonly" => "on"
]
);
}
$query = Capsule::table("tblcustomfields")->where('relid', $id)->where('fieldname', 'networkid')->where('type', 'product')->get();
if (!$query) {
Capsule::table("tblcustomfields")->insert(
[
"type" => "product",
"relid" => $id,
"fieldname" => "networkid",
"fieldtype" => "text",
"adminonly" => "on"
]
);
}
# Should return an array of the module options for each product - maximum of 24
return [
"API Key" => [
"FriendlyName" => "API Key",
"Type" => "text", # Text Box
"Size" => "25", # Defines the Field Width
"Description" => "",
],
"Secret Key" => [
"FriendlyName" => "Secret Key",
"Type" => "text", # Text Box
"Size" => "25", # Defines the Field Width
"Description" => "",
],
"End Point" => [
"FriendlyName" => "End Point",
"Type" => "text", # Text Box
"Size" => "25", # Defines the Field Width
"Description" => "API url",
],
"License" => [
"FriendlyName" => "License",
"Type" => "text", # Text Box
"Size" => "25", # Defines the Field Width
"Description" => "",
],
"create_opt" => array(
"FriendlyName" => "",
"Description" => "<a href='#' id='createoption'>Create Config Option</a><script>
$(document).ready(function(){
$( '#createoption' ).click(function() {
$.ajax({
url: 'index.php',
method: 'POST',
data: 'ajaxpage=createconfig&productid=" . $id . "',
success: function(data){
console.log(data);
window.location.href='configproducts.php?action=edit&id=" . $id . "&tab=3#tab=3';
}
});
});
});
</script>"
),
];
}
function cloudstack_CreateAccount($params) {
$licensecheck = cloudstack_license_checkLicense($params['configoption4']);
if ($licensecheck['status'] != 'Active') {
return 'License is not valid';
}
$params["username"] = strtolower(str_replace(' ', '', $params['clientsdetails']['firstname'] . $params['clientsdetails']['lastname'] . $params['serviceid']));
$dname = $params["username"];
$error = false;
$domain = $params["domain"];
$username = $params["username"];
$password = $params["password"];
#client details
$firstname = $params['clientsdetails']['firstname'];
$lastname = $params['clientsdetails']['lastname'];
$email = $params['clientsdetails']['email'];
$cloudstack = request($params);
if (empty($params['customfields']['domainid'])) {
$domain = $cloudstack->createDomain($domain);
logModuleCall('CloudStack', 'CreateDomain', $domain, json_encode($domain));
$domainid = $domain->createdomainresponse->domain->id;
$queryacct = Capsule::select("SELECT * FROM `tblcustomfields` WHERE fieldname='domainid' AND relid='" . $params['pid'] . "' AND type='product'");
cloudstack_api($params["serviceid"], $queryacct[0]->id, $domain->createdomainresponse->domain->id);
} else {
$domainid = $params['customfields']['domainid'];
}
if (isset($domainid)) {
try {
if (empty($params['customfields']['cloudstackaccountid'])) {
$account = $cloudstack->createAccount(2, $email, $firstname, $lastname, $password, $username, $username, $domainid);
$senddata = array(2, $email, $firstname, $lastname, $password, $username, $username, $domainid);
logModuleCall('CloudStack', 'CreateAccount', $senddata, json_encode($account));
$accountid = $account->createaccountresponse->account->id;
$queryacc = Capsule::select("SELECT * FROM `tblcustomfields` WHERE fieldname='cloudstackaccountid' AND relid='" . $params['pid'] . "' AND type='product'");
cloudstack_api($params["serviceid"], $queryacc[0]->id, $account->createaccountresponse->account->id);
} else {
$accountid = $params['customfields']['cloudstackaccountid'];
}
if (!empty($accountid)) {
$zoneid = $params['configoptions']['Zones'];
$serviceofferid = $params['configoptions']['ServiceOffer'];
$diskOfferingId = $params['configoptions']['DiskOffer'];
$networktype = 'Account';
if (empty($params['customfields']['networkid'])) {
$networkoffering = $cloudstack->listNetworkOfferings();
} else {
$networkid = $params['customfields']['networkid'];
}
$templateid = $params['configoptions']['Template'];
if (isset($params['password'])) {
$password = $params['password'];
$passwordenabled = true;
}
$vmresp = $cloudstack->deployVirtualMachine($serviceofferid, $templateid, $zoneid, $params['username'], $diskOfferingId, $dname, $domainid, $group = "", $hostId = "", '', $keyPair = "", $dname, $networkid = '', $securityGroupIds = '', $securityGroupNames = '', $size = '', $userData = '', $memory, $password, $passwordenabled);
logModuleCall('CloudStack', 'CreateServer', $vmresp, json_encode($vmresp));
if (isset($vmresp->deployvirtualmachineresponse->errortext)) {
$error = true;
$errormsg = $vmresp->deployvirtualmachineresponse->errortext;
} else {
$row = Capsule::select("SELECT * FROM `tblcustomfields` WHERE fieldname='cloudstackvmid' AND relid='" . $params['pid'] . "' AND type='product'");
cloudstack_api($params["serviceid"], $row[0]->id, $vmresp->deployvirtualmachineresponse->id);
}
//exit();
} else {
$error = true;
$errormsg = $account->createaccountresponse->errortext;
}
} catch (Exception $e) {
$errormsg = $e->getMessage();
}
} else {
$error = true;
// print_r($domain); exit();
$errormsg = $domain->createdomainresponse->errortext;
}
if ($error == false) {
$result = "success";
} else {
$result = $errormsg;
}
return $result;
}
function cloudstack_TerminateAccount($params) {
$licensecheck = cloudstack_license_checkLicense($params['configoption4']);
if ($licensecheck['status'] != 'Active') {
return 'License is not valid';
}
$cloudstack = request($params);
$id = $params['customfields']['cloudstackaccountid'];
$did = $params['customfields']['domainid'];
$domain = $cloudstack->deleteAccount($id);
//$cloudstack->deleteDomain($did);
$cloudstack->deleteDomain($did);
if ($domain->deleteaccountresponse->jobid) {
$result = "success";
} else {
$result = $domain->deleteaccountresponse->errortext;
}
return $result;
}
function cloudstack_SuspendAccount($params) {
$licensecheck = cloudstack_license_checkLicense($params['configoption4']);
if ($licensecheck['status'] != 'Active') {
return 'License is not valid';
}
$cloudstack = request($params);
$id = $params['customfields']['cloudstackaccountid'];
$domain = $cloudstack->disableAccount(TRUE, $params['username'], '', $id);
//print_r($domain); exit();
if ($domain->disableaccountresponse->jobid) {
$result = "success";
} else {
$result = $domain->disableaccountresponse->errortext;
}
return $result;
}
function cloudstack_UnsuspendAccount($params) {
$licensecheck = cloudstack_license_checkLicense($params['configoption4']);
if ($licensecheck['status'] != 'Active') {
return 'License is not valid';
}
$cloudstack = request($params);
$id = $params['customfields']['cloudstackaccountid'];
$domain = $cloudstack->enableAccount($params['username'], '', $id);
//print_r($domain); exit();
if (!empty($domain->enableaccountresponse->account->id)) {
$result = "success";
} else {
$result = $domain->enableaccountresponse->errortext;
}
return $result;
}
function cloudstack_ChangePassword($params) {
$licensecheck = cloudstack_license_checkLicense($params['configoption4']);
if ($licensecheck['status'] != 'Active') {
return 'License is not valid';
}
$cloudstack = request($params);
$id = $params['customfields']['cloudstackvmid'];
$reset = $cloudstack->resetPasswordForVirtualMachine($id);
// print_r($reset); exit();
if ($reset->resetpasswordforvirtualmachineresponse->jobid) {
$result = "success";
} else {
$result = $reset->resetpasswordforvirtualmachineresponse->errortext;
}
return $result;
}
//function cloudstack_ChangePackage($params) {
//
// # Code to perform action goes here...
//
// if ($successful) {
// $result = "success";
// } else {
// $result = "Error Message Goes Here...";
// }
// return $result;
//}
function cloudstack_ClientArea($params) {
$licensecheck = cloudstack_license_checkLicense($params['configoption4']);
if ($licensecheck['status'] != 'Active') {
return 'License is not valid';
}
$id = $params['customfields']['cloudstackvmid'];
$account = $params['customfields']['cloudstackaccountid'];
$did = $params['customfields']['domainid'];
$cloudstack = request($params);
// cloudstack_CreateAccount($params)
if (!empty($_POST['displayname'])) {
if (preg_match('/^[a-zA-Z]+[a-zA-Z0-9_]+$/', $_POST['displayname'])) {
$updateresp = $cloudstack->updateVirtualMachine($id, $_POST['displayname']);
if (isset($updateresp->updatevirtualmachineresponse->virtualmachine->id)) {
$message = "Update Successfully.";
} else {
$message = "Error in Update VM.";
}
} else {
$message = "Name Must be string.";
}
}
if ($_GET['page'] == 'rebuild') {
$template = $cloudstack->listTemplates('all');
$templateid = $template->listtemplatesresponse->template;
$templateopt = '';
foreach ($templateid as $templateo) {
$templateopt .= '<option value=' . $templateo->id . '>' . $templateo->name . '</option>';
}
}
if ($_POST['createsnapshot'] == 'createsnapshot') {
$snapresp = $cloudstack->createVMSnapshot($id, $_POST['description'], $_POST['name'], $_POST['quiescevm'], $_POST['snapshotmemory']);
// print_r($snapresp); exit();
if (isset($snapresp->createvmsnapshotresponse->id)) {
$message = 'Snapshot Is created';
} else {
$message = $snapresp->createvmsnapshotresponse->errortext;
}
}
if ($_GET['page'] == 'snapshot') {
if (isset($_GET['snapdelete'])) {
$resp = $cloudstack->deleteVMSnapshot($_GET['snapdelete']);
if (isset($resp->deletevmsnapshotresponse->jobid)) {
header('Location:clientarea.php?action=productdetails&page=snapshot&id=' . $_GET['id']);
exit();
} else {
$message = $snapresp->deletevmsnapshotresponse->errortext;
}
}
$response = $cloudstack->listVMSnapshot($did);
}
if ($_POST['rebuild'] == 'rebuild') {
$templateid = $_POST['template'];
$vmresp = $cloudstack->restoreVirtualMachine($id, $templateid);
if (isset($vmresp->restorevmresponse->errortext)) {
$message = $vmresp->restorevmresponse->errortext;
} else {
$message = 'Rebuild Successfully.';
}
}
if ($_POST['networkcreate'] == 'networkcreate') {
$networkofferings = $cloudstack->listNetworkOfferings();
// print_r($networkoffering);
$networkoffering = $networkofferings->listnetworkofferingsresponse->networkoffering[2]->id;
$dname = $_POST['displaytext'];
$zoneid = $params['configoptions']['Zones'];
$serviceofferid = $params['configoptions']['ServiceOffer'];
$diskOfferingId = $params['configoptions']['DiskOffer'];
$networktype = 'Account';
$domainid = $params['customfields']['domainid'];
$ipend = $_POST['ipend'];
$gateway = $_POST['gateway'];
$isDefault = $_POST['isdefault'];
$netmask = $_POST['netmask'];
$ipstart = $_POST['ipstart'];
$networks = $cloudstack->createNetwork($dname, $dname, $networkoffering, $zoneid, $params['username'], $networktype, $domainid, $ipend, $gateway, $isDefault = "", true, $netmask, $params['domain'], $ipstart);
$networkid = $networks->createnetworkresponse->network->id;
if (isset($networks->createnetworkresponse->errortext)) {
$message = $networks->createnetworkresponse->errortext;
} else {
$message = 'Successfully Added.';
}
}
if ($_GET['page'] == 'networking') {
// echo $account;
//print_r($cloudstack->listNetworks($account, 'c2e2f287-da19-402d-be17-fd32ef4fc34f'));
}
if ($_POST['resize'] == 'resize') {
$data = $cloudstack->changeServiceForVirtualMachine($id, $_POST['serviceoffer']);
if (isset($data->changeserviceforvirtualmachineresponse->errortext)) {
$message = $data->changeserviceforvirtualmachineresponse->errortext;
} else {
$message = "Successfully Done.";
}
}
if ($_GET['page'] == 'resize') {
$serviceoffer = $cloudstack->listServiceOfferings(); //disk offered
$serviceofferid = $serviceoffer->listserviceofferingsresponse->serviceoffering;
$serviceoffersoption = '';
foreach ($serviceofferid as $serviceop) {
// print_r($serviceop);
$serviceoffersoption .= '<option value=' . $serviceop->id . '>' . $serviceop->name . '</option>';
}
}
if ((!isset($_GET['page']) || $_GET['page'] == 'updatevm') && !empty($id)) {
$virtualmachine = $cloudstack->listVirtualMachines($account = "", $domainId = "", $forVirtualNetwork = "", $groupId = "", $hostId = "", $hypervisor = "", $id);
}
// print_r($virtualmachine);
// print_r($cloudstack->deleteDomain('9d3488cf-2e74-4c0b-96af-150fd5b50de9'));
// print_r($cloudstack->listUsers());
//print_r($cloudstack->queryAsyncJobResult('24a5637f-80d7-4040-9ff9-6046a5e5c1a2'));
return array(
'templatefile' => 'clientarea',
'vars' => array(
'message' => $message,
'zone' => $zonesoption,
'serviceoffer' => $serviceoffersoption,
'diskoffer' => $diskoffers,
'template' => $templateopt,
'snapshot' => $response,
'vmid' => $id,
'virtualmachine' => isset($virtualmachine->listvirtualmachinesresponse->virtualmachine[0]) ? $virtualmachine->listvirtualmachinesresponse->virtualmachine[0] : '',
'logs' => $cloudstack->listAsyncJobs()->listasyncjobsresponse->asyncjobs
),
);
}
function cloudstack_reboot($params) {
$cloudstack = request($params);
$id = $params['customfields']['cloudstackvmid'];
if (empty($id)) {
return 'No VM found.';
}
$reboot = $cloudstack->rebootVirtualMachine($id);
// print_r($reboot); exit();
if (isset($reboot->rebootvirtualmachineresponse->jobid)) {
$result = "success";
} else {
$result = $reboot->rebootvirtualmachineresponse->errortext;
}
return $result;
}
function cloudstack_shutdown($params) {
$cloudstack = request($params);
$id = $params['customfields']['cloudstackvmid'];
if (empty($id)) {
return 'No VM found.';
}
$stop = $cloudstack->stopVirtualMachine($id);
if ($stop->stopvirtualmachineresponse->jobid) {
$result = "success";
} else {
$result = $stop->stopvirtualmachineresponse->errortext;
}
return $result;
}
function cloudstack_start($params) {
$cloudstack = request($params);
$id = $params['customfields']['cloudstackvmid'];
if (empty($id)) {
return 'No VM found.';
}
$start = $cloudstack->startVirtualMachine($id);
if ($start->startvirtualmachineresponse->jobid) {
$result = "success";
} else {
$result = $start->startvirtualmachineresponse->errortext;
}
return $result;
}
function cloudstack_ClientAreaCustomButtonArray() {
$buttonarray = array(
"Reboot Server" => "reboot",
"Shutdown Server" => "shutdown",
"Start Server" => "start",
);
return $buttonarray;
}
function cloudstack_AdminCustomButtonArray() {
$buttonarray = array(
"Reboot Server" => "reboot",
"Shutdown Server" => "shutdown",
"Start Server" => "start",
);
return $buttonarray;
}
function cloudstack_UsageUpdate($params) {
$serverid = $params['serverid'];
$serverhostname = $params['serverhostname'];
$serverip = $params['serverip'];
$serverusername = $params['serverusername'];
$serverpassword = $params['serverpassword'];
$serveraccesshash = $params['serveraccesshash'];
$serversecure = $params['serversecure'];
# Run connection to retrieve usage for all domains/accounts on $serverid
# Now loop through results and update DB
foreach ($results AS $domain => $values) {
update_query("tblhosting", array(
"diskused" => $values['diskusage'],
"dislimit" => $values['disklimit'],
"bwused" => $values['bwusage'],
"bwlimit" => $values['bwlimit'],
"lastupdate" => "now()",
), array("server" => $serverid, "domain" => $values['domain']));
}
}
function request($params) {
require_once __DIR__ . '/class/CloudStackClient.php';
$cloudstack = new CloudStackClient($params['configoption3'], $params['configoption1'], $params['configoption2']);
return $cloudstack;
}
function cloudstack_rebuild($params) {
}
function cloustack_generateconfigoption($name, $id, $data) {
// echo $id;
# Configurable Option
$addconfigrablegroupname = "Cloudstak-" . $name . " " . $id . ":";
$addconfigurabledescription = $name;
$addconfigurableoptionname = $name;
$configurableoptionresult = Capsule::table('tblproductconfiglinks')->where('pid', $id)->get();
$configurableoptionlinkresult = Capsule::table('tblproductconfiggroups')->where('name', $addconfigrablegroupname)->get();
// print_r($configurableoptionlinkresult);
if (empty($configurableoptionlinkresult)) {
try {
$configurablegroupid = Capsule::table('tblproductconfiggroups')
->insertGetId(
[
"name" => $addconfigrablegroupname,
"description" => $addconfigurabledescription
]
);
Capsule::table('tblproductconfiglinks')
->insertGetId(
[
"gid" => $configurablegroupid,
"pid" => $id
]
);
$configid = Capsule::table('tblproductconfigoptions')
->insertGetId(
[
"gid" => $configurablegroupid,
"optionname" => $addconfigurableoptionname,
"optiontype" => "1",
"qtyminimum" => '',
"qtymaximum" => '',
"order" => "",
"hidden" => ""
]
);
foreach ($data as $key => $n) {
$tblpricing_rel_id[] = Capsule::table('tblproductconfigoptionssub')
->insertGetId(
[
"configid" => $configid,
"optionname" => $key . "|" . $n,
"sortorder" => "",
"hidden" => ""
]
);
}
$datas = Capsule::table('tblcurrencies')->orderBy('code', 'DESC')->get();
foreach ($datas as $data) {
$curr_id = $data->id;
$curr_code = $data->code;
$currenciesarray[$curr_id] = $curr_code;
}
foreach ($tblpricing_rel_id as $tdval) {
foreach ($currenciesarray as $curr_id => $currency) {
Capsule::table('tblpricing')->insert(
[
'type' => 'configoptions',
'currency' => $curr_id,
'relid' => $tdval,
'msetupfee' => '',
'qsetupfee' => '',
'annually' => '',
'biennially' => '',
'triennially' => ''
]
);
}
}
} catch (Exception $e) {
print_r($e->getMessage());
}
}
}
function cloudstack_api($sid, $fid, $value) {
$command = 'UpdateClientProduct';
$postData = array(
'serviceid' => $sid,
'customfields' => base64_encode(serialize(array($fid => $value))),
);
$adminUsername = '1'; // Optional for WHMCS 7.2 and later
$results = localAPI($command, $postData, $adminUsername);
}
//license
function cloudstack_license_checkLicense($licensekey, $localkey = "") {
$whmcsurl = "http://whmcsninja.com/members/"; #enter your own whmcs url here
$licensing_secret_key = '@#cloudstack$%^@'; #you can enter your own secret key here
$check_token = time() . md5(mt_rand(1000000000, 1e+010) . $licensekey);
$checkdate = date("Ymd");
$usersip = isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : $_SERVER['LOCAL_ADDR'];
$localkeydays = 10;
$allowcheckfaildays = 1;
$localkeyvalid = false;
// for local key start
$lkey = Capsule::table('tblconfiguration')->where('setting', 'cloudstack_localkey')->get(); //add for local key
if ($lkey) {
$localkey = $lkey[0]->value;
}
// for local key end
if ($localkey) {
$localkey = str_replace("\n", "", $localkey);
$localdata = substr($localkey, 0, strlen($localkey) - 32);
$md5hash = substr($localkey, strlen($localkey) - 32);
if ($md5hash == md5($localdata . $licensing_secret_key)) {
$localdata = strrev($localdata);
$md5hash = substr($localdata, 0, 32);
$localdata = substr($localdata, 32);
$localdata = base64_decode($localdata);
$localkeyresults = unserialize($localdata);
$originalcheckdate = $localkeyresults['checkdate'];
if ($md5hash == md5($originalcheckdate . $licensing_secret_key)) {
$localexpiry = date("Ymd", mktime(0, 0, 0, date("m"), date("d") - $localkeydays, date("Y")));
if ($localexpiry < $originalcheckdate) {
$localkeyvalid = true;
$results = $localkeyresults;
$validdomains = explode(",", $results['validdomain']);
if (!in_array($_SERVER['SERVER_NAME'], $validdomains)) {
$localkeyvalid = false;
$localkeyresults['status'] = "Invalid";
$results = array();
}
$validips = explode(",", $results['validip']);
if (!in_array($usersip, $validips)) {
$localkeyvalid = false;
$localkeyresults['status'] = "Invalid";
$results = array();
}
if ($results['validdirectory'] != dirname(__FILE__)) {
$localkeyvalid = false;
$localkeyresults['status'] = "Invalid";
$results = array();
}
}
}
// print_r($results); exit("df");
}
}
if (!$localkeyvalid) {
$postfields['licensekey'] = $licensekey;
$postfields['domain'] = $_SERVER['SERVER_NAME'];
$postfields['ip'] = $usersip;
$postfields['dir'] = dirname(__FILE__);
if ($check_token) {
$postfields['check_token'] = $check_token;
}
if (function_exists("curl_exec")) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $whmcsurl . "modules/servers/licensing/verify.php");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);
} else {
$fp = fsockopen($whmcsurl, 80, $errno, $errstr, 5);
if ($fp) {
$querystring = "";
foreach ($postfields as $k => $v) {
$querystring .= "{$k}=" . urlencode($v) . "&";
}
$header = "POST " . $whmcsurl . "modules/servers/licensing/verify.php HTTP/1.0\r\n";
$header .= "Host: " . $whmcsurl . "\r\n";
$header .= "Content-type: application/x-www-form-urlencoded\r\n";
$header .= "Content-length: " . @strlen(@$querystring) . "\r\n";
$header .= "Connection: close\r\n\r\n";
$header .= $querystring;
$data = "";
@stream_set_timeout(@$fp, 20);
@fputs(@$fp, @$header);
$status = @socket_get_status(@$fp);
while (!feof(@$fp) && $status) {
$data .= @fgets(@$fp, 1024);
$status = @socket_get_status(@$fp);
}
@fclose(@$fp);
}
}
if (!$data) {
$localexpiry = date("Ymd", mktime(0, 0, 0, date("m"), date("d") - ( $localkeydays + $allowcheckfaildays ), date("Y")));
if ($localexpiry < $originalcheckdate) {
$results = $localkeyresults;
} else {
$results['status'] = "Invalid";
$results['description'] = "Remote Check Failed";
return $results;
}
}
preg_match_all("/<(.*?)>([^<]+)<\\/\\1>/i", $data, $matches);
$results = array();
foreach ($matches[1] as $k => $v) {
$results[$v] = $matches[2][$k];
}
if ($results['md5hash'] && $results['md5hash'] != md5($licensing_secret_key . $check_token)) {
$results['status'] = "Invalid";
$results['description'] = "MD5 Checksum Verification Failed";
return $results;
}
if ($results['status'] == "Active") {
$results['checkdate'] = $checkdate;
$data_encoded = serialize($results);
$data_encoded = base64_encode($data_encoded);
$data_encoded = md5($checkdate . $licensing_secret_key) . $data_encoded;
$data_encoded = strrev($data_encoded);
$data_encoded = $data_encoded . md5($data_encoded . $licensing_secret_key);
$data_encoded = wordwrap($data_encoded, 80, "\n", true);
$results['localkey'] = $data_encoded;
// for local key start
if (!Capsule::table('tblconfiguration')->where('setting', 'cloudstack_localkey')->get()) {
Capsule::table('tblconfiguration')->insert(
[
'setting' => 'cloudstack_localkey',
'value' => $results['localkey']
]
);
} else {
Capsule::table('tblconfiguration')
->where('setting', 'cloudstack_localkey')
->update(
[
'value' => $results['localkey']
]
);
}
// for local key end
}
$results['remotecheck'] = true;
}
unset($postfields);
unset($data);
unset($matches);
unset($whmcsurl);
unset($licensing_secret_key);
unset($checkdate);
unset($usersip);
unset($localkeydays);
unset($allowcheckfaildays);
unset($md5hash);
return $results;
}
@font-face {
font-family:'HelveticaNeue-Regular';
src: url('../fonts/HelveticaNeue_gdi.eot');
src: url('../fonts/HelveticaNeue_gdi.eot?#iefix') format('embedded-opentype'),
url('../fonts/HelveticaNeue_gdi.woff') format('woff'),
url('../fonts/HelveticaNeue_gdi.ttf') format('truetype'),
url('../fonts/HelveticaNeue_gdi.svg#HelveticaNeue-Regular') format('svg');
font-weight: 400;
font-style: normal;
font-stretch: normal;
/*unicode-range: U+0-10FFFF;*/
}
#field { margin-left: .5em; float: left; }
#field, label { float: left; font-family: Arial, Helvetica, sans-serif; font-size: small; }
br { clear: both; }
input { border: 1px solid black; margin-bottom: .5em; }
input.error { border: 1px solid red; }
label.error {
color: #f00;
}
label.valid {
display: block;
width: 16px;
height: 16px;
position: absolute;
}
#myform table tr td, #general-form table tr td{
vertical-align: top !important;
}
#top-search-bar {
height: 39px;
margin-top: 20px;
}
#top-search-bar .drop-middle-bg {
background: url(../images/middle-bg.jpg) repeat-x;
height: 39px;
padding: 0 10px;
}
#top-search-bar .search-block, #filter .search-block {
background: url(../images/search-bg.png) no-repeat;
width: 202px;
height: 26px;
float: right;
margin: 7px 0px 0px 0px;
position: relative;
}
.searchbox-submit {
border: 0px;
background-color: transparent;
position: absolute;
top: 0px;
right: 0px;
width: 26px;
height: 26px;
}
input#searchvalue {
width: 165px;
padding: 0;
border: 0;
margin-top: 4px;
height: 20px;
margin-left: 5px;
}
/*-----------------Table formatting--------------------*/
.table {
width: 100%;
margin-bottom: 18px;
}
.table-framed {
border: 1px solid #DDD;
border-collapse: separate;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}
table {
max-width: 100%;
background-color: transparent;
border-collapse: collapse;
border-spacing: 0;
}
.table caption + thead tr:first-child th, .table caption + thead tr:first-child td, .table colgroup + thead tr:first-child th, .table colgroup + thead tr:first-child td, .table thead:first-child tr:first-child th, .table thead:first-child tr:first-child td {
border-top: 0;
}
.table thead th {
vertical-align: bottom;
}
.table th {
font-weight: bold;
}
.table td, .table th {
padding: 8px;
line-height: 18px;
text-align: left;
vertical-align: top;
border-top: 1px solid #dddddd;
}
.table-striped tbody tr:nth-child(odd) td, .table-striped tbody tr:nth-child(odd) th {
background-color: #f9f9f9;
}
.table tr:nth-child(even) td {
background-color: #fff;
}
.table tbody tr:hover td, .table tbody tr:hover th {
background-color: #f5f5f5;
}
span.edit-btn a img {
vertical-align: top;
}
.no_background{background:none !important;}
#wrapper{margin:0px;padding:0px;width:100%;}
.manage_content{margin:30px 0px;padding:0px;max-width:850px;width:100%;}
.manage_tab_sec{margin:0px;padding:0px;}
ul.manage_tab_menu{margin:0px;padding:0px;}
ul.manage_tab_menu li {float: left;list-style: outside none none;margin:0 7px 3px 0;max-width: 10%;text-align: center;width: 100%;}
ul.manage_tab_menu li a {background: #f1f1f3 none repeat scroll 0 0;border-radius:3px;float: left;padding: 16px 5px 10px;text-decoration: none;width: 100%;}
ul.manage_tab_menu li a i {display: block;height: 31px;padding: 0;text-align: center; width: 100%;font-size: 31px;}
.m_detail{margin:0px;padding:0px;background:url(../images/detail_icon.png) no-repeat center;}
.m_back{margin:0px;padding:0px;background:url(../images/backup.png) no-repeat center; background-size: 30%;}
.m_us{margin:0px;padding:0px; background:url(../images/us_icon.png) no-repeat center;}
.m_pwr{margin:0px;padding:0px; background:url(../images/power_icon.png) no-repeat center;}
.m_res{margin:0px;padding:0px; background:url(../images/resources_icon.png) no-repeat center;}
.m_data{margin:0px;padding:0px; background:url(../images/data_icon.png) no-repeat center;}
.m_ftp{margin:0px;padding:0px; background:url(../images/update_icon.png) no-repeat center;}
.m_rev{margin:0px;padding:0px; background:url(../images/reverse.png) no-repeat center;}
.m_stst{margin:0px;padding:0px; background:url(../images/statis_icon.png) no-repeat center;}
ul.manage_tab_menu li a p{margin:0x;padding:6px 0px 0;font-family:'HelveticaNeue-Regular';font-size:12px;color:#1c1c1c;}
ul.manage_tab_menu li a:hover, ul.manage_tab_menu li a.selected{background:#006687;transition:all 0.4s ease 0s;color: white;}
ul.manage_tab_menu li a:hover p, ul.manage_tab_menu li a.selected p{color:#fff;}
ul.manage_tab_menu li a:hover i.m_detail, ul.manage_tab_menu li a.selected i.m_detail{ background:url(../images/detail_icon_hr.png) no-repeat center;}
ul.manage_tab_menu li a:hover i.m_back, ul.manage_tab_menu li a.selected i.m_back {background:url(../images/backup.png) no-repeat center;background-size: 30%;}
ul.manage_tab_menu li a:hover i.m_us, ul.manage_tab_menu li a.selected i.m_us{ background:url(../images/us_icon_hr.png) no-repeat center;}
ul.manage_tab_menu li a:hover i.m_pwr, ul.manage_tab_menu li a.selected i.m_pwr{ background:url(../images/power_icon_hr.png) no-repeat center;}
ul.manage_tab_menu li a:hover i.m_res, ul.manage_tab_menu li a.selected i.m_res{ background:url(../images/resources_icon_hr.png) no-repeat center;}
ul.manage_tab_menu li a:hover i.m_data, ul.manage_tab_menu li a.selected i.m_data{ background:url(../images/data_icon_hr.png) no-repeat center;}
ul.manage_tab_menu li a:hover i.m_ftp, ul.manage_tab_menu li a.selected i.m_ftp{ background:url(../images/update_icon_hr.png) no-repeat center;}
ul.manage_tab_menu li a:hover i.m_rev, ul.manage_tab_menu li a.selected i.m_rev{ background:url(../images/reverse_hr.png) no-repeat center;}
ul.manage_tab_menu li a:hover i.m_stst, ul.manage_tab_menu li a.selected i.m_stst{ background:url(../images/statis_icon_hr.png) no-repeat center;}
/************** manage_tab_content **************/
.manage_tab_content{margin:20px 0 5px;padding:0px;background:#f1f1f3;border:1px solid #006687;border-radius:3px;width:100%;float:left;clear:both; text-align: left;}
.tab_row {clear: both;margin: 0;padding: 0;width: 100%;font-size: 16px;font-family:'HelveticaNeue-Regular';}
.tab_row strong {background: #006687 none repeat scroll 0 0;border-bottom: 2px solid #006687;color: #fff;float: left;font-weight: normal;line-height: 27px;margin: 0;max-width: 254px;padding: 10px 18px;text-align: right;vertical-align: text-bottom;width: 30%;}
.tab_row span {border-bottom: 1px solid #ccc;border-top:1px solid #fff;float: left;line-height: 27px; max-width: 633px;padding: 10px 31px;width: 70%;}
/****************** power_sec *******************/
.m_power{padding:20px 25px;}
.power_sec{margin:20px 0px;padding:0px;}
.nav-tabs{border:none;}
ul.power_tab li a{background: #f1f1f3 none repeat scroll 0 0;border-radius: 3px !important; margin: 0 7px 0 0; border:none;color: #389a38;font-family:'HelveticaNeue-Regular';font-size:15px;}
.nav-tabs > li.active > a, .nav-tabs > li.active > a:focus, .nav-tabs > li.active > a:hover{background:#006687;color:#fff;border:none;}
.tab-pane p{font-size: 16px;font-family:'HelveticaNeue-Regular'; color:#1c1c1c;line-height:30px;margin:0px;padding:0px;}
.reb_btn{background:#46a546; margin:20px 0 0px;padding:8px 28px;float:right;clear:both;font-size: 16px;font-family:'HelveticaNeue-Regular'; color:#fff;letter-spacing:0.1em;border-radius:3px;text-shadow: 0 1px 3px #0b660b; text-decoration:none;transition:all 0.4s ease 0s;border:2px solid #f1f1f3;}
.reb_btn:hover{text-decoration:none !important;color:#46a546;background:none;border:2px solid #46a546; text-shadow:none;}
/****************** data *******************/
.power_tab li {margin-bottom:3px;}
.power_tab li a img {margin: 0 8px 0 0;vertical-align: middle;}
ul.power_tab li a i {background-position: center top;display: block;float: left;height: 14px;margin: 4px 8px 0 0;padding: 0;text-align: center;width: 30px;}
.hd_info{margin:0px;padding:0px; background:url(../images/hdinfo_icon.png) no-repeat left top;}
.cp_info{margin:0px;padding:0px; background:url(../images/cpifo_icon.png) no-repeat left top;}
.power_tab > li a:hover .hd_info, .power_tab > li a:focus .hd_info{background:url(../images/hdinfo_icon_hr.png) no-repeat left top;}
.power_tab > li a:hover .hd_info, .power_tab > li a:focus .cp_info{background:url(../images/hdinfo_icon_hr.png) no-repeat left top;}
.power_tab > li > a:focus, .nav > li > a:hover {background-color: #006687;text-decoration: none;color:#fff;}
.text_b {font-weight:bold !important; color:#4bba4b !important;letter-spacing:0.05em;}
/****************** data *******************/
.manage_heading{background:#272727;margin:0px;padding:0px;width:100%;}
.manage_heading h2{margin:0px;padding:10px 0px 10px 25px;font-size: 20px;font-family:'HelveticaNeue-Regular'; color:#6bb76b;}
.m_detail_cont{margin:0px;padding:12px 25px;}
.m_detail_cont p{margin:0px;padding:0px;font-size: 15px;font-family:'HelveticaNeue-Regular'; color:#444444;line-height:24px;letter-spacing:0.05em;}
.m_detail_cont p strong{font-weight:800;color:#222;font-size: 15px;}
.ftp_row strong p{margin:0px !important;}
.ftp_row strong{text-align:center !important;font-weight:bold;letter-spacing:0.05em;padding:29px 18px 24px !important;max-width:264px;}
.ftp_row span{border-top:1px solid #ccc;}
.progress {border-radius: 24px;background:#fff;box-shadow: 0 1px 2px #bfbfbf;height: 16px;margin: 1px 0;}
.progress-bar {background-color: #46a546;}
.manage_table{margin:0px;padding:0px;}
.row_heading {border-bottom: 1px solid #ccc;height: 40px;line-height:40px;width: 100%;}
.rh2{background:#ecf5ec;}
.r4TableHead {font-size: 14px;font-family:'HelveticaNeue-Regular'; color:#111;float: left;overflow: hidden;padding: 0;text-align: left;width: 9%;}
.row_heading div:first-child {text-align: center;width: 5%;}
.row_heading div:nth-child(2n) {width: 19%;}
.row_heading div:nth-child(3n) {width: 19%;}
.r4TableCell{ float: left;font-size: 13px;font-family:'HelveticaNeue-Regular'; color:#444444;overflow: hidden;padding: 0;text-align: left; width: 9%;}
.manage_content .row{margin:0px !important;}
.manage_content .col-lg-12, .col-md-12{padding:0px !important;}
.r4TableCell a { padding: 0 15px 0 0;}
@media only screen and (max-width: 320px) {
.manage_content { margin: 30px auto; max-width: 850px;padding: 0;width: 99%;}
ul.power_tab li a {font-size: 13px;padding: 10px 12px;}
.manage_tab_content .tab_row:nth-child(3n) span { line-height: 13px;}
.tab_row { font-size: 13px; }
.tab_row strong {padding: 10px 7px; width: 50%;}
.tab_row span {padding: 10px 12px;width: 50%;}
.row_heading div:first-child {text-align: center; width: 7%;}
.r4TableCell { font-size: 11px;line-height: 16px; overflow: hidden; padding: 4px 4px; text-align: center;vertical-align: bottom;width: 8%;word-break: break-all;}
.r4TableHead {color: #111;float: left;font-size: 12px;line-height: 16px;overflow: hidden;padding: 3px 0;text-align: center;width: 8%;}
}
@media only screen and (min-width: 321px) and (max-width: 480px) {
.manage_content {margin: 30px auto;max-width: 850px;padding: 0;width: 99%;}
ul.power_tab li a {
font-size: 13px;
padding: 10px 12px;
}
.tab_row { font-size: 13px; }
.tab_row strong {padding: 10px 7px; width: 50%;}
.tab_row span {padding: 10px 12px;width: 50%;}
.row_heading div:first-child {text-align: center;width: 7%;}
.r4TableCell {font-size: 11px;line-height: 16px;overflow: hidden;padding: 4px 4px;text-align: center;vertical-align: bottom;width: 8%;word-break: break-all;}
.r4TableHead {font-size: 12px; line-height: 16px;overflow: hidden;padding: 3px 0;text-align: center;width: 8%;}
}
@media only screen and (min-width: 481px) and (max-width: 768px) {
.manage_content { margin: 30px auto;max-width: 850px; padding: 0;width: 98%;}
.row_heading div:first-child {text-align: center;width: 7%;}
.r4TableCell {font-size: 13px;line-height: 16px;overflow: hidden;padding: 4px 4px;text-align: center;vertical-align: bottom;width: 8%;word-break: break-all;
}
.r4TableHead {
font-size: 13px;
line-height: 16px;
overflow: hidden;
padding: 3px 0;
text-align: center;
width: 8%;
}
.tab_row { font-size: 14px; }
.tab_row strong {padding: 10px 7px; width: 50%; max-width:none;}
.tab_row span {padding: 10px 12px;width: 50%;}
}
@media only screen and (min-width: 769px) and (max-width: 980px) {
}
.powerstatus {
margin: 15px 0 0;
}
#powerloader {
clear: both;
display: inline-table;
padding: 10px;
position: relative;
text-align: center;
}
.fa-li.fa.fa-spinner.fa-spin {
display: inline-table;
position: static;
text-align: center;
width: auto;
}
.m_detail_cont.tab-content.manage_tab_content.m_power {
border: medium none !important;
}
.reb_btn:hover{
text-decoration: none !important;
}
.col-sm-3 .form-group .reb_btn ,.col-sm-4 .form-group .reb_btn {
margin: 0;
padding: 5px 20px;
}
#loaderabckground {
background: #000 none repeat scroll 0 0;
height: 100%;
left: 0;
opacity: 0.7;
position: fixed;
top: 0;
width: 100%;
z-index: 99999;
}
#serverloader {
height: 100%;
left: 0;
margin: 0 auto;
opacity: 0.6;
position: fixed;
top: 40%;
width: 100%;
z-index: 99999;
}
.radio-inline {
cursor: pointer;
display: inline-block;
font-weight: 400;
margin-bottom: 0;
padding-left: 20px;
position: relative;
vertical-align: middle;
}
label {
display: inline-block;
font-weight: 700;
margin-bottom: 5px;
max-width: 100%;
}
.form-group {
margin-bottom: 15px;
}
.checkbox input[type="checkbox"], .checkbox-inline input[type="checkbox"], .radio input[type="radio"], .radio-inline input[type="radio"] {
margin-left: -20px;
position: absolute;
}
.col-sm-6 {
width: 50%;
}
/*.col-sm-1, .col-sm-10, .col-sm-11, .col-sm-12, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9 {
float: left;
}
.col-lg-1, .col-lg-10, .col-lg-11, .col-lg-12, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-md-1, .col-md-10, .col-md-11, .col-md-12, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-sm-1, .col-sm-10, .col-sm-11, .col-sm-12, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-xs-1, .col-xs-10, .col-xs-11, .col-xs-12, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9 {
min-height: 1px;
padding-left: 15px;
padding-right: 15px;
position: relative;
}*/
.form-control {
background-color: #fff;
background-image: none;
border: 1px solid #ccc;
border-radius: 4px;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset;
color: #555;
display: block;
font-size: 14px;
height: 34px;
line-height: 1.42857;
padding: 6px 12px;
transition: border-color 0.15s ease-in-out 0s, box-shadow 0.15s ease-in-out 0s;
width: 60%;
}
.col-sm-12 {
width: 100%;
}
.col-sm-4 {
width: 33.3333%;
}
.col-sm-5 {
width: 41.6667%;
}
.btn-group-vertical > .btn-group::after, .btn-group-vertical > .btn-group::before, .btn-toolbar::after, .btn-toolbar::before, .clearfix::after, .clearfix::before, .container-fluid::after, .container-fluid::before, .container::after, .container::before, .dl-horizontal dd::after, .dl-horizontal dd::before, .form-horizontal .form-group::after, .form-horizontal .form-group::before, .modal-footer::after, .modal-footer::before, .nav::after, .nav::before, .navbar-collapse::after, .navbar-collapse::before, .navbar-header::after, .navbar-header::before, .navbar::after, .navbar::before, .pager::after, .pager::before, .panel-body::after, .panel-body::before, .row::after, .row::before {
content: " ";
display: table;
}
.table {
margin-bottom: 20px;
max-width: 100%;
width: 100%;
}
table {
background-color: transparent;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
.table > caption + thead > tr:first-child > td, .table > caption + thead > tr:first-child > th, .table > colgroup + thead > tr:first-child > td, .table > colgroup + thead > tr:first-child > th, .table > thead:first-child > tr:first-child > td, .table > thead:first-child > tr:first-child > th {
border-top: 0 none;
}
table.table-list thead th {
background-color: #e6ecef;
border-bottom: 1px solid #ccc;
color: #333;
font-size: 13px;
}
.table > thead > tr > th {
border-bottom: 2px solid #ddd;
vertical-align: bottom;
}
.table > tbody > tr > td, .table > tbody > tr > th, .table > tfoot > tr > td, .table > tfoot > tr > th, .table > thead > tr > td, .table > thead > tr > th {
border-top: 1px solid #ddd;
line-height: 1.42857;
padding: 8px;
vertical-align: top;
}
table.table-list th {
text-align: center;
}
table.table-list tbody td, table.table-list tbody td {
padding: 5px 10px;
vertical-align: middle;
}
.table-list > tbody > tr:nth-child(2n+1) > td, .table-list > tbody > tr:nth-child(2n+1) > th {
background-color: #fafafa;
}
table.table-list tbody td, table.table-list tbody td {
padding: 5px 10px;
vertical-align: middle;
}
.table-list > tbody > tr > td {
background-color: #fff;
font-size: 15px;
}
.reversebtn{
margin: 0 !important;
padding: 5px 18px !important;
float:none;
}
.reverseinput{
border: 0;
box-shadow: none;
border-radius: 5px;
padding: 5px;
width: 276px;
background: none;
outline: none;
}
.reverseinput2{
border: 1px solid #ccc;
border-radius: 5px;
padding: 5px;
width: 307px;
}
.container-blur {
background: transparent none repeat scroll 0 0;
height: 100%;
left: 0;
position: absolute;
right: 0;
width: 100%;
z-index: 999999999;
}
a:focus, a:hover {
outline: medium none;
text-decoration: none;
}
.Card {
background: none repeat scroll 0% 0% #FEFEFE;
border: 1px solid #DDD;
position: relative;
border-radius: 0px;
margin: 15px;
}
section {
margin-bottom: 15px;
}
.CardHeader {
padding: 15px 20px 0px;
}
.Card-body {
padding: 20px;
}
.disabled {
pointer-events: none;
cursor: default;
}
.offset-sm-3 {
margin-left: 25%;
}
.ontop {
width: 100%;
height: 100%;
top: 0;
left: 0;
position: absolute;
background-color: #cccccc;
color: #aaaaaa;
opacity: .4;
filter: alpha(opacity = 50);
}
#popup {
width: 70%;
height: 200px;
position: absolute;
color: #000000;
background-color: #ffffff;
/* To align popup window at the center of screen*/
top: 41%;
left: 61%;
margin-top: -112px;
margin-left: -244px;
}
.Dropdown-menu--right {
left: auto;
right: 0px;
}
.Dropdown-menu {
border: 1px solid #DDD;
width: 200px;
text-align: right;
position: absolute;
/*top: 31px;*/
z-index: 1000;
/*left: 0px;*/
display: none;
margin-right: 46px;
}
.Dropdown-group:not(:last-of-type) {
border-bottom: 1px solid #DDD;
}
.Dropdown-menu {
text-align: right;
}
.Dropdown-item {
width: 100%;
display: block;
border: 0px none;
padding: 0px 15px;
margin-left: 0px !important;
}
.Dropdown-first, .Dropdown-item, .Dropdown-toggle {
text-align: left;
}
.btn, .Dropdown-first, .Dropdown-item, .Dropdown-toggle {
padding: 6px 8px;
text-decoration: none;
border-radius: 0px;
border: 1px solid green;
background: none repeat scroll 0% 0% green;
color : white;
}
.Dropdown-item{
height : 32px;
}
center{
text-align:left;
margin-left: 40px;
}
.Modal-header {
background: none repeat scroll 0% 0% #F0F0F0;
padding: 3px;
border-bottom: 1px solid #CCC;
padding-left:10px;
}
.Modal-body {
padding: 10px 20px;
overflow-y: auto;
}
.form-group {
margin-bottom: 10px !important;
font-size: 18px;
}
.errorbox {
background-image: url(../images/error.png);
background-repeat: no-repeat;
background-position: 15px;
margin: 10px 0;
padding: 6px 5px 6px 60px;
min-height: 28px;
background-color: #f2d4ce;
border: 1px solid #ae432e;
color: #c00;
text-align: left;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
-o-border-radius: 5px;
border-radius: 5px;
}
/*** custom css **/
.btn-restart {
background: #006687;
float: left;
margin-left: 2%;
color:#ffffff;
font-weight:bold;
border: 1px solid #006687;
border-radius: 5px;
}
.btn-powerOn{
background: #006687;
float: left;
color:#ffffff;
font-weight:bold;
border: 1px solid #006687;
border-radius: 5px;
}
.btn-powerOff{
background: #006687;
float: left;
color:#ffffff;
font-weight:bold;
border: 1px solid #006687;
border-radius: 5px;
}
.controls_btn.btn-group.btn-group-justified .btn {
padding: 7px;
white-space: inherit;
border-radius:0px;
width: 15%;
margin-right: 4px;
}
.manage_img {
width: 35%;
}
button.poweroff {
background: #b71e1e !important;
border-color: #a01818 !important;
}
button.poweroff:hover{
background: #902222 !important;
border-color: #651717 !important;
}
<?php
use WHMCS\Database\Capsule;
add_hook('AdminAreaPage', 1, function($vars) {
if ($_POST['ajaxpage'] == 'createconfig') {
require_once 'cloudstack.php';
$data = Capsule::table('tblproducts')
->where('id', '=', $_POST['productid'])
->where('servertype', '=', 'cloudstack')->first();
$params['configoption3'] = $data->configoption3;
$params['configoption1'] = $data->configoption1;
$params['configoption2'] = $data->configoption2;
$params['data'] = $data->configoption2;
$cloudstack = request($params);
$zones = $cloudstack->listZones(); // zones lists
// print_r($zones); exit();
$zone = [];
foreach ($zones->listzonesresponse->zone as $zonename) {
$zone[$zonename->id] = $zonename->name;
}
$serviceoffers = $cloudstack->listServiceOfferings(); //disk offered
$soffer = [];
foreach ($serviceoffers->listserviceofferingsresponse->serviceoffering as $serviceoffer) {
$soffer[$serviceoffer->id] = $serviceoffer->name;
}
$disk = [];
$diskoffers = $cloudstack->listDiskOfferings(); //disk offered
foreach ($diskoffers->listdiskofferingsresponse->diskoffering as $diskoffer) {
$disk[$diskoffer->id] = $diskoffer->name;
}
$temp = [];
$templates = $cloudstack->listTemplates('all');
//print_r($templates); exit();
foreach ($templates->listtemplatesresponse->template as $template) {
$temp[$template->id] = $template->name;
}
cloustack_generateconfigoption('Zones', $_POST['productid'], $zone);
cloustack_generateconfigoption('ServiceOffer', $_POST['productid'], $soffer);
cloustack_generateconfigoption('DiskOffer', $_POST['productid'], $disk);
cloustack_generateconfigoption('Template', $_POST['productid'], $temp);
echo "success";
exit();
}
});
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment