From 5a82ce8d05eb30148d8079aed01c503c73dd58d6 Mon Sep 17 00:00:00 2001 From: TheTroll Date: Wed, 17 Mar 2010 18:23:56 +0100 Subject: File browsing --- bin/backend.php | 20 +++----------- bin/files.php | 86 ++++++++++++++++++++++++++++++++++++++++++--------------- bin/jsonapi.php | 11 ++++++-- bin/vdr.php | 3 ++ 4 files changed, 79 insertions(+), 41 deletions(-) (limited to 'bin') diff --git a/bin/backend.php b/bin/backend.php index 3eaa127..cf37e2e 100755 --- a/bin/backend.php +++ b/bin/backend.php @@ -111,22 +111,10 @@ switch ($action) break; case ("browseFolder"): - $path = $_REQUEST['path']; - if ( $path == "/video/" ) { - $tree = file_get_contents("textfiles/browseFolder-rec.txt"); - } - else if ( $path == "/mnt/media/Videos/" ) { - $tree = file_get_contents("textfiles/browseFolder-vid.txt"); - } - else if ( $path == "/mnt/media/Music/" ) { - $tree = file_get_contents("textfiles/browseFolder-aud.txt"); - } - else - { - $tree = file_get_contents("textfiles/browseFolder-rec.txt"); - } - print $tree; - break; + $path = $_REQUEST['path']; + $tree = browseFolder($_REQUEST['path']); + print $tree; + break; case ("browseRec"): $tree = file_get_contents("textfiles/browseRec.txt"); 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; +} + ?> diff --git a/bin/jsonapi.php b/bin/jsonapi.php index dcc3dd4..eba9725 100755 --- a/bin/jsonapi.php +++ b/bin/jsonapi.php @@ -7,8 +7,8 @@ function getGlobals() $ret = array(); $ret['streamdev_server'] = $vdrstreamdev; $ret['rec_path'] = $vdrrecpath; - $ret['video_path'] = "/mnt/media/Video/"; - $ret['audio_path'] = "/mnt/media/Music/"; + $ret['video_path'] = "/home/storage/Foot/"; + $ret['audio_path'] = "/home/www/mp3/"; return json_encode($ret); } @@ -113,5 +113,12 @@ function getRunningSessions() } +function browseFolder($path) +{ + $ret = array(); + $ret['list'] = filesgetlisting($path); + + return json_encode($ret); +} ?> diff --git a/bin/vdr.php b/bin/vdr.php index 4eb1906..e10a139 100755 --- a/bin/vdr.php +++ b/bin/vdr.php @@ -61,6 +61,7 @@ function vdrgetcategories() if (!is_utf8($curcat)) $curcat = utf8_encode($curcat); +// $curcat = rawurlencode($curcat); } else if ($line[0] != "") $curcatchancount++; @@ -178,6 +179,8 @@ function vdrgetchannels($category, $now) if (!is_utf8($tmpchan['name'])) $tmpchan['name'] = utf8_encode($tmpchan['name']); +// $tmpchan['name'] = rawurlencode($tmpchan['name']); + $chanlist[] = $tmpchan; } -- cgit v1.2.3