3 include_once( "functions.php" );
5 $extra_path = sanitise_filename( $_GET["path"] );
6 $excluded_preprepare = explode( ":", $_GET["exclude"] );
10 foreach( $excluded_preprepare as $ex )
12 $excluded[] = sanitise_filename( $ex );
15 $full_videos_dir = $videos_dir;
19 $full_videos_dir .= "/$extra_path";
22 function is_video_dir( $full_path )
24 if( substr_compare( $full_path, "/.", -2 ) == 0 or
25 substr_compare( $full_path, "/..", -3 ) == 0 or
26 substr_compare( $full_path, "/deleted", -8 ) == 0 or
27 substr_compare( $full_path, "/tvguide", -8 ) == 0 )
32 return is_dir( $full_path );
35 function is_not_excluded( $filename )
39 return !in_array( $filename, $excluded );
42 function get_filenames_recursive( &$filenames, $top_dir, $sub_dir = "" )
44 $handle = opendir( "$top_dir/$sub_dir" );
47 while( ( $filename = readdir( $handle ) ) )
49 if( strlen( $sub_dir ) > 0 )
51 $filepath = "$sub_dir/$filename";
55 $filepath = $filename;
57 if( is_not_excluded( $filename ) &&
58 is_video_dir( "$top_dir/$sub_dir/$filename" ) )
60 get_filenames_recursive( $filenames, $top_dir, $filepath );
64 $filenames[$filepath] = '';
71 function pretty_date( $date )
76 (int)( substr( $date, 11, 2 ) ),
77 (int)( substr( $date, 14, 2 ) ),
79 (int)( substr( $date, 5, 2 ) ),
80 (int)( substr( $date, 8, 2 ) ),
81 (int)( substr( $date, 0, 4 ) ) );
83 return date( "D d M, H:i", $tm );
86 function get_info_from_file( $fn )
94 $handle = fopen( $fn, "r" );
98 while ( !feof( $handle ) )
100 $line = fgets( $handle );
101 $line = substr( $line, 0, -1 );
103 list( $k, $v ) = split( "=", $line, 2 );
127 case "channel_pretty":
138 return array( $title, $date, $channel, $sub_title, $description );
141 function get_info_from_filename( $fn )
143 if( preg_match( '/^(.*?)-(.*)\\..*$/', $fn, $matches ) )
145 $title = $matches[1];
150 $title = substr( $fn, 0, strlen( $fn ) - 4 );
154 return array( $title, $date );
157 function get_info( $filename, $filenames )
159 global $full_videos_dir;
163 if( preg_match( '/^(.*)\\.flv$/', $filename, $matches ) )
166 $infofn = $matches[1] . ".rtvinfo";
168 if( array_key_exists( $infofn, $filenames ) )
170 list( $title, $date, $channel, $sub_title, $description ) =
171 get_info_from_file( $full_videos_dir . "/" . $infofn );
175 list( $title, $date ) = get_info_from_filename( $filename );
180 $titles[$title][] = array( $num, $date, $channel, $sub_title,
185 return array( $title, $date, $channel, $sub_title, $description );
188 // This is a hash filename -> nothing of all files in the videos directory
189 // and subdirectories
190 $filenames = array();
191 get_filenames_recursive( $filenames, $full_videos_dir );
193 // This is a hash filename -> nothing of all files in the deleted directory
194 $deleted_filenames = array();
195 $handle = opendir( $deleted_dir );
198 while( ( $filename = readdir( $handle ) ) )
200 $deleted_filenames[$filename] = '';
207 // This is a hash title->array( array( filenumber, date, filename, channel ) )
211 $nondeleted_filenames = array();
213 foreach ( $filenames as $fn => $blank )
215 $modified_fn = str_replace( "/", "_", $fn );
216 if( !array_key_exists( $modified_fn, $deleted_filenames ) )
218 $nondeleted_filenames[$fn] = '';
221 #array_diff_key( $filenames, $deleted_filenames );
223 $sorted_fns = array_keys( $nondeleted_filenames );
226 foreach( $sorted_fns as $filename )
228 list( $title, $date, $channel, $sub_title, $description ) = get_info(
229 $filename, $nondeleted_filenames );
233 $titles[$title][] = array( $num, $date, $channel, $sub_title,
234 $description, $filename );
244 <title
>Recorded programmes
</title
>
245 <style type
="text/css">
247 font
-family
: verdana
, sans
-serif
;
251 text
-decoration
: none
;
268 span
.smalltime
:hover
{
281 <script language
="JavaScript">
283 function makeRequest( url
, arg
)
287 if( window
.XMLHttpRequest
) // Mozilla, Safari etc.
289 httpRequest
= new XMLHttpRequest();
291 else if( window
.ActiveXObject
) // IE
295 httpRequest
= new ActiveXObject( "Msxml2.XMLHTTP" );
301 httpRequest
= new ActiveXObject( "Microsoft.XMLHTTP" );
314 httpRequest
.onreadystatechange
= function()
316 receiveAnswer( httpRequest
, arg
);
319 httpRequest
.open('GET', url
, true);
320 httpRequest
.send('');
323 function receiveAnswer( httpRequest
, prog_filename
)
325 if( httpRequest
.readyState
== 4 )
327 if( httpRequest
.status
!= 200 )
329 document
.location
= "delete_error.php?filename=" + prog_filename
335 function mouse_over( tr_id
)
337 tr_el
= document
.getElementById( tr_id
);
338 tr_el
.style
.backgroundColor
= '#ffaaaa';
341 function mouse_out( tr_id
)
343 tr_el
= document
.getElementById( tr_id
);
344 tr_el
.style
.backgroundColor
= 'transparent';
347 function title_click( table_id
)
349 table_el
= document
.getElementById( table_id
);
350 if( table_el
.style
.display
== 'inline' )
352 table_el
.style
.display
= 'none';
356 table_el
.style
.display
= 'inline';
361 function delete_prog( prog_filename
)
363 makeRequest( 'delete.php?filename=' + prog_filename
, prog_filename
);
364 tr_el
= document
.getElementById( 'tr_' + prog_filename
);
365 tr_el
.style
.display
= 'none';
372 <h1
>Recorded programmes
</h1
>
378 foreach( $titles as $title => $arr )
380 list( $num, $date, $channel, $sub_title ) = $arr[0];
381 print "<h2><a class='title' href='javascript: title_click( \"table_$table_counter\" )'>$title</a></h2>\n";
383 print "<table id='table_$table_counter' style='display: none' width='90%' cellpadding='0' cellspacing='0' border='0'>";
384 foreach( $arr as $lst )
386 list( $num, $date, $channel, $sub_title, $description,
388 print "<tr id='tr_$filename'><td><a href='play.php?filename=$filename' style='padding-right: 10px'";
390 print " title='$description'";
396 print $sub_title . " <span class='smalltime'>(";
399 print pretty_date( $date );
403 print " on $channel";
412 print "<td><a class='deletelink' onmouseover='mouse_over(\"tr_$filename\")' onmouseout='mouse_out(\"tr_$filename\")' href='javascript: delete_prog( \"$filename\" )'>[DELETE]</a></td></tr>\n";