diff --git a/index.html b/index.html index 7bd2c78..1765c12 100644 --- a/index.html +++ b/index.html @@ -15,6 +15,13 @@
+
+
+ Terminal + +
+ +
Message
diff --git a/readme.md b/readme.md index 5b02260..0780b65 100644 --- a/readme.md +++ b/readme.md @@ -13,11 +13,22 @@ Simply put it in the public Directory and enjoy. - [x] Delete Files - [x] create new file - [x] create new folder -- [] rename file -- [] unzip files -- [] add mobile fileupload +- [x] In-built Shell +- [ ] rename file +- [ ] unzip files +- [ ] add mobile fileupload ### Attribution -File icons created by Dimitry Miroliubov - Flaticon -Folder icons created by kumakamu - Flaticon -Large File Upload by fcup on github by lovefc \ No newline at end of file +File icons created by Dimitry Miroliubov - Flaticon
+Folder icons created by kumakamu - Flaticon
+Large File Upload - fcup on by lovefc
+Terminal - p0wny-shell by flozz
+ + + + + +## logs + +-- added Terminal (Feb 15 2023) + diff --git a/src/css/style.css b/src/css/style.css index 2945fdb..0c2b948 100644 --- a/src/css/style.css +++ b/src/css/style.css @@ -29,7 +29,22 @@ overflow: hidden; display: none; } - +.iframe{ + padding: 5px; + position: absolute; + bottom: 0%; + right: 0%; + z-index: 9999; + background: #222; + width: 79%; + border-radius : 12px 0px; +} +.iframe iframe{ + width: 100%; +} +.iframe div span{ + color : white; +} .container .save{ position: absolute; bottom: 5%; @@ -171,4 +186,7 @@ .modal { width: 250px; } + .iframe { + width: 99%; + } } \ No newline at end of file diff --git a/src/js/init.js b/src/js/init.js index f89a9de..756ccc4 100644 --- a/src/js/init.js +++ b/src/js/init.js @@ -2,7 +2,7 @@ import db from "./tinylib.js" const codeEditor = { // To add a custom path edit currentDir key EX : "/var/user/home/" // leave null to auto detect server root path - currentDir: null, + currentDir: "C:/xampp/htdocs/php/CodeEditor", rootPath: null, selectedFile: null, fileIcon: (ext, name = null) => { @@ -280,7 +280,23 @@ const codeEditor = { document.body.style.border = "0px solid green" let files = event.dataTransfer.files; this.upload(files) - }) + }); + + + let isClosed = false; + document.getElementById("close-shell").onclick = () => { + if(!isClosed){ + document.querySelector('#terminal').style.display = "none"; + document.querySelector('#close-shell').innerHTML = "⇈"; + isClosed = true; + }else{ + document.querySelector('#close-shell').innerHTML = "×"; + document.querySelector('#terminal').style.display = "block"; + isClosed = false; + } + } + + }, previousDir: function () { diff --git a/src/php/shell.php b/src/php/shell.php new file mode 100644 index 0000000..a9f9cf2 --- /dev/null +++ b/src/php/shell.php @@ -0,0 +1,516 @@ +&1)?$/", $cmd)) { + chdir(expandPath("~")); + } elseif (preg_match("/^\s*cd\s+(.+)\s*(2>&1)?$/", $cmd)) { + chdir($cwd); + preg_match("/^\s*cd\s+([^\s]+)\s*(2>&1)?$/", $cmd, $match); + chdir(expandPath($match[1])); + } elseif (preg_match("/^\s*download\s+[^\s]+\s*(2>&1)?$/", $cmd)) { + chdir($cwd); + preg_match("/^\s*download\s+([^\s]+)\s*(2>&1)?$/", $cmd, $match); + return featureDownload($match[1]); + } else { + chdir($cwd); + exec($cmd, $stdout); + } + + return array( + "stdout" => $stdout, + "cwd" => getcwd() + ); +} + +function featurePwd() { + return array("cwd" => getcwd()); +} + +function featureHint($fileName, $cwd, $type) { + chdir($cwd); + if ($type == 'cmd') { + $cmd = "compgen -c $fileName"; + } else { + $cmd = "compgen -f $fileName"; + } + $cmd = "/bin/bash -c \"$cmd\""; + $files = explode("\n", shell_exec($cmd)); + return array( + 'files' => $files, + ); +} + +function featureDownload($filePath) { + $file = @file_get_contents($filePath); + if ($file === FALSE) { + return array( + 'stdout' => array('File not found / no read permission.'), + 'cwd' => getcwd() + ); + } else { + return array( + 'name' => basename($filePath), + 'file' => base64_encode($file) + ); + } +} + +function featureUpload($path, $file, $cwd) { + chdir($cwd); + $f = @fopen($path, 'wb'); + if ($f === FALSE) { + return array( + 'stdout' => array('Invalid path / no write permission.'), + 'cwd' => getcwd() + ); + } else { + fwrite($f, base64_decode($file)); + fclose($f); + return array( + 'stdout' => array('Done.'), + 'cwd' => getcwd() + ); + } +} + +if (isset($_GET["feature"])) { + + $response = NULL; + + switch ($_GET["feature"]) { + case "shell": + $cmd = $_POST['cmd']; + if (!preg_match('/2>/', $cmd)) { + $cmd .= ' 2>&1'; + } + $response = featureShell($cmd, $_POST["cwd"]); + break; + case "pwd": + $response = featurePwd(); + break; + case "hint": + $response = featureHint($_POST['filename'], $_POST['cwd'], $_POST['type']); + break; + case 'upload': + $response = featureUpload($_POST['path'], $_POST['file'], $_POST['cwd']); + } + + header("Content-Type: application/json"); + echo json_encode($response); + die(); +} + +?> + + + + + + p0wny@shell:~# + + + + + + + +
+
+  
+            
+
+ +
+ +
+
+
+ + +