diff --git a/index.php b/index.php index 569a3e1..2e82d0b 100644 --- a/index.php +++ b/index.php @@ -2,6 +2,7 @@ + @@ -19,15 +20,20 @@ window.onresize = function() { changeFrameHeight(); } + document.onkeydown = function(e) { //对整个页面监听 + var keyNum = window.event ? e.keyCode : e.which; + if (keyNum == 13) { + document.getElementById("fm").submit(); + document.getElementById("command").value = ""; + } + } - -
- - + +
diff --git a/terminal.php b/terminal.php index 0c3c3c5..0ed826a 100644 --- a/terminal.php +++ b/terminal.php @@ -28,16 +28,16 @@ if(!opendir("fileroot")){ ", FILE_APPEND); + $commands = explode(" ", $_POST['command']); + file_put_contents("recent.txt", $pwd . " $ " . $commands[0] . "
", FILE_APPEND); $output_str = file_get_contents("recent.txt"); echo $output_str; - $commands = explode(" ", $_POST['command']); - if ($_POST['command'] == NULL) { + if ($commands[0] == NULL) { echo ""; exit(0); - } else if ($_POST['command'] == "pwd") { + } else if ($commands[0] == "pwd") { file_put_contents("recent.txt", $pwd . "
", FILE_APPEND); - } else if ($_POST['command'] == "clear") { + } else if ($commands[0] == "clear") { file_put_contents("recent.txt", ""); } else if ($commands[0] == "help") { $help = file_get_contents("static/terminal.php/help.txt");