Improved speeds of dir retrieval.
This commit is contained in:
parent
4d87b63366
commit
677fe2f020
|
@ -25,14 +25,14 @@ function createItem($FILE, $TYPE) {
|
||||||
|
|
||||||
// File or folder delition
|
// File or folder delition
|
||||||
function deleteItem($FILE) {
|
function deleteItem($FILE) {
|
||||||
if (is_dir($FILE)){
|
if (filetype($FILE) == "dir"){
|
||||||
//GLOB_MARK adds a slash to directories returned
|
//GLOB_MARK adds a slash to directories returned
|
||||||
$files = glob($FILE . '*', GLOB_MARK);
|
$files = glob($FILE . '*', GLOB_MARK);
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
deleteItem($file);
|
deleteItem($file);
|
||||||
}
|
}
|
||||||
rmdir($FILE);
|
rmdir($FILE);
|
||||||
} else if (is_file($FILE)) {
|
} else if (filetype($FILE) == "file") {
|
||||||
unlink($FILE);
|
unlink($FILE);
|
||||||
} else {
|
} else {
|
||||||
$message = "Server: [Error] --> Failed to delete item! Not a folder or file!";
|
$message = "Server: [Error] --> Failed to delete item! Not a folder or file!";
|
||||||
|
@ -73,7 +73,7 @@ function uploadFiles($targetDir) {
|
||||||
// Check if file already exists
|
// Check if file already exists
|
||||||
$targetFile = $targetDir . $fileName;
|
$targetFile = $targetDir . $fileName;
|
||||||
if (file_exists($targetFile)) {
|
if (file_exists($targetFile)) {
|
||||||
if (is_file($targetFile)) {
|
if (filetype($targetFile) == "file") {
|
||||||
unlink($targetFile);
|
unlink($targetFile);
|
||||||
$message = "Server: [Warnning] --> This file already exists. Overwriting it.";
|
$message = "Server: [Warnning] --> This file already exists. Overwriting it.";
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -4,7 +4,7 @@ include_once 'serverMessanger.php';
|
||||||
|
|
||||||
// Start of retrieving dir data
|
// Start of retrieving dir data
|
||||||
function startListing($NEWPATH, $MERGESEASSONS, $PASSWD) {
|
function startListing($NEWPATH, $MERGESEASSONS, $PASSWD) {
|
||||||
if (is_dir($NEWPATH)) {
|
if (filetype($NEWPATH) == "dir") {
|
||||||
include_once 'lockedFolders.php';
|
include_once 'lockedFolders.php';
|
||||||
|
|
||||||
if (checkForLock($NEWPATH, $PASSWD) == false) {
|
if (checkForLock($NEWPATH, $PASSWD) == false) {
|
||||||
|
@ -28,12 +28,13 @@ function startListing($NEWPATH, $MERGESEASSONS, $PASSWD) {
|
||||||
|
|
||||||
// Used for recursion
|
// Used for recursion
|
||||||
function listDir(&$GeneratedXML, &$NEWPATH, &$MERGESEASSONS, &$subPath) {
|
function listDir(&$GeneratedXML, &$NEWPATH, &$MERGESEASSONS, &$subPath) {
|
||||||
$dirContents = scandir($NEWPATH);
|
// $dirContents = scandir($NEWPATH);
|
||||||
foreach ($dirContents as $fileName) {
|
$handle = opendir($NEWPATH);
|
||||||
|
while (false !== ($fileName = readdir($handle))) {
|
||||||
// Filter for . and .. items We have controls for these actions
|
// Filter for . and .. items We have controls for these actions
|
||||||
if ($fileName !== "." && $fileName !== "..") {
|
if ($fileName !== "." && $fileName !== "..") {
|
||||||
$fullPath = $NEWPATH . $fileName;
|
$fullPath = $NEWPATH . $fileName;
|
||||||
if ($MERGESEASSONS == "trueHere" && is_dir($fullPath) &&
|
if ($MERGESEASSONS == "trueHere" && filetype($fullPath) == "dir" &&
|
||||||
strpos(strtolower($fileName), 'season') !== false) {
|
strpos(strtolower($fileName), 'season') !== false) {
|
||||||
$fileName .= "/";
|
$fileName .= "/";
|
||||||
listDir($GeneratedXML, $fullPath, $MERGESEASSONS, $fileName);
|
listDir($GeneratedXML, $fullPath, $MERGESEASSONS, $fileName);
|
||||||
|
@ -42,11 +43,12 @@ function listDir(&$GeneratedXML, &$NEWPATH, &$MERGESEASSONS, &$subPath) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
closedir($handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assign XML Markup based on file type
|
// Assign XML Markup based on file type
|
||||||
function processItem(&$GeneratedXML, &$fullPath, &$fileName, $subPath) {
|
function processItem(&$GeneratedXML, &$fullPath, &$fileName, $subPath) {
|
||||||
if (is_dir($fullPath)) {
|
if (filetype($fullPath) == "dir") {
|
||||||
$GeneratedXML .= "<DIR>" . $fileName . "/</DIR>";
|
$GeneratedXML .= "<DIR>" . $fileName . "/</DIR>";
|
||||||
} elseif (preg_match('/^.*\.(mkv|avi|flv|mov|m4v|mpg|wmv|mpeg|mp4|webm)$/i', strtolower($fileName))) {
|
} elseif (preg_match('/^.*\.(mkv|avi|flv|mov|m4v|mpg|wmv|mpeg|mp4|webm)$/i', strtolower($fileName))) {
|
||||||
$NAMEHASH = hash('sha256', $fileName);
|
$NAMEHASH = hash('sha256', $fileName);
|
||||||
|
|
Loading…
Reference in New Issue