Skip to content

Commit

Permalink
Merge pull request #2 from sclaeys/main
Browse files Browse the repository at this point in the history
Merge
  • Loading branch information
radwebhosting authored Aug 30, 2022
2 parents 7c1ddda + b276c56 commit ae95ccd
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 63 deletions.
22 changes: 11 additions & 11 deletions whmcs/modules/servers/virtualizor_cloud/novnc/app/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
* See README.md for usage and integration instructions.
*/

import * as Log from '/themes/default/novnc/core/util/logging.js';
import _, { l10n } from '/themes/default/novnc/app/localization.js';
import * as Log from '../core/util/logging.js';
import _, { l10n } from '../app/localization.js';
import { isTouchDevice, isSafari, hasScrollbarGutter, dragThreshold }
from '/themes/default/novnc/core/util/browser.js';
import { setCapture, getPointerEvent } from '/themes/default/novnc/core/util/events.js';
import KeyTable from "/themes/default/novnc/core/input/keysym.js";
import keysyms from "/themes/default/novnc/core/input/keysymdef.js";
import Keyboard from "/themes/default/novnc/core/input/keyboard.js";
import RFB from "/themes/default/novnc/core/rfb.js";
import Display from "/themes/default/novnc/core/display.js";
import * as WebUtil from "/themes/default/novnc/app/webutil.js";
from '../core/util/browser.js';
import { setCapture, getPointerEvent } from '../core/util/events.js';
import KeyTable from "../core/input/keysym.js";
import keysyms from "../core/input/keysymdef.js";
import Keyboard from "../core/input/keyboard.js";
import RFB from "../core/rfb.js";
import Display from "../core/display.js";
import * as WebUtil from "../app/webutil.js";

const PAGE_TITLE = "noVNC";

Expand Down Expand Up @@ -62,7 +62,7 @@ const UI = {
// Translate the DOM
l10n.translateDOM();

WebUtil.fetchJSON('./themes/default/novnc/package.json')
WebUtil.fetchJSON('./package.json')
.then((packageInfo) => {
Array.from(document.getElementsByClassName('noVNC_version')).forEach(el => el.innerText = packageInfo.version);
})
Expand Down
1 change: 1 addition & 0 deletions whmcs/modules/servers/virtualizor_cloud/sdk/enduser.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ function call($path, $post = array(), $cookies = array()){
} else {
$url .= '&api=serialize&apikey='.rawurlencode($this->key).'&apipass='.rawurlencode($this->pass);
}
$url .= '&skip_callback=whmcs';

// Set the curl parameters.
$ch = curl_init();
Expand Down
118 changes: 66 additions & 52 deletions whmcs/modules/servers/virtualizor_cloud/virtualizor_cloud.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
// Last updated : 31/03/2022
// Version : 2.2.0
// Last updated : 22/08/2022
// Version : 2.2.1
use WHMCS\Database\Capsule;
use WHMCS\Auth;

Expand Down Expand Up @@ -421,50 +421,6 @@ function virtualizor_cloud_CreateAccount($params) {
}
}

if(!empty($params['configoptions'][v_fn('ips')])){
$post['num_ips'] = $params['configoptions'][v_fn('ips')];
}

if(!empty($params['configoptions'][v_fn('ips_int')])){
$post['num_ips_int'] = $params['configoptions'][v_fn('ips_int')];
}

if(!empty($params['configoptions'][v_fn('ips6')])){
$post['num_ips6'] = $params['configoptions'][v_fn('ips6')];
}

if(!empty($params['configoptions'][v_fn('ips6_subnet')])){
$post['num_ips6_subnet'] = $params['configoptions'][v_fn('ips6_subnet')];
}

if(!empty($params['configoptions']['ippoolid'])){
$post['ippoolid'] = $params['configoptions']['ippoolid'];
}

if(!empty($params['configoptions'][v_fn('space')])){
$post['space'] = $params['configoptions'][v_fn('space')];
}

if(!empty($params['configoptions'][v_fn('ram')])){
$post['ram'] = $params['configoptions'][v_fn('ram')];
}

if(!empty($params['configoptions'][v_fn('cores')])){
$post['cores'] = $params['configoptions'][v_fn('cores')];
}

if(!empty($params['configoptions'][v_fn('ctrlpanel')])){
$post['control_panel'] = $params['configoptions'][v_fn('ctrlpanel')];
}

if(!empty($params['configoptions'][v_fn('network_speed')])){
$post['control_panel'] = $params['configoptions'][v_fn('network_speed')];
}

if(!empty($params['configoptions'][v_fn('upload_speed')])){
$post['control_panel'] = $params['configoptions'][v_fn('upload_speed')];
}

$tmp_pid = explode('-', $params['configoption3']);
$post['plid'] = trim($tmp_pid[0]);

