add a command:pwd. update the information the command help provides. optimize the file system
This commit is contained in:
+4
-1
@@ -1,4 +1,7 @@
|
|||||||
*.test.md
|
*.test.md
|
||||||
pwd.txt
|
/pwd.txt
|
||||||
recent.txt
|
recent.txt
|
||||||
.vscode
|
.vscode
|
||||||
|
tmp.txt
|
||||||
|
/fileroot/*
|
||||||
|
/fileroot
|
||||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
@@ -1,2 +0,0 @@
|
|||||||
clear - clears the screen<br/>
|
|
||||||
help - displays this help message<br/>
|
|
||||||
@@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<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">
|
||||||
<title>Terminal</title>
|
<title>Terminal</title>
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
clear - clears the screen<br/>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
help - displays the help message<br/>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
pwd - shows the working directory<br/>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
clear - clears the screen<br/>
|
||||||
|
pwd - shows the working directory<br/>
|
||||||
|
help - displays this help message<br/>
|
||||||
|
type help [command] to show more details<br/>
|
||||||
+22
-6
@@ -7,15 +7,22 @@ if (file_get_contents("recent.txt") == NULL) {
|
|||||||
if (file_get_contents("pwd.txt") == NULL) {
|
if (file_get_contents("pwd.txt") == NULL) {
|
||||||
file_put_contents("pwd.txt", "/");
|
file_put_contents("pwd.txt", "/");
|
||||||
}
|
}
|
||||||
|
if(!opendir("fileroot")){
|
||||||
|
if(!mkdir("fileroot")){
|
||||||
|
echo "Error creating directory.No permissions?";
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<link rel="preload" href="style.css" as="style" />
|
<link rel="preload" href="static/terminal.php/style.css" as="style" />
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<!-- <meta http-equiv="refresh" content="2"> -->
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<link rel="icon" href="favicon.ico" type="image/x-icon">
|
||||||
<title>frame</title>
|
<title>frame</title>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css" />
|
<link rel="stylesheet" type="text/css" href="static/terminal.php/style.css" />
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
@@ -24,14 +31,23 @@ if (file_get_contents("pwd.txt") == NULL) {
|
|||||||
file_put_contents("recent.txt", $pwd . " $ " . $_POST['command'] . "<br/>", FILE_APPEND);
|
file_put_contents("recent.txt", $pwd . " $ " . $_POST['command'] . "<br/>", FILE_APPEND);
|
||||||
$output_str = file_get_contents("recent.txt");
|
$output_str = file_get_contents("recent.txt");
|
||||||
echo $output_str;
|
echo $output_str;
|
||||||
|
$commands = explode(" ", $_POST['command']);
|
||||||
if ($_POST['command'] == NULL) {
|
if ($_POST['command'] == NULL) {
|
||||||
echo "<script>window.scrollTo(0,document.body.scrollHeight)</script>";
|
echo "<script>window.scrollTo(0,document.body.scrollHeight)</script>";
|
||||||
exit(0);
|
exit(0);
|
||||||
|
} else if ($_POST['command'] == "pwd") {
|
||||||
|
file_put_contents("recent.txt", $pwd . "<br/>", FILE_APPEND);
|
||||||
} else if ($_POST['command'] == "clear") {
|
} else if ($_POST['command'] == "clear") {
|
||||||
file_put_contents("recent.txt", "");
|
file_put_contents("recent.txt", "");
|
||||||
} else if ($_POST['command'] == "help") {
|
} else if ($commands[0] == "help") {
|
||||||
$help = file_get_contents("help.txt");
|
$help = file_get_contents("static/terminal.php/help.txt");
|
||||||
file_put_contents("recent.txt", $help, FILE_APPEND);
|
if (sizeof($commands) == 1) {
|
||||||
|
file_put_contents("recent.txt", $help, FILE_APPEND);
|
||||||
|
} else if (sizeof($commands) == 2 && file_get_contents("static/help/$commands[1].txt") != NULL) {
|
||||||
|
file_put_contents("recent.txt", file_get_contents("static/help/$commands[1].txt"), FILE_APPEND);
|
||||||
|
} else {
|
||||||
|
file_put_contents("recent.txt", "Unknown command.<br/>", FILE_APPEND);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
file_put_contents("recent.txt", "Unknown command.<br/>", FILE_APPEND);
|
file_put_contents("recent.txt", "Unknown command.<br/>", FILE_APPEND);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user