From 808ca2490d43fc5723988675723a47fb20cb16b2 Mon Sep 17 00:00:00 2001 From: AsPiD21 <72015749+AsPiD21@users.noreply.github.com> Date: Mon, 28 Sep 2020 18:08:44 +0300 Subject: [PATCH] Add files via upload --- addons/oncontrol/classes/Loader.php | 258 ++-- addons/oncontrol/lang/english.php | 250 ++-- addons/oncontrol/logics/vmlist.php | 590 ++++----- addons/oncontrol/oncontrol.php | 222 ++-- addons/oncontrol/pages/configuration/menu.php | 8 +- .../pages/configuration/moduleconfig.php | 305 +++-- .../pages/configuration/newConfig.php | 373 +++--- addons/oncontrol/pages/vmlist/freeip.php | 23 +- addons/oncontrol/pages/vmlist/menu.php | 10 +- addons/oncontrol/pages/vmlist/panel.php | 1060 ++++++++--------- addons/oncontrol/pages/vmlist/qutas.php | 190 ++- addons/oncontrol/pages/vmlist/reinstall.php | 340 +++--- .../pages/vmlist/service_manager.php | 8 +- addons/oncontrol/pages/vmlist/vmlist.php | 826 ++++++------- servers/onconnector/hooks.php | 631 +++++----- servers/onconnector/lib/ONConnect.php | 348 +++--- servers/onconnector/onconnector.php | 526 +++----- 17 files changed, 2768 insertions(+), 3200 deletions(-) diff --git a/addons/oncontrol/classes/Loader.php b/addons/oncontrol/classes/Loader.php index e4d8bde..c9c41df 100644 --- a/addons/oncontrol/classes/Loader.php +++ b/addons/oncontrol/classes/Loader.php @@ -1,131 +1,129 @@ -onconnect = new ONConnect(); - ini_set('error_reporting', E_ALL); - ini_set('display_errors', 0); - ini_set('display_startup_errors', 1); - $this->vars = $vars; - $this->LANG = $this->vars['_lang']; - $this->tabs = $_GET['tabs']; - $this->mod = $_GET['mod']; - $pageUrl['mod'] = $this->mod; - $pageUrl['tabs'] = $this->tabs; - $pageUrl = http_build_query($pageUrl); - $this->modulelink=$vars['modulelink'].'&'.$pageUrl; - } - - private function addOrUpdate($name,$value){ - if(Capsule::table( 'tblconfiguration' ) - ->where('setting',$name) - ->get()) { - Capsule::table( 'tblconfiguration' ) - ->where('setting',$name) - ->update([ - 'setting'=>$name, - 'value'=>$value - ]); - } - else{ - $result = Capsule::table('tblconfiguration') - ->insert([ - 'setting' => $name, - 'value' => $value - ]); - }; - } - private function loadTabs() - { - ?> - - -
- -
- tabs == NULL) { - $this->tabs = 'vmlist'; - $this->mod = 'vmlist'; - }?> - loadTabs();?> - breadCrumbs();?> - -
-
- loadPageMenu();?> -
- -
- loadPageContent();?> -
-
- - tabs = 'configuration'; - $this->mod = 'moduleconfig'; - ?> - loadTabs();?> - breadCrumbs();?> - -
-
- loadPageMenu();?> -
- -
- loadPageContent();?> -
-
- tabs) { - require_once($_SERVER['DOCUMENT_ROOT'] . '/modules/addons/oncontrol/pages/' . $this->tabs . '/menu.php'); - } - } - - public function loadPageContent() - { - if($this->mod) { - require_once($_SERVER['DOCUMENT_ROOT'] . '/modules/addons/oncontrol/pages/' . $this->tabs . '/' . $this->mod . '.php'); - } - } - +onconnect = new ONConnect(); + ini_set('error_reporting', E_ALL); + ini_set('display_errors', 1); + ini_set('display_startup_errors', 1); + $this->vars = $vars; + $this->LANG = $this->vars['_lang']; + $this->tabs = $_GET['tabs']; + $this->mod = $_GET['mod']; + $pageUrl['mod'] = $this->mod; + $pageUrl['tabs'] = $this->tabs; + $pageUrl = http_build_query($pageUrl); + $this->modulelink=$vars['modulelink'].'&'.$pageUrl; + } + + private function addOrUpdate($name,$value){ + if(Capsule::table( 'tblconfiguration' ) + ->where('setting',$name) + ->get()) { + Capsule::table( 'tblconfiguration' ) + ->where('setting',$name) + ->update([ + 'setting'=>$name, + 'value'=>$value + ]); + } + else{ + $result = Capsule::table('tblconfiguration') + ->insert([ + 'setting' => $name, + 'value' => $value + ]); + }; + } + private function loadTabs() + { + ?> + + +
+ +
+ tabs == NULL) { + $this->tabs = 'vmlist'; + $this->mod = 'vmlist'; + }?> + loadTabs();?> + breadCrumbs();?> + +
+
+ loadPageMenu();?> +
+ +
+ loadPageContent();?> +
+
+ + tabs = 'configuration'; + $this->mod = 'moduleconfig'; + ?> + loadTabs();?> + breadCrumbs();?> + +
+
+ loadPageMenu();?> +
+ +
+ loadPageContent();?> +
+
+ tabs) { + require_once($_SERVER['DOCUMENT_ROOT'] . '/modules/addons/oncontrol/pages/' . $this->tabs . '/menu.php'); + } + } + + public function loadPageContent() + { + if($this->mod) { + require_once($_SERVER['DOCUMENT_ROOT'] . '/modules/addons/oncontrol/pages/' . $this->tabs . '/' . $this->mod . '.php'); + } + } + } \ No newline at end of file diff --git a/addons/oncontrol/lang/english.php b/addons/oncontrol/lang/english.php index 7fb82bb..c9cacca 100644 --- a/addons/oncontrol/lang/english.php +++ b/addons/oncontrol/lang/english.php @@ -1,126 +1,126 @@ - \ No newline at end of file diff --git a/addons/oncontrol/logics/vmlist.php b/addons/oncontrol/logics/vmlist.php index 65ee2ca..874bda8 100644 --- a/addons/oncontrol/logics/vmlist.php +++ b/addons/oncontrol/logics/vmlist.php @@ -1,296 +1,296 @@ - - -select('value')->where('setting',ione_address)->get(); - -$arrayVariant=[ - 'Active'=>['RUNNING','POWEROFF'], - 'Suspended'=>['SUSPENDED','POWEROFF'] -]; - -$arrayProblems=[ - 'notInWhmcs'=>'Отсутствующие в WHMCS', - 'hasError'=>'Заполнены с ошибками', - 'noStatus'=>'Не совпадают статусы' -]; - -$searchStatusWhmcs=$_REQUEST['statusWhmcs']; -$statusOn=$_REQUEST['statusOn']; -$searchHost=$_REQUEST['host']; -$searchIP=$_REQUEST['searchForIp']; -$smartStatus=$_REQUEST['selectFilterStatus']; - -$page=$_REQUEST['page']; -$pageCount=20; - -$hostsON=Capsule::table('mod_iOne_vmlist_cache') - ->groupBy('host') - ->lists('host'); - -$satesON=Capsule::table('mod_iOne_vmlist_cache') - ->groupBy('state') - ->lists('state'); - -$satusWhmcs=Capsule::table('tblhosting') - ->groupBy('domainstatus') - ->lists('domainstatus'); - - -if(!$searchStatusWhmcs){ - $searchStatusWhmcs=['Suspended','Active']; -}; - -if(!$statusOn){ - $statusOn=$satesON; -}; - -if(!$searchHost){ - $searchHost=$hostsON; -} - -if(in_array('notInWhmcs',$smartStatus)){ - $loginWhmcs=Capsule::table('tblhosting') - ->join('mod_on_user','mod_on_user.id_service','=','tblhosting.id') - ->lists('vmid'); - $userIdOn=Capsule::table('mod_iOne_vmlist_cache') - ->whereNotIn('vmid',$loginWhmcs) - ->lists('login'); -} - -if(in_array('hasError',$smartStatus)){ - $hostingIds[]=Capsule::table('tblhosting') - ->join('mod_on_user','mod_on_user.id_service','=','tblhosting.id') - ->orWhere('mod_on_user.vmid',' ') - ->orWhere('mod_on_user.userid',' ') - ->orWhere('mod_on_user.loginon',' ') - ->orwhereNull('mod_on_user.vmid') - ->orWhereNull('mod_on_user.userid') - ->orWhereNull('mod_on_user.loginon') - ->lists('hosting.id'); -} - - -if(in_array('noStatus',$smartStatus)){ - foreach ($arrayVariant as $key=>$variant) { - $hostingIds[] = Capsule::table('tblhosting') - ->select('mod_iOne_vmlist_cache.state','tblhosting.domainstatus','tblhosting.id') - ->join('mod_on_user', 'mod_on_user.id_service', '=', 'tblhosting.id') - ->join('mod_iOne_vmlist_cache', 'mod_iOne_vmlist_cache.vmid', '=', 'mod_on_user.vmid') - ->where('tblhosting.domainstatus',$key) - ->whereNotIn('mod_iOne_vmlist_cache.state',$variant) - ->lists('tblhosting.id'); - } -} - - -$pageGetUrl['statusWhmcs']=$searchStatusWhmcs; -$pageGetUrl['statusOn']=$statusOn; -$pageGetUrl['selectFilterStatus']=$smartStatus; -$pageGetUrl['host']=$searchHost; -$pageGetUrl['searchForIp']=$searchIP; -$pageGetUrl=http_build_query($pageGetUrl); - - -if(!$page) { - require_once($_SERVER['DOCUMENT_ROOT'] . '/modules/servers/onconnector/lib/ONConnect.php'); - $onconnect = new ONConnect(); - $dataON = $onconnect->compare_info(); - $userON = $dataON['result'][0]; - $hostsON = $dataON['result'][1]; - - $answerCount = Capsule::table('mod_iOne_vmlist_cache') - ->truncate(); - $answerCount = Capsule::table('mod_iOne_vmlist_cache') - ->insert($userON); -} - -if(count($hostingIds)==0 && count($userIdOn)==0) { - $answerCount = Capsule::table('tblproducts') - ->select( - 'tblproducts.gid', - 'tblhosting.userid', - 'tblhosting.domainstatus', - 'tblhosting.dedicatedip', - 'mod_on_user.id_service', - 'mod_on_user.loginon', - 'mod_on_user.passwordon', - 'mod_on_user.userid as useridOn', - 'mod_on_user.vmid') - ->join('tblhosting', 'tblproducts.id', '=', 'tblhosting.packageid') - ->join('mod_on_user', 'mod_on_user.id_service', '=', 'tblhosting.id') - ->leftJoin('mod_iOne_vmlist_cache', 'mod_iOne_vmlist_cache.vmid', '=', 'mod_on_user.vmid') - ->whereIn('tblproducts.gid', $groups) - ->whereIn('tblhosting.domainstatus', $searchStatusWhmcs) - ->whereIn('mod_iOne_vmlist_cache.state', $statusOn) - ->whereIn('mod_iOne_vmlist_cache.host', $searchHost) - ->where('tblhosting.dedicatedip', 'like', '%' . $searchIP . '%') - ->count(); - - $userWHMCS = Capsule::table('tblproducts') - ->select( - 'tblproducts.gid', - 'tblhosting.domainstatus', - 'tblhosting.userid', - 'mod_on_user.id_service', - 'mod_on_user.loginon', - 'mod_on_user.passwordon', - 'mod_on_user.userid as useridOn', - 'mod_on_user.vmid', - 'tblhosting.dedicatedip', - 'mod_iOne_vmlist_cache.state', - 'mod_iOne_vmlist_cache.host') - ->join('tblhosting', 'tblproducts.id', '=', 'tblhosting.packageid') - ->join('mod_on_user', 'mod_on_user.id_service', '=', 'tblhosting.id') - ->leftJoin('mod_iOne_vmlist_cache', 'mod_iOne_vmlist_cache.vmid', '=', 'mod_on_user.vmid') - ->whereIn('tblproducts.gid', $groups) - ->whereIn('tblhosting.domainstatus', $searchStatusWhmcs) - ->whereIn('mod_iOne_vmlist_cache.state', $statusOn) - ->whereIn('mod_iOne_vmlist_cache.host', $searchHost) - ->where('tblhosting.dedicatedip', 'like', '%' . $searchIP . '%') - ->offset(($page - 1) * $pageCount) - ->limit($pageCount) - ->orderBy('mod_iOne_vmlist_cache.vmid', 'asc') - ->get(); -} -elseif(count($hostingIds)!=0 && count($userIdOn)==0){ - - $resultHostingIds=[]; - foreach ($hostingIds as $ids){ - $resultHostingIds=array_merge($resultHostingIds,$ids); - } - - $answerCount = Capsule::table('tblproducts') - ->select( - 'tblproducts.gid', - 'tblhosting.userid', - 'tblhosting.domainstatus', - 'tblhosting.dedicatedip', - 'mod_on_user.id_service', - 'mod_on_user.loginon', - 'mod_on_user.passwordon', - 'mod_on_user.userid as useridOn', - 'mod_on_user.vmid') - ->join('tblhosting', 'tblproducts.id', '=', 'tblhosting.packageid') - ->join('mod_on_user', 'mod_on_user.id_service', '=', 'tblhosting.id') - ->leftJoin('mod_iOne_vmlist_cache', 'mod_iOne_vmlist_cache.vmid', '=', 'mod_on_user.vmid') - ->whereIn('tblproducts.gid', $groups) - ->whereIn('tblhosting.domainstatus', $searchStatusWhmcs) - ->whereIn('mod_iOne_vmlist_cache.state', $statusOn) - ->whereIn('mod_iOne_vmlist_cache.host', $searchHost) - ->whereIn('tblhosting.id',$resultHostingIds) - ->where('tblhosting.dedicatedip', 'like', '%' . $searchIP . '%') - ->count(); - - $userWHMCS = Capsule::table('tblproducts') - ->select( - 'tblproducts.gid', - 'tblhosting.domainstatus', - 'tblhosting.userid', - 'mod_on_user.id_service', - 'mod_on_user.loginon', - 'mod_on_user.passwordon', - 'mod_on_user.userid as useridOn', - 'mod_on_user.vmid', - 'tblhosting.dedicatedip', - 'mod_iOne_vmlist_cache.state', - 'mod_iOne_vmlist_cache.host') - ->join('tblhosting', 'tblproducts.id', '=', 'tblhosting.packageid') - ->join('mod_on_user', 'mod_on_user.id_service', '=', 'tblhosting.id') - ->leftJoin('mod_iOne_vmlist_cache', 'mod_iOne_vmlist_cache.vmid', '=', 'mod_on_user.vmid') - ->whereIn('tblproducts.gid', $groups) - ->whereIn('tblhosting.domainstatus', $searchStatusWhmcs) - ->whereIn('mod_iOne_vmlist_cache.state', $statusOn) - ->whereIn('mod_iOne_vmlist_cache.host', $searchHost) - ->whereIn('tblhosting.id',$resultHostingIds) - ->where('tblhosting.dedicatedip', 'like', '%' . $searchIP . '%') - ->offset(($page - 1) * $pageCount) - ->limit($pageCount) - ->orderBy('mod_iOne_vmlist_cache.vmid', 'asc') - ->get(); -} -elseif(count($hostingIds)==0 && count($userIdOn)!=0){ - $answerCount = Capsule::table('mod_iOne_vmlist_cache') - ->whereIn('login',$userIdOn) - ->where('ip', 'like', '%' . $searchIP . '%') - ->count(); - - $userWHMCS = Capsule::table('mod_iOne_vmlist_cache') - ->whereIn('login',$userIdOn) - ->where('ip', 'like', '%' . $searchIP . '%') - ->offset(($page - 1) * $pageCount) - ->limit($pageCount) - ->orderBy('mod_iOne_vmlist_cache.vmid', 'asc') - ->get(); -} -elseif(count($hostingIds)!=0 && count($userIdOn)!=0){} - -foreach ($userWHMCS as $oneUser) -{ - if(!$oneUser->vmid){ - $oneUser->col='warning'; - } - if(!$oneUser->loginon){ - $oneUser->col='info'; - } - if(!$oneUser->host){ - $oneUser->col='danger'; - } - if(!$oneUser->col){ - $oneUser->col='success'; - } -} - -$pageAll=ceil($answerCount/$pageCount); - -$minPage=$page-3; -$maxPage=$page+3; -if($minPage<1){ - $minPage=1; -} -if($maxPage>$pageAll){ - $maxPage=$pageAll; -} -$LANG=$vars['_lang']; + + +select('value')->where('setting',ione_address)->get(); + +$arrayVariant=[ + 'Active'=>['RUNNING','POWEROFF'], + 'Suspended'=>['SUSPENDED','POWEROFF'] +]; + +$arrayProblems=[ + 'notInWhmcs'=>'Missing in WHMCS', + 'hasError'=>'Filled with errors', + 'noStatus'=>'Statuses do not match' +]; + +$searchStatusWhmcs=$_REQUEST['statusWhmcs']; +$statusOn=$_REQUEST['statusOn']; +$searchHost=$_REQUEST['host']; +$searchIP=$_REQUEST['searchForIp']; +$smartStatus=$_REQUEST['selectFilterStatus']; + +$page=$_REQUEST['page']; +$pageCount=20; + +$hostsON=Capsule::table('mod_iOne_vmlist_cache') + ->groupBy('host') + ->lists('host'); + +$satesON=Capsule::table('mod_iOne_vmlist_cache') + ->groupBy('state') + ->lists('state'); + +$satusWhmcs=Capsule::table('tblhosting') + ->groupBy('domainstatus') + ->lists('domainstatus'); + + +if(!$searchStatusWhmcs){ + $searchStatusWhmcs=['Suspended','Active']; +}; + +if(!$statusOn){ + $statusOn=$satesON; +}; + +if(!$searchHost){ + $searchHost=$hostsON; +} + +if(in_array('notInWhmcs',$smartStatus)){ + $loginWhmcs=Capsule::table('tblhosting') + ->join('mod_on_user','mod_on_user.id_service','=','tblhosting.id') + ->lists('vmid'); + $userIdOn=Capsule::table('mod_iOne_vmlist_cache') + ->whereNotIn('vmid',$loginWhmcs) + ->lists('login'); +} + +if(in_array('hasError',$smartStatus)){ + $hostingIds[]=Capsule::table('tblhosting') + ->join('mod_on_user','mod_on_user.id_service','=','tblhosting.id') + ->orWhere('mod_on_user.vmid',' ') + ->orWhere('mod_on_user.userid',' ') + ->orWhere('mod_on_user.loginon',' ') + ->orwhereNull('mod_on_user.vmid') + ->orWhereNull('mod_on_user.userid') + ->orWhereNull('mod_on_user.loginon') + ->lists('hosting.id'); +} + + +if(in_array('noStatus',$smartStatus)){ + foreach ($arrayVariant as $key=>$variant) { + $hostingIds[] = Capsule::table('tblhosting') + ->select('mod_iOne_vmlist_cache.state','tblhosting.domainstatus','tblhosting.id') + ->join('mod_on_user', 'mod_on_user.id_service', '=', 'tblhosting.id') + ->join('mod_iOne_vmlist_cache', 'mod_iOne_vmlist_cache.vmid', '=', 'mod_on_user.vmid') + ->where('tblhosting.domainstatus',$key) + ->whereNotIn('mod_iOne_vmlist_cache.state',$variant) + ->lists('tblhosting.id'); + } +} + + +$pageGetUrl['statusWhmcs']=$searchStatusWhmcs; +$pageGetUrl['statusOn']=$statusOn; +$pageGetUrl['selectFilterStatus']=$smartStatus; +$pageGetUrl['host']=$searchHost; +$pageGetUrl['searchForIp']=$searchIP; +$pageGetUrl=http_build_query($pageGetUrl); + + +if(!$page) { + require_once($_SERVER['DOCUMENT_ROOT'] . '/modules/servers/onconnector/lib/ONConnect.php'); + $onconnect = new ONConnect(); + $dataON = $onconnect->compare_info(); + $userON = $dataON['result'][0]; + $hostsON = $dataON['result'][1]; + + $answerCount = Capsule::table('mod_iOne_vmlist_cache') + ->truncate(); + $answerCount = Capsule::table('mod_iOne_vmlist_cache') + ->insert($userON); +} + +if(count($hostingIds)==0 && count($userIdOn)==0) { + $answerCount = Capsule::table('tblproducts') + ->select( + 'tblproducts.gid', + 'tblhosting.userid', + 'tblhosting.domainstatus', + 'tblhosting.dedicatedip', + 'mod_on_user.id_service', + 'mod_on_user.loginon', + 'mod_on_user.passwordon', + 'mod_on_user.userid as useridOn', + 'mod_on_user.vmid') + ->join('tblhosting', 'tblproducts.id', '=', 'tblhosting.packageid') + ->join('mod_on_user', 'mod_on_user.id_service', '=', 'tblhosting.id') + ->leftJoin('mod_iOne_vmlist_cache', 'mod_iOne_vmlist_cache.vmid', '=', 'mod_on_user.vmid') + ->whereIn('tblproducts.gid', $groups) + ->whereIn('tblhosting.domainstatus', $searchStatusWhmcs) + ->whereIn('mod_iOne_vmlist_cache.state', $statusOn) + ->whereIn('mod_iOne_vmlist_cache.host', $searchHost) + ->where('tblhosting.dedicatedip', 'like', '%' . $searchIP . '%') + ->count(); + + $userWHMCS = Capsule::table('tblproducts') + ->select( + 'tblproducts.gid', + 'tblhosting.domainstatus', + 'tblhosting.userid', + 'mod_on_user.id_service', + 'mod_on_user.loginon', + 'mod_on_user.passwordon', + 'mod_on_user.userid as useridOn', + 'mod_on_user.vmid', + 'tblhosting.dedicatedip', + 'mod_iOne_vmlist_cache.state', + 'mod_iOne_vmlist_cache.host') + ->join('tblhosting', 'tblproducts.id', '=', 'tblhosting.packageid') + ->join('mod_on_user', 'mod_on_user.id_service', '=', 'tblhosting.id') + ->leftJoin('mod_iOne_vmlist_cache', 'mod_iOne_vmlist_cache.vmid', '=', 'mod_on_user.vmid') + ->whereIn('tblproducts.gid', $groups) + ->whereIn('tblhosting.domainstatus', $searchStatusWhmcs) + ->whereIn('mod_iOne_vmlist_cache.state', $statusOn) + ->whereIn('mod_iOne_vmlist_cache.host', $searchHost) + ->where('tblhosting.dedicatedip', 'like', '%' . $searchIP . '%') + ->offset(($page - 1) * $pageCount) + ->limit($pageCount) + ->orderBy('mod_iOne_vmlist_cache.vmid', 'asc') + ->get(); +} +elseif(count($hostingIds)!=0 && count($userIdOn)==0){ + + $resultHostingIds=[]; + foreach ($hostingIds as $ids){ + $resultHostingIds=array_merge($resultHostingIds,$ids); + } + + $answerCount = Capsule::table('tblproducts') + ->select( + 'tblproducts.gid', + 'tblhosting.userid', + 'tblhosting.domainstatus', + 'tblhosting.dedicatedip', + 'mod_on_user.id_service', + 'mod_on_user.loginon', + 'mod_on_user.passwordon', + 'mod_on_user.userid as useridOn', + 'mod_on_user.vmid') + ->join('tblhosting', 'tblproducts.id', '=', 'tblhosting.packageid') + ->join('mod_on_user', 'mod_on_user.id_service', '=', 'tblhosting.id') + ->leftJoin('mod_iOne_vmlist_cache', 'mod_iOne_vmlist_cache.vmid', '=', 'mod_on_user.vmid') + ->whereIn('tblproducts.gid', $groups) + ->whereIn('tblhosting.domainstatus', $searchStatusWhmcs) + ->whereIn('mod_iOne_vmlist_cache.state', $statusOn) + ->whereIn('mod_iOne_vmlist_cache.host', $searchHost) + ->whereIn('tblhosting.id',$resultHostingIds) + ->where('tblhosting.dedicatedip', 'like', '%' . $searchIP . '%') + ->count(); + + $userWHMCS = Capsule::table('tblproducts') + ->select( + 'tblproducts.gid', + 'tblhosting.domainstatus', + 'tblhosting.userid', + 'mod_on_user.id_service', + 'mod_on_user.loginon', + 'mod_on_user.passwordon', + 'mod_on_user.userid as useridOn', + 'mod_on_user.vmid', + 'tblhosting.dedicatedip', + 'mod_iOne_vmlist_cache.state', + 'mod_iOne_vmlist_cache.host') + ->join('tblhosting', 'tblproducts.id', '=', 'tblhosting.packageid') + ->join('mod_on_user', 'mod_on_user.id_service', '=', 'tblhosting.id') + ->leftJoin('mod_iOne_vmlist_cache', 'mod_iOne_vmlist_cache.vmid', '=', 'mod_on_user.vmid') + ->whereIn('tblproducts.gid', $groups) + ->whereIn('tblhosting.domainstatus', $searchStatusWhmcs) + ->whereIn('mod_iOne_vmlist_cache.state', $statusOn) + ->whereIn('mod_iOne_vmlist_cache.host', $searchHost) + ->whereIn('tblhosting.id',$resultHostingIds) + ->where('tblhosting.dedicatedip', 'like', '%' . $searchIP . '%') + ->offset(($page - 1) * $pageCount) + ->limit($pageCount) + ->orderBy('mod_iOne_vmlist_cache.vmid', 'asc') + ->get(); +} +elseif(count($hostingIds)==0 && count($userIdOn)!=0){ + $answerCount = Capsule::table('mod_iOne_vmlist_cache') + ->whereIn('login',$userIdOn) + ->where('ip', 'like', '%' . $searchIP . '%') + ->count(); + + $userWHMCS = Capsule::table('mod_iOne_vmlist_cache') + ->whereIn('login',$userIdOn) + ->where('ip', 'like', '%' . $searchIP . '%') + ->offset(($page - 1) * $pageCount) + ->limit($pageCount) + ->orderBy('mod_iOne_vmlist_cache.vmid', 'asc') + ->get(); +} +elseif(count($hostingIds)!=0 && count($userIdOn)!=0){} + +foreach ($userWHMCS as $oneUser) +{ + if(!$oneUser->vmid){ + $oneUser->col='warning'; + } + if(!$oneUser->loginon){ + $oneUser->col='info'; + } + if(!$oneUser->host){ + $oneUser->col='danger'; + } + if(!$oneUser->col){ + $oneUser->col='success'; + } +} + +$pageAll=ceil($answerCount/$pageCount); + +$minPage=$page-3; +$maxPage=$page+3; +if($minPage<1){ + $minPage=1; +} +if($maxPage>$pageAll){ + $maxPage=$pageAll; +} +$LANG=$vars['_lang']; ?> \ No newline at end of file diff --git a/addons/oncontrol/oncontrol.php b/addons/oncontrol/oncontrol.php index 6d3a0d1..2f726ac 100644 --- a/addons/oncontrol/oncontrol.php +++ b/addons/oncontrol/oncontrol.php @@ -1,118 +1,104 @@ - "Open Nebula Control", - "description" => "Open Nebula Control", - "version" => "0.5", - "author" => "support.by", - "language"=> 'english' - ); - return $configarray; -} - - -function oncontrol_activate() -{ - $query = "CREATE TABLE `mod_iOne_vmlist_cache` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `vmid` int(11) NOT NULL, - `userid` int(11) NOT NULL, - `host` VARCHAR(64) NOT NULL, - `login` VARCHAR(64) NOT NULL, - `ip` VARCHAR(64) NOT NULL, - `state` VARCHAR(64) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1"; - $result = full_query($query); - - $query = "CREATE TABLE `mod_onconfiguratorAddon` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` VARCHAR(64) NOT NULL, - `descriptions` VARCHAR (512), - `body` VARCHAR(1024) NOT NULL, - `os` VARCHAR (128), - `Addon` INT (11), - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1"; - $result = full_query($query); - - $query = "CREATE TABLE `mod_onconfiguratorOS` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `templateid` int(11) NOT NULL, - `addonid` int(11) NOT NULL, - `description` varchar(1024), - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1"; - $result = full_query($query); - - $query = "CREATE TABLE `mod_on_user` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `loginon` VARCHAR(64) NOT NULL, - `passwordon` VARCHAR(64) NOT NULL, - `userid` int(11) NOT NULL, - `useridOn`int(11) NOT NULL, - `vmid` int(11) NOT NULL, - `id_service` int(11) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1"; - $result = full_query($query); - - $query = "CREATE TABLE `mod_onconfigurator` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `idtariff` int(11) NOT NULL, - `os` VARCHAR(64) NOT NULL, - `addonid` int(11) NOT NULL, - `templateid`int(11) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1"; - $result = full_query($query); - -} - -function oncontrol_deactivate($vars) -{ - $deletedate = Capsule::table('tblconfiguration')->where('setting', 'ione_delete')->get(); - if ($deletedate[0]->value == 'on'){ - $query = "DROP TABLE `mod_onconfiguratorAddon`"; - $result = full_query($query); - - $query = "DROP TABLE `mod_onconfiguratorOS`"; - $result = full_query($query); - - $query = "DROP TABLE `mod_on_user`"; - $result = full_query($query); - - $query = "DROP TABLE `mod_iOne_vmlist_cache`"; - $result = full_query($query); - - $query = "DROP TABLE `mod_onconfigurator`"; - $result = full_query($query); - - return array('status'=>'success','description'=>'All data is deleted'); - }else{ - return array('status'=>'success','description'=>'Module removed'); - } -} - - -function oncontrol_output($vars) -{ - require_once ('classes/Loader.php'); - $loader = new Loader($vars); - $host = Capsule::table('tblconfiguration')->where('setting', 'ione_config_host')->get(); - $port = Capsule::table('tblconfiguration')->where('setting', 'ione_config_port')->get(); - $address = Capsule::table('tblconfiguration')->where('setting', 'ione_address')->get(); - if ($host == NULL || $port == NULL || $address == NULL){ - $loader->constructPageFirstStart(); - }else{ - $loader->constructPage(); - } -} - + "Open Nebula Control", + "description" => "Open Nebula Control", + "version" => "0.5", + "author" => "support.by", + "language"=> 'english' + ); + return $configarray; +} + + +function oncontrol_activate() +{ + $query = "CREATE TABLE `mod_iOne_vmlist_cache` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `vmid` int(11) NOT NULL, + `userid` int(11) NOT NULL, + `host` VARCHAR(64) NOT NULL, + `login` VARCHAR(64) NOT NULL, + `ip` VARCHAR(64) NOT NULL, + `state` VARCHAR(64) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1"; + $result = full_query($query); + + $query = "CREATE TABLE `mod_onconfiguratorOS` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `templateid` int(11) NOT NULL, + `addonid` int(11) NOT NULL, + `description` varchar(1024), + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1"; + $result = full_query($query); + + $query = "CREATE TABLE `mod_on_user` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `loginon` VARCHAR(64) NOT NULL, + `passwordon` VARCHAR(64) NOT NULL, + `userid` int(11) NOT NULL, + `useridOn`int(11) NOT NULL, + `vmid` int(11) NOT NULL, + `id_service` int(11) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1"; + $result = full_query($query); + + $query = "CREATE TABLE `mod_onconfigurator` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `idtariff` int(11) NOT NULL, + `os` VARCHAR(64) NOT NULL, + `addonid` int(11) NOT NULL, + `templateid`int(11) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1"; + $result = full_query($query); + + +} + +function oncontrol_deactivate($vars) +{ + $deletedate = Capsule::table('tblconfiguration')->where('setting', 'ione_delete')->get(); + if ($deletedate[0]->value == 'on'){ + $query = "DROP TABLE `mod_onconfiguratorOS`"; + $result = full_query($query); + + $query = "DROP TABLE `mod_on_user`"; + $result = full_query($query); + + $query = "DROP TABLE `mod_iOne_vmlist_cache`"; + $result = full_query($query); + + $query = "DROP TABLE `mod_onconfigurator`"; + $result = full_query($query); + + return array('status'=>'success','description'=>'All data is deleted'); + }else{ + return array('status'=>'success','description'=>'Module removed'); + } +} + + +function oncontrol_output($vars) +{ + require_once ('classes/Loader.php'); + $loader = new Loader($vars); + $host = Capsule::table('tblconfiguration')->where('setting', 'ione_config_host')->get(); + $port = Capsule::table('tblconfiguration')->where('setting', 'ione_config_port')->get(); + $address = Capsule::table('tblconfiguration')->where('setting', 'ione_address')->get(); + if ($host == NULL || $port == NULL || $address == NULL){ + $loader->constructPageFirstStart(); + }else{ + $loader->constructPage(); + } +} + diff --git a/addons/oncontrol/pages/configuration/menu.php b/addons/oncontrol/pages/configuration/menu.php index 99ed016..ef465f9 100644 --- a/addons/oncontrol/pages/configuration/menu.php +++ b/addons/oncontrol/pages/configuration/menu.php @@ -1,4 +1,4 @@ - + diff --git a/addons/oncontrol/pages/configuration/moduleconfig.php b/addons/oncontrol/pages/configuration/moduleconfig.php index c35264b..98a3ab3 100644 --- a/addons/oncontrol/pages/configuration/moduleconfig.php +++ b/addons/oncontrol/pages/configuration/moduleconfig.php @@ -1,161 +1,144 @@ -where('setting',$name) - ->get()) { - Capsule::table( 'tblconfiguration' ) - ->where('setting',$name) - ->update([ - 'setting'=>$name, - 'value'=>$value - ]); - } - else{ - $result = Capsule::table('tblconfiguration') - ->insert([ - 'setting' => $name, - 'value' => $value - ]); - }; -} - - - if ($_POST['save'] == 'save') { - if ($_POST['host']) { - $this->addOrUpdate('ione_config_host', $_POST['host']); - } - - if ($_POST['port']) { - $this->addOrUpdate('ione_config_port', $_POST['port']); - } - - if ($_POST['address']) { - $this->addOrUpdate('ione_address', $_POST['address']); - } - - if ($_POST['admin']) { - $this->addOrUpdate('whmcs_admin', $_POST['admin']); - } - - if ($_POST['customfield']) { - $this->addOrUpdate('customfield', $_POST['customfield']); - } - - if ($_POST['iaas_group']) { - $this->addOrUpdate('ione_iaas_group', $_POST['iaas_group']); - } - - if ($_POST['ansiblePort']) { - $this->addOrUpdate('ansibledb_config_port', $_POST['ansiblePort']); - } - - if ($_POST['groups']) { - $strGroup = implode($_POST['groups'], ','); - $this->addOrUpdate('vmlist_config_groups', $strGroup); - } - if ($_POST['useAnsible']) { - $this->addOrUpdate('ione_use_ansible', $_POST['useAnsible']); - } else { - $this->addOrUpdate('ione_use_ansible', 'off'); - } - if ($_POST['deletedate']) { - $this->addOrUpdate('ione_delete', $_POST['deletedate']); - } else { - $this->addOrUpdate('ione_delete', 'off'); - } - -} - - $host = Capsule::table('tblconfiguration')->where('setting', 'ione_config_host')->get(); - $port = Capsule::table('tblconfiguration')->where('setting', 'ione_config_port')->get(); - $address = Capsule::table('tblconfiguration')->where('setting', 'ione_address')->get(); - $admin = Capsule::table('tblconfiguration')->where('setting', 'whmcs_admin')->get(); - $custom = Capsule::table('tblconfiguration')->where('setting', 'customfield')->get(); - $portAnsible = Capsule::table('tblconfiguration')->where('setting', 'ansibledb_config_port')->get(); - $isCheckAnsible = Capsule::table('tblconfiguration')->where('setting', 'ione_use_ansible')->get(); - $deletedate = Capsule::table('tblconfiguration')->where('setting', 'ione_delete')->get(); - $iaas = Capsule::table('tblconfiguration')->where('setting', 'ione_iaas_group')->get(); - - - $descriptions = Capsule::table('tbladdons') - ->select('description') - ->where('description', 'like', '%"GROUP"%') - ->lists('description'); - $groups = []; - - foreach ($descriptions as $description) { - $jsn = json_decode($description); - if (!in_array($jsn->GROUP, $groups)) { - $groups[] = $jsn->GROUP; - } - } - - $currentGroups = Capsule::table('tblconfiguration') - ->where('setting', 'vmlist_config_groups') - ->pluck('value'); - $currentGroups = explode(',', $currentGroups); - -?> - -
-
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
-
- -
-
-
- - -
-
-
- - -
-
- - value=='on'){print 'checked';}?>> - -
- - value=='on'){print 'checked';}?>> - -
- - -
-
- - - - +where('setting',$name) + ->get()) { + Capsule::table( 'tblconfiguration' ) + ->where('setting',$name) + ->update([ + 'setting'=>$name, + 'value'=>$value + ]); + } + else{ + $result = Capsule::table('tblconfiguration') + ->insert([ + 'setting' => $name, + 'value' => $value + ]); + }; +} + + +if($_POST['save'] == 'save') { + if ($_POST['host']) { + $this->addOrUpdate('ione_config_host', $_POST['host']); + } + + if ($_POST['port']) { + $this->addOrUpdate('ione_config_port', $_POST['port']); + } + + if ($_POST['address']) { + $this->addOrUpdate('ione_address', $_POST['address']); + } + + if ($_POST['admin']) { + $this->addOrUpdate('whmcs_admin', $_POST['admin']); + } + + if ($_POST['customfield']) { + $this->addOrUpdate('customfield', $_POST['customfield']); + } + + if ($_POST['groups']) { + $strGroup = implode($_POST['groups'], ','); + $this->addOrUpdate('vmlist_config_groups', $strGroup); + } + if ($_POST['deletedate']) { + $this->addOrUpdate('ione_delete', $_POST['deletedate']); + } else { + $this->addOrUpdate('ione_delete', 'off'); + } + + if ($_POST['login']) { + $this->addOrUpdate('ione_config_login', $_POST['login']); + } + if ($_POST['passwd']) { + $this->addOrUpdate('ione_config_passwd', $_POST['passwd']); + } + +} + + $host = Capsule::table('tblconfiguration')->where('setting', 'ione_config_host')->get(); + $port = Capsule::table('tblconfiguration')->where('setting', 'ione_config_port')->get(); + $address = Capsule::table('tblconfiguration')->where('setting', 'ione_address')->get(); + $admin = Capsule::table('tblconfiguration')->where('setting', 'whmcs_admin')->get(); + $custom = Capsule::table('tblconfiguration')->where('setting', 'customfield')->get(); + $deletedate = Capsule::table('tblconfiguration')->where('setting', 'ione_delete')->get(); + $login = Capsule::table('tblconfiguration')->where('setting', 'ione_config_login')->get(); + $passwd = Capsule::table('tblconfiguration')->where('setting', 'ione_config_passwd')->get(); + + + $descriptions = Capsule::table('tbladdons') + ->select('description') + ->where('description', 'like', '%"GROUP"%') + ->lists('description'); + $groups = []; + + foreach ($descriptions as $description) { + $jsn = json_decode($description); + if (!in_array($jsn->GROUP, $groups)) { + $groups[] = $jsn->GROUP; + } + } + + $currentGroups = Capsule::table('tblconfiguration') + ->where('setting', 'vmlist_config_groups') + ->pluck('value'); + $currentGroups = explode(',', $currentGroups); + +?> + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ + +
+
+ + value=='on'){print 'checked';}?>> + +
+ + +
+
+ + + + diff --git a/addons/oncontrol/pages/configuration/newConfig.php b/addons/oncontrol/pages/configuration/newConfig.php index 425a81c..0f23d6d 100644 --- a/addons/oncontrol/pages/configuration/newConfig.php +++ b/addons/oncontrol/pages/configuration/newConfig.php @@ -1,187 +1,186 @@ - -%s
-%s',$bigText,$allText); -} - -function onconfigurator_successMessage($bigText,$allText){ - printf('
-%s
%s -
',$bigText,$allText); -} - - -if($_POST['action']){ - $action=key($_POST['action']); - switch ($action){ - case 'add': - $result=Capsule::table( 'mod_onconfiguratorOS' ) - ->insert([ - 'addonid'=>$_POST['osadd'], - 'templateid'=>$_POST['templateid'], - 'description'=>$_POST['descriptions'], - ]); - if ($result){ - onconfigurator_successMessage($this->LANG['dataadd'].' ',$this->LANG['dataaddbd']); - }else{ - onconfigurator_errorMessage($this->LANG['Error'].' ',$this->LANG['faildb']); - } - break; - case 'edit': - $result=Capsule::table( 'mod_onconfiguratorOS' ) - ->where('id',$_POST['id']) - ->update([ - 'addonid'=>$_POST['osadd'], - 'templateid'=>$_POST['templateid'], - 'description'=>$_POST['descriptions'], - ]); - if ($result){ - onconfigurator_successMessage($this->LANG['updatedate'].' ',$this->LANG['updatedatedb']); - }else{ - onconfigurator_errorMessage($this->LANG['error'].' ',$this->LANG['errordb']); - } - break; - case 'delete': - foreach ($_POST['check'] as $key=>$value){ - $check[]=$key; - } - $result=Capsule::table( 'mod_onconfiguratorOS' ) - ->whereIn('id',$check) - ->delete(); - if ($result){ - onconfigurator_successMessage($this->LANG['datadel'].' ',$this->LANG['datadeldb']); - }else{ - onconfigurator_errorMessage($this->LANG['error'].' ',$this->LANG['deldb']); - } - break; - } -} -$tariffs=Capsule::table('mod_onconfiguratorOS')->get(); -?> - - - -
- - - - - - - - - - - - - - - -
#LANG['osname']?>LANG['idtem']?>LANG['desc']?>
select('name')->where( 'id',$os->addonid)->first()->name?>templateid?>description,0,200)?>...
- -
- - - -
-
- -
-
LANG['addtariff']?>
-
- -
- - - LANG['entid']?> -
-
- -
-
- - - LANG['optfield']?> -
- -
-
- + +%s
+%s',$bigText,$allText); +} + +function onconfigurator_successMessage($bigText,$allText){ + printf('
+%s
%s +
',$bigText,$allText); +} + + +if($_POST['action']){ + $action=key($_POST['action']); + switch ($action){ + case 'add': + $result=Capsule::table( 'mod_onconfiguratorOS' ) + ->insert([ + 'addonid'=>$_POST['osadd'], + 'templateid'=>$_POST['templateid'], + 'description'=>$_POST['descriptions'], + ]); + if ($result){ + onconfigurator_successMessage($this->LANG['dataadd'].' ',$this->LANG['dataaddbd']); + }else{ + onconfigurator_errorMessage($this->LANG['Error'].' ',$this->LANG['faildb']); + } + break; + case 'edit': + $result=Capsule::table( 'mod_onconfiguratorOS' ) + ->where('id',$_POST['id']) + ->update([ + 'addonid'=>$_POST['osadd'], + 'templateid'=>$_POST['templateid'], + 'description'=>$_POST['descriptions'], + ]); + if ($result){ + onconfigurator_successMessage($this->LANG['updatedate'].' ',$this->LANG['updatedatedb']); + }else{ + onconfigurator_errorMessage($this->LANG['error'].' ',$this->LANG['errordb']); + } + break; + case 'delete': + foreach ($_POST['check'] as $key=>$value){ + $check[]=$key; + } + $result=Capsule::table( 'mod_onconfiguratorOS' ) + ->whereIn('id',$check) + ->delete(); + if ($result){ + onconfigurator_successMessage($this->LANG['datadel'].' ',$this->LANG['datadeldb']); + }else{ + onconfigurator_errorMessage($this->LANG['error'].' ',$this->LANG['deldb']); + } + break; + } +} +$tariffs=Capsule::table('mod_onconfiguratorOS')->get(); +?> + + + +
+ + + + + + + + + + + + + + + +
#LANG['osname']?>LANG['idtem']?>LANG['desc']?>
select('name')->where( 'id',$os->addonid)->first()->name?>templateid?>description,0,200)?>...
+ +
+ + + +
+
+ +
+
LANG['addtariff']?>
+
+ +
+ + + LANG['entid']?> +
+
+ +
+
+ + + LANG['optfield']?> +
+ +
+
+ diff --git a/addons/oncontrol/pages/vmlist/freeip.php b/addons/oncontrol/pages/vmlist/freeip.php index 2222d16..c33b500 100644 --- a/addons/oncontrol/pages/vmlist/freeip.php +++ b/addons/oncontrol/pages/vmlist/freeip.php @@ -1,12 +1,13 @@ -onconnect->compare_info(); -$freeIP = $result['result']['2']['0']; -?> - - - - - - +onconnect->compare_info(); +$freeIP = $result['result']['2']['0']; + +?> +
+ + + + +
\ No newline at end of file diff --git a/addons/oncontrol/pages/vmlist/menu.php b/addons/oncontrol/pages/vmlist/menu.php index 0cf27df..9fb524f 100644 --- a/addons/oncontrol/pages/vmlist/menu.php +++ b/addons/oncontrol/pages/vmlist/menu.php @@ -1,5 +1,5 @@ - + diff --git a/addons/oncontrol/pages/vmlist/panel.php b/addons/oncontrol/pages/vmlist/panel.php index d4980c2..77710b5 100644 --- a/addons/oncontrol/pages/vmlist/panel.php +++ b/addons/oncontrol/pages/vmlist/panel.php @@ -1,549 +1,513 @@ -select('id', 'name', 'description') - ->get(); - -$service = Capsule::table('tblproducts') - ->select('tblproducts.name', 'tblhosting.userid', 'tblhosting.packageid', 'tblhosting.dedicatedip', - 'tblhosting.domain', 'tblhosting.id', 'server') - ->join('tblhosting', 'tblproducts.id', '=', 'tblhosting.packageid') - ->where('tblhosting.id', $system_id) - ->first(); - -$service_addons = Capsule::table('tblhostingaddons') - ->where('hostingid', $system_id) - ->get(); - -$service_user = Capsule::table('tblclients') - ->where('id', $service->userid) - ->first(); - -$ansibles = Capsule::table('mod_onconfiguratorAddon') - ->get(); - -$machineInfo = Capsule::table('mod_on_user') - ->where('id_service', $system_id) - ->first(); - -$server_ip = Capsule::table('tblservers') - ->where('id', $service->server) - ->select('ipaddress') - ->first()->ipaddress; - -$snapshotList = $this->onconnect->getSnapshotList($machineInfo->vmid); -if ($snapshotList['result']['0'] == '') { - unset ($snapshotList['result']['0']); -} - - -$reinstal_settings = Capsule::table('tblproduct_upgrade_products') - ->where('product_id', $service->packageid) - ->select('upgrade_product_id') - ->get(); - -$vm_data = $this->onconnect->getVmData($machineInfo->vmid)['result']; - -$groups = []; -foreach ($addons as $addon) { - $addon->description = json_decode($addon->description, 1); - if (json_last_error() === JSON_ERROR_NONE && $addon->description != '') { - $groups = add_group_to_array($groups, $addon->description['GROUP']); - } -} - -function getStatusMachine($onconnect, $vmid) -{ - $status = $onconnect->lcmStateStr($vmid); - if ($status->result == 'LCM_INIT') { - $status = $onconnect->stateStr($vmid); - } - return $status; -} - -function add_group_to_array($current_array, $group) -{ - if (isset($group)) { - if (!in_array($group, $current_array)) { - $current_array[] = $group; - } - } - return $current_array; -} - - -function is_checked_box($addon_name) -{ - if ($_POST[$addon_name] == 'on') { - return 'checked'; - } else { - return ''; - } -} - -function get_color_by_status($status) -{ - switch ($status) { - - case 'RUNNING': - return 'green'; - - default : - return 'blue'; - } -} - - -$wanted_groups = []; - -foreach ($_POST as $wanted_group => $value) { - if ($value == 'on' && is_string($wanted_group)) { - $wanted_groups[] = $wanted_group; - } -} - -if (count($wanted_groups) == 0) { - $_POST[$groups[0]] = 'on'; -} - -function disable_current_state($service, $status) -{ - if ($service->domainstatus == $status) { - echo 'disabled'; - } -} - -$status = getStatusMachine($this->onconnect, $machineInfo->vmid); - -//SUSPEND BUTTON PROPERTIES -switch ($status['result']) { - case 'RUNNING': - $suspendButtonTitle = 'Suspend'; - $suspendButtonValue = 'suspend'; - $suspendButtonGlyph = 'glyphicon-pause'; - $suspendButtonType = 'warning'; - break; - - default : - $suspendButtonTitle = 'Resume'; - $suspendButtonValue = 'unsuspend'; - $suspendButtonGlyph = 'glyphicon-play'; - $suspendButtonType = 'success'; - if ($status['result'] == 'SAVE_SUSPEND' or $status['result'] == 'BOOT_SUSPENDED') { - $suspendButtondDisable = 'disabled'; - } - break; - -} - -// POWER BUTTON PROPERTIES -switch ($status['result']) { - case 'RUNNING': - $powerButtonTitle = 'Power off'; - $powerButtonValue = 'shutdown'; - $powerButtonGlyph = 'glyphicon-off'; - $powerButtonType = 'danger'; - break; - - default : - $powerButtonTitle = 'Power on'; - $powerButtonValue = 'shutdown'; - $powerButtonGlyph = 'glyphicon-off'; - $powerButtonType = 'success'; - $powerButtonDisable = 'disabled'; - break; -} - - -// REBOOT BUTTON PROPERTIES -switch ($status['result']) { - case 'RUNNING': - break; - - default: - $rebootButtonDisable = 'disabled'; - break; -} - -// REFRESH BUTTON PROPERTIES -switch ($status['result']) { - case 'RUNNING': - break; - - default: - $refreshButtonDisable = 'disabled'; - break; -} - -$isCheckAnsible=Capsule::table( 'tblconfiguration' )->where('setting','ione_use_ansible')->get(); -$LANG=$this->vars['_lang']; -$cloudlink = Capsule::table('tblconfiguration') - ->select('value')->where('setting',ione_address)->get(); -?> - - - -
-
-
- -
- - -
-
-
-
- : id; ?> -
-
- : - - -
-
- : -
-
- vmid ?> -
-
- : -
-
-
- -
- : name ?> -
-
- : -
-
- : MB -
-
- : -
-
-
- - - -
- -
-
- -
- -
- -
-
- -
-
- -
-
- -
-
-
-
- -
- -
" method="POST"> -
- -
-
- - -
- -
- -
- - -
-
    - -
    -
  • : : - - - - -
  • -
    - - -
    - - - -
