0

我一直在我的应用程序分支中使用 wterm,但现在猜测已经很老了并且已经停产了。我尝试迁移到 jquery-terminal,但我不太了解如何配置。

使用旧 wterm:
https ://github.com/wanderleihuttel/webacula/blob/branch-7.4/application/views/scripts/bconsole/wterminal.phtml

当前:
https ://github.com/wanderleihuttel/webacula/blob/branch-7.5/application/views/scripts/bconsole/wterminal.phtml

有一个简单的模式可以配置吗?并且只包括我允许的命令?

我目前的功能:

$('#wterm').terminal(function(command, term) {
    term.pause();
    if(command != ""){
       $.post('<?php echo $this->baseUrl, '/bconsole/cmd' ?>', {'bcommand': command, 'command': cmd }).then(function(response) {
           term.echo(response,{raw:true}).resume();
       });
    } else{
      term.exec('clear').resume();  
    } //end if
  }, 
  {
    greetings: welcome,
    prompt: 'bconsole> ',
    height: 400,
    onBlur: function(){
       return false;
    }
  }
);
4

1 回答 1

0

您可以使用它(如果您只想执行 cmd 对象列表中的命令),但如果您希望此终端是公共的,您还应该过滤服务器上的命令。

var available = Object.keys(cmd);

$('#wterm').terminal(function(command, term) {
    term.pause();
    var name = $.terminal.parse_command(command).name;
    // run only commands that are on the list
    if (available.indexOf(name) != -1) {
       $.post('<?php echo $this->baseUrl, '/bconsole/cmd' ?>', {'bcommand': command, 'command': cmd }).then(function(response) {
           term.echo(response,{raw:true}).resume();
       });
    } else{
      term.exec('clear').resume();  
    } //end if
  }, 
  {
    greetings: welcome,
    prompt: 'bconsole> ',
    height: 400,
    onBlur: function(){
       return false;
    }
  }
);
于 2017-05-09T07:25:10.673 回答