*/ class Home extends AbstractController { use WhmcsParams; use ProductService; use ApiService; use OutputBuffer; use UserService; public function index() { $view = Helper\viewIntegrationAddon(); $view->initCustomAssetFiles(); //serviceActions $view->addElement(ServiceActions::class); // serviceInformationDataTable $view->addElement(ServiceInformation::class); $view->addElement(IpAddressDataTable::class); $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) { } } $view->addElement(ReinstallTab::class); } else { $view->addElement(TemplateDataTable::class); } $view->addElement(CpuGraph::class) ->addElement(MemoryGraph::class) ->addElement(NetworkGraph::class) ->addElement(DiskGraph::class) ->addElement(UserDataTable::class); return $view; } public function novnc() { $this->cleanOutputBuffer(); $this->acl()->novnc(); $this->console(['novnc' => 1]); } public function xtermjs() { $this->cleanOutputBuffer(); $this->acl()->novnc(); $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(); } }