-
-
-
-
-
- - value=='on'):?> -
-
- -
-

:

-
-
- - -
-
-
- - -
- - - - - - -
-
-
-
-
-
- - - - +select('id', 'name', 'description') + ->get(); + +$service = Capsule::table('tblproducts') + ->select('tblproducts.name', 'tblhosting.userid', 'tblhosting.packageid', 'tblhosting.dedicatedip', + 'tblhosting.domain', 'tblhosting.id', 'server') + ->join('tblhosting', 'tblproducts.id', '=', 'tblhosting.packageid') + ->where('tblhosting.id', $system_id) + ->first(); + +$service_addons = Capsule::table('tblhostingaddons') + ->where('hostingid', $system_id) + ->get(); + +$service_user = Capsule::table('tblclients') + ->where('id', $service->userid) + ->first(); + + +$machineInfo = Capsule::table('mod_on_user') + ->where('id_service', $system_id) + ->first(); + +$server_ip = Capsule::table('tblservers') + ->where('id', $service->server) + ->select('ipaddress') + ->first()->ipaddress; + +$snapshotList = $this->onconnect->getSnapshotList($machineInfo->vmid); +$snapshotList = json_decode($snapshotList); +if ($snapshotList['result']['0'] == '') { + unset ($snapshotList['result']['0']); +} + + +$reinstal_settings = Capsule::table('tblproduct_upgrade_products') + ->where('product_id', $service->packageid) + ->select('upgrade_product_id') + ->get(); + +$vm_data = $this->onconnect->getVmData($machineInfo->vmid->result); + +$groups = []; +foreach ($addons as $addon) { + $addon->description = json_decode($addon->description, 1); + if (json_last_error() === JSON_ERROR_NONE && $addon->description != '') { + $groups = add_group_to_array($groups, $addon->description['GROUP']); + } +} + +function getStatusMachine($onconnect, $vmid) +{ + $status = $onconnect->lcmStateStr($vmid); + if ($status->result == 'LCM_INIT') { + $status = $onconnect->stateStr($vmid); + } + return $status; +} + +function add_group_to_array($current_array, $group) +{ + if (isset($group)) { + if (!in_array($group, $current_array)) { + $current_array[] = $group; + } + } + return $current_array; +} + + +function is_checked_box($addon_name) +{ + if ($_POST[$addon_name] == 'on') { + return 'checked'; + } else { + return ''; + } +} + +function get_color_by_status($status) +{ + switch ($status) { + + case 'RUNNING': + return 'green'; + + default : + return 'blue'; + } +} + + +$wanted_groups = []; + +foreach ($_POST as $wanted_group => $value) { + if ($value == 'on' && is_string($wanted_group)) { + $wanted_groups[] = $wanted_group; + } +} + +if (count($wanted_groups) == 0) { + $_POST[$groups[0]] = 'on'; +} + +function disable_current_state($service, $status) +{ + if ($service->domainstatus == $status) { + echo 'disabled'; + } +} + +$status = getStatusMachine($this->onconnect, $machineInfo->vmid); +$status = json_decode($status); +switch ($status['result']) { + case 'RUNNING': + $suspendButtonTitle = 'Suspend'; + $suspendButtonValue = 'suspend'; + $suspendButtonGlyph = 'glyphicon-pause'; + $suspendButtonType = 'warning'; + break; + + default : + $suspendButtonTitle = 'Resume'; + $suspendButtonValue = 'unsuspend'; + $suspendButtonGlyph = 'glyphicon-play'; + $suspendButtonType = 'success'; + if ($status['result'] == 'SAVE_SUSPEND' or $status['result'] == 'BOOT_SUSPENDED') { + $suspendButtondDisable = 'disabled'; + } + break; + +} + + +switch ($status['result']) { + case 'RUNNING': + $powerButtonTitle = 'Power off'; + $powerButtonValue = 'shutdown'; + $powerButtonGlyph = 'glyphicon-off'; + $powerButtonType = 'danger'; + break; + + default : + $powerButtonTitle = 'Power on'; + $powerButtonValue = 'shutdown'; + $powerButtonGlyph = 'glyphicon-off'; + $powerButtonType = 'success'; + $powerButtonDisable = 'disabled'; + break; +} + + + +switch ($status['result']) { + case 'RUNNING': + break; + + default: + $rebootButtonDisable = 'disabled'; + break; +} + +// REFRESH BUTTON PROPERTIES +switch ($status['result']) { + case 'RUNNING': + break; + + default: + $refreshButtonDisable = 'disabled'; + break; +} + +$vm_data = json_decode($vm_data); +$LANG=$this->vars['_lang']; +$cloudlink = Capsule::table('tblconfiguration') + ->select('value')->where('setting',ione_address)->get(); +?> + + + +
+
+
+ +
+ + +
+
+
+
+ : id; ?> +
+
+ : + + +
+
+ : +
+
+ vmid ?> +
+
+ : +
+
+
+ +
+ : name ?> +
+
+ : +
+
+ : MB +
+
+ : +
+
+
+ + + +
+ +
+
+ +
+ +
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+ +
+ +
" method="POST"> +
+ +
+
+ +
+ +
+ +
+ + +
+
    + +
    +
  • : : + + + + +
  • +
    + + +
    + + + +
+
+
+
+
+
+ + +
\ No newline at end of file diff --git a/addons/oncontrol/pages/vmlist/qutas.php b/addons/oncontrol/pages/vmlist/qutas.php index 25e75f6..bfca06c 100644 --- a/addons/oncontrol/pages/vmlist/qutas.php +++ b/addons/oncontrol/pages/vmlist/qutas.php @@ -1,97 +1,95 @@ -onconnect->datastoresMonitoring(); -$quotasRam = $this->onconnect->hostsMonitoring(); -$LANG=$this->vars['_lang']; - -?> - - -
- - - - - - - - - - - - - - - - - -
:
: / (%)
-
- -
- - - - - - - - - - - -
/ (%)
+onconnect->datastoresMonitoring(); +$quotasRam = $this->onconnect->hostsMonitoring(); +$LANG=$this->vars['_lang']; +?> + + +
+ + response as $quota):?> + + + + + + + + + + + + + + + +
name?>: cpu?> running_vms?>
: reserved?>/full_size?> (reserved/$quota->full_size*100)?>%)
+
+ +
+ + response as $quota):?> + + + used,-2) == 'GB'){ + $quotamod = round($quota->used) / 1000; + }else{ + $quotamod = round($quota->used); + } + ?> + + + + + + +
name?>used?>/full_size?> (full_size*100)?>%)
\ No newline at end of file diff --git a/addons/oncontrol/pages/vmlist/reinstall.php b/addons/oncontrol/pages/vmlist/reinstall.php index c19df56..552e963 100644 --- a/addons/oncontrol/pages/vmlist/reinstall.php +++ b/addons/oncontrol/pages/vmlist/reinstall.php @@ -1,183 +1,157 @@ -vars['_lang']; -if (!defined("WHMCS")) { - die("This file cannot be accessed directly"); -} - -ini_set('display_errors', 0); -$idRefreshSystem=$_GET['serviceId']; -extract($_POST);?> -
-
-where('id', $idRefreshSystem) - ->first()->packageid; - - $reinstal_settings = Capsule::table('tblproduct_upgrade_products') - ->where('product_id', $packageid) - ->select('id', 'upgrade_product_id', 'product_id') - ->get(); - if(!$reinstal_settings){ - $oneObject = new stdClass(); - $oneObject -> upgrade_product_id=$packageid; - $reinstal_settings[]=$oneObject; - print ($packageid); - } - - $ansibles = Capsule::table('mod_onconfiguratorAddon') - ->select('id','name','descriptions','os') - ->get(); - - $operating_systems = Capsule::table('tbladdons') - ->select('tbladdons.id as addonid','tbladdons.name as os') - ->join('mod_onconfiguratorOS','mod_onconfiguratorOS.addonid','=','tbladdons.id') - ->where('tbladdons.description','like','%"GROUP": "os"%') - ->get(); - - $osConfig = Capsule::table('mod_onconfigurator') - ->select('os','addonid','idtariff') - ->get(); - - - if(!$operating_systems):?> -
- : -
-
- - - - -
-
-

