如何限制 jQuery 终端中的命令
How to limit commands in jQuery terminal
我一直在我的应用程序 fork 中使用 wterm,但现在 guess 已经过时并且已停产。我尝试迁移到 jquery-terminal,但我不太了解如何配置。
有没有简单的配置模式?并且只包含我允许的命令?
我当前的功能:
$('#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;
}
}
);
您可以使用它,(如果您只想执行 cmd 对象列表中的命令)但是如果您希望此终端成为 public,您还应该过滤服务器上的命令。 =11=]
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;
}
}
);
我一直在我的应用程序 fork 中使用 wterm,但现在 guess 已经过时并且已停产。我尝试迁移到 jquery-terminal,但我不太了解如何配置。
有没有简单的配置模式?并且只包含我允许的命令?
我当前的功能:
$('#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;
}
}
);
您可以使用它,(如果您只想执行 cmd 对象列表中的命令)但是如果您希望此终端成为 public,您还应该过滤服务器上的命令。 =11=]
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;
}
}
);