-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathterminal.php
54 lines (51 loc) · 1.66 KB
/
terminal.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!DOCTYPE html>
<?php
ini_set("display_errors", "Off");
if (file_get_contents("recent.txt") == NULL) {
file_put_contents("recent.txt", "Welcome to the terminal!<br/>Type 'help' to see a list of commands.<br/>");
}
if (file_get_contents("pwd.txt") == NULL) {
file_put_contents("pwd.txt", "/");
}
$pwd = file_get_contents("pwd.txt");
if (!opendir("fileroot" . $pwd)) {
!file_put_contents("pwd.txt", "/");
}
if (!opendir("fileroot")) {
if (!mkdir("fileroot")) {
echo "Error creating directory.No permissions?";
exit(0);
}
}
?>
<html>
<head>
<link rel="preload" href="static/terminal.php/style.css" as="style" />
<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>frame</title>
<link rel="stylesheet" type="text/css" href="static/terminal.php/style.css" />
</head>
<body>
<?php
$pwd = file_get_contents("pwd.txt");
$commands = explode(" ", $_POST['command']);
file_put_contents("recent.txt", $pwd . " $ " . $_POST['command'] . "<br/>", FILE_APPEND);
$output_str = file_get_contents("recent.txt");
echo $output_str;
if ($commands[0] == NULL) {
echo "<script>window.scrollTo(0,document.body.scrollHeight)</script>";
exit(0);
}
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>";
?>
</body>
</html>