Created
February 14, 2009 21:35
-
-
Save fuba/64483 to your computer and use it in GitHub Desktop.
cgi script to generate directory index for perlrtmp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use utf8; | |
use strict; | |
use warnings; | |
use URI::Escape qw(uri_escape_utf8 uri_unescape); | |
use File::Slurp; | |
use Encode; | |
use constant DIR => '/Volumes/sanjou530/friio/'; # edit here | |
my $filename = decode_utf8(uri_unescape($ENV{QUERY_STRING})); | |
$filename =~ s|.*?([^/]+)$|$1|; | |
$filename = encode_utf8($filename); | |
print "Content-Type: text/html;charset=utf8\n\n"; | |
if ($filename) { | |
my @data = <DATA>; | |
my $data_str = join '', @data; | |
$data_str =~ s/\%s/$filename/m; | |
$data_str =~ s/\%S/$ENV{SERVER_NAME}/m; | |
print $data_str; | |
} | |
else { | |
my @files = read_dir(DIR); | |
#use YAML; | |
#print '<pre>'.YAML::Dump(\%ENV).'</pre>'; | |
for my $file (@files) { | |
next unless ($file =~ /\.mpg/); | |
print '<li><a href="./?'.uri_escape_utf8(decode_utf8($file)).'">'.$file.'</a></li>'."\n"; | |
} | |
} | |
__END__ | |
<html> | |
<body> | |
<script type='text/javascript' src='swfobject.js'></script> | |
<div id='preview'>This div will be replaced</div> | |
<script type='text/javascript'> | |
var s1 = new SWFObject('player.swf','player','320','200','9','#ffffff'); | |
s1.addParam('allowfullscreen','true'); | |
s1.addParam('allowscriptaccess','always'); | |
s1.addParam('wmode','opaque'); | |
s1.addParam('flashvars','streamer=rtmp://%S&file=%s.flv'); | |
s1.write('preview'); | |
</script> | |
</body> | |
</html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment