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>
|
<iframe id="FormSubmitter" name="FormSubmitter" frameborder="0" ></iframe>
|
||||||
</div>
|
</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/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/xmlParser.js" charset="utf-8"></script>
|
||||||
<script type="text/javascript" src="resources/js/ajax.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) {
|
function getDir(query) {
|
||||||
var formUlPth = document.getElementById("DIRPATHUL");
|
var formUlPth = document.getElementById("DIRPATHUL");
|
||||||
|
var mergeType = document.getElementById("MergeType");
|
||||||
|
var passwd = undefined;
|
||||||
var path = "";
|
var path = "";
|
||||||
var cookies = "";
|
var cookies = "";
|
||||||
var dirCookie = "";
|
var dirCookie = "";
|
||||||
@ -46,19 +48,27 @@ function getDir(query) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create path from array of items
|
// Create path from array of items
|
||||||
for (pathNode of pathNodes) {
|
for (pathNode of pathNodes) { path += pathNode; }
|
||||||
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);
|
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);
|
process(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get dir info...
|
// Get dir info...
|
||||||
function process(path) {
|
function process(path) {
|
||||||
var mergeType = document.getElementById("MergeType");
|
var xhttp = new XMLHttpRequest(); // Create the xhttp object
|
||||||
var xhttp = new XMLHttpRequest(); // Create the xhttp object
|
|
||||||
|
|
||||||
// This is actually run after open and send are done
|
// This is actually run after open and send are done
|
||||||
xhttp.onreadystatechange = function() {
|
xhttp.onreadystatechange = function() {
|
||||||
@ -76,8 +86,5 @@ function process(path) {
|
|||||||
xhttp.open("POST", "resources/php/getDirList.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.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
||||||
xhttp.overrideMimeType('application/xml'); // Force return to be XML
|
xhttp.overrideMimeType('application/xml'); // Force return to be XML
|
||||||
xhttp.send(path + "&mergeType=" + mergeType.checked + "Here"); // Start the process
|
xhttp.send(path); // Start the process
|
||||||
|
|
||||||
// Use a cookie for persistence during browser session....
|
|
||||||
document.cookie = path + "; expires=Sun, 31 Dec 2034 12:00:00 UTC";
|
|
||||||
}
|
}
|
||||||
|
26
resources/js/passwordFieldInsert.js
Normal file
26
resources/js/passwordFieldInsert.js
Normal file
@ -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');
|
const insertArea = document.getElementById('dynDiv');
|
||||||
|
|
||||||
async function updateHTMLDirList(returnData) {
|
async function updateHTMLDirList(returnData) {
|
||||||
var dirPath = returnData.getElementsByTagName('PATH_HEAD')[0].innerHTML;
|
try {
|
||||||
|
var dirPath = returnData.getElementsByTagName('PATH_HEAD')[0].innerHTML;
|
||||||
|
} catch (e) {
|
||||||
|
createPassField(returnData);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var dirs = returnData.getElementsByTagName('DIR');
|
var dirs = returnData.getElementsByTagName('DIR');
|
||||||
var videos = returnData.getElementsByTagName('VID_FILE');
|
var videos = returnData.getElementsByTagName('VID_FILE');
|
||||||
var images = returnData.getElementsByTagName('IMG_FILE');
|
var images = returnData.getElementsByTagName('IMG_FILE');
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
$MEDIAPLAYER = "mpv ";
|
||||||
$MPLAYER_WH = " -xy 1600 -geometry 50%:50% ";
|
$MPLAYER_WH = " -xy 1600 -geometry 50%:50% ";
|
||||||
$MEDIAPLAYER = "mplayer";
|
|
||||||
$MUSICPLAYER = "/opt/deadbeef/bin/deadbeef";
|
$MUSICPLAYER = "/opt/deadbeef/bin/deadbeef";
|
||||||
$IMGVIEWER = "mirage";
|
$IMGVIEWER = "mirage";
|
||||||
$OFFICEPROG = "libreoffice";
|
$OFFICEPROG = "libreoffice";
|
||||||
$PDFVIEWER = "evince";
|
$PDFVIEWER = "evince";
|
||||||
$TEXTVIEWER = "leafpad";
|
$TEXTVIEWER = "leafpad";
|
||||||
$FILEMANAGER = "spacefm";
|
$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));
|
$EXTNSN = strtolower(pathinfo($FILE, PATHINFO_EXTENSION));
|
||||||
|
|
||||||
if (preg_match('(mkv|avi|flv|mov|m4v|mpg|wmv|mpeg|mp4|webm)', $EXTNSN) === 1) {
|
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) {
|
} else if (preg_match('(png|jpg|jpeg|gif)', $EXTNSN) === 1) {
|
||||||
shell_exec($IMGVIEWER . ' "' . $FILE . '" > /dev/null &');
|
shell_exec($IMGVIEWER . ' "' . $FILE . '" > /dev/null &');
|
||||||
} else if (preg_match('(psf|mp3|ogg|flac)', $EXTNSN) === 1) {
|
} else if (preg_match('(psf|mp3|ogg|flac)', $EXTNSN) === 1) {
|
||||||
|
@ -3,16 +3,24 @@
|
|||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
// Start of retrieving dir data
|
// Start of retrieving dir data
|
||||||
function startListing($NEWPATH, $MERGESEASSONS) {
|
function startListing($NEWPATH, $MERGESEASSONS, $PASSWD) {
|
||||||
if (is_dir($NEWPATH)) {
|
if (is_dir($NEWPATH)) {
|
||||||
$GeneratedXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><DIR_LIST>"
|
include 'lockedFolders.php';
|
||||||
. "<PATH_HEAD>" . $NEWPATH . "</PATH_HEAD>";
|
if (checkForLock($NEWPATH, $PASSWD) == false) {
|
||||||
$subPath = ""; // This is used for season scanning as a means of properly getting
|
$GeneratedXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><DIR_LIST>"
|
||||||
// the video src.... It's left blank when not in a sub dir
|
. "<PATH_HEAD>" . $NEWPATH . "</PATH_HEAD>";
|
||||||
listDir($GeneratedXML, $NEWPATH, $MERGESEASSONS, $subPath);
|
$subPath = ""; // This is used for season scanning as a means of properly getting
|
||||||
|
// the video src.... It's left blank when not in a sub dir
|
||||||
|
listDir($GeneratedXML, $NEWPATH, $MERGESEASSONS, $subPath);
|
||||||
|
|
||||||
$GeneratedXML .= "</DIR_LIST>";
|
$GeneratedXML .= "</DIR_LIST>";
|
||||||
echo $GeneratedXML;
|
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
|
// Determin action
|
||||||
chdir("../../");
|
chdir("../../");
|
||||||
if (isset($_POST['dirQuery'])) {
|
if (isset($_POST['dirQuery'])) {
|
||||||
startListing(trim($_POST['dirQuery']), $_POST['mergeType']);
|
startListing(trim($_POST['dirQuery']), $_POST['mergeType'], $_POST['passwd']);
|
||||||
} else {
|
} else {
|
||||||
echo "<h2 class='error'>Error! Illegal Access Method!</h2>";
|
echo "<h2 class='error'>Error! Illegal Access Method!</h2>";
|
||||||
}
|
}
|
||||||
|
20
resources/php/lockedFolders.php
Normal file
20
resources/php/lockedFolders.php
Normal file
@ -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
Block a user