=$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 @@
-
-
-}
-
-$start = microtime(true);
-vmlist_javaScripts();
-$cloudlink = Capsule::table('tblconfiguration')
- ->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'];
-?>
-
-
-
-
-
-
-
- =$LANG['thClientsId']?>
- =$LANG['thHostingId']?>
- =$LANG['thLoginOpenNebula']?>
- =$LANG['thUserIdOpenNebula']?>
- =$LANG['thVmidOpenNebula']?>
- =$LANG['thStatusOpenNebula']?>
- =$LANG['thStatusWHMCS']?>
- =$LANG['thHost']?>
- =$LANG['thIpAddress']?>
- =$LANG['thDo']?>
-
-
-
-
-
- =$oneUser->userid?>
- =$oneUser->id_service?>
- =$oneUser->loginon?>
- =$oneUser->useridOn?>
- =$oneUser->vmid?>
- =$oneUser->state?>
- =$oneUser->domainstatus?>
- =$oneUser->host?>
- =$oneUser->dedicatedip?>
-
- =$LANG['modEdit']?>
-
-
-
-
-
-
-
-print ($LANG['timescript'].': '.(microtime(true) - $start).' '.$LANG['second'] );
+
+
+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'];
+?>
+
+
+
+
+
+
+
+ =$LANG['thClientsId']?>
+ =$LANG['thHostingId']?>
+ =$LANG['thLoginOpenNebula']?>
+ =$LANG['thUserIdOpenNebula']?>
+ =$LANG['thVmidOpenNebula']?>
+ =$LANG['thStatusOpenNebula']?>
+ =$LANG['thStatusWHMCS']?>
+ =$LANG['thHost']?>
+ =$LANG['thIpAddress']?>
+ =$LANG['thDo']?>
+
+
+
+
+
+ =$oneUser->userid?>
+ =$oneUser->id_service?>
+ =$oneUser->loginon?>
+ =$oneUser->useridOn?>
+ =$oneUser->vmid?>
+ =$oneUser->state?>
+ =$oneUser->domainstatus?>
+ =$oneUser->host?>
+ =$oneUser->dedicatedip?>
+
+ =$LANG['modEdit']?>
+
+
+
+
+
+
+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',
- ),
- );
-}
+