Have recursion option or season folders.
This commit is contained in:
parent
a572e723c5
commit
218e5a3afc
|
@ -24,6 +24,9 @@
|
|||
<input type="button" value="New Dir" onclick="createItem('dir')">
|
||||
<input type="button" value="New File" onclick="createItem('file')">
|
||||
<br/>
|
||||
<label target="MergeType"> <input id="MergeType" type="checkbox">Merge Seasson Folders.</label>
|
||||
<button type="button" name="button" onclick="getDir('./')">Refresh</button>
|
||||
<button type="button" name="button" onclick="getDir('../')">../</button>
|
||||
Path: <span id="path"></span>
|
||||
</h2>
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ function getDir(query) {
|
|||
|
||||
// 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
|
||||
|
@ -75,7 +76,7 @@ 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); // Start the process
|
||||
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";
|
||||
|
|
|
@ -8,7 +8,7 @@ function renameItem(obj) {
|
|||
console.log("Old name: " + oldName);
|
||||
console.log("New name: " + newName);
|
||||
|
||||
xhttp.open("POST", "resources/php/filesystemActions.php", false);
|
||||
xhttp.open("POST", "resources/php/filesystemActions.php", true);
|
||||
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
||||
xhttp.send(formData);
|
||||
}
|
||||
|
@ -20,9 +20,9 @@ function createItem(type) {
|
|||
var xhttp = new XMLHttpRequest();
|
||||
newItem.value = "";
|
||||
|
||||
xhttp.open("POST", "resources/php/filesystemActions.php", false);
|
||||
xhttp.open("POST", "resources/php/filesystemActions.php", true);
|
||||
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
||||
xhttp.send("createItem=true&item=" + fullPth + "&type=" + type + "");
|
||||
xhttp.send("createItem=true&item=" + fullPth + "&type=" + type);
|
||||
}
|
||||
|
||||
function startDeleteItem(item) {
|
||||
|
@ -40,7 +40,7 @@ function deleteItem(item) {
|
|||
if (answer == true) {
|
||||
var xhttp = new XMLHttpRequest();
|
||||
|
||||
xhttp.open("POST", "resources/php/filesystemActions.php", false);
|
||||
xhttp.open("POST", "resources/php/filesystemActions.php", true);
|
||||
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
||||
xhttp.send("deleteItem=true&item=" + fullPth);
|
||||
|
||||
|
|
|
@ -2,51 +2,72 @@
|
|||
|
||||
session_start();
|
||||
|
||||
// Retrieve data
|
||||
function dirListing($NEWPATH) {
|
||||
// Start of retrieving dir data
|
||||
function startListing($NEWPATH, $MERGESEASSONS) {
|
||||
if (is_dir($NEWPATH)) {
|
||||
$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
|
||||
// the video src.... It's left blank when not in a sub dir
|
||||
listDir($GeneratedXML, $NEWPATH, $MERGESEASSONS, $subPath);
|
||||
|
||||
$dirContents = scandir($NEWPATH);
|
||||
foreach ($dirContents as $fileName) {
|
||||
$fullPath = $NEWPATH . $fileName;
|
||||
|
||||
if (is_dir($NEWPATH . $fileName)) {
|
||||
$GeneratedXML .= "<DIR>" . $fileName . "/</DIR>";
|
||||
} elseif (preg_match('/^.*\.(mkv|avi|flv|mov|m4v|mpg|wmv|mpeg|mp4|webm)$/i', strtolower($fileName))) {
|
||||
$NAMEHASH = hash('sha256', $fileName);
|
||||
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 .=
|
||||
"<VID_FILE>"
|
||||
. "<VID_IMG>/resources/images/thumbnails/" . $NAMEHASH . ".jpg</VID_IMG>"
|
||||
. "<VID_NAME>" . $fileName . "</VID_NAME>" .
|
||||
"</VID_FILE>";
|
||||
} elseif (preg_match('/^.*\.(png|jpg|gif|jpeg)$/i', strtolower($fileName))) {
|
||||
$GeneratedXML .=
|
||||
"<IMG_FILE>"
|
||||
. "<IMAGE_NAME>" . $fileName . "</IMAGE_NAME>"
|
||||
. "</IMG_FILE>";
|
||||
} else {
|
||||
$GeneratedXML .=
|
||||
"<FILE>"
|
||||
. "<FILE_NAME>" . $fileName . "</FILE_NAME>"
|
||||
. "</FILE>";
|
||||
}
|
||||
}
|
||||
$GeneratedXML .= "</DIR_LIST>";
|
||||
echo $GeneratedXML;
|
||||
}
|
||||
}
|
||||
|
||||
// Used for recursion
|
||||
function listDir(&$GeneratedXML, &$NEWPATH, &$MERGESEASSONS, &$subPath) {
|
||||
$dirContents = scandir($NEWPATH);
|
||||
foreach ($dirContents as $fileName) {
|
||||
// Filter for . and .. items We have controls for these actions
|
||||
if ($fileName !== "." && $fileName !== "..") {
|
||||
$fullPath = $NEWPATH . $fileName;
|
||||
if ($MERGESEASSONS == "trueHere" && is_dir($fullPath) &&
|
||||
strpos(strtolower($fileName), 'season') !== false) {
|
||||
$fileName .= "/";
|
||||
listDir($GeneratedXML, $fullPath, $MERGESEASSONS, $fileName);
|
||||
} else {
|
||||
processItem($GeneratedXML, $fullPath, $fileName, $subPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Assign XML Markup based on file type
|
||||
function processItem(&$GeneratedXML, &$fullPath, &$fileName, $subPath) {
|
||||
if (is_dir($fullPath)) {
|
||||
$GeneratedXML .= "<DIR>" . $fileName . "/</DIR>";
|
||||
} elseif (preg_match('/^.*\.(mkv|avi|flv|mov|m4v|mpg|wmv|mpeg|mp4|webm)$/i', strtolower($fileName))) {
|
||||
$NAMEHASH = hash('sha256', $fileName);
|
||||
if (!file_exists('resources/images/thumbnails/' . $NAMEHASH . '.jpg')) {
|
||||
shell_exec('resources/ffmpegthumbnailer -t 65% -s 320 -c jpg -i "'
|
||||
. $subPath . $fullPath . '" -o resources/images/thumbnails/'
|
||||
. $NAMEHASH . '.jpg');
|
||||
}
|
||||
$GeneratedXML .=
|
||||
"<VID_FILE>"
|
||||
. "<VID_IMG>/resources/images/thumbnails/" . $NAMEHASH . ".jpg</VID_IMG>"
|
||||
. "<VID_NAME>" . $subPath . $fileName . "</VID_NAME>" .
|
||||
"</VID_FILE>";
|
||||
} elseif (preg_match('/^.*\.(png|jpg|gif|jpeg)$/i', strtolower($fileName))) {
|
||||
$GeneratedXML .=
|
||||
"<IMG_FILE>"
|
||||
. "<IMAGE_NAME>" . $subPath . $fileName . "</IMAGE_NAME>"
|
||||
. "</IMG_FILE>";
|
||||
} else {
|
||||
$GeneratedXML .=
|
||||
"<FILE>"
|
||||
. "<FILE_NAME>" . $subPath . $fileName . "</FILE_NAME>"
|
||||
. "</FILE>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Determin action
|
||||
chdir("../../");
|
||||
if (isset($_POST['dirQuery'])) {
|
||||
dirListing(trim($_POST['dirQuery']));
|
||||
startListing(trim($_POST['dirQuery']), $_POST['mergeType']);
|
||||
} else {
|
||||
echo "<h2 class='error'>Error! Illegal Access Method!</h2>";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue