2017-05-09 1 views
0

저는 응용 프로그램 포크에서 wterm을 사용하고 있었지만 지금은 매우 오래되어서 중단 된 것 같습니다. 내가 jquery - 터미널로 마이 그 레이션하려고했습니다,하지만 잘 구성하는 방법을 이해하지 못했습니다. 오래된 wterm와jQuery 터미널에서 명령을 제한하는 방법

:
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; 
    } 
    } 
); 

답변

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; 
    } 
    } 
); 
+0

감사합니다. 그것은 일했다! –

관련 문제