From b499fc63bb285e8319b080b42d98e18c54e09d21 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Wed, 13 May 2009 22:35:07 +0100 Subject: [PATCH] Allow specifying a "path" and/or "exclude" directory to the index page to show only a subset of all programmes by directory. --- playonwii/index.php | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/playonwii/index.php b/playonwii/index.php index d72ed8a..a4e85a3 100644 --- a/playonwii/index.php +++ b/playonwii/index.php @@ -2,6 +2,16 @@ include_once( "functions.php" ); +$extra_path = $_GET["path"]; +$excluded = explode( ":", $_GET["exclude"] ); + +$full_videos_dir = $videos_dir; + +if( $extra_path ) +{ + $full_videos_dir .= "/$extra_path"; +} + function is_video_dir( $full_path ) { if( substr_compare( $full_path, "/.", -2 ) == 0 or @@ -15,6 +25,13 @@ function is_video_dir( $full_path ) return is_dir( $full_path ); } +function is_not_excluded( $filename ) +{ + global $excluded; + + return !in_array( $filename, $excluded ); +} + function get_filenames_recursive( &$filenames, $top_dir, $sub_dir = "" ) { $handle = opendir( "$top_dir/$sub_dir" ); @@ -30,7 +47,8 @@ function get_filenames_recursive( &$filenames, $top_dir, $sub_dir = "" ) { $filepath = $filename; } - if( is_video_dir( "$top_dir/$sub_dir/$filename" ) ) + if( is_not_excluded( $filename ) && + is_video_dir( "$top_dir/$sub_dir/$filename" ) ) { get_filenames_recursive( $filenames, $top_dir, $filepath ); } @@ -131,7 +149,7 @@ function get_info_from_filename( $fn ) function get_info( $filename, $filenames ) { - global $videos_dir; + global $full_videos_dir; $title = Null; @@ -143,7 +161,7 @@ function get_info( $filename, $filenames ) if( array_key_exists( $infofn, $filenames ) ) { list( $title, $date, $channel, $sub_title, $description ) = - get_info_from_file( $videos_dir . "/" . $infofn ); + get_info_from_file( $full_videos_dir . "/" . $infofn ); } else { @@ -163,7 +181,7 @@ function get_info( $filename, $filenames ) // This is a hash filename -> nothing of all files in the videos directory // and subdirectories $filenames = array(); -get_filenames_recursive( $filenames, $videos_dir ); +get_filenames_recursive( $filenames, $full_videos_dir ); // This is a hash filename -> nothing of all files in the deleted directory $deleted_filenames = array(); -- 2.11.4.GIT