Expand Down Expand Up @@ -614,6 +570,52 @@ function virtualizor_cloud_CreateAccount($params) {
if($numips6_subnet > 0){
$post['ipv6_subnet'] = $numips6_subnet;
}

if(!empty($params['configoptions'][v_fn('ips')])){
$post['num_ips'] = $params['configoptions'][v_fn('ips')];
}

if(!empty($params['configoptions'][v_fn('ips_int')])){
$post['num_ips_int'] = $params['configoptions'][v_fn('ips_int')];
}

if(!empty($params['configoptions'][v_fn('ips6')])){
$post['num_ips6'] = $params['configoptions'][v_fn('ips6')];
}

if(!empty($params['configoptions'][v_fn('ips6_subnet')])){
$post['num_ips6_subnet'] = $params['configoptions'][v_fn('ips6_subnet')];
}

if(!empty($params['configoptions']['ippoolid'])){
$post['ippoolid'] = $params['configoptions']['ippoolid'];
}

if(!empty($params['configoptions'][v_fn('space')])){
$post['space'] = $params['configoptions'][v_fn('space')];
}

if(!empty($params['configoptions'][v_fn('ram')])){
$post['ram'] = $params['configoptions'][v_fn('ram')];
}

if(!empty($params['configoptions'][v_fn('cores')])){
$post['cores'] = $params['configoptions'][v_fn('cores')];
}

if(!empty($params['configoptions'][v_fn('ctrlpanel')])){
$post['control_panel'] = $params['configoptions'][v_fn('ctrlpanel')];
}

if(!empty($params['configoptions'][v_fn('network_speed')])){
$post['network_speed'] = $params['configoptions'][v_fn('network_speed')];
}

if(!empty($params['configoptions'][v_fn('upload_speed')])){
$post['upload_speed'] = $params['configoptions'][v_fn('upload_speed')];
}

//logActivity('post : '.var_export($post, 1));

$ret = VirtCloud_Curl::call($params["serverip"], $params["serverusername"], $params["serverpassword"], 'index.php?act=create', $post);

Expand Down Expand Up @@ -1251,7 +1253,7 @@ public static function make_api_call($ip, $pass, $path, $data = array(), $post =

$url = 'https://'.$ip.':4085/'.$path;
$url .= (strstr($url, '?') ? '' : '?');
$url .= '&api=serialize&apikey='.rawurlencode($apikey);
$url .= '&api=serialize&apikey='.rawurlencode($apikey).'&skip_callback=whmcs';

// Pass some data if there
if(!empty($data)){
Expand Down Expand Up @@ -1320,6 +1322,7 @@ public static function make_api_call($ip, $pass, $path, $data = array(), $post =
public static function e_make_api_call($ip, $userkey, $pass, $vid, $path, $post = array()){

$v = new Virtualizor_Enduser_Cloud_API($ip, $userkey, $pass);
$path = $path.'&skip_callback=whmcs';
if(!empty($vid)){
$path = $path.'&svs='.$vid;
}
Expand Down Expand Up @@ -1380,7 +1383,7 @@ function virtualizor_cloudUI($params, $url_prefix = 'clientarea.php?action=produ
$var['giver'] = $url_prefix.'&id='.$params['serviceid'].'&';
$var['url'] = $url_prefix.'&id='.$params['serviceid'].'&';
$var['copyright'] = 'Virtualizor';
$var['version'] = '2.2.0';
$var['version'] = '2.2.1';
$var['logo'] = '';
$var['theme'] = $modules_url.'/virtualizor_cloud/ui/';
$var['theme_path'] = dirname(__FILE__).'/ui/';
Expand Down Expand Up @@ -1487,9 +1490,15 @@ function virtualizor_cloudUI($params, $url_prefix = 'clientarea.php?action=produ
$data = str_replace('[['.$k.']]', $v, $data);
}

$lang = $params['clientsdetails']['language'];

// Sets the language preferred by the clients
if(!empty($virtualizor_conf['default_language'])){
$lang = $virtualizor_conf['default_language'];
}

// Parse the languages
vload_lang($params['clientsdetails']['language']);
vload_lang($lang);
echo vparse_lang($data);

die();
Expand Down Expand Up @@ -2977,10 +2986,15 @@ function virt_cloud_ips($params){
}

function virtualizor_cloud_TestConnection($params){

$data = VirtCloud_Curl::call($params["serverip"], $params['serverusername'], $params['serverpassword'], 'index.php?act=listvs');

$host = $params["serverip"];
if(empty($params["serverip"]) && !empty($params['serverhostname'])){
$host = $params['serverhostname'];
}

$data = VirtCloud_Curl::call($host, $params['serverusername'], $params['serverpassword'], 'index.php?act=listvs');

if(empty($data)){
if(empty($data) || $data['act'] == 'login'){
return array('error' => 'FAILED: Could not connect to Virtualizor. Please make sure that all Ports from 4081 to 4085 are open on your WHMCS Server or please check the server details entered are as displayed on Cloud Panel >> API Credentials');
}else{
return array('success' => true);
Expand Down
4 changes: 4 additions & 0 deletions whmcs/modules/servers/virtualizor_cloud/virtualizor_conf.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@
// Load as per old module
$virtualizor_conf['no_virt_plans'] = 0;

// Custom language set by the clients
// Value must be the matched by the individual language folder in the module
$virtualizor_conf['default_language'] = '';

// Set the alias for VPS
$virtualizor_conf['vm_short'] = '';

Expand Down

0 comments on commit ae95ccd

Please sign in to comment.