"
+ + iconImg
+ + "
"
+ + "";
}
}
}
diff --git a/resources/js/controlers.js b/resources/js/controlers.js
deleted file mode 100644
index 560c517..0000000
--- a/resources/js/controlers.js
+++ /dev/null
@@ -1,82 +0,0 @@
-function showImg(imgLoc) {
- var imgView = document.getElementById("imgView");
- var toPlayerButton = "
∽
";
- var popButton = "
↗
";
- var CloseBttn = "
X
";
-
- imgView.style.display = "block";
- imgView.innerHTML = CloseBttn + popButton + toPlayerButton;
- imgView.innerHTML += "
";
-
- dragContainer(imgView); // Set for dragging events
-}
-
-function showMedia(media) {
- var tempRef = media.toLowerCase();
- if (tempRef.includes(".mkv") || tempRef.includes(".avi") || tempRef.includes(".flv") ||
- tempRef.includes(".mov") || tempRef.includes(".m4v") || tempRef.includes(".mpg") ||
- tempRef.includes(".wmv") || tempRef.includes(".mpeg") || tempRef.includes(".psf")) {
- openInLocalProg(media);
- } else {
- var mediaView = document.getElementById("fileView");
- var toPlayerButton = "
∽
";
- var popButton = "
↗
";
- var CloseBttn = "
X
";
-
- mediaView.style.display = "block";
- mediaView.innerHTML = CloseBttn + popButton + toPlayerButton;
- mediaView.innerHTML += "
";
-
- dragContainer(mediaView); // Set for dragging events
- }
-}
-
-function openInLocalProg(media) {
- var xhttp = new XMLHttpRequest();
-
- xhttp.open("POST", "resources/php/open.php", true);
- xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
- xhttp.send("media=" + media);
-}
-
-function tgglServerMsgView() {
- var serverMsgView = document.getElementById("toggleServerMsg");
- if (serverMsgView.style.display == "none") {
- serverMsgView.style.display = "block";
- } else {
- serverMsgView.style.display = "none";
- }
-}
-
-function closeImg() {
- var imgView = document.getElementById("imgView");
- imgView.style.display = "none";
-}
-
-function closeMedia() {
- var mediaView = document.getElementById("fileView");
- mediaView.style.display = "none";
- mediaView.children[3].src = "";
-}
-
-function clearDirCookie() {
- var expireDate = "Thu, 01 Jan 1970 00:00:00 UTC";
- document.cookie = "dirQuery=; expires=" + expireDate;
- location.reload();
-}
-
-function onloadSetBG() { updateBG("resources/images/backgrounds/000.jpg"); }
-function updateBG(bgImg) { document.getElementById("bg").src = bgImg; }
-
-
-// SSE events if supported
-if(typeof(EventSource) !== "undefined") {
- var source = new EventSource("resources/php/sse.php");
- source.onmessage = function(event) {
- if (event.data === "updateListing") {
- getDirSSE();
- }
- };
-} else {
- console.log("SSE Not Supported In Browser...");
-}
diff --git a/resources/js/dragContainer.js b/resources/js/dragContainerEvents.js
similarity index 100%
rename from resources/js/dragContainer.js
rename to resources/js/dragContainerEvents.js
diff --git a/resources/js/fileSystemControls.js b/resources/js/fileSystemControls.js
new file mode 100644
index 0000000..0737ad9
--- /dev/null
+++ b/resources/js/fileSystemControls.js
@@ -0,0 +1,128 @@
+var formerFileName = "";
+
+function showImg(imgLoc) {
+ var path = document.getElementById("path").innerHTML;
+ var imgView = document.getElementById("imgView");
+ var fullImage = path + imgLoc;
+ var toPlayerButton = "
∽
";
+ var popButton = "
↗
";
+ var CloseBttn = "
X
";
+ imgView.style.display = "block";
+ imgView.innerHTML = CloseBttn + popButton + toPlayerButton;
+
+ imgView.innerHTML += "
";
+ dragContainer(imgView); // Set for dragging events
+}
+
+function showMedia(media) {
+ var path = document.getElementById("path").innerHTML;
+ var tempRef = media.toLowerCase();
+ var fullMedia = path + media;
+
+ if (tempRef.includes(".mp4") || tempRef.includes(".webm") ||
+ tempRef.includes(".mp3") || tempRef.includes(".ogg") ||
+ tempRef.includes(".pdf") || tempRef.includes(".flac")) {
+ var mediaView = document.getElementById("fileView");
+ var toPlayerButton = "
∽
";
+ var popButton = "
↗
";
+ var CloseBttn = "
X
";
+
+ mediaView.style.display = "block";
+ mediaView.innerHTML = CloseBttn + popButton + toPlayerButton;
+ mediaView.innerHTML += "
";
+
+ dragContainer(mediaView); // Set for dragging events
+ } else {
+ openInLocalProg(fullMedia);
+ }
+}
+
+function openInLocalProg(media) {
+ var xhttp = new XMLHttpRequest();
+
+ xhttp.open("POST", "resources/php/open.php", true);
+ xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+ xhttp.send("media=" + media);
+}
+
+function enableEdit(obj) {
+ obj.style.backgroundColor = "#ffffffff";
+ obj.style.color = '#000000ff';
+ obj.readOnly = '';
+ formerFileName = obj.value;
+}
+
+function disableEdits(obj) {
+ obj.style.backgroundColor = "#ffffff00";
+ obj.style.color = '#ffffff';
+ obj.value = formerFileName;
+ obj.readOnly = "true";
+}
+
+function renameItem(obj) {
+ var path = document.getElementById("path").innerHTML;
+ var oldName = formerFileName;
+ var newName = obj.value;
+ var formData = "oldName=" + oldName + "&newName=" + newName + "&path=" + path;
+ var xhttp = new XMLHttpRequest();
+
+ console.log("Old name: " + oldName);
+ console.log("New name: " + newName);
+
+ xhttp.open("POST", "resources/php/rename.php", false);
+ xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+ xhttp.send(formData);
+
+ getDirSSE();
+}
+
+function createDir() {
+ var path = document.getElementById("path").innerHTML;
+ var newItem = document.getElementById("NewItem").value;
+ var fullPth = path + newItem;
+ var xhttp = new XMLHttpRequest();
+
+ xhttp.open("POST", "resources/php/newFileOrDir.php", false);
+ xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+ xhttp.send("item=" + fullPth + "&isDir=dir");
+ getDirSSE();
+}
+
+function createFile() {
+ var path = document.getElementById("path").innerHTML;
+ var newItem = document.getElementById("NewItem").value;
+ var fullPth = path + newItem;
+
+ var xhttp = new XMLHttpRequest();
+
+ xhttp.open("POST", "resources/php/newFileOrDir.php", false);
+ xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+ xhttp.send("item=" + fullPth + "&isFile=file");
+ getDirSSE();
+}
+
+function startDeleteItem(item) {
+ // Get the item name
+ itemObj = item;
+}
+
+function deleteItem(item) {
+ var path = document.getElementById("path").innerHTML;
+
+ // Clicked yes to delete and there is an item
+ if (itemObj != undefined && itemObj != null) {
+ var fullPth = path + itemObj;
+ var answer = confirm("Are you sure you want to delete: " + fullPth);
+ if (answer == true) {
+ var xhttp = new XMLHttpRequest();
+
+ xhttp.open("POST", "resources/php/delete.php", false);
+ xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+ xhttp.send("item=" + fullPth);
+
+ console.log("Deleted: " + fullPth);
+ itemObj = null;
+ getDirSSE();
+ }
+ }
+}
diff --git a/resources/js/uiControls.js b/resources/js/uiControls.js
new file mode 100644
index 0000000..40e0205
--- /dev/null
+++ b/resources/js/uiControls.js
@@ -0,0 +1,46 @@
+
+function tgglServerMsgView() {
+ var serverMsgView = document.getElementById("toggleServerMsg");
+ if (serverMsgView.style.display == "none") {
+ serverMsgView.style.display = "block";
+ } else {
+ serverMsgView.style.display = "none";
+ }
+}
+
+function closeImg() {
+ var imgView = document.getElementById("imgView");
+ imgView.style.display = "none";
+}
+
+function closeMedia() {
+ var mediaView = document.getElementById("fileView");
+ mediaView.style.display = "none";
+ mediaView.children[3].src = "";
+}
+
+function clearDirCookie() {
+ var expireDate = "Thu, 01 Jan 1970 00:00:00 UTC";
+ document.cookie = "dirQuery=; expires=" + expireDate;
+ location.reload();
+}
+
+function clearDlList() {
+ document.getElementById("CLEARBTTN").click();
+}
+
+function onloadSetBG() { updateBG("resources/images/backgrounds/000.jpg"); }
+function updateBG(bgImg) { document.getElementById("bg").src = bgImg; }
+
+
+// SSE events if supported
+if(typeof(EventSource) !== "undefined") {
+ var source = new EventSource("resources/php/sse.php");
+ source.onmessage = function(event) {
+ if (event.data === "updateListing") {
+ getDirSSE();
+ }
+ };
+} else {
+ console.log("SSE Not Supported In Browser...");
+}
diff --git a/resources/js/uiEvents.js b/resources/js/uiEvents.js
new file mode 100644
index 0000000..2600787
--- /dev/null
+++ b/resources/js/uiEvents.js
@@ -0,0 +1,49 @@
+// ondblclick
+document.onclick = function (event) {
+ var obj = event.target;
+ var callingID = obj.id;
+ var classNM = obj.className;
+
+ // Left click detect
+ if (event.which == 1) {
+ if (callingID == "dirID") {
+ var node = obj.parentNode;
+ getDir(node.children[1].value);
+ } else if (callingID == "movieID") {
+ var node = obj.parentNode;
+ showMedia(node.children[1].value);
+ } else if (callingID == "fileID") {
+ var node = obj.parentNode;
+ showMedia(node.children[1].value);
+ } else if (callingID == "imageID") {
+ showImg(obj.alt);
+ } else if (callingID == "titleID") {
+ enableEdit(obj);
+ }
+ // Right click detect
+ } else if (event.which == 3) {
+ if (callingID == "imageID") {
+ startDeleteItem(obj.alt);
+ } else if (callingID == "dirID" || callingID == "fileID" ||
+ callingID == "movieID") {
+ var node = obj.parentNode;
+ startDeleteItem(node.children[1].value);
+ } else if (classNM == "fileStyle" || classNM == "dirStyle" ||
+ classNM == "movieStyle") {
+ startDeleteItem(obj.children[1].value);
+ }
+ }
+}
+
+document.onkeydown = function (event) {
+ var obj = event.target;
+ var callingID = event.target.id;
+ var keyCodeVal = event.keyCode;
+
+ // If keycode == Enter
+ if (keyCodeVal == 13) {
+ if (callingID == "titleID") {
+ renameItem(obj);
+ }
+ }
+}
diff --git a/resources/php/delete.php b/resources/php/delete.php
new file mode 100644
index 0000000..207de76
--- /dev/null
+++ b/resources/php/delete.php
@@ -0,0 +1,22 @@
+
diff --git a/resources/php/newFileOrDir.php b/resources/php/newFileOrDir.php
new file mode 100644
index 0000000..592c5d0
--- /dev/null
+++ b/resources/php/newFileOrDir.php
@@ -0,0 +1,21 @@
+
diff --git a/resources/php/open.php b/resources/php/open.php
index 74db9ea..8560229 100644
--- a/resources/php/open.php
+++ b/resources/php/open.php
@@ -3,19 +3,24 @@
function openFile($FILE) {
include 'config.php';
- if (preg_match('(mkv|wmv|mp4|webm|avi|m4v|ogv|flv)', strtolower($FILE)) === 1) {
- shell_exec('cd ../../ && ' . $MEDIAPLAYER . ' "' . $FILE . '" &');
- } else if (preg_match('(png|jpg|jpeg|gif)', strtolower($FILE)) === 1) {
- shell_exec('cd ../../ && ' . $IMGVIEWER . ' "' . $FILE . '" &');
- } else if (preg_match('(psf|mp3|ogg|flac)', strtolower($FILE)) === 1) {
- shell_exec('cd ../../ && ' . $MUSICPLAYER . ' "' . $FILE . '" &');
- } else if (preg_match('(pdf)', strtolower($FILE)) === 1) {
- shell_exec('cd ../../ && ' . $PDFVIEWER . ' "' . $FILE . '" &');
+ if (preg_match('(.mkv|.avi|.flv|.mov|.m4v|.mpg|.wmv|.mpeg)', strtolower($FILE)) === 1) {
+ shell_exec($MEDIAPLAYER . " \"" . $FILE . "\" &");
+ } else if (preg_match('(.png|.jpg|.jpeg|.gif)', strtolower($FILE)) === 1) {
+ shell_exec($IMGVIEWER . ' "' . $FILE . '" &');
+ } else if (preg_match('(.psf|.mp3|.ogg|.flac)', strtolower($FILE)) === 1) {
+ shell_exec($MUSICPLAYER . ' "' . $FILE . '" &');
+ } else if (preg_match('(.txt)', strtolower($FILE)) === 1) {
+ shell_exec($TEXTVIEWER . ' "' . $FILE . '" &');
+ } else if (preg_match('(.pdf)', strtolower($FILE)) === 1) {
+ shell_exec($PDFVIEWER . ' "' . $FILE . '" &');
+ // Has to be below b/c pdf somehow regesters and an office app.... wtf....
+ } else if (preg_match('(.odt|.doc|.docx|.rtf)', strtolower($FILE)) === 1) {
+ shell_exec($OFFICEPROG . ' "' . $FILE . '" &');
}
-
}
+chdir("../../");
if (isset($_POST["media"])) {
openFile($_POST["media"]);
}
diff --git a/resources/php/process.php b/resources/php/process.php
index 83cf4ad..9358550 100644
--- a/resources/php/process.php
+++ b/resources/php/process.php
@@ -1,40 +1,35 @@
"
- . "" . $CLEANPATH . " ";
+ . "" . $PATH . " ";
$dirContents = scandir($PATH);
foreach ($dirContents as $fileName) {
- $fullPath = $CLEANPATH . $fileName;
+ $fullPath = $PATH . $fileName;
if (is_dir($PATH . $fileName)) {
$GeneratedXML .= "" . $fileName . "/ ";
} elseif (preg_match('/^.*\.(mkv|avi|flv|mov|m4v|mpg|wmv|mpeg|mp4|webm)$/i', strtolower($fileName))) {
$NAMEHASH = hash('sha256', $fileName);
- if (!file_exists('../images/thumbnails/' . $NAMEHASH . '.jpg')) {
- shell_exec('../ffmpegthumbnailer -t 65% -s 320 -c jpg -i "'
- . $PATH . $fileName . '" -o ../images/thumbnails/'
+ if (!file_exists('resources/images/thumbnails/' . $NAMEHASH . '.jpg')) {
+ shell_exec('resources/ffmpegthumbnailer -t 65% -s 320 -c jpg -i "'
+ . $fullPath . '" -o resources/images/thumbnails/'
. $NAMEHASH . '.jpg');
}
$GeneratedXML .=
""
. "/resources/images/thumbnails/" . $NAMEHASH . ".jpg "
- . "" . $fullPath . " "
. "" . $fileName . " " .
" ";
} elseif (preg_match('/^.*\.(png|jpg|gif|jpeg)$/i', strtolower($fileName))) {
$GeneratedXML .=
""
- . "". $fullPath . " "
. "" . $fileName . " "
. " ";
} else {
$GeneratedXML .=
""
- . "" . $fullPath . " "
. "" . $fileName . " "
. " ";
}
@@ -44,10 +39,11 @@ function dirListing($PATH) {
}
// Determin action
+chdir("../../");
if (isset($_POST['dirQuery'])) {
dirListing(trim($_POST['dirQuery']));
} else {
- echo "Error! Illegal Access Method! ";
+ echo "Error! Illegal Access Method! ";
}
?>
diff --git a/resources/php/rename.php b/resources/php/rename.php
new file mode 100644
index 0000000..3873d26
--- /dev/null
+++ b/resources/php/rename.php
@@ -0,0 +1,12 @@
+
diff --git a/resources/php/sse.php b/resources/php/sse.php
index 3cfe746..c1efeb6 100644
--- a/resources/php/sse.php
+++ b/resources/php/sse.php
@@ -1,13 +1,10 @@
Server: [Warnning] --> This file already exists. Overwriting it.";
@@ -55,13 +55,14 @@ function uploadFiles($targetDir) {
echo "