From 5a82ce8d05eb30148d8079aed01c503c73dd58d6 Mon Sep 17 00:00:00 2001 From: TheTroll Date: Wed, 17 Mar 2010 18:23:56 +0100 Subject: File browsing --- bin/files.php | 86 +++++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 63 insertions(+), 23 deletions(-) (limited to 'bin/files.php') diff --git a/bin/files.php b/bin/files.php index ae2507d..dfcda00 100755 --- a/bin/files.php +++ b/bin/files.php @@ -1,7 +1,5 @@ $audioext) - { - if (glob($dir .'*.' .$audioext)) - return 1; - } - - return 0; + return 'unknown'; } function mediagetmusicinfo($file ="") @@ -169,4 +157,56 @@ function generatelogo($type, $name, $dest) } } +function filesgetlisting($dir) +{ + $listing = array(); + + $dir_handle = @opendir($dir); + if (!$dir_handle) + return $listing; + + while ($medianame = readdir($dir_handle)) + { + if($medianame == "." || $medianame == ".." || $medianame == 'lost+found') + continue; + + $medianame_array[] = $medianame; + } + + if ($medianame_array[0] == NULL) + return $listing; + + // Alphabetical sorting + sort($medianame_array); + + foreach($medianame_array as $value) + { + $newentry = array(); + + $newentry['name'] = $value; + $newentry['path'] = $dir ."/" .$value; + + $type = filegettype($dir ."/" .$value); + + switch ($type) + { + case 'audio': + // More info + case 'video': + case 'rec': + case 'folder': + $newentry['type'] = $type; + break; + default: + continue; + + } + + // Add new entry + $listing[] = $newentry; + } + + return $listing; +} + ?> -- cgit v1.2.3