add command:mkdir.fixbug.optimize command help

This commit is contained in:
2024-07-14 19:54:48 +08:00
parent 1f22b6b9fd
commit 1fd7ee5b66
4 changed files with 16 additions and 4 deletions
+2 -1
View File
@@ -1 +1,2 @@
help - displays the help message<br/> help - displays the help message<br/>
help [command] displays the help message for a specific command<br/>
+2
View File
@@ -0,0 +1,2 @@
mkdir - creates a new directory<br/>
if the directory already exists, an error is returned<br/>
+1
View File
@@ -1,4 +1,5 @@
clear - clears the screen<br/> clear - clears the screen<br/>
pwd - shows the working directory<br/> pwd - shows the working directory<br/>
mkdir - creates a new directory<br/>
help - displays this help message<br/> help - displays this help message<br/>
type help [command] to show more details<br/> type help [command] to show more details<br/>
+11 -3
View File
@@ -7,8 +7,8 @@ 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 (!opendir("fileroot")) {
if(!mkdir("fileroot")){ if (!mkdir("fileroot")) {
echo "Error creating directory.No permissions?"; echo "Error creating directory.No permissions?";
exit(0); exit(0);
} }
@@ -29,7 +29,7 @@ if(!opendir("fileroot")){
<?php <?php
$pwd = file_get_contents("pwd.txt"); $pwd = file_get_contents("pwd.txt");
$commands = explode(" ", $_POST['command']); $commands = explode(" ", $_POST['command']);
file_put_contents("recent.txt", $pwd . " $ " . $commands[0] . "<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;
if ($commands[0] == NULL) { if ($commands[0] == NULL) {
@@ -37,6 +37,14 @@ if(!opendir("fileroot")){
exit(0); exit(0);
} else if ($commands[0] == "pwd") { } else if ($commands[0] == "pwd") {
file_put_contents("recent.txt", $pwd . "<br/>", FILE_APPEND); file_put_contents("recent.txt", $pwd . "<br/>", FILE_APPEND);
} else if ($commands[0] == "mkdir" && sizeof($commands) == 2) {
if (!opendir("fileroot/".$commands[1])) {
if (!mkdir("fileroot/".$commands[1])) {
file_put_contents("recent.txt", "Error creating directory.No permissions?<br/>", FILE_APPEND);
}
} else {
file_put_contents("recent.txt", "Directory already exists.<br/>", FILE_APPEND);
}
} else if ($commands[0] == "clear") { } else if ($commands[0] == "clear") {
file_put_contents("recent.txt", ""); file_put_contents("recent.txt", "");
} else if ($commands[0] == "help") { } else if ($commands[0] == "help") {