optimize terminal.php
This commit is contained in:
+1
-1
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
function cat($commands)
|
||||
function func($commands)
|
||||
{
|
||||
$pwd = file_get_contents("pwd.txt");
|
||||
if (sizeof($commands) > 2) {
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
function cd($commands)
|
||||
function func($commands)
|
||||
{
|
||||
if (sizeof($commands) > 2) {
|
||||
file_put_contents("recent.txt", "Invalid number of arguments.<br/>", FILE_APPEND);
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
function clear($commands)
|
||||
function func($commands)
|
||||
{
|
||||
if (sizeof($commands) == 1) {
|
||||
file_put_contents("recent.txt", "");
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
function help($commands)
|
||||
function func($commands)
|
||||
{
|
||||
$help = file_get_contents("static/terminal.php/help.txt");
|
||||
if (sizeof($commands) == 1) {
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
function ls($commands)
|
||||
function func($commands)
|
||||
{
|
||||
$pwd = file_get_contents("pwd.txt");
|
||||
if (sizeof($commands) == 1) {
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
function mdir($commands)
|
||||
function func($commands)
|
||||
{
|
||||
$pwd = file_get_contents("pwd.txt");
|
||||
if (sizeof($commands) == 2) {
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
function pwd($commands)
|
||||
function func($commands)
|
||||
{
|
||||
$pwd = file_get_contents("pwd.txt");
|
||||
if (sizeof($commands) == 1) {
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ function deleteDirectory($dir)
|
||||
}
|
||||
return rmdir($dir);
|
||||
}
|
||||
function rm($commands)
|
||||
function func($commands)
|
||||
{
|
||||
$pwd = file_get_contents("pwd.txt");
|
||||
if ($commands[1] == "-r") {
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
function touc($commands)
|
||||
function func($commands)
|
||||
{
|
||||
$pwd = file_get_contents("pwd.txt");
|
||||
if (sizeof($commands) == 2) {
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
make php
|
||||
write php
|
||||
write help.txt <command_name>.txt
|
||||
edit terminal.php
|
||||
+5
-28
@@ -40,34 +40,11 @@ if (!opendir("fileroot")) {
|
||||
echo "<script>window.scrollTo(0,document.body.scrollHeight)</script>";
|
||||
exit(0);
|
||||
}
|
||||
if ($commands[0] == "pwd") {
|
||||
include "commands/pwd.php";
|
||||
pwd($commands);
|
||||
} else if ($commands[0] == "mkdir") {
|
||||
include "commands/mkdir.php";
|
||||
mdir($commands);
|
||||
} else if ($commands[0] == "rm") {
|
||||
include "commands/rm.php";
|
||||
rm($commands);
|
||||
} else if ($commands[0] == "clear") {
|
||||
include "commands/clear.php";
|
||||
clear($commands);
|
||||
} else if ($commands[0] == "cd") {
|
||||
include "commands/cd.php";
|
||||
cd($commands);
|
||||
} else if ($commands[0] == "help") {
|
||||
include "commands/help.php";
|
||||
help($commands);
|
||||
} else if ($commands[0] == "touch") {
|
||||
include "commands/touch.php";
|
||||
touc($commands);
|
||||
} else if ($commands[0] == "cat") {
|
||||
include "commands/cat.php";
|
||||
cat($commands);
|
||||
} else if ($commands[0] == "ls") {
|
||||
include "commands/ls.php";
|
||||
ls($commands);
|
||||
} else {
|
||||
if(file_get_contents("commands/$commands[0].php") != NULL){
|
||||
include "commands/$commands[0].php";
|
||||
func($commands);
|
||||
}
|
||||
else{
|
||||
file_put_contents("recent.txt", "Unknown command.<br/>try 'help' or 'help [command]'<br/>", FILE_APPEND);
|
||||
}
|
||||
echo "<script>window.location.href=\"terminal.php\";</script>";
|
||||
|
||||
Reference in New Issue
Block a user