Created extremely simple directory locking system.
This commit is contained in:
parent
5a54e2c8df
commit
b63903dde0
|
@ -59,6 +59,7 @@
|
|||
<iframe id="FormSubmitter" name="FormSubmitter" frameborder="0" ></iframe>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="resources/js/passwordFieldInsert.js" charset="utf-8"></script>
|
||||
<script type="text/javascript" src="resources/js/cookieHandler.js" charset="utf-8"></script>
|
||||
<script type="text/javascript" src="resources/js/xmlParser.js" charset="utf-8"></script>
|
||||
<script type="text/javascript" src="resources/js/ajax.js" charset="utf-8"></script>
|
||||
|
|
|
@ -14,6 +14,8 @@ if(typeof(EventSource) !== "undefined") {
|
|||
|
||||
function getDir(query) {
|
||||
var formUlPth = document.getElementById("DIRPATHUL");
|
||||
var mergeType = document.getElementById("MergeType");
|
||||
var passwd = undefined;
|
||||
var path = "";
|
||||
var cookies = "";
|
||||
var dirCookie = "";
|
||||
|
@ -46,18 +48,26 @@ function getDir(query) {
|
|||
}
|
||||
|
||||
// Create path from array of items
|
||||
for (pathNode of pathNodes) {
|
||||
path += pathNode;
|
||||
for (pathNode of pathNodes) { path += pathNode; }
|
||||
|
||||
try {
|
||||
passwd = document.getElementById("PASSWD").value;
|
||||
} catch (e) {
|
||||
passwd = "";
|
||||
}
|
||||
|
||||
formUlPth.value = path; // Setup upload path for form
|
||||
// Setup upload path for form and make a cookie for persistence during browser session....
|
||||
formUlPth.value = path;
|
||||
path = "dirQuery=" + encodeURIComponent(path);
|
||||
document.cookie = path + "; expires=Sun, 31 Dec 2034 12:00:00 UTC";
|
||||
path +="&mergeType=" + mergeType.checked
|
||||
+ "Here&passwd=" + passwd;
|
||||
|
||||
process(path);
|
||||
}
|
||||
|
||||
// Get dir info...
|
||||
function process(path) {
|
||||
var mergeType = document.getElementById("MergeType");
|
||||
var xhttp = new XMLHttpRequest(); // Create the xhttp object
|
||||
|
||||
// This is actually run after open and send are done
|
||||
|
@ -76,8 +86,5 @@ function process(path) {
|
|||
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 + "&mergeType=" + mergeType.checked + "Here"); // Start the process
|
||||
|
||||
// Use a cookie for persistence during browser session....
|
||||
document.cookie = path + "; expires=Sun, 31 Dec 2034 12:00:00 UTC";
|
||||
xhttp.send(path); // Start the process
|
||||
}
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
function createPassField(returnData) {
|
||||
var msg = returnData.getElementsByTagName('MESSAGE')[0].innerHTML;
|
||||
console.log("No PATH_HEAD tag in XML. Checking for error MESSAGE tag.");
|
||||
console.log("Message: " + msg);
|
||||
|
||||
insertArea.innerHTML = "";
|
||||
var passField = document.createElement("INPUT");
|
||||
var submitBttn = document.createElement("BUTTON");
|
||||
passField.id = "PASSWD";
|
||||
passField.type = "password";
|
||||
passField.placeholder = "Password...";
|
||||
submitBttn.innerHTML = "Submit";
|
||||
|
||||
passField.onkeyup = (eve) => {
|
||||
if (eve.key == "Enter") {
|
||||
getDir("./");
|
||||
}
|
||||
};
|
||||
|
||||
submitBttn.onclick = () => {
|
||||
getDir("./");
|
||||
};
|
||||
|
||||
insertArea.appendChild(passField);
|
||||
insertArea.appendChild(submitBttn);
|
||||
}
|
|
@ -1,7 +1,13 @@
|
|||
const insertArea = document.getElementById('dynDiv');
|
||||
|
||||
async function updateHTMLDirList(returnData) {
|
||||
try {
|
||||
var dirPath = returnData.getElementsByTagName('PATH_HEAD')[0].innerHTML;
|
||||
} catch (e) {
|
||||
createPassField(returnData);
|
||||
return;
|
||||
}
|
||||
|
||||
var dirs = returnData.getElementsByTagName('DIR');
|
||||
var videos = returnData.getElementsByTagName('VID_FILE');
|
||||
var images = returnData.getElementsByTagName('IMG_FILE');
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
<?php
|
||||
|
||||
$MEDIAPLAYER = "mpv ";
|
||||
$MPLAYER_WH = " -xy 1600 -geometry 50%:50% ";
|
||||
$MEDIAPLAYER = "mplayer";
|
||||
$MUSICPLAYER = "/opt/deadbeef/bin/deadbeef";
|
||||
$IMGVIEWER = "mirage";
|
||||
$OFFICEPROG = "libreoffice";
|
||||
$PDFVIEWER = "evince";
|
||||
$TEXTVIEWER = "leafpad";
|
||||
$FILEMANAGER = "spacefm";
|
||||
$LOCKEDFOLDERS = "./MEGA_Sync/222_Photos/Other/::::./MEGA_Sync/333_Movies-Music/Other/";
|
||||
$LOCKPASSWORD = "1234";
|
||||
|
||||
?>
|
||||
|
|
|
@ -102,7 +102,7 @@ function openFile($FILE) {
|
|||
$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 &");
|
||||
shell_exec($MEDIAPLAYER . "\"" . $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) {
|
||||
|
|
|
@ -3,8 +3,10 @@
|
|||
session_start();
|
||||
|
||||
// Start of retrieving dir data
|
||||
function startListing($NEWPATH, $MERGESEASSONS) {
|
||||
function startListing($NEWPATH, $MERGESEASSONS, $PASSWD) {
|
||||
if (is_dir($NEWPATH)) {
|
||||
include 'lockedFolders.php';
|
||||
if (checkForLock($NEWPATH, $PASSWD) == false) {
|
||||
$GeneratedXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><DIR_LIST>"
|
||||
. "<PATH_HEAD>" . $NEWPATH . "</PATH_HEAD>";
|
||||
$subPath = ""; // This is used for season scanning as a means of properly getting
|
||||
|
@ -13,6 +15,12 @@ function startListing($NEWPATH, $MERGESEASSONS) {
|
|||
|
||||
$GeneratedXML .= "</DIR_LIST>";
|
||||
echo $GeneratedXML;
|
||||
} else {
|
||||
$GeneratedXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
||||
. "<MESSAGE>Folder is locked."
|
||||
. "</MESSAGE>";
|
||||
echo $GeneratedXML;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,7 +75,7 @@ function processItem(&$GeneratedXML, &$fullPath, &$fileName, $subPath) {
|
|||
// Determin action
|
||||
chdir("../../");
|
||||
if (isset($_POST['dirQuery'])) {
|
||||
startListing(trim($_POST['dirQuery']), $_POST['mergeType']);
|
||||
startListing(trim($_POST['dirQuery']), $_POST['mergeType'], $_POST['passwd']);
|
||||
} else {
|
||||
echo "<h2 class='error'>Error! Illegal Access Method!</h2>";
|
||||
}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
// Check if sub folder is in locked folder
|
||||
function checkForLock($NEWPATH, $PASSWD) {
|
||||
include 'config.php';
|
||||
|
||||
$LOCKS = explode("::::", $LOCKEDFOLDERS);
|
||||
$size = sizeof($LOCKS);
|
||||
|
||||
for ($i = 0; $i < $size; $i++) {
|
||||
if (strpos($NEWPATH, $LOCKS[$i]) !== false) {
|
||||
if ($PASSWD == $LOCKPASSWORD) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue