Change config to match my new setup.
[recordtv.git] / playonwii / functions.php
blobbbde25727ad753c620570225b806a05c0ea1fc70
1 <?php
3 $videos_dir = "/home/andy/Videos/Wii";
4 $deleted_dir = "$videos_dir/deleted";
5 $videos_uri = "/filesvideo";
7 $allowed_chars_re = "/[\\/0-9a-zA-Z_-]/";
9 # Compare with rtv_utils.py's prepare_filename method
10 function prepare_filename( $filename )
12 global $allowed_chars_re;
14 $len = strlen( $filename );
15 if ( substr( $filename, $len - 4 ) != ".flv" and
16 substr( $filename, $len - 4 ) != ".avi" )
18 return "not_an_flv";
20 $extension = substr( $filename, $len - 4 );
21 $filename = substr( $filename, 0, $len - 4 );
23 $ans = sanitise_filename( $filename );
25 return $ans.$extension;
28 function sanitise_filename( $filename )
30 global $allowed_chars_re;
32 $len = strlen( $filename );
34 $ans = "";
36 for( $i = 0; $i < $len; $i++ )
38 $char = $filename[$i];
39 if( preg_match( $allowed_chars_re, $char ) )
41 $ans .= $char;
43 else
45 $ans .= "_";
49 return $ans;