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";
27 function is_video_dir( $full_path )
29 if( substr_compare( $full_path, "/.", -2 ) == 0 or
30 substr_compare( $full_path, "/..", -3 ) == 0 or
31 substr_compare( $full_path, "/deleted", -8 ) == 0 or
32 substr_compare( $full_path, "/tvguide", -8 ) == 0 )
37 return is_dir( $full_path );
40 function is_not_excluded( $filename )
44 return !in_array( $filename, $excluded );
47 function get_filenames_recursive( &$filenames, $top_dir, $sub_dir = "" )
49 $handle = opendir( "$top_dir/$sub_dir" );
52 while( ( $filename = readdir( $handle ) ) )
54 if( strlen( $sub_dir ) > 0 )
56 $filepath = "$sub_dir/$filename";
60 $filepath = $filename;
62 if( is_not_excluded( $filename ) &&
63 is_video_dir( "$top_dir/$sub_dir/$filename" ) )
65 get_filenames_recursive( $filenames, $top_dir, $filepath );
69 $filenames[$filepath] = '';
76 function pretty_date( $date )
81 (int)( substr( $date, 11, 2 ) ),
82 (int)( substr( $date, 14, 2 ) ),
84 (int)( substr( $date, 5, 2 ) ),
85 (int)( substr( $date, 8, 2 ) ),
86 (int)( substr( $date, 0, 4 ) ) );
88 return date( "D d M, H:i", $tm );
91 function single_quote_attribute_escape( $value )
93 return str_replace( "'", "'", $value );
96 function get_info_from_file( $fn )
104 $handle = fopen( $fn, "r" );
108 while ( !feof( $handle ) )
110 $line = fgets( $handle );
111 $line = substr( $line, 0, -1 );
113 list( $k, $v ) = split( "=", $line, 2 );
137 case "channel_pretty":
148 return array( $title, $date, $channel, $sub_title, $description );
151 function get_info_from_filename( $fn )
153 if( preg_match( '/^(.*?)-(.*)\\..*$/', $fn, $matches ) )
155 $title = $matches[1];
160 $title = substr( $fn, 0, strlen( $fn ) - 4 );
164 return array( $title, $date );
167 function get_info( $filename, $filenames )
169 global $full_videos_dir;
173 if( preg_match( '/^(.*)\\.(flv|avi)$/', $filename, $matches ) )
176 $infofn = $matches[1] . ".rtvinfo";
178 if( array_key_exists( $infofn, $filenames ) )
180 list( $title, $date, $channel, $sub_title, $description ) =
181 get_info_from_file( $full_videos_dir . "/" . $infofn );
185 list( $title, $date ) = get_info_from_filename( $filename );
190 $titles[$title][] = array( $num, $date, $channel, $sub_title,
195 return array( $title, $date, $channel, $sub_title, $description );
198 // This is a hash filename -> nothing of all files in the videos directory
199 // and subdirectories
200 $filenames = array();
201 get_filenames_recursive( $filenames, $full_videos_dir );
203 // This is a hash filename -> nothing of all files in the deleted directory
204 $deleted_filenames = array();
205 $handle = opendir( $deleted_dir );
208 while( ( $filename = readdir( $handle ) ) )
210 $deleted_filenames[$filename] = '';
217 // This is a hash title->array( array( filenumber, date, filename, channel ) )
221 $nondeleted_filenames = array();
223 foreach ( $filenames as $fn => $blank )
225 $modified_fn = str_replace( "/", "_", "$extra_path$fn" );
226 if( !array_key_exists( $modified_fn, $deleted_filenames ) )
228 $nondeleted_filenames[$fn] = '';
231 #array_diff_key( $filenames, $deleted_filenames );
233 $sorted_fns = array_keys( $nondeleted_filenames );
236 foreach( $sorted_fns as $filename )
238 list( $title, $date, $channel, $sub_title, $description ) = get_info(
239 $filename, $nondeleted_filenames );
243 $titles[$title][] = array( $num, $date, $channel, $sub_title,
244 $description, $filename );
254 <title
>Recorded programmes
</title
>
255 <style type
="text/css">
257 font
-family
: verdana
, sans
-serif
;
261 text
-decoration
: none
;
278 span
.smalltime
:hover
{
291 <script language
="JavaScript">
293 function makeRequest( url
, arg
)
297 if( window
.XMLHttpRequest
) // Mozilla, Safari etc.
299 httpRequest
= new XMLHttpRequest();
301 else if( window
.ActiveXObject
) // IE
305 httpRequest
= new ActiveXObject( "Msxml2.XMLHTTP" );
311 httpRequest
= new ActiveXObject( "Microsoft.XMLHTTP" );
324 httpRequest
.onreadystatechange
= function()
326 receiveAnswer( httpRequest
, arg
);
329 httpRequest
.open('GET', url
, true);
330 httpRequest
.send('');
333 function receiveAnswer( httpRequest
, prog_filename
)
335 if( httpRequest
.readyState
== 4 )
337 if( httpRequest
.status
!= 200 )
339 document
.location
= "delete_error.php?filename=" + prog_filename
345 function mouse_over( tr_id
)
347 tr_el
= document
.getElementById( tr_id
);
348 tr_el
.style
.backgroundColor
= '#ffaaaa';
351 function mouse_out( tr_id
)
353 tr_el
= document
.getElementById( tr_id
);
354 tr_el
.style
.backgroundColor
= 'transparent';
357 function title_click( table_id
)
359 table_el
= document
.getElementById( table_id
);
360 if( table_el
.style
.display
== 'inline' )
362 table_el
.style
.display
= 'none';
366 table_el
.style
.display
= 'inline';
371 function delete_prog( prog_filename
)
373 makeRequest( 'delete.php?filename=' + prog_filename
,
375 tr_el
= document
.getElementById( 'tr_' + prog_filename
);
376 tr_el
.style
.display
= 'none';
383 <h1
>Recorded programmes
</h1
>
389 foreach( $titles as $title => $arr )
391 list( $num, $date, $channel, $sub_title ) = $arr[0];
392 print "<h2><a class='title' href='javascript: title_click( \"table_$table_counter\" )'>$title</a></h2>\n";
394 print "<table id='table_$table_counter' style='display: none' width='90%' cellpadding='0' cellspacing='0' border='0'>";
395 foreach( $arr as $lst )
397 list( $num, $date, $channel, $sub_title, $description,
400 $ext = substr( $filename, strlen( $filename ) - 4 );
401 $play_url = "$videos_uri/$filename";
404 $play_url = "play.php?filename=$filename";
407 print "<tr id='tr_$extra_path$filename'><td><a href='$play_url' style='padding-right: 10px'";
409 print " title='".single_quote_attribute_escape( $description )
416 print $sub_title . " <span class='smalltime'>(";
419 print pretty_date( $date );
423 print " on $channel";
432 print "<td><a class='deletelink' onmouseover='mouse_over(\"tr_$extra_path$filename\")' onmouseout='mouse_out(\"tr_$extra_path$filename\")' href='javascript: delete_prog( \"$extra_path$filename\" )'>[DELETE]</a></td></tr>\n";