-
- -
-
-

=

-

-
-
- -
-
- -
- - - -
- -
- - -
- -
- - -
- -
- - - - - - - -
- -
-
-
- - -
-
-
-
-
-
- - - +vars['_lang']; +if (!defined("WHMCS")) { + die("This file cannot be accessed directly"); +} + +$idRefreshSystem=$_GET['serviceId']; +extract($_POST);?> +
+
+where('id', $idRefreshSystem) + ->first()->packageid; + + $reinstal_settings = Capsule::table('tblproduct_upgrade_products') + ->where('product_id', $packageid) + ->select('id', 'upgrade_product_id', 'product_id') + ->get(); + if(!$reinstal_settings){ + $oneObject = new stdClass(); + $oneObject -> upgrade_product_id=$packageid; + $reinstal_settings[]=$oneObject; + print ($packageid); + } + + $operating_systems = Capsule::table('tbladdons') + ->select('tbladdons.id as addonid','tbladdons.name as os') + ->join('mod_onconfiguratorOS','mod_onconfiguratorOS.addonid','=','tbladdons.id') + ->where('tbladdons.description','like','%"GROUP": "os"%') + ->get(); + + $osConfig = Capsule::table('mod_onconfigurator') + ->select('os','addonid','idtariff') + ->get(); + + + if(!$operating_systems):?> +
+ : +
+
+ + + + +
+
+

+
+ +
+
+

=

+

+
+
+ +
+
+ + +
+ + +
+ +
+ + +
+ +
+ + + + + +
+ +
+
+
+ + +
+
+
+
+
+
+ + + diff --git a/addons/oncontrol/pages/vmlist/service_manager.php b/addons/oncontrol/pages/vmlist/service_manager.php index 9cd00ec..2f230fc 100644 --- a/addons/oncontrol/pages/vmlist/service_manager.php +++ b/addons/oncontrol/pages/vmlist/service_manager.php @@ -1,11 +1,9 @@ '; -// print_r($_POST); -// echo ''; + extract($_POST); require_once($_SERVER['DOCUMENT_ROOT'] . '/modules/servers/onconnector/lib/ONConnect.php'); @@ -102,7 +100,7 @@ if (isset($message)): ?> -
+

