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