*/ class Home extends AbstractController { use WhmcsParams; use ProductService; use ApiService; use OutputBuffer; use UserService; use BaseClientController; use LicenseValidator; /** * @var ModuleSettingRepository */ protected $moduleSetting; public function index() { $view = Helper\viewIntegrationAddon(); $view->initCustomAssetFiles(); $this->moduleSetting = new ModuleSettingRepository(); //serviceActions if($this->moduleSetting->isPermissionServiceActions() ){ $view->addElement(ServiceActions::class); } // serviceInformationDataTable if($this->moduleSetting->isPermissionInformation()){ $view->addElement(ServiceInformation::class); } if($this->moduleSetting->isPermissionIpAddresses()){ $view->addElement(IpAddressDataTable::class); } if($this->moduleSetting->isPermissionIpSet()){ $view->addElement(IpSetDataTable::class); } if ($this->vm() instanceof Kvm) { if ($this->vm()->config()['agent'] == 1) { try { $this->vm()->agent()->getHostname(); $view->addElement(NetworkInterfacesDataTable::class); } catch (\Exception $ex) { } } if($this->moduleSetting->isPermissionReinstall()){ $view->addElement(ReinstallTab::class); } } else if($this->moduleSetting->isPermissionReinstall() && $this->vm() instanceof Lxc){ $view->addElement(TemplateDataTable::class); } if($this->moduleSetting->isPermissionGraph()){ $view->addElement(CpuGraph::class) ->addElement(MemoryGraph::class) ->addElement(NetworkGraph::class) ->addElement(DiskGraph::class); } if($this->moduleSetting->isPermissionUserDetails()){ $view->addElement(UserDataTable::class); } return $view; } public function novnc() { $this->cleanOutputBuffer(); $this->acl()->novnc(); $this->moduleSetting = new ModuleSettingRepository(); if($this->moduleSetting->getConsoleApiKey() && $this->moduleSetting->consoleHost && $this->isLicensePayingFullAnnuallyPrice()){ $this->novncProxy(); } $this->console(['novnc' => 1]); } public function xtermjs() { $this->cleanOutputBuffer(); $this->acl()->novnc(); $this->moduleSetting = new ModuleSettingRepository(); if($this->moduleSetting->getConsoleApiKey() && $this->moduleSetting->consoleHost){ $this->xtermjsProxy(); } $this->console(['xtermjs' => 1]); } private function console($request = []) { $serverHost = $this->getWhmcsParamByKey('serverip') ? $this->getWhmcsParamByKey('serverip') : $this->getWhmcsParamByKey('serverhostname'); //Host $consoleHost = $this->getWhmcsParamByKey('serverhostname') ? $this->getWhmcsParamByKey('serverhostname') : $this->getWhmcsParamByKey('serverip'); if ($this->configuration()->getConsoleHost()) { $consoleHost = $this->configuration()->getConsoleHost(); } //Port $consolePort = 8006; if(is_numeric($this->getWhmcsParamByKey('serverport'))){ $consolePort = $this->getWhmcsParamByKey('serverport'); } if (preg_match('/\:/', $consoleHost)) { $ex = explode(":", $consoleHost); $consoleHost = $ex['0']; $consolePort = $ex['1']; } try { //User $vpsUser = $this->getUser(); if (empty($vpsUser->username)) { throw new \Exception('User does not have permissions to access noVNC console'); } //Load Users API if(!preg_match('/\:/', $serverHost) && $this->getWhmcsParamByKey('serverport') ){ $serverHost .=":".$this->getWhmcsParamByKey('serverport'); } $api = new Api($serverHost, $vpsUser->username, $vpsUser->realm, $vpsUser->getPassword()); $api->debug(ModuleSettings::isDebug()); //User Authorization $ticket = $api->getLoginTicket(); $request['token'] = $ticket['ticket']; $request['CSRFPreventionToken'] = $ticket['CSRFPreventionToken']; $request['console'] = $this->vm()->getVirtualization(); /* @deprecated $vars['virtualization'] since version 2.6.0 */ $request['virtualization'] = $this->vm()->getVirtualization(); $request['node'] = $this->vm()->getNode(); $request['vmid'] = $this->vm()->getVmid(); } catch (\Exception $ex) { $request['error'] = $ex->getMessage(); } $response = new RedirectResponse("https://{$consoleHost}:{$consolePort}/novnc/mgnovnc.html?" . http_build_query($request)); $response->send(); } }