3 include_once( "functions.php" );
5 function pretty_date( $date )
10 (int)( substr( $date, 11, 2 ) ),
11 (int)( substr( $date, 14, 2 ) ),
13 (int)( substr( $date, 5, 2 ) ),
14 (int)( substr( $date, 8, 2 ) ),
15 (int)( substr( $date, 0, 4 ) ) );
17 return date( "D d M, H:i", $tm );
20 function get_info_from_file( $fn )
28 $handle = fopen( $fn, "r" );
32 while ( !feof( $handle ) )
34 $line = fgets( $handle );
35 $line = substr( $line, 0, -1 );
37 list( $k, $v ) = split( "=", $line, 2 );
61 case "channel_pretty":
72 return array( $title, $date, $channel, $sub_title, $description );
75 function get_info_from_filename( $fn )
77 if( preg_match( '/^(.*?)-(.*)\\..*$/', $fn, $matches ) )
84 $title = substr( $fn, 0, strlen( $fn ) - 4 );
88 return array( $title, $date );
91 function get_info( $filename, $filenames )
97 if( preg_match( '/^(.*)\\.flv$/', $filename, $matches ) )
100 $infofn = $matches[1] . ".rtvinfo";
102 if( array_key_exists( $infofn, $filenames ) )
104 list( $title, $date, $channel, $sub_title, $description ) =
105 get_info_from_file( $videos_dir . "/" . $infofn );
109 list( $title, $date ) = get_info_from_filename( $filename );
114 $titles[$title][] = array( $num, $date, $channel, $sub_title,
119 return array( $title, $date, $channel, $sub_title, $description );
122 // This is a hash filename -> nothing of all files in the videos directory
123 $filenames = array();
124 $handle = opendir( $videos_dir );
127 while( ( $filename = readdir( $handle ) ) )
129 $filenames[$filename] = '';
135 // This is a hash filename -> nothing of all files in the deleted directory
136 $deleted_filenames = array();
137 $handle = opendir( $deleted_dir );
140 while( ( $filename = readdir( $handle ) ) )
142 $deleted_filenames[$filename] = '';
148 // This is a hash title->array( array( filenumber, date, filename, channel ) )
152 $nondeleted_filenames = array_diff_key( $filenames, $deleted_filenames );
154 $sorted_fns = array_keys( $nondeleted_filenames );
155 rsort( $sorted_fns );
157 foreach( $sorted_fns as $filename )
159 list( $title, $date, $channel, $sub_title, $description ) = get_info(
160 $filename, $nondeleted_filenames );
164 $titles[$title][] = array( $num, $date, $channel, $sub_title,
165 $description, $filename );
175 <title
>Recorded programmes
</title
>
176 <style type
="text/css">
178 font
-family
: verdana
, sans
-serif
;
182 text
-decoration
: none
;
199 span
.smalltime
:hover
{
212 <script language
="JavaScript">
214 function makeRequest( url
, arg
)
218 if( window
.XMLHttpRequest
) // Mozilla, Safari etc.
220 httpRequest
= new XMLHttpRequest();
222 else if( window
.ActiveXObject
) // IE
226 httpRequest
= new ActiveXObject( "Msxml2.XMLHTTP" );
232 httpRequest
= new ActiveXObject( "Microsoft.XMLHTTP" );
245 httpRequest
.onreadystatechange
= function()
247 receiveAnswer( httpRequest
, arg
);
250 httpRequest
.open('GET', url
, true);
251 httpRequest
.send('');
254 function receiveAnswer( httpRequest
, prog_filename
)
256 if( httpRequest
.readyState
== 4 )
258 if( httpRequest
.status
!= 200 )
260 document
.location
= "delete_error.php?filename=" + prog_filename
266 function mouse_over( tr_id
)
268 tr_el
= document
.getElementById( tr_id
);
269 tr_el
.style
.backgroundColor
= '#ffaaaa';
272 function mouse_out( tr_id
)
274 tr_el
= document
.getElementById( tr_id
);
275 tr_el
.style
.backgroundColor
= 'transparent';
278 function title_click( table_id
)
280 table_el
= document
.getElementById( table_id
);
281 if( table_el
.style
.display
== 'inline' )
283 table_el
.style
.display
= 'none';
287 table_el
.style
.display
= 'inline';
292 function delete_prog( prog_filename
)
294 makeRequest( 'delete.php?filename=' + prog_filename
, prog_filename
);
295 tr_el
= document
.getElementById( 'tr_' + prog_filename
);
296 tr_el
.style
.display
= 'none';
303 <h1
>Recorded programmes
</h1
>
309 foreach( $titles as $title => $arr )
311 list( $num, $date, $channel, $sub_title ) = $arr[0];
312 print "<h2><a class='title' href='javascript: title_click( \"table_$table_counter\" )'>$title</a></h2>\n";
314 print "<table id='table_$table_counter' style='display: none' width='90%' cellpadding='0' cellspacing='0' border='0'>";
315 foreach( $arr as $lst )
317 list( $num, $date, $channel, $sub_title, $description,
319 print "<tr id='tr_$filename'><td><a href='play.php?filename=$filename' style='padding-right: 10px'";
321 print " title='$description'";
327 print $sub_title . " <span class='smalltime'>(";
330 print pretty_date( $date );
334 print " on $channel";
343 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";