diff --git a/addons/oncontrol/pages/vmlist/vmlist.php b/addons/oncontrol/pages/vmlist/vmlist.php index 668dfbf..a90c052 100644 --- a/addons/oncontrol/pages/vmlist/vmlist.php +++ b/addons/oncontrol/pages/vmlist/vmlist.php @@ -1,413 +1,413 @@ - - -select('value')->where('setting',ione_address)->get(); - - -$arrayVariant=[ - 'Active'=>['RUNNING','POWEROFF'], - 'Suspended'=>['SUSPENDED','POWEROFF'] -]; - -$arrayProblems=[ - 'notInWhmcs'=>$this->LANG['misswhmcs'], - 'hasError'=>$this->LANG['fillederror'], - 'noStatus'=>$this->LANG['notmatch'] -]; - -$searchStatusWhmcs=$_REQUEST['statusWhmcs']; -$statusOn=$_REQUEST['statusOn']; -$searchHost=$_REQUEST['host']; -$searchIP=$_REQUEST['searchForIp']; -$smartStatus=$_REQUEST['selectFilterStatus']; - -$page=$_REQUEST['page']; -$pageCount=20; - -$hostsON=Capsule::table('mod_iOne_vmlist_cache') - ->groupBy('host') - ->lists('host'); - -$satesON=Capsule::table('mod_iOne_vmlist_cache') - ->groupBy('state') - ->lists('state'); - -$satusWhmcs=Capsule::table('tblhosting') - ->groupBy('domainstatus') - ->lists('domainstatus'); - - -if(!$searchStatusWhmcs){ - $searchStatusWhmcs=['Suspended','Active']; -}; - -if(!$statusOn){ - $statusOn=$satesON; -}; - -if(!$searchHost){ - $searchHost=$hostsON; -} - -if(in_array('notInWhmcs',$smartStatus)){ //missing in whmcs - $loginWhmcs=Capsule::table('tblhosting') - ->join('mod_on_user','mod_on_user.id_service','=','tblhosting.id') - ->lists('vmid'); - - $userIdOn=Capsule::table('mod_iOne_vmlist_cache') - ->whereNotIn('vmid',$loginWhmcs) - ->lists('login'); -} - -if(in_array('hasError',$smartStatus)){ //filled with an error - $hostingIds[]=Capsule::table('tblhosting') - ->join('mod_on_user','mod_on_user.id_service','=','tblhosting.id') - ->orWhere('mod_on_user.vmid',' ') - ->orWhere('mod_on_user.userid',' ') - ->orWhere('mod_on_user.loginon',' ') - ->orwhereNull('mod_on_user.vmid') - ->orWhereNull('mod_on_user.userid') - ->orWhereNull('mod_on_user.loginon') - ->lists('hosting.id'); -} - - -if(in_array('noStatus',$smartStatus)){ //if the statuses do not match - foreach ($arrayVariant as $key=>$variant) { - $hostingIds[] = Capsule::table('tblhosting') - ->select('mod_iOne_vmlist_cache.state','tblhosting.domainstatus','tblhosting.id') - ->join('mod_on_user', 'mod_on_user.id_service', '=', 'tblhosting.id') - ->join('mod_iOne_vmlist_cache', 'mod_iOne_vmlist_cache.vmid', '=', 'mod_on_user.vmid') - ->where('tblhosting.domainstatus',$key) - ->whereNotIn('mod_iOne_vmlist_cache.state',$variant) - ->lists('tblhosting.id'); - } -} - - -$pageGetUrl['statusWhmcs']=$searchStatusWhmcs; -$pageGetUrl['statusOn']=$statusOn; -$pageGetUrl['selectFilterStatus']=$smartStatus; -$pageGetUrl['host']=$searchHost; -$pageGetUrl['searchForIp']=$searchIP; -$pageGetUrl=http_build_query($pageGetUrl); - - -if(!$page) { - require_once($_SERVER['DOCUMENT_ROOT'] . '/modules/servers/onconnector/lib/ONConnect.php'); - $onconnect = new ONConnect(); - $dataON = $onconnect->compare_info(); - $userON = $dataON['result'][0]; - $hostsON = $dataON['result'][1]; - if(count($userON)>0) { - $answerCount = Capsule::table('mod_iOne_vmlist_cache') - ->truncate(); - $answerCount = Capsule::table('mod_iOne_vmlist_cache') - ->insert($userON); - } -} - -if(count($hostingIds)==0 && count($userIdOn)==0) { - $answerCount = Capsule::table('tblproducts') - ->select( - 'tblproducts.gid', - 'tblhosting.userid', - 'tblhosting.domainstatus', - 'tblhosting.dedicatedip', - 'mod_on_user.id_service', - 'mod_on_user.loginon', - 'mod_on_user.passwordon', - 'mod_on_user.userid as useridOn', - 'mod_on_user.vmid') - ->join('tblhosting', 'tblproducts.id', '=', 'tblhosting.packageid') - ->join('mod_on_user', 'mod_on_user.id_service', '=', 'tblhosting.id') - ->leftJoin('mod_iOne_vmlist_cache', 'mod_iOne_vmlist_cache.vmid', '=', 'mod_on_user.vmid') - ->whereIn('tblproducts.servertype', ['onconnector','ione']) - ->whereIn('tblhosting.domainstatus', $searchStatusWhmcs) - ->whereIn('mod_iOne_vmlist_cache.state', $statusOn) - ->whereIn('mod_iOne_vmlist_cache.host', $searchHost) - ->where('tblhosting.dedicatedip', 'like', '%' . $searchIP . '%') - ->count(); - - $userWHMCS = Capsule::table('tblproducts') - ->select( - 'tblproducts.gid', - 'tblhosting.domainstatus', - 'tblhosting.userid', - 'mod_on_user.id_service', - 'mod_on_user.loginon', - 'mod_on_user.passwordon', - 'mod_on_user.userid as useridOn', - 'mod_on_user.vmid', - 'tblhosting.dedicatedip', - 'mod_iOne_vmlist_cache.state', - 'mod_iOne_vmlist_cache.host') - ->join('tblhosting', 'tblproducts.id', '=', 'tblhosting.packageid') - ->join('mod_on_user', 'mod_on_user.id_service', '=', 'tblhosting.id') - ->leftJoin('mod_iOne_vmlist_cache', 'mod_iOne_vmlist_cache.vmid', '=', 'mod_on_user.vmid') - ->whereIn('tblproducts.servertype', ['onconnector','ione']) - ->whereIn('tblhosting.domainstatus', $searchStatusWhmcs) - ->whereIn('mod_iOne_vmlist_cache.state', $statusOn) - ->whereIn('mod_iOne_vmlist_cache.host', $searchHost) - ->where('tblhosting.dedicatedip', 'like', '%' . $searchIP . '%') - ->offset(($page - 1) * $pageCount) - ->limit($pageCount) - ->orderBy('mod_iOne_vmlist_cache.vmid', 'asc') - ->get(); -} -elseif(count($hostingIds)!=0 && count($userIdOn)==0){ - - $resultHostingIds=[]; - foreach ($hostingIds as $ids){ - $resultHostingIds=array_merge($resultHostingIds,$ids); - } - - $answerCount = Capsule::table('tblproducts') - ->select( - 'tblproducts.gid', - 'tblhosting.userid', - 'tblhosting.domainstatus', - 'tblhosting.dedicatedip', - 'mod_on_user.id_service', - 'mod_on_user.loginon', - 'mod_on_user.passwordon', - 'mod_on_user.userid as useridOn', - 'mod_on_user.vmid') - ->join('tblhosting', 'tblproducts.id', '=', 'tblhosting.packageid') - ->join('mod_on_user', 'mod_on_user.id_service', '=', 'tblhosting.id') - ->leftJoin('mod_iOne_vmlist_cache', 'mod_iOne_vmlist_cache.vmid', '=', 'mod_on_user.vmid') - ->whereIn('tblproducts.servertype', ['onconnector','ione']) - ->whereIn('tblhosting.domainstatus', $searchStatusWhmcs) - ->whereIn('mod_iOne_vmlist_cache.state', $statusOn) - ->whereIn('mod_iOne_vmlist_cache.host', $searchHost) - ->whereIn('tblhosting.id',$resultHostingIds) - ->where('tblhosting.dedicatedip', 'like', '%' . $searchIP . '%') - ->count(); - - $userWHMCS = Capsule::table('tblproducts') - ->select( - 'tblproducts.gid', - 'tblhosting.domainstatus', - 'tblhosting.userid', - 'mod_on_user.id_service', - 'mod_on_user.loginon', - 'mod_on_user.passwordon', - 'mod_on_user.userid as useridOn', - 'mod_on_user.vmid', - 'tblhosting.dedicatedip', - 'mod_iOne_vmlist_cache.state', - 'mod_iOne_vmlist_cache.host') - ->join('tblhosting', 'tblproducts.id', '=', 'tblhosting.packageid') - ->join('mod_on_user', 'mod_on_user.id_service', '=', 'tblhosting.id') - ->leftJoin('mod_iOne_vmlist_cache', 'mod_iOne_vmlist_cache.vmid', '=', 'mod_on_user.vmid') - ->whereIn('tblproducts.servertype', ['onconnector','ione']) - ->whereIn('tblhosting.domainstatus', $searchStatusWhmcs) - ->whereIn('mod_iOne_vmlist_cache.state', $statusOn) - ->whereIn('mod_iOne_vmlist_cache.host', $searchHost) - ->whereIn('tblhosting.id',$resultHostingIds) - ->where('tblhosting.dedicatedip', 'like', '%' . $searchIP . '%') - ->offset(($page - 1) * $pageCount) - ->limit($pageCount) - ->orderBy('mod_iOne_vmlist_cache.vmid', 'asc') - ->get(); -} -elseif(count($hostingIds)==0 && count($userIdOn)!=0){ //does not exist in whmcs - $answerCount = Capsule::table('mod_iOne_vmlist_cache') - ->whereIn('login',$userIdOn) - ->where('ip', 'like', '%' . $searchIP . '%') - ->count(); - - $userWHMCS = Capsule::table('mod_iOne_vmlist_cache') - ->whereIn('login',$userIdOn) - ->where('ip', 'like', '%' . $searchIP . '%') - ->offset(($page - 1) * $pageCount) - ->limit($pageCount) - ->orderBy('mod_iOne_vmlist_cache.vmid', 'asc') - ->get(); - var_dump($answerCount); -} -elseif(count($hostingIds)!=0 && count($userIdOn)!=0){} - -foreach ($userWHMCS as $oneUser) -{ - if(!$oneUser->vmid){ - $oneUser->col='warning'; - } - if(!$oneUser->loginon){ - $oneUser->col='info'; - } - if(!$oneUser->host){ - $oneUser->col='danger'; - } - if(!$oneUser->col){ - $oneUser->col='success'; - } -} - -$pageAll=ceil($answerCount/$pageCount); - -$minPage=$page-3; -$maxPage=$page+3; -if($minPage<1){ - $minPage=1; -} - -if($maxPage>$pageAll){ - $maxPage=$pageAll; -} - -$LANG=$this->vars['_lang']; -?> - - - -
-
-
    -
  • -
-
-
-
    - -
  • - - -
  • - -
  • - - -
  • - -
  • - - -
  • - -
  • - - -
  • - -
  • - - -
  • -
-
-
-
-
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
userid?>id_service?>loginon?>useridOn?>vmid?>state?>domainstatus?>host?>dedicatedip?> - -
-
-
- -
- -
- -
-
- - + +select('value')->where('setting',ione_address)->get(); + + +$arrayVariant=[ + 'Active'=>['RUNNING','POWEROFF'], + 'Suspended'=>['SUSPENDED','POWEROFF'] +]; + +$arrayProblems=[ + 'notInWhmcs'=>$this->LANG['misswhmcs'], + 'hasError'=>$this->LANG['fillederror'], + 'noStatus'=>$this->LANG['notmatch'] +]; + +$searchStatusWhmcs=$_REQUEST['statusWhmcs']; +$statusOn=$_REQUEST['statusOn']; +$searchHost=$_REQUEST['host']; +$searchIP=$_REQUEST['searchForIp']; +$smartStatus=$_REQUEST['selectFilterStatus']; + +$page=$_REQUEST['page']; +$pageCount=20; + +$hostsON=Capsule::table('mod_iOne_vmlist_cache') + ->groupBy('host') + ->lists('host'); + +$satesON=Capsule::table('mod_iOne_vmlist_cache') + ->groupBy('state') + ->lists('state'); + +$satusWhmcs=Capsule::table('tblhosting') + ->groupBy('domainstatus') + ->lists('domainstatus'); + + +if(!$searchStatusWhmcs){ + $searchStatusWhmcs=['Suspended','Active']; +}; + +if(!$statusOn){ + $statusOn=$satesON; +}; + +if(!$searchHost){ + $searchHost=$hostsON; +} + +if(in_array('notInWhmcs',$smartStatus)){ + $loginWhmcs=Capsule::table('tblhosting') + ->join('mod_on_user','mod_on_user.id_service','=','tblhosting.id') + ->lists('vmid'); + + $userIdOn=Capsule::table('mod_iOne_vmlist_cache') + ->whereNotIn('vmid',$loginWhmcs) + ->lists('login'); +} + +if(in_array('hasError',$smartStatus)){ //filled with an error + $hostingIds[]=Capsule::table('tblhosting') + ->join('mod_on_user','mod_on_user.id_service','=','tblhosting.id') + ->orWhere('mod_on_user.vmid',' ') + ->orWhere('mod_on_user.userid',' ') + ->orWhere('mod_on_user.loginon',' ') + ->orwhereNull('mod_on_user.vmid') + ->orWhereNull('mod_on_user.userid') + ->orWhereNull('mod_on_user.loginon') + ->lists('hosting.id'); +} + + +if(in_array('noStatus',$smartStatus)){ //if the statuses do not match + foreach ($arrayVariant as $key=>$variant) { + $hostingIds[] = Capsule::table('tblhosting') + ->select('mod_iOne_vmlist_cache.state','tblhosting.domainstatus','tblhosting.id') + ->join('mod_on_user', 'mod_on_user.id_service', '=', 'tblhosting.id') + ->join('mod_iOne_vmlist_cache', 'mod_iOne_vmlist_cache.vmid', '=', 'mod_on_user.vmid') + ->where('tblhosting.domainstatus',$key) + ->whereNotIn('mod_iOne_vmlist_cache.state',$variant) + ->lists('tblhosting.id'); + } +} + + +$pageGetUrl['statusWhmcs']=$searchStatusWhmcs; +$pageGetUrl['statusOn']=$statusOn; +$pageGetUrl['selectFilterStatus']=$smartStatus; +$pageGetUrl['host']=$searchHost; +$pageGetUrl['searchForIp']=$searchIP; +$pageGetUrl=http_build_query($pageGetUrl); + + +if(!$page) { + require_once($_SERVER['DOCUMENT_ROOT'] . '/modules/servers/onconnector/lib/ONConnect.php'); + $onconnect = new ONConnect(); + $dataON = $onconnect->compare_info(); + $userON = $dataON['response'][0]; + $hostsON = $dataON['response'][1]; + if(count($userON)>0) { + $answerCount = Capsule::table('mod_iOne_vmlist_cache') + ->truncate(); + $answerCount = Capsule::table('mod_iOne_vmlist_cache') + ->insert($userON); + } +} + +if(count($hostingIds)==0 && count($userIdOn)==0) { + $answerCount = Capsule::table('tblproducts') + ->select( + 'tblproducts.gid', + 'tblhosting.userid', + 'tblhosting.domainstatus', + 'tblhosting.dedicatedip', + 'mod_on_user.id_service', + 'mod_on_user.loginon', + 'mod_on_user.passwordon', + 'mod_on_user.userid as useridOn', + 'mod_on_user.vmid') + ->join('tblhosting', 'tblproducts.id', '=', 'tblhosting.packageid') + ->join('mod_on_user', 'mod_on_user.id_service', '=', 'tblhosting.id') + ->leftJoin('mod_iOne_vmlist_cache', 'mod_iOne_vmlist_cache.vmid', '=', 'mod_on_user.vmid') + ->whereIn('tblproducts.servertype', ['onconnector','ione']) + ->whereIn('tblhosting.domainstatus', $searchStatusWhmcs) + ->whereIn('mod_iOne_vmlist_cache.state', $statusOn) + ->whereIn('mod_iOne_vmlist_cache.host', $searchHost) + ->where('tblhosting.dedicatedip', 'like', '%' . $searchIP . '%') + ->count(); + + $userWHMCS = Capsule::table('tblproducts') + ->select( + 'tblproducts.gid', + 'tblhosting.domainstatus', + 'tblhosting.userid', + 'mod_on_user.id_service', + 'mod_on_user.loginon', + 'mod_on_user.passwordon', + 'mod_on_user.userid as useridOn', + 'mod_on_user.vmid', + 'tblhosting.dedicatedip', + 'mod_iOne_vmlist_cache.state', + 'mod_iOne_vmlist_cache.host') + ->join('tblhosting', 'tblproducts.id', '=', 'tblhosting.packageid') + ->join('mod_on_user', 'mod_on_user.id_service', '=', 'tblhosting.id') + ->leftJoin('mod_iOne_vmlist_cache', 'mod_iOne_vmlist_cache.vmid', '=', 'mod_on_user.vmid') + ->whereIn('tblproducts.servertype', ['onconnector','ione']) + ->whereIn('tblhosting.domainstatus', $searchStatusWhmcs) + ->whereIn('mod_iOne_vmlist_cache.state', $statusOn) + ->whereIn('mod_iOne_vmlist_cache.host', $searchHost) + ->where('tblhosting.dedicatedip', 'like', '%' . $searchIP . '%') + ->offset(($page - 1) * $pageCount) + ->limit($pageCount) + ->orderBy('mod_iOne_vmlist_cache.vmid', 'asc') + ->get(); +} +elseif(count($hostingIds)!=0 && count($userIdOn)==0){ + + $resultHostingIds=[]; + foreach ($hostingIds as $ids){ + $resultHostingIds=array_merge($resultHostingIds,$ids); + } + + $answerCount = Capsule::table('tblproducts') + ->select( + 'tblproducts.gid', + 'tblhosting.userid', + 'tblhosting.domainstatus', + 'tblhosting.dedicatedip', + 'mod_on_user.id_service', + 'mod_on_user.loginon', + 'mod_on_user.passwordon', + 'mod_on_user.userid as useridOn', + 'mod_on_user.vmid') + ->join('tblhosting', 'tblproducts.id', '=', 'tblhosting.packageid') + ->join('mod_on_user', 'mod_on_user.id_service', '=', 'tblhosting.id') + ->leftJoin('mod_iOne_vmlist_cache', 'mod_iOne_vmlist_cache.vmid', '=', 'mod_on_user.vmid') + ->whereIn('tblproducts.servertype', ['onconnector','ione']) + ->whereIn('tblhosting.domainstatus', $searchStatusWhmcs) + ->whereIn('mod_iOne_vmlist_cache.state', $statusOn) + ->whereIn('mod_iOne_vmlist_cache.host', $searchHost) + ->whereIn('tblhosting.id',$resultHostingIds) + ->where('tblhosting.dedicatedip', 'like', '%' . $searchIP . '%') + ->count(); + + $userWHMCS = Capsule::table('tblproducts') + ->select( + 'tblproducts.gid', + 'tblhosting.domainstatus', + 'tblhosting.userid', + 'mod_on_user.id_service', + 'mod_on_user.loginon', + 'mod_on_user.passwordon', + 'mod_on_user.userid as useridOn', + 'mod_on_user.vmid', + 'tblhosting.dedicatedip', + 'mod_iOne_vmlist_cache.state', + 'mod_iOne_vmlist_cache.host') + ->join('tblhosting', 'tblproducts.id', '=', 'tblhosting.packageid') + ->join('mod_on_user', 'mod_on_user.id_service', '=', 'tblhosting.id') + ->leftJoin('mod_iOne_vmlist_cache', 'mod_iOne_vmlist_cache.vmid', '=', 'mod_on_user.vmid') + ->whereIn('tblproducts.servertype', ['onconnector','ione']) + ->whereIn('tblhosting.domainstatus', $searchStatusWhmcs) + ->whereIn('mod_iOne_vmlist_cache.state', $statusOn) + ->whereIn('mod_iOne_vmlist_cache.host', $searchHost) + ->whereIn('tblhosting.id',$resultHostingIds) + ->where('tblhosting.dedicatedip', 'like', '%' . $searchIP . '%') + ->offset(($page - 1) * $pageCount) + ->limit($pageCount) + ->orderBy('mod_iOne_vmlist_cache.vmid', 'asc') + ->get(); +} +elseif(count($hostingIds)==0 && count($userIdOn)!=0){ //does not exist in whmcs + $answerCount = Capsule::table('mod_iOne_vmlist_cache') + ->whereIn('login',$userIdOn) + ->where('ip', 'like', '%' . $searchIP . '%') + ->count(); + + $userWHMCS = Capsule::table('mod_iOne_vmlist_cache') + ->whereIn('login',$userIdOn) + ->where('ip', 'like', '%' . $searchIP . '%') + ->offset(($page - 1) * $pageCount) + ->limit($pageCount) + ->orderBy('mod_iOne_vmlist_cache.vmid', 'asc') + ->get(); + var_dump($answerCount); +} +elseif(count($hostingIds)!=0 && count($userIdOn)!=0){} + +foreach ($userWHMCS as $oneUser) +{ + if(!$oneUser->vmid){ + $oneUser->col='warning'; + } + if(!$oneUser->loginon){ + $oneUser->col='info'; + } + if(!$oneUser->host){ + $oneUser->col='danger'; + } + if(!$oneUser->col){ + $oneUser->col='success'; + } +} + +$pageAll=ceil($answerCount/$pageCount); + +$minPage=$page-3; +$maxPage=$page+3; +if($minPage<1){ + $minPage=1; +} + +if($maxPage>$pageAll){ + $maxPage=$pageAll; +} + +$LANG=$this->vars['_lang']; +?> + + + +
+
+
    +
  • +
+
+
+
    + +
  • + + +
  • + +
  • + + +
  • + +
  • + + +
  • + +
  • + + +
  • + +
  • + + +
  • +
+
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
userid?>id_service?>loginon?>useridOn?>vmid?>state?>domainstatus?>host?>dedicatedip?> + +
+
+
+ +
+ +
+ +
+
+ +where('invoiceid', $params['invoiceid']) - ->get(); - - $tblhosting = Capsule::table('tblhosting') - ->where('orderid', $order[0]->id) - ->get(); - - logModuleCall( - 'onconnector', - __FUNCTION__, - $params, - $params, - "Paid" - ); - - $data = Capsule::table('mod_on_user') - ->where('id_service', $tblhosting[0]->id) - ->get(); - - $server = Capsule::table('tblservers') - ->where('id', $tblhosting[0]->server) - ->get(); - if (isset($server[0]->ipaddress) && ctype_digit($data[0]->userid) && ctype_digit($data[0]->vmid)) { - - require_once("lib/ONConnect.php"); - $onconnect = new ONConnect($server[0]->ipaddress); - $result = $onconnect->Unsuspend($data[0]->vmid); - - Capsule::table('tblhosting') - ->where('orderid', $order[0]->id) - ->update( - array( - 'domainstatus' => 'Activity', - )); - } - } catch (Exception $e) { - logModuleCall( - 'onconnector', - __FUNCTION__, - $params, - $e->getMessage(), - $e->getTraceAsString() - ); - } - -} - -function hook_onconnector_EmailTplMergeFields(array $params) -{ - $merge_fields = []; - $merge_fields['ONLogin'] = "User ON"; - $merge_fields['OnPassword'] = "Password ON"; - $merge_fields['wiki_link'] = "Wiki link"; - return $merge_fields; -} - -function hook_onconnector_EmailPreSend(array $params) -{ - $date = Capsule::table('mod_on_user') - ->where('id_service', $params['relid']) - ->get(); - $merge_fields = []; - $merge_fields['ONLogin'] = $date[0]->loginon; - $merge_fields['OnPassword'] = $date[0]->passwordon; - $marge_fields['wiki_link'] = 'https://goo.gl/k5VgQE'; - return $merge_fields; -} - -add_hook('AddonSuspended', 1, function ($vars) { - $command = 'GetClientsProducts'; - $postData = array( - 'serviceid' => $vars['serviceid'], - ); // Getting service; - $adminlog = Capsule::table('tblconfiguration')->where('setting', 'whmcs_admin')->get(); - $adminUsername = $adminlog[0]->value; // Init using hell api; - - $results = localAPI($command, $postData, $adminUsername); - - logModuleCall( - 'AddonSuspended', - __FUNCTION__, - 'Suspend attempt', - $vars, - $vars - ); - - if ($results['products']['product'][0]['status'] == 'Active') { - - $command = 'UpdateClientAddon'; - $postData = array( - 'id' => $vars['id'], - 'status' => 'Active', - ); - $adminlog = Capsule::table('tblconfiguration')->where('setting', 'whmcs_admin')->get(); - $adminUsername = $adminlog[0]->value; // Optional for WHMCS 7.2 and later - - $results = localAPI($command, $postData, $adminUsername); - print_r($results); - } -}); - -add_hook('PreModuleSuspend', 1, function ($params) { - - $iaas_servers = Capsule::table( 'mod_iaas_servers' )->where('idproduct','=',$params['pid'])->get(); - if($iaas_servers == null) { - - if ($params['params']['moduletype'] != 'onconnector') { - return true; - } else { - logModuleCall( - 'immun', - __FUNCTION__, - 'Suspend attempt', - $params, - get_declared_classes() - ); - } - - if (class_exists('WHMCS\Form')) { - logModuleCall( - 'immun', - __FUNCTION__, - 'Manual suspend', - $params, - get_declared_classes() - ); - } - - if (strstr($params['params']['suspendreason'], 'force')) { - return true; - } else { - $castomfild = Capsule::table('tblcustomfieldsvalues') - ->where('relid', $params['params']['userid']) - ->where('fieldid', '3697') - ->get(); - - - - $customname = Capsule::table('tblconfiguration')->where('setting', 'customfield')->get(); - $customfildcheck = Capsule::table('tblcustomfields') - ->select('id')->where('fieldname', $customname[0]->value)->get(); - $castomfild = Capsule::table('tblcustomfieldsvalues') - ->where('relid', $params['params']['userid']) - ->where('fieldid', $customfildcheck[0]->id) - ->get(); - - if (((!isset($castomfild[0]->value)) || ($castomfild[0]->value != 'Да')) && ((!isset($castomfild[0]->value)) || ($castomfild[0]->value != 'Yes')) && (date(N) < 5)) { - - // If immun field not created or not filled with 'Yes', and today is not 5, 6 or 7-th weekday. - - $command = 'GetClientsProducts'; - $postData = array( - 'serviceid' => $params['params']['serviceid'], - ); // Getting service; - $adminlog = Capsule::table('tblconfiguration')->where('setting', 'whmcs_admin')->get(); - $adminUsername = $adminlog[0]->value; // Init using hell api; - - $results = localAPI($command, $postData, $adminUsername); - $age = time() - strtotime($results['products']['product'][0]['regdate']); // Service 'age'; - - if ($age < 2592000) { // If service isn't older than 30 days; - logModuleCall( - 'immun', - __FUNCTION__, - 'Service age is lower than 30 days', - $params, - $params - ); - $result['abortcmd'] = true; // Setting param for suspend cancellation; - return $result; // Return vars to handler; - } - - $invoiceitems = Capsule::table('tblinvoiceitems') - ->where('relid', $params['params']['serviceid']) - ->get(); // Getting invoices for this service from DB; - - if (!$invoiceitems) { // If no invoices; - logModuleCall( - 'immun', - __FUNCTION__, - 'Service suspended', - $params, - $params - ); - $result['abortcmd'] = true; // Setting param for suspend cancellation; - return $result; // Return vars to handler; - } - - $lastInvoice = array_pop($invoiceitems); // Getting last invoice(dangerous, check it twice); - - if (time() < strtotime($lastInvoice->duedate)) { // If pay-date earlier than today. - logModuleCall( - 'immun', - __FUNCTION__, - 'Invoice transfered or delayed', - $params, - $params - ); - - $result['abortcmd'] = true; // Setting param for suspend cancellation; - return $result; // Return vars to handler; - } - - $delay = Capsule::table('support_delay_invoice') - ->where('invoice_id', $lastInvoice->invoiceid) - ->get(); // Getting from DB next pay-date; - - if (time() < strtotime($delay[0]->expire_date)) // If today is earlier than delayed pay-date; - { - $result['abortcmd'] = true; // Setting param for suspend cancellation; - return $result; // Return vars to handler; - } else { - logModuleCall( - 'immun', - __FUNCTION__, - 'Service suspended', - $params, - $params - ); - return true; // Suspending - } - } else { - logModuleCall( - 'immun', - __FUNCTION__, - 'Immun-service suspend attempt', - $params, - $params['params']['suspendreason'] - ); - - $result['error'] = "This service has suspend immun"; - $result['abortcmd'] = true; - return $result; - } - } - } -}); -add_hook('InvoicePaid', 1, function ($vars) { - - $command = 'GetInvoice'; - $postData = array( - 'invoiceid' => $vars['invoiceid'], - ); - $adminlog = Capsule::table('tblconfiguration')->where('setting', 'whmcs_admin')->get(); - $adminUsername = $adminlog[0]->value; - - $results = localAPI($command, $postData, $adminUsername); - $usid = $results['userid']; - - $command = 'GetClientsProducts'; - $postData = array( - 'clientid' => $usid, - 'stats' => true, - ); - $adminlog = Capsule::table('tblconfiguration')->where('setting', 'whmcs_admin')->get(); - $adminUsername = $adminlog[0]->value; - - $results = localAPI($command, $postData, $adminUsername); - - - if (strripos($results['products']['product'][0]['translated_groupname'], 'Trial') > -1) { - $command = 'ModuleCreate'; - $postData = array( - 'accountid' => $results['products']['product'][0]['id'], - ); - - $adminlog = Capsule::table('tblconfiguration')->where('setting', 'whmcs_admin')->get(); - $adminUsername = $adminlog[0]->value; - - $results = localAPI($command, $postData, $adminUsername); - - } - - logModuleCall( - 'onconnector', - __FUNCTION__, - $vars, $results, $results - ); - - return; - -}); -add_hook('EmailPreSend', 1, 'hook_onconnector_EmailPreSend'); -add_hook('EmailTplMergeFields', 1, 'hook_onconnector_EmailTplMergeFields'); -add_hook('InvoiceUnpaid', 1, 'hook_onconnector_Invoice'); -add_hook('InvoiceCancelled', 1, 'hook_onconnector_InvoiceCancelled'); -add_hook('ClientEdit', 1, 'hook_onconnector_clientedit'); -add_hook('AfterInvoicingGenerateInvoiceItems', 1, 'hook_onconnector_AfterInvoicingGenerateInvoiceItems'); -add_hook('ClientAreaPageProductDetails', 1, function ($vars) { - $userDate = Capsule::table('mod_on_user') - ->select('loginon', 'passwordon') - ->where('id_service', $vars['serviceid']) - ->first(); - $extraTemplateVariables['loginOn'] = $userDate->loginon; - $extraTemplateVariables['passwordOn'] = $userDate->passwordon; - return $extraTemplateVariables; -}); - -add_hook('ClientAreaPageProductDetails', 1, function ($vars) { - $userDate = Capsule::table('mod_on_user') - ->select('loginon', 'passwordon') - ->where('id_service', $vars['serviceid']) - ->first(); - $extraTemplateVariables['loginOn'] = $userDate->loginon; - $extraTemplateVariables['passwordOn'] = $userDate->passwordon; - return $extraTemplateVariables; -}); - - - - add_hook('ClientAreaPageHome', 1, function ($vars) { - if ($vars['clientsdetails']['userid']){ - $result = ''; - $counter = 0; - $id = $vars['clientsdetails']['userid']; - $key = 413397; - $result = strlen($id) . $id; - while (strlen($result) < 6) { - if ($counter > strlen($id)) { - $counter = 0; - } - $result .= str_split($vars['clientsdetails']['userid'])[0]; - $counter++; - } - $key = (string)$key; - for ($i = 0; $i < 6; $i++) { - $result[$i] = ($result[$i] + $key[$i]) % 10; - } - $extraTemplateVariables['clientPinCode'] = $result; - return $extraTemplateVariables; - - } - }); +where('id_service', $params['relid']) + ->get(); + $merge_fields = []; + $merge_fields['ONLogin'] = $date[0]->loginon; + $merge_fields['OnPassword'] = $date[0]->passwordon; + $marge_fields['wiki_link'] = 'https://goo.gl/k5VgQE'; + return $merge_fields; +} + + + +add_hook('AddonSuspended', 1, function ($vars) { + $command = 'GetClientsProducts'; + $postData = array( + 'serviceid' => $vars['serviceid'], + ); // Getting service; + $adminlog = Capsule::table('tblconfiguration')->where('setting', 'whmcs_admin')->get(); + $adminUsername = $adminlog[0]->value; + + $results = localAPI($command, $postData, $adminUsername); + + logModuleCall( + 'AddonSuspended', + __FUNCTION__, + 'Suspend attempt', + $vars, + $vars + ); + + if ($results['products']['product'][0]['status'] == 'Active') { + + $command = 'UpdateClientAddon'; + $postData = array( + 'id' => $vars['id'], + 'status' => 'Active', + ); + $adminlog = Capsule::table('tblconfiguration')->where('setting', 'whmcs_admin')->get(); + $adminUsername = $adminlog[0]->value; + + $results = localAPI($command, $postData, $adminUsername); + print_r($results); + } +}); + +add_hook('PreModuleSuspend', 1, function ($params) { + + if ($params['params']['moduletype'] != 'onconnector') { + return true; + } else { + logModuleCall( + 'immun', + __FUNCTION__, + 'Suspend attempt', + $params, + get_declared_classes() + ); + } + + if (class_exists('WHMCS\Form')) { + logModuleCall( + 'immun', + __FUNCTION__, + 'Manual suspend', + $params, + get_declared_classes() + ); + } + + if (strstr($params['params']['suspendreason'], 'force')) { + return true; + } else { + $customname = Capsule::table('tblconfiguration')->where('setting', 'customfield')->get(); + $customfildcheck = Capsule::table('tblcustomfields') + ->select('id')->where('fieldname', $customname[0]->value)->get(); + $castomfild = Capsule::table('tblcustomfieldsvalues') + ->where('relid', $params['params']['userid']) + ->where('fieldid', $customfildcheck[0]->id) + ->get(); + + if (((!isset($castomfild[0]->value)) || ($castomfild[0]->value != 'Да') || ($castomfild[0]->value != 'Yes')) && (date(N) < 5)) { + + $command = 'GetClientsProducts'; + $postData = array( + 'serviceid' => $params['params']['serviceid'], + ); // Getting service; + $adminlog = Capsule::table('tblconfiguration')->where('setting', 'whmcs_admin')->get(); + $adminUsername = $adminlog[0]->value; + + $results = localAPI($command, $postData, $adminUsername); + $age = time() - strtotime($results['products']['product'][0]['regdate']); // Service 'age'; + + if ($age < 432000) { // If service isn't older than 30 days; + logModuleCall( + 'immun', + __FUNCTION__, + 'Service age is lower than 30 days', + $params, + $params + ); + $result['abortcmd'] = true; // Setting param for suspend cancellation; + return $result; // Return vars to handler; + } + + $invoiceitems = Capsule::table('tblinvoiceitems') + ->where('relid', $params['params']['serviceid']) + ->get(); // Getting invoices for this service from DB; + + if (!$invoiceitems) { // If no invoices; + logModuleCall( + 'immun', + __FUNCTION__, + 'Service suspended', + $params, + $params + ); + $result['abortcmd'] = true; // Setting param for suspend cancellation; + return $result; // Return vars to handler; + } + + $lastInvoice = array_pop($invoiceitems); // Getting last invoice(dangerous, check it twice); + + if (time() < strtotime($lastInvoice->duedate)) { // If pay-date earlier than today. + logModuleCall( + 'immun', + __FUNCTION__, + 'Invoice transfered or delayed', + $params, + $params + ); + + $result['abortcmd'] = true; // Setting param for suspend cancellation; + return $result; // Return vars to handler; + } + + $delay = Capsule::table('support_delay_invoice') + ->where('invoice_id', $lastInvoice->invoiceid) + ->get(); // Getting from DB next pay-date; + + if (time() < strtotime($delay[0]->expire_date)) { + $result['abortcmd'] = true; // Setting param for suspend cancellation; + return $result; // Return vars to handler; + } else { + logModuleCall( + 'immun', + __FUNCTION__, + 'Service suspended', + $params, + $params + ); + return true; // Suspending + } + } else { + logModuleCall( + 'immun', + __FUNCTION__, + 'Immun-service suspend attempt', + $params, + $params['params']['suspendreason'] + ); + + $result['error'] = "This service has suspend immun"; + $result['abortcmd'] = true; + return $result; + } + } +}); + +add_hook('InvoicePaid', 1, function ($vars) { + + $command = 'GetInvoice'; + $postData = array( + 'invoiceid' => $vars['invoiceid'], + ); + $adminlog = Capsule::table('tblconfiguration')->where('setting', 'whmcs_admin')->get(); + $adminUsername = $adminlog[0]->value; + + $results = localAPI($command, $postData, $adminUsername); + $usid = $results['userid']; + + $command = 'GetClientsProducts'; + $postData = array( + 'clientid' => $usid, + 'stats' => true, + ); + $adminlog = Capsule::table('tblconfiguration')->where('setting', 'whmcs_admin')->get(); + $adminUsername = $adminlog[0]->value; + + $results = localAPI($command, $postData, $adminUsername); + + + if (strripos($results['products']['product'][0]['translated_groupname'], 'Trial') > -1) { + $command = 'ModuleCreate'; + $postData = array( + 'accountid' => $results['products']['product'][0]['id'], + ); + $adminlog = Capsule::table('tblconfiguration')->where('setting', 'whmcs_admin')->get(); + $adminUsername = $adminlog[0]->value; + + $results = localAPI($command, $postData, $adminUsername); + + } + + logModuleCall( + 'onconnector', + __FUNCTION__, + $vars, $results, $results + ); + + return; + +}); + +add_hook('EmailPreSend', 1, 'hook_onconnector_EmailPreSend'); +add_hook('EmailTplMergeFields', 1, 'hook_onconnector_EmailTplMergeFields'); + + +add_hook('ClientAreaPageProductDetails', 1, function ($vars) { + $userDate = Capsule::table('mod_on_user') + ->select('loginon', 'passwordon') + ->where('id_service', $vars['serviceid']) + ->first(); + $extraTemplateVariables['loginOn'] = $userDate->loginon; + $extraTemplateVariables['passwordOn'] = $userDate->passwordon; + return $extraTemplateVariables; +}); + +add_hook('ClientAreaPageProductDetails', 1, function ($vars) { + $userDate = Capsule::table('mod_on_user') + ->select('loginon', 'passwordon') + ->where('id_service', $vars['serviceid']) + ->first(); + $extraTemplateVariables['loginOn'] = $userDate->loginon; + $extraTemplateVariables['passwordOn'] = $userDate->passwordon; + return $extraTemplateVariables; +}); + + +add_hook('ClientAreaPageHome', 1, function ($vars) { + if ($vars['clientsdetails']['userid']){ + $result = ''; + $counter = 0; + $id = $vars['clientsdetails']['userid']; + $key = 413397; + $result = strlen($id) . $id; + while (strlen($result) < 6) { + if ($counter > strlen($id)) { + $counter = 0; + } + $result .= str_split($vars['clientsdetails']['userid'])[0]; + $counter++; + } + $key = (string)$key; + for ($i = 0; $i < 6; $i++) { + $result[$i] = ($result[$i] + $key[$i]) % 10; + } + $extraTemplateVariables['clientPinCode'] = $result; + return $extraTemplateVariables; + + } + }); diff --git a/servers/onconnector/lib/ONConnect.php b/servers/onconnector/lib/ONConnect.php index a0337e5..18e88de 100644 --- a/servers/onconnector/lib/ONConnect.php +++ b/servers/onconnector/lib/ONConnect.php @@ -1,105 +1,128 @@ dsn, 'Failed to load class ZMQContext'); - } - if(!$ip) { - $ip = Capsule::table('tblconfiguration')->where('setting', 'ione_config_host')->get(); - $ip=$ip[0]->value; + public function CurlLogin() + { + $username = Capsule::table('tblconfiguration')->where('setting', 'ione_config_login')->get(); + $password = Capsule::table('tblconfiguration')->where('setting', 'ione_config_passwd')->get(); + $addr = Capsule::table('tblconfiguration')->where('setting', 'ione_address')->get(); + + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $addr[0]->value.'login'); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_HEADER, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array())); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($ch, CURLOPT_USERPWD, $username[0]->value . ":" . $password[0]->value); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + $response = curl_exec($ch); + curl_close($ch); + + $cookie_start = stristr($response, 'sunstone'); + $cookie = stristr($cookie_start, ' path', true); + + + if (Capsule::table('tblconfiguration') + ->where('setting', 'cookie_on') + ->get()) { + Capsule::table('tblconfiguration') + ->where('setting', 'cookie_on') + ->update([ + 'setting' => 'cookie_on', + 'value' => $cookie + ]); + } else { + $result = Capsule::table('tblconfiguration') + ->insert([ + 'setting' => 'cookie_on', + 'value' => $cookie + ]); }; - if(!$port) { - $port = Capsule::table('tblconfiguration')->where('setting', 'ione_config_port')->get(); - $port=$port[0]->value; - } - $this->debug=$debugMod; - $this->dsn="tcp://".$ip.":".$port; - } - private function farmJson($method,$params) - { - $message= array ( - "jsonrpc"=>"2.0", - "method"=>$method, - "params"=>$params, - "id"=>rand(0,999), - ); - return json_encode($message); - } + return; + } + + public function CurlConnect($method, $params) + { + $i = 0; + do{ + $get_cookie = Capsule::table('tblconfiguration')->select('value')->where('setting', 'cookie_on')->get(); + $addr = Capsule::table('tblconfiguration')->where('setting', 'ione_address')->get(); + + $cookie_on = $get_cookie[0]->value; + $i++; + $data = array('params' => $params); + $data_json = json_encode($data); + + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $addr[0]->value.'/ione/' . $method); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_HEADER, 1); + curl_setopt($ch, CURLOPT_VERBOSE, true); + curl_setopt($ch, CURLOPT_COOKIE, $cookie_on); + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); + curl_setopt($ch, CURLOPT_POSTFIELDS, $data_json); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + $response = curl_exec($ch); + if ($response === false) { + logModuleCall( + __CLASS__, + __FUNCTION__. " error:", + curl_getinfo($ch), + 'err #' . curl_errno($ch) . ": " . curl_error($ch), + ); + } + $error = stripos($response, '401 Unauthorized'); + if ($error === false) {} else { + + $i++; + if ($i < 5) { + curl_close($ch); + $this->CurlLogin(); + } else { + curl_close($ch); + $err = new stdClass(); + $err->response->error = 'Error connection to IONE'; + logModuleCall( + __CLASS__, + __FUNCTION__, + 'error connect', + $err + ); + return $err; + } + } + curl_close($ch); - private function closeConnection(){ - $endpoints = $this->socket->getEndpoints(); - if (!in_array($this->dsn, $endpoints['connect'])) { - $this->socket->disconnect($this->dsn); - } - } + }while($error != ''); - private function logParams($params,$message=null) - { - logModuleCall( - __CLASS__, - __FUNCTION__, - $this->dsn, $params, $message - ); - return '{"id":970,"jsonrpc":"2.0","result":{"userid":666,"vmid":666,"ip":"255.255.255.255"}}'; + $response_start = stristr($response, '{'); + $array_answer = json_decode ($response_start); + + return $array_answer; } - private function zmqCommunication($method,$params,$persistenId='onConnector') - { - $json = $this->farmJson($method,$params); - - try { - $this->context = new ZMQContext(); - $this->socket = $this->context->getSocket(ZMQ::SOCKET_REQ, 'ZMQSockIone'); - $this->socket->setSockOpt(ZMQ::SOCKOPT_RCVTIMEO,-1); - $this->socket->setSockOpt(ZMQ::SOCKOPT_SNDTIMEO,10000); - $endpoints = $this->socket->getEndpoints(); - if (!in_array($this->dsn, $endpoints['connect'])) { - $this->socket->connect($this->dsn); - } - if($this->debug){ - $message=$this->logParams($json); - }else { - $this->socket->send($json); - $message = $this->socket->recv(); - $this->logParams($json,$message); - } - $this->closeConnection(); - return $message; - } catch (Exception $exception){ - $this->closeConnection(); - logModuleCall( - __CLASS__, - __FUNCTION__, - $exception, $this->dsn, 'Information could not be retrieved because the server was not reachable' - ); - return ['error'=>true, - 'errorMessage'=>'Information could not be retrieved because the server was not reachable']; - } + public function IaaS($method,$params){ + $json=$this->CurlConnect($method,$params); + return $json; } public function Suspend($vmid,$force=false) { $param=array( - array ( + array ( 'vmid'=>$vmid, 'force'=>$force, 'log'=>true ) ); - $json=$this->zmqCommunication("Suspend",$param); - return json_decode($json,true); + $json=$this->CurlConnect("Suspend",$param); + return $json; } public function Unsuspend($vmid) @@ -109,125 +132,65 @@ public function Unsuspend($vmid) 'vmid' =>$vmid ) ); - $json=$this->zmqCommunication("Unsuspend",$param); - return json_decode($json,true); + $json=$this->CurlConnect("Unsuspend",$param); + return $json; } public function Shutdown($vmid) { $param=array($vmid); - $json=$this->zmqCommunication("Shutdown",$param); - return json_decode($json,true); + $json=$this->CurlConnect("Shutdown",$param); + return $json; } public function Reboot($vmid,$bool=true) { $param=array($vmid,$bool); - $json=$this->zmqCommunication("Reboot",$param); - return json_decode($json,true); + $json=$this->CurlConnect("Reboot",$param); + return $json; } public function Terminate($userid, $vmid) { $param=array($userid,$vmid); - $json=$this->zmqCommunication("Terminate",$param); - return json_decode($json,true); - } - public function TerminateIaas($uid) - { - $param=array($uid); - $json=$this->zmqCommunication("UserDelete",$param); - return json_decode($json,true); + $json=$this->CurlConnect("Terminate",$param); + return $json; } public function getVmByName($name) // Getting VM data by name, using for button 'check' { $param=array($name); - $json=$this->zmqCommunication("get_vm_by_uname",$param); - return json_decode($json,true); + $json=$this->CurlConnect("get_vm_by_uname",$param); + return $json; } public function GetIP($vmid) // Getting VM IP using VMID { $param=array($vmid); - $json=$this->zmqCommunication("GetIP",$param); - return json_decode($json,true); + $json=$this->CurlConnect("GetIP",$param); + return $json; } - public function Test($param=array("PING")) // Checking IONe availability sending 'ping', answer should be 'pong' + public function Test() // Checking IONe availability sending 'ping', answer should be 'pong' { - $json=$this->zmqCommunication("Test",$param); - return json_decode($json,true); + $param=array("PING"); + $json=$this->CurlConnect("Test",$param); + return $json; } public function compare_info($ips=[]) // Getting data about all VMs from IONe { $params=array($ips); - $json=$this->zmqCommunication("compare_info",$params); - return json_decode($json,true); + $json=$this->CurlConnect("compare_info",$params); + $json_new = json_decode(json_encode($json),true); + return $json_new; } public function createVMwithSpecs($arrayParam) // Creating VM from template with params { $param=array($arrayParam); - $json=$this->zmqCommunication("CreateVMwithSpecs",$param); - return json_decode($json,true); - } - - public function UserCreateIaaS($arrayParam) // Creating iaas user - { - - $param=array( $arrayParam['login'],$arrayParam['pass'],$arrayParam['groupid'],$arrayParam['locale']); - $json=$this->zmqCommunication("UserCreate",$param); - return json_decode($json,true); - } - - - - public function RetrieveShowback($uid,$time,$balance) // get date about iaas users - { - $checkiaas = Capsule::table('tbladdonmodules')->select('*')->where('module','=','opennebulavdc')->get(); - if($checkiaas) { - $param['uid'] = $uid; - $param['time'] = $time; - $param['balance'] = $balance; - - $params = array( - array( - 'uid' => $uid, - 'time' => $time, - 'balance' => $balance - ), - ); - - logModuleCall( - 'onconnector', - __FUNCTION__, - 'test', - $params - ); - $json = $this->zmqCommunication("IaaS_Gate", $params); - } - - return json_decode($json,true); - } - - public function SuspendUserIaas($uid){ - $checkiaas = Capsule::table('tbladdonmodules')->select('*')->where('module','=','opennebulavdc')->get(); - if($checkiaas) { - $params = array($uid); - $json = $this->zmqCommunication("SuspendUser", $params); - return json_decode($json,true); - } - } - - public function UnSuspendUserIaas($uid){ - $checkiaas = Capsule::table('tbladdonmodules')->select('*')->where('module','=','opennebulavdc')->get(); - if($checkiaas) { - $params = array($uid); - $json = $this->zmqCommunication("UnsuspendUser", $params); - return json_decode($json,true); - } + $json=$this->CurlConnect("CreateVMwithSpecs",$param); + return $json; } public function NewAccount($login, $pass, $templateid, $groupid, $rootpass, $trial, $services, $ansiblebool, $serviceid) @@ -243,16 +206,16 @@ public function NewAccount($login, $pass, $templateid, $groupid, $rootpass, $tri 'ansible'=>$ansiblebool, 'services'=>$services, 'serviceid'=>$serviceid - ) + ) ); - $json=$this->zmqCommunication("NewAccount",$param); - return json_decode($json,true); + $json=$this->CurlConnect("NewAccount",$param); + return $json; } public function Reinstall($params) { - $json=$this->zmqCommunication("Reinstall",$params); - return json_decode($json,true); + $json=$this->CurlConnect("Reinstall",$params); + return $json; } public function setBackup($func_name, $params = array()) @@ -261,8 +224,8 @@ public function setBackup($func_name, $params = array()) 'method'=>$func_name, 'params'=>$params )); - $json=$this->zmqCommunication("FreeNASController",$params); - return json_decode($json,true); + $json=$this->CurlConnect("FreeNASController",$params); + return $json; } public function AnsibleController($host,$serviceName) @@ -271,77 +234,78 @@ public function AnsibleController($host,$serviceName) 'host'=>$host, 'services' => $serviceName )); - $json=$this->zmqCommunication("AnsibleController",$params); - return json_decode($json,true); + $json=$this->CurlConnect("AnsibleController",$params); + return $json; } public function import($params) { $params=array($params); - $json=$this->zmqCommunication("IMPORT",$params); - return json_decode($json,true); + $json=$this->CurlConnect("IMPORT",$params); + return $json; } public function getSnapshotList($vmid) { - $json=$this->zmqCommunication("GetSnapshotList",array($vmid)); - return json_decode($json,true); + $json=$this->CurlConnect("GetSnapshotList",array($vmid)); + return $json; } public function MKSnapshot($vmid, $name) { $params=array($vmid,$name); - $json=$this->zmqCommunication("MKSnapshot",$params); - return json_decode($json,true); + $json=$this->CurlConnect("MKSnapshot",$params); + return $json; } public function RMSnapshot($vmid, $snapid) { $params=array($vmid,$snapid); - $json=$this->zmqCommunication("RMSnapshot",$params); - return json_decode($json,true); + $json=$this->CurlConnect("RMSnapshot",$params); + return $json; } public function RevSnapshot($vmid, $snapid) { $params=array($vmid,$snapid); - $json=$this->zmqCommunication("RevSnapshot",$params); - return json_decode($json,true); + $json=$this->CurlConnect("RevSnapshot",$params); + return $json; } public function lcmStateStr($vmid) { - $json=$this->zmqCommunication("LCM_STATE_STR",array($vmid)); - return json_decode($json,true); + $json=$this->CurlConnect("LCM_STATE_STR",array($vmid)); + return $json; } public function stateStr($vmid) { - $json=$this->zmqCommunication("STATE_STR",array($vmid)); - return json_decode($json,true); + $json=$this->CurlConnect("STATE_STR",array($vmid)); + return $json; } public function getVmData($vmid) { - $json=$this->zmqCommunication("get_vm_data",array($vmid)); - return json_decode($json,true); + $json=$this->CurlConnect("get_vm_data",array($vmid)); + return $json; } public function datastoresMonitoring($type='img') { - $json=$this->zmqCommunication("DatastoresMonitoring",array($type)); - return json_decode($json,true); + $json=$this->CurlConnect("DatastoresMonitoring",array($type)); + return $json; } public function hostsMonitoring() { - $json=$this->zmqCommunication("HostsMonitoring",array()); - return json_decode($json,true); + $json=$this->CurlConnect("HostsMonitoring",array()); + return $json; } public function reinstallNew($param) { - $json=$this->zmqCommunication("ReinstallNew",array($param)); - return json_decode($json,true); + $json=$this->CurlConnect("ReinstallNew",array($param)); + return $json; } -} + +} \ No newline at end of file diff --git a/servers/onconnector/onconnector.php b/servers/onconnector/onconnector.php index 51c8d40..8fc7780 100644 --- a/servers/onconnector/onconnector.php +++ b/servers/onconnector/onconnector.php @@ -1,11 +1,9 @@ join('mod_onconfiguratorOS','mod_onconfiguratorOS.addonid','=','tblhostingaddons.addonid') ->first(); + $allOptions['templateid']=$templateid->templateid; $root='root'; @@ -194,162 +195,137 @@ function onconnector_CreateAccount(array $params) $allOptions['ds_type']='SSD'; $allOptions['iops']=1000; break; + } } - } - $allOptions['groupid']=$params['configoption1']; + $allOptions['groupid']=$params['configoption1']; - $onaccaunt=Capsule::table('mod_on_user') - ->where('id_service',$params['serviceid']) - ->first(); + $onaccaunt=Capsule::table('mod_on_user') + ->where('id_service',$params['serviceid']) + ->first(); + $userid=$onaccaunt->userid; + $vmid=$onaccaunt->vmid; - $userid=$onaccaunt->userid; - $vmid=$onaccaunt->vmid; + if (!is_numeric($userid) && !is_numeric($vmid)) + { + $ansibles=[]; + $allOptions['ansible']=false; + foreach (Capsule::table( 'tblhostingaddons' ) + ->select('mod_onconfiguratorAddon.id') + ->where('tblhostingaddons.hostingid',$params['serviceid']) + ->join('mod_onconfiguratorAddon','mod_onconfiguratorAddon.Addon','=','tblhostingaddons.addonid') + ->get() as $item) { + $ansibles[]=$item->id; + } + if($allOptions['services']){ + $allOptions['ansible']=true; + }else{ + $allOptions['ansible']=false; + } - if (!ctype_digit($userid) && !ctype_digit($vmid)) - { - $ansibles=[]; - $allOptions['ansible']=false; - foreach (Capsule::table( 'tblhostingaddons' ) - ->select('mod_onconfiguratorAddon.id') - ->where('tblhostingaddons.hostingid',$params['serviceid']) - ->join('mod_onconfiguratorAddon','mod_onconfiguratorAddon.Addon','=','tblhostingaddons.addonid') - ->get() as $item) { - $ansibles[]=$item->id; - } - $isCheckAnsible=Capsule::table( 'tblconfiguration' )->where('setting','ione_use_ansible')->get(); - if($isCheckAnsible[0]->value=='on') { - require_once($_SERVER['DOCUMENT_ROOT'] . '/modules/addons/oncontrol/classes/ActivateAnsible.php'); - $ansibleDB = new AutoActivateAnsible($params['serviceid']); - $allOptions['services'] = $ansibleDB->getServicesFromIds($ansibles); - } + $allOptions['password'] = passgenerator(); + $allOptions['login'] = 'user_' . $params['serviceid']; - if($allOptions['services']){ - $allOptions['ansible']=true; - }else{ - $allOptions['ansible']=false; - } + $postData = array( + 'password2' => passgenerator(), + ); - $allOptions['password'] = passgenerator(); - $allOptions['login'] = 'user_' . $params['serviceid']; + $allOptions['passwd'] = $postData['password2']; - $postData = array( - 'password2' => passgenerator(), - ); + $adminlog = Capsule::table('tblconfiguration')->where('setting', 'whmcs_admin')->get(); + $adminUsername = $adminlog[0]->value; - $allOptions['passwd'] = $postData['password2']; + $passroot = localAPI('EncryptPassword', $postData,$adminUsername); + if ($passroot['result'] == 'error'){ + return "Error adminuser. Check configure module."; + } - $adminlog = Capsule::table('tblconfiguration')->where('setting', 'whmcs_admin')->get(); - $adminUsername = $adminlog[0]->value; + require_once("lib/ONConnect.php"); - $passroot = localAPI('EncryptPassword', $postData,$adminUsername); - if ($passroot['result'] == 'error'){ - return "Error adminuser. Check configure module."; - } + if(!$allOptions['iops']) // If IOPS is null + { + return "Error allocating a new virtual machine template. IOPS attribute must be a positive integer value"; + } - require_once("lib/ONConnect.php"); - // Record the error in WHMCS's module log. - logModuleCall( - 'onconnector', - __FUNCTION__, - $params, - $allOptions - ); + if(!$allOptions['cpu']) // If CPU is null + { + return "Error allocating a new virtual machine template. CPU attribute must be a positive integer value"; + } - if(!$allOptions['iops']) // If IOPS is null - { - return "Error allocating a new virtual machine template. IOPS attribute must be a positive integer value"; - } + if(!$allOptions['ram']) // If RAM is null + { + return "Error allocating a new virtual machine template. RAM attribute must be a positive integer value"; + } - if(!$allOptions['cpu']) // If CPU is null - { - return "Error allocating a new virtual machine template. CPU attribute must be a positive integer value"; - } + if(!$allOptions['drive']) // If Drive is null + { + return "Error allocating a new virtual machine template. Drive attribute must be a positive integer value"; + } + if(!($allOptions['ds_type'] == 'HDD' || $allOptions['ds_type'] == 'SSD')) // If drive type is not set + { + return "Error allocating a new virtual machine template. Disk type attribute must be (HDD/SSD) constant value"; + } - if(!$allOptions['ram']) // If RAM is null - { - return "Error allocating a new virtual machine template. RAM attribute must be a positive integer value"; - } + if(!($allOptions['units'] == 'GB' || $allOptions['units'] == 'TB' || $allOptions['units'] == 'MB' || $allOptions['units'] == 'KB' || $allOptions['units'] == 'B')) // If units is not set + { + return "Error allocating a new virtual machine template. Units attribute must be (TB/GB/MB/KB/B) constant value"; + } - if(!$allOptions['drive']) // If Drive is null - { - return "Error allocating a new virtual machine template. Drive attribute must be a positive integer value"; - } - if(!($allOptions['ds_type'] == 'HDD' || $allOptions['ds_type'] == 'SSD')) // If drive type is not set - { - return "Error allocating a new virtual machine template. Disk type attribute must be (HDD/SSD) constant value"; - } - if(!($allOptions['units'] == 'GB' || $allOptions['units'] == 'TB' || $allOptions['units'] == 'MB' || $allOptions['units'] == 'KB' || $allOptions['units'] == 'B')) // If units is not set - { - return "Error allocating a new virtual machine template. Units attribute must be (TB/GB/MB/KB/B) constant value"; - } + $onconnect = new ONConnect( $params['serverip'],$params['serverport'] ); + $result = $onconnect->createVMwithSpecs($allOptions); - $azure = Capsule::table( 'mod_azure_servers' )->where('idproduct','=',$params['pid'])->get(); - if($azure != null){ - $allOptions['release'] = true; - $allOptions['username'] = 'azuser'; - $allOptions['extra'] = array('type' => 'azure', - 'instance_size' => $azurename); - logModuleCall( - 'onconnector', - 'azure', - $params, - $allOptions - ); - } - logModuleCall( - 'onconnector', - __FUNCTION__, - $params, - $allOptions - ); + if($result->response->error==true) + { + return 'error: '.$result->errorMessage; + } - $onconnect = new ONConnect( $params['serverip'],$params['serverport'] ); - $result = $onconnect->createVMwithSpecs($allOptions); + if($result->response->error=='UserAllocateError') //If user already exists(name taken); + { + return "User user_$params[serviceid] already exists in ON"; + } - if($result['result']['error']=='UserAllocateError') //If user already exists(name taken); - { - return "User user_$params[serviceid] already exists in ON"; - } - if($result['result']['exeption']){ //If some unhandled Exeption - return $result['result']['exeption']; - } + if($result->response->exeption){ //If some unhandled Exeption + return $result['result']['exeption']; + } - if ($result['result']['error']=='TemplateLoadError') //If template not set - { - return 'error: Template load error'; - } + if ($result->response->error=='TemplateLoadError') //If template not set + { + return 'error: Template load error'; + } - if(!$result['result']){ //If answer is empty. - return 'error: Error getting data from IONe'; - } + if(!$result->response){ //If answer is empty. - Capsule::table( 'tblhosting' ) - ->where('id',$params['serviceid']) - ->update( - array ( - 'dedicatedip' => $result['result']['ip'], - 'username'=>$root, - 'password'=>$passroot['password'], - 'domain'=>$result['result']['ip'], - ) - ); + return 'error: Error getting data from IONe'; + } - addinbd( $params['serviceid'], $allOptions['login'], $allOptions['password'], $result['result']['userid'], $result['result']['vmid']); + Capsule::table( 'tblhosting' ) + ->where('id',$params['serviceid']) + ->update( + array ( + 'dedicatedip' => $result->response->ip, + 'username'=>$root, + 'password'=>$passroot['password'], + 'domain'=>$result->response->ip, + ) + ); + + addinbd( $params['serviceid'], $allOptions['login'], $allOptions['password'], $result->response->userid, $result->response->vmid); + + } + else + { + return 'error: Only one account for one service'; + } - } - else { - return 'error: Only one account for one service'; - } } catch (Exception $e) @@ -387,7 +363,7 @@ function onconnector_SuspendAccount(array $params) ->where('hostingid', $params['serviceid']) ->update(['status' => 'Suspended']); - if (ctype_digit($vmid)) { + if (is_numeric($vmid)) { require_once("lib/ONConnect.php"); $onconnect = new ONConnect($params['serverip']); $result = $onconnect->Suspend($vmid, $reason); @@ -401,41 +377,43 @@ function onconnector_SuspendAccount(array $params) 'priority' => 'Medium', 'markdown' => true, ); - - $adminlog = Capsule::table('tblconfiguration')->where('setting', 'whmcs_admin')->get(); - $adminUsername = $adminlog[0]->value; + $adminlog = Capsule::table('tbladmins') + ->select('username')->where('disabled', '=', '0')->get(); + $adminUsername = $adminlog[0]->username; $results = localAPI($command, $postData, $adminUsername); return "error: Auth data is incorrect"; } + return 'success'; } function onconnector_ChangePackage(array $params) { - $onaccaunt=Capsule::table('mod_on_user') - ->select('vmid') - ->where('id_service',$params['serviceid']) - ->first(); // Getting user_id, vmid, Login, Password, - $vmid=$onaccaunt->vmid; - if(ctype_digit($vmid)) { - require_once("lib/ONConnect.php"); - $onconnect = new ONConnect($params['serverip']); - $result = $onconnect->Unsuspend($vmid); - if ($result['result']['userid']) { - Capsule::table('mod_on_user') - ->where('id_service', $params['serviceid']) - ->update( - array( - 'userid' => $result['result']['userid'], - ) - ); + $onaccaunt=Capsule::table('mod_on_user') + ->select('vmid') + ->where('id_service',$params['serviceid']) + ->first(); // Getting user_id, vmid, Login, Password, + $vmid=$onaccaunt->vmid; + if(is_numeric($vmid)) { + require_once("lib/ONConnect.php"); + $onconnect = new ONConnect($params['serverip']); + $result = $onconnect->Unsuspend($vmid); + if ($result->response->userid) { + Capsule::table('mod_on_user') + ->where('id_service', $params['serviceid']) + ->update( + array( + 'userid' => $result->response->userid, + ) + ); + } + $result = json_encode( $result ); + } + else + { + return "error: Auth data is incorrect"; } - $result = json_encode( $result ); - } - else { - return "error: Auth data is incorrect"; - } return 'success'; } @@ -453,24 +431,27 @@ function onconnector_UnsuspendAccount(array $params) $vmid = $onaccaunt->vmid; // Putting query-results to vars - if (ctype_digit($vmid)) { + if (is_numeric($vmid)) { require_once("lib/ONConnect.php"); $onconnect = new ONConnect($params['serverip']); $result = $onconnect->Unsuspend($vmid); } else { return "error: Auth data is incorrect"; } + return 'success'; } function onconnector_TerminateAccount(array $params) { + try { $onaccaunt=Capsule::table('mod_on_user')->where('id_service',$params['serviceid'])->first(); $userid=$onaccaunt->userid; $vmid=$onaccaunt->vmid; - if(ctype_digit($userid) && ctype_digit($vmid)) + + if(is_numeric($userid) && is_numeric($vmid)) { require_once( "lib/ONConnect.php" ); $onconnect = new ONConnect($params['serverip']); @@ -479,6 +460,7 @@ function onconnector_TerminateAccount(array $params) } else { + return "error: Auth data is incorrect"; } } catch (Exception $e) { @@ -495,27 +477,6 @@ function onconnector_TerminateAccount(array $params) return 'success'; } -function onconnector_TestConnection(array $params) -{ - require_once( "lib/ONConnect.php" ); - $onconnect= new ONConnect($params['serverip']); - $result=$onconnect->Test(); - if($result['result']=='PONG') - { - $success = true; - } - else - { - $success = false; - $errorMsg = $result['result'] ; - } - - return array( - 'success' => $success, - 'error' => $errorMsg, - ); -} - function onconnector_AdminCustomButtonArray() { return array( @@ -531,7 +492,7 @@ function onconnector_restart(array $params) require_once( "lib/ONConnect.php" ); $onaccaunt=Capsule::table('mod_on_user')->where('id_service',$params['serviceid'])->first(); $vmid=$onaccaunt->vmid; - if(ctype_digit($vmid)) { + if(is_numeric($vmid)) { $onconnect = new ONConnect( $params['serverip'] ); $result = $onconnect->Reboot( $vmid ); } @@ -566,7 +527,7 @@ function onconnector_down(array $params) ->where('id_service',$params['serviceid']) ->first(); $vmid=$onaccaunt->vmid; - if(ctype_digit($vmid)) { + if(is_numeric($vmid)) { $onconnect = new ONConnect( $params['serverip'] ); $result = $onconnect->Shutdown( $vmid ); } @@ -592,6 +553,7 @@ function onconnector_down(array $params) return 'success'; } + function onconnector_buttonForeFunction(array $params){ require_once("lib/ONConnect.php"); @@ -599,206 +561,31 @@ function onconnector_buttonForeFunction(array $params){ $user= 'user_'.$params['serviceid']; $result = $onconnect->getVmByName($user); - if($result['result']['vmid']!='none') { + if($result->response->vmid!='none') { Capsule::table('mod_on_user') ->where('id_service', $params['serviceid']) ->update( [ 'loginon' => $user, - 'vmid' => $result['result']['vmid'], - 'userid' => $result['result']['userid'] + 'vmid' => $result->response->vmid, + 'userid' => $result->response->userid ] ); } - if($result['result']['ip']!='nil') { + if($result->response->ip!='nil') { Capsule::table('tblhosting') ->where('id',$params['serviceid']) ->update( [ - 'dedicatedip'=>$result['result']['ip'] + 'dedicatedip'=>$result->response->ip ] ); } } -function onconnector_buttonThreeFunction(array $params) -{ - - try - { - $product=Capsule::table( 'tblproducts' ) - ->where('id',$params['packageid']) - ->first(); - - $c=strpos($product->name,"RIAL VDS"); - if (!empty($c)){ - $trial=true; - } - - $onaccaunt=Capsule::table('mod_on_user') - ->where('id_service',$params['serviceid']) - ->first(); - - $userid=$onaccaunt->userid; - $vmid=$onaccaunt->vmid; - - if (!isset($userid) || !ctype_digit($vmid)) - { - $adonbool=false; - foreach (Capsule::table( 'tblhostingaddons' ) - ->select('mod_onconfiguratorAddon.id') - ->where('tblhostingaddons.hostingid',$params['serviceid']) - ->join('mod_onconfiguratorAddon','mod_onconfiguratorAddon.Addon','=','tblhostingaddons.addonid') - ->max('price') as $item) { - $addons[]=$item->id; - } - - require_once($_SERVER['DOCUMENT_ROOT'] . '/modules/addons/oncontrol/classes/ActivateAnsible.php'); - $ansibleDB = new AutoActivateAnsible(); - $ansible = $ansibleDB->getServicesFromIds($addons); - - if ($ansible) { - $ansiblebool = true; - } - - $os=Capsule::table( 'tblhostingaddons' ) - ->select('tblhostingaddons.addonid','mod_onconfigurator.templateid','mod_onconfigurator.os') - ->where('tblhostingaddons.hostingid',$params['serviceid']) - ->where('idtariff',$params['packageid']) - ->join('mod_onconfigurator','mod_onconfigurator.addonid','=','tblhostingaddons.addonid') - ->sum('mod_onconfigurator.os'); - - if($os){ - if (stristr( $os->os, 'windows')!=false){ - $root='Administrator'; - } - else{ - $root='root'; - } - $temlaitid=$os->templateid; - } - - $pass = passgenerator(); - $user = 'user_' . $params['serviceid']; - - $postData = array( - 'password2' => passgenerator(), - ); - - - - $passroot = localAPI('EncryptPassword', $postData); - require_once("lib/ONConnect.php"); - - - $onconnect = new ONConnect( $params['serverip'],$params['serverport'] ); - - $result = $onconnect->NewAccount( $user, $pass, $temlaitid, $params['configoption1'],$postData['password2'],$trial,$ansible,$ansiblebool,$params['serviceid']); - - if($result['error']==true) - { - return 'error: '.$result['errorMessage']; - } - if($result['result']['error']=='UserAllocateError') // If user already exists; - { - return "User user_$params[serviceid] already exists in IONe"; - } - - if ($result['result']['error']=='TemplateLoadError') // If template is not set; - { - return 'error: Template error, check template in IONe configurator'; - } - - if(!$result['result']){ // If answer is empty. - return 'error: Error getting data from IONe'; - } - - Capsule::table( 'tblhosting' ) - ->where('id',$params['serviceid']) - ->update( - array ( - 'dedicatedip' => $result['result']['ip'], - 'username'=>$root, - 'password'=>$passroot['password'], - 'domain'=>$result['result']['ip'], - ) - ); - - $order=Capsule::table( 'tblhosting' ) - ->select('orderid') - ->where('id',$params['serviceid']) - ->first(); - - addinbd( $params['serviceid'], $user, $pass, $result['result']['userid'], $result['result']['vmid']); - - } - else - { - return 'error: Only one service for one account'; - } - } - - catch (Exception $e) - { - // Record the error in WHMCS's module log. - logModuleCall( - 'onconnector', - __FUNCTION__, - $params, - $e->getMessage(), - $e->getTraceAsString() - ); - - return $e->getMessage(); - } - return 'success'; -} - -function onconnector_buttonTwoFunction(array $params) -{ - try { - $onaccaunt=Capsule::table('mod_on_user')->where('id_service',$params['serviceid'])->first(); - $vmid=$onaccaunt->vmid; - if(ctype_digit($vmid)) { - require_once("lib/ONConnect.php"); - $onconnect = new ONConnect( $params['serverip'] ); - $result = $onconnect->GetIP( $vmid ); - } - else{ - return "error: Auth data is incorrect"; - } - Capsule::table( 'tblhosting' ) - ->where('id',$params['serviceid']) - ->update( - array ( - 'dedicatedip' => $result['result'], - 'username'=>'root', - 'password'=>'l+sxDZmZrK6Ch1AKRVwTatw1wPP4zlCJxaArkCsCkp1a', - 'domain'=>$result['result'], - ) ); - logModuleCall( - 'onconnector', - __FUNCTION__, - $params, - $result, - $result); - } catch (Exception $e) { - // Record the error in WHMCS's module log. - logModuleCall( - 'onconnector', - __FUNCTION__, - $params, - $e->getMessage(), - $e->getTraceAsString() - ); - - return $e->getMessage(); - } - return 'success'; -} function onconnector_AdminServicesTabFields(array $params) { @@ -814,12 +601,12 @@ function onconnector_AdminServicesTabFields(array $params) $vmid=$onaccaunt->vmid; } - $fieldsarray = array( - 'Login ON' => '', - 'Passwordon ON' => '', - 'userid ON' => '', - 'vmid ON' => '', - ); + $fieldsarray = array( + 'Login ON' => '', + 'Passwordon ON' => '', + 'userid ON' => '', + 'vmid ON' => '', + ); } catch (Exception $e) { @@ -935,15 +722,4 @@ function onconnector_ClientArea(array $params) } } -function onconnector_mycustomfunction($vars) { - return array( - 'templatefile' => 'templates/mysimplepanel', - 'breadcrumb' => array( - 'stepurl.php?action=this&var=that' => 'Custom Function', - ), - 'vars' => array( - 'test1' => 'hello', - 'test2' => 'world', - ), - ); -} +