summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheTroll <trolldev@gmail.com>2010-03-18 18:12:03 +0100
committerTheTroll <trolldev@gmail.com>2010-03-18 18:12:03 +0100
commit394c0c1ce48314fc6d52f3b8d29e5d4f21c3bfdc (patch)
tree9079b218eb5284fab2d2b37daeb5635f34ed38de
parent19f7bf5bbe473eb76b3089702986b92eb2235003 (diff)
downloadistreamdev-394c0c1ce48314fc6d52f3b8d29e5d4f21c3bfdc.tar.gz
istreamdev-394c0c1ce48314fc6d52f3b8d29e5d4f21c3bfdc.tar.bz2
Optimizing file browsing
-rwxr-xr-xbin/files.php39
1 files changed, 14 insertions, 25 deletions
diff --git a/bin/files.php b/bin/files.php
index 34db5bf..be2a364 100755
--- a/bin/files.php
+++ b/bin/files.php
@@ -158,11 +158,12 @@ function generatelogo($type, $name, $dest)
function filesgetlisting($dir)
{
- $listing = array();
+ $filelisting = array();
+ $folderlisting = array();
$dir_handle = @opendir($dir);
if (!$dir_handle)
- return $listing;
+ return array();
while ($medianame = readdir($dir_handle))
{
@@ -173,38 +174,19 @@ function filesgetlisting($dir)
}
if ($medianame_array[0] == NULL)
- return $listing;
+ return array();
// Alphabetical sorting
sort($medianame_array);
- // List folders
- foreach($medianame_array as $value)
- {
- $type = filegettype($dir ."/" .$value);
-
- if ($type != 'folder')
- continue;
-
- $newentry = array();
- $newentry['name'] = $value;
- $newentry['path'] = $dir ."/" .$value .'/';
- $newentry['type'] = 'folder';
-
- $listing[] = $newentry;
- }
-
$number = 1;
- // List files
+ // List files and folders
foreach($medianame_array as $value)
{
$type = filegettype($dir ."/" .$value);
- if ($type == 'folder')
- continue;
-
$newentry = array();
$newentry['name'] = $value;
$newentry['path'] = $dir ."/" .$value;
@@ -217,14 +199,21 @@ function filesgetlisting($dir)
$newentry['number'] = $number;
$number++;
case 'video':
+ case 'folder':
case 'rec':
- $listing[] = $newentry;
+ if ($type == 'folder')
+ {
+ $newentry['path'] = $newentry['path'] .'/';
+ $folderlisting[] = $newentry;
+ }
+ else
+ $filelisting[] = $newentry;
break;
default:
}
}
- return $listing;
+ return array_merge($folderlisting, $filelisting);
}
?>