public function prepareView(\Nethgui\View\ViewInterface $view)
 {
     parent::prepareView($view);
     if ($this->getRequest()->isValidated()) {
         $view['cert'] = $this->getCertPath();
     }
 }
示例#2
0
 public function prepareView(\Nethgui\View\ViewInterface $view)
 {
     parent::prepareView($view);
     if (isset($this->parameters['name'])) {
         $view['SetDefault'] = $view->getModuleUrl('../SetDefault/' . $this->parameters['name']);
         $view['x509text'] = $this->getX509text();
     }
     $view['GenerateLink'] = $view->getModuleUrl('../Generate');
 }
 public function prepareView(\Nethgui\View\ViewInterface $view)
 {
     parent::prepareView($view);
     $name = \Nethgui\array_head($this->getRequest()->getPath());
     $view['ovpn'] = $view->getModuleUrl('/VPN/Accounts/download/ovpn/' . $name);
     $view['pem'] = $view->getModuleUrl('/VPN/Accounts/download/pem/' . \Nethgui\array_head($this->getRequest()->getPath()));
     $view['ca'] = $view->getModuleUrl('/VPN/Accounts/download/ca/' . \Nethgui\array_head($this->getRequest()->getPath()));
     $view['pkcs12'] = $view->getModuleUrl('/VPN/Accounts/download/pkcs12/' . \Nethgui\array_head($this->getRequest()->getPath()));
     if ($this->getRequest()->isValidated()) {
         $command = "";
         $file = "";
         $path = $this->getRequest()->getPath();
         $name = array_pop($path);
         $type = array_pop($path);
         $mime = 'text/plain; charset=UTF-8';
         switch ($type) {
             case 'ovpn':
                 $command = $this->prepareCommand("/usr/libexec/nethserver/openvpn-local-client", array($name));
                 $mime = 'application/x-openvpn-profile';
                 $file = "{$name}.ovpn";
                 break;
             case 'ca':
                 $command = $this->prepareCommand("/bin/cat", array("/etc/pki/tls/certs/NSRV.crt"));
                 $mime = 'application/x-pem-file';
                 $file = "ca.crt";
                 break;
             case 'pem':
                 $command = $this->prepareCommand("/bin/cat", array("/var/lib/nethserver/certs/{$name}.key", "/var/lib/nethserver/certs/{$name}.crt", "/etc/pki/tls/certs/NSRV.crt"));
                 $file = "{$name}.pem";
                 $mime = 'application/x-pem-file';
                 break;
             case 'pkcs12':
                 $command = $this->prepareCommand("/bin/cat", array("/var/lib/nethserver/certs/{$name}.p12"));
                 $file = "{$name}.p12";
                 $mime = 'application/x-pkcs12';
                 break;
         }
         $view->getCommandList('/Main')->setDecoratorTemplate(function (\Nethgui\View\ViewInterface $view) use($command, $file, $mime) {
             // Discard any output buffer:
             while (ob_get_level() > 0) {
                 ob_end_clean();
             }
             header(sprintf('Content-type: %s', $mime));
             header('Content-Disposition: attachment; filename="' . $file . '"');
             passthru($command);
             exit(0);
         });
     }
 }
 protected function onParametersSaved($changedParameters)
 {
     parent::onParametersSaved($changedParameters);
     $this->getPlatform()->signalEvent('interface-update &');
 }
示例#5
0
 public function prepareView(\Nethgui\View\ViewInterface $view)
 {
     parent::prepareView($view);
     if (!$this->getRequest()->isMutation() && $this->getRequest()->isValidated()) {
         $view['deviceInfos'] = $this->getNicInfo($view);
     }
     $view['bootproto'] = $view['bootproto'] ? $view['bootproto'] : 'none';
     $view['roleDatasource'] = array_map(function ($fmt) use($view) {
         return array($fmt, $view->translate($fmt . '_label'));
     }, $this->getParent()->getInterfaceRoles());
 }
示例#6
0
 public function prepareView(\Nethgui\View\ViewInterface $view)
 {
     parent::prepareView($view);
     if ($view->getTargetFormat() === $view::TARGET_XHTML) {
         $view['__key'] = $this->getKey();
     }
 }
 public function prepareView(\Nethgui\View\ViewInterface $view)
 {
     $view['account'] = "";
     parent::prepareView($view);
 }
 public function prepareView(\Nethgui\View\ViewInterface $view)
 {
     $view->setTemplate('NethServer\\Template\\Dhcp\\Modify');
     parent::prepareView($view);
 }
 public function prepareView(\Nethgui\View\ViewInterface $view)
 {
     parent::prepareView($view);
     $view['pf'] = '';
 }