summaryrefslogtreecommitdiff
path: root/bin/files.php
diff options
context:
space:
mode:
authorTheTroll <trolldev@gmail.com>2010-03-17 18:23:56 +0100
committerTheTroll <trolldev@gmail.com>2010-03-17 18:23:56 +0100
commit5a82ce8d05eb30148d8079aed01c503c73dd58d6 (patch)
treee410b38831fe03b68a84b136cf09505ba1d55add /bin/files.php
parent9f94e565988c2cd5bf765b4d21584b1ac2fcb64f (diff)
downloadistreamdev-5a82ce8d05eb30148d8079aed01c503c73dd58d6.tar.gz
istreamdev-5a82ce8d05eb30148d8079aed01c503c73dd58d6.tar.bz2
File browsing
Diffstat (limited to 'bin/files.php')
-rwxr-xr-xbin/files.php86
1 files changed, 63 insertions, 23 deletions
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 @@
<?php
-$audiotypes='mp3 aac wav ';
-
function mediagetinfostream($stream)
{
// Get info
@@ -83,7 +81,7 @@ function mediagetwidth($file)
return $fileinfo['video']['resolution_x'];
}
-function mediagettype($file)
+function filegettype($file)
{
global $videotypes, $audiotypes;
@@ -92,30 +90,20 @@ function mediagettype($file)
$file = str_replace("\\'", "'", $file);
if (is_dir($file))
- return 3;
+ {
+ if ($fileext == "rec")
+ return "rec";
+ else
+ return 'folder';
+ }
else if (preg_match("$/$", $fileext))
- return 0;
+ return 'none';
else if (preg_match("/" .$fileext ." /", $videotypes))
- return 'tv';
+ return 'video';
else if (preg_match("/" .$fileext ." /", $audiotypes))
- return 'rec';
+ return 'audio';
else
- return 'vid';
-}
-
-function mediadirhasaudio($dir)
-{
- global $audiotypes;
-
- $audioextarray = explode(' ', $audiotypes);
-
- foreach ($audioextarray as $num => $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;
+}
+
?>