diff --git a/README.md b/README.md index 26f002e..525bf61 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Notes: 1. Allow for move and copy. 3. Fix the ' and & naming issue. 4. Implement themes functionality. -5. Look to refactor code. + # Images ![1 Home](Images/1.png) diff --git a/index.html b/index.html index 4573ac3..8248e6b 100644 --- a/index.html +++ b/index.html @@ -20,9 +20,9 @@
- - - + + +
    Path:   @@ -46,11 +46,11 @@ - + - - + + + - diff --git a/resources/css/main.css b/resources/css/main.css index 9517dfa..42c976e 100644 --- a/resources/css/main.css +++ b/resources/css/main.css @@ -82,6 +82,11 @@ #imgView { overflow: hidden; left: 15em; } +#NewItem { + background-color: #ffffff; + color: #000000; + text-align: center; +} /* Classes */ .imgViewImg { diff --git a/resources/js/ajax.js b/resources/js/ajax.js index 6efc1af..4a3d1a6 100644 --- a/resources/js/ajax.js +++ b/resources/js/ajax.js @@ -1,24 +1,37 @@ var pathNodes = []; +// SSE events if supported +if(typeof(EventSource) !== "undefined") { + var source = new EventSource("resources/php/sse.php"); + source.onmessage = function(event) { + if (event.data === "updateListing") { + getDir("./"); + } + }; +} else { + console.log("SSE Not Supported In Browser..."); +} + function getDir(query) { - var formULPTH = document.getElementById("DIRPATHUL"); + var formUlPth = document.getElementById("DIRPATHUL"); var path = ""; - var temp = ""; + var cookies = ""; + var dirCookie = ""; // push or pop to path list if (query === "/") { // Process path from cookie and set to array/list - if (document.cookie) { - temp = document.cookie.replace("dirQuery=", ""); - temp = temp.split("/"); - // Subtract one b/c paths end with / and create empty slot - var size = temp.length - 1; + dirCookie = getCookie("dirQuery"); + if (dirCookie != "" && dirCookie != "./") { + dirCookie = dirCookie.split("/"); + dirCookie.pop(); // account for ending empty slot + var size = dirCookie.length; for (var i = 0; i < size; i++) { - pathNodes.push(temp[i] + "/"); + pathNodes.push(dirCookie[i] + "/"); } - // If no cookie, setup path from root } else { + pathNodes = []; pathNodes.push("." + query); } } else if (query === "../") { @@ -34,18 +47,11 @@ function getDir(query) { // Create path from array of items for (pathNode of pathNodes) { - path += pathNode; console.log(pathNode); + path += pathNode; } - // For some reason, PHPSESSID= gets inserted when in sub dir. - // temp work arround is to trim it. - if (path.includes("PHPSESSID=")) { - path = path.split("; ").pop(); - } - - formULPTH.value = path; // Setup upload path for form + formUlPth.value = path; // Setup upload path for form path = "dirQuery=" + path; - console.log("Path : " + path); process(path); } @@ -66,7 +72,7 @@ function process(path) { } } }; - xhttp.open("POST", "resources/php/process.php", true); // Open the connection + xhttp.open("POST", "resources/php/getDirList.php", true); // Open the connection xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xhttp.overrideMimeType('application/xml'); // Force return to be XML xhttp.send(path); // Start the process diff --git a/resources/js/cookieHandler.js b/resources/js/cookieHandler.js new file mode 100644 index 0000000..2f7f011 --- /dev/null +++ b/resources/js/cookieHandler.js @@ -0,0 +1,15 @@ +function getCookie(cname) { + var name = cname + "="; + var decodedCookie = decodeURIComponent(document.cookie); + var ca = decodedCookie.split(';'); + for(var i = 0; i diff --git a/resources/php/upload.php b/resources/php/filesystemActions.php old mode 100755 new mode 100644 similarity index 55% rename from resources/php/upload.php rename to resources/php/filesystemActions.php index fc8a2f5..1fddb9a --- a/resources/php/upload.php +++ b/resources/php/filesystemActions.php @@ -1,7 +1,39 @@ " . "" @@ -61,12 +93,42 @@ function uploadFiles($targetDir) { echo ""; } -// Check access type. +// Local program file access +function openFile($FILE) { + include 'config.php'; + $EXTNSN = strtolower(pathinfo($FILE, PATHINFO_EXTENSION)); + + if (preg_match('(mkv|avi|flv|mov|m4v|mpg|wmv|mpeg|mp4|webm)', $EXTNSN) === 1) { + shell_exec($MEDIAPLAYER . $MPLAYER_WH . "\"" . $FILE . "\" > /dev/null &"); + } else if (preg_match('(png|jpg|jpeg|gif)', $EXTNSN) === 1) { + shell_exec($IMGVIEWER . ' "' . $FILE . '" > /dev/null &'); + } else if (preg_match('(psf|mp3|ogg|flac)', $EXTNSN) === 1) { + shell_exec($MUSICPLAYER . ' "' . $FILE . '" > /dev/null &'); + } else if (preg_match('(odt|doc|docx|rtf)', $EXTNSN) === 1) { + shell_exec($OFFICEPROG . ' "' . $FILE . '" > /dev/null &'); + } else if (preg_match('(txt)', $EXTNSN) === 1) { + shell_exec($TEXTVIEWER . ' "' . $FILE . '" > /dev/null &'); + } else if (preg_match('(pdf)', $EXTNSN) === 1) { + shell_exec($PDFVIEWER . ' "' . $FILE . '" > /dev/null &'); + } +} + + chdir("../../"); -if(isset($_POST["UploadFiles"]) && isset($_POST["DIRPATHUL"])) { +if (isset($_POST["createItem"]) && isset($_POST["item"]) && isset($_POST["type"])) { + createItem($_POST["item"], $_POST["type"]); +} else if (isset($_POST["deleteItem"]) && isset($_POST["item"])) { + deleteItem($_POST["item"]); +} else if (isset($_POST["renameItem"]) && isset($_POST["oldName"]) && isset($_POST["newName"]) && isset($_POST["path"])) { + renameItem($_POST["oldName"], $_POST["newName"], $_POST["path"]); +} else if(isset($_POST["UploadFiles"]) && isset($_POST["DIRPATHUL"])) { uploadFiles($_POST["DIRPATHUL"]); +} else if (isset($_POST["media"])) { + openFile($_POST["media"]); } else { echo "Server: [Error] --> Incorrect access attempt!"; } + + ?> diff --git a/resources/php/process.php b/resources/php/getDirList.php similarity index 100% rename from resources/php/process.php rename to resources/php/getDirList.php diff --git a/resources/php/newFileOrDir.php b/resources/php/newFileOrDir.php deleted file mode 100644 index 7382acb..0000000 --- a/resources/php/newFileOrDir.php +++ /dev/null @@ -1,23 +0,0 @@ - diff --git a/resources/php/open.php b/resources/php/open.php deleted file mode 100644 index 8c98cc9..0000000 --- a/resources/php/open.php +++ /dev/null @@ -1,28 +0,0 @@ - /dev/null &"); - } else if (preg_match('(png|jpg|jpeg|gif)', $EXTNSN) === 1) { - shell_exec($IMGVIEWER . ' "' . $FILE . '" > /dev/null &'); - } else if (preg_match('(psf|mp3|ogg|flac)', $EXTNSN) === 1) { - shell_exec($MUSICPLAYER . ' "' . $FILE . '" > /dev/null &'); - } else if (preg_match('(odt|doc|docx|rtf)', $EXTNSN) === 1) { - shell_exec($OFFICEPROG . ' "' . $FILE . '" > /dev/null &'); - } else if (preg_match('(txt)', $EXTNSN) === 1) { - shell_exec($TEXTVIEWER . ' "' . $FILE . '" > /dev/null &'); - } else if (preg_match('(pdf)', $EXTNSN) === 1) { - shell_exec($PDFVIEWER . ' "' . $FILE . '" > /dev/null &'); - } -} - - -chdir("../../"); -if (isset($_POST["media"])) { - openFile($_POST["media"]); -} - -?> diff --git a/resources/php/rename.php b/resources/php/rename.php deleted file mode 100644 index ab3b770..0000000 --- a/resources/php/rename.php +++ /dev/null @@ -1,15 +0,0 @@ -