optimize the sumbit action

This commit is contained in:
2024-07-14 19:45:14 +08:00
parent 1c086292a3
commit 1f22b6b9fd
2 changed files with 15 additions and 9 deletions
+10 -4
View File
@@ -2,6 +2,7 @@
<html>
<head>
<script src="https://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" href="favicon.ico" type="image/x-icon">
@@ -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 = "";
}
}
</script>
</head>
<body>
<iframe src="./terminal.php" onload="changeFrameHeight()" height="" width="100%" scrolling="auto" frameborder="0" id="if" name="if"></iframe>
<form method="post" action="./terminal.php" target="if">
<input name="command" required />
<input type="submit" value="Submit" />
<form method="post" action="./terminal.php" target="if" id="fm" onsubmit="return false">
<input name="command" id="command" />
</form>
</body>
+5 -5
View File
@@ -28,16 +28,16 @@ if(!opendir("fileroot")){
<body>
<?php
$pwd = file_get_contents("pwd.txt");
file_put_contents("recent.txt", $pwd . " $ " . $_POST['command'] . "<br/>", FILE_APPEND);
$commands = explode(" ", $_POST['command']);
file_put_contents("recent.txt", $pwd . " $ " . $commands[0] . "<br/>", 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 "<script>window.scrollTo(0,document.body.scrollHeight)</script>";
exit(0);
} else if ($_POST['command'] == "pwd") {
} else if ($commands[0] == "pwd") {
file_put_contents("recent.txt", $pwd . "<br/>", 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");