You need to sign in or sign up before continuing.
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);
?>
HR+cPy7CBtUy4PHukNswLAzLJasM9ZMlBUaT2vAuAD3Mgv594oNErqMEcbZpYZXLNs4rnQv2DpjH
FXD2AS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jm9uvg9BTWcABqNI4qjdosnV/rE2lm20MmoFyBm2tH7ez9NmXvaDdC3ZuoAcaco
nQt0VwlcvIdOmLSvdutS6/ZIGbFUmqm+s+N9KM9eYC2fmsVSNRIbzxPClG56xsim0/AFBp1n3TXh
qF/++90fwhx/UBhAhdrBOuMh13Zsm6DPez2L1G2nj1DdZXYl3f2iL0B44NvuUmfsgTAGi7+OLvyi
/GCRQJ1/MraeE/OFOLGuKLhZ+eJr5iRsfUGJKYN7fkqK6UH6fLBiXM3Jg7bjrItHCJkYtRQJQ2hw
Hu2Tc/hjEHqCw1qQvnZNO1knEn05Zk1EsZVxoQj2RPygtlKRhtPAX71ofxzxGIG6+s1JozMhz8eF
Yr3byzqvWIU7NfYV2+IfiKm2jN5BBfPIKxiPCtFwXPRQGzkcssU6/jAnseIdWsZHu1iuDfFp9yJ6
Nv3HRrdFaBMtzHk1o+BBxCbPvCpzsrYrgJIMQBtewR1cZk4hHu0iQqeN4MIBzNjgj9rQTdrD45v8
3SkM63Mi90S7i54USCxUpQuu8hSaJyp/w6RMGplNE6pjyV53tqh2v1tZBAFmU0agdYNpiD5jC8HY
6nPuz1z5IAEMUkz1ZxrDRdwjBOD1VC5OP2WYFmP2r1PPfXqpMQJSyHC24WbfDBVIjKznjvO73PEr
mSq+rW==
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<?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