#!/usr/bin/perl -w
#--------------------------------------------------------------------------
# play_flv.pl - creates webpage with embedded video to show in popup
# written by Eric Pence
#--------------------------------------------------------------------------
use strict;
use CGI qw(-oldstyle_urls :standard);
use CGI::Carp qw(fatalsToBrowser);

# Define global variables
use vars qw($curr_dir $log_file);

#--------------------------------------------------------------------------
# Grab the current directory from $0. The following regular expression
# looks for 'CURR_DIR\xxxxx.xxx' or 'CURR_DIR/xxxxx.xxx'. Place it in
# the BEGIN block so we can use it to include modules
#--------------------------------------------------------------------------
BEGIN {
$0 =~ '(.*[\\\/])\w+\.\w+$';
$curr_dir = $1 || "./";

# Set up error log file
$log_file = "error_log.txt";
use CGI::Carp qw(carpout);
open(LOG, ">>${curr_dir}${log_file}")
or die "Unable to append to error log: $!";
carpout(*LOG);
}

my $q = new CGI;

# Get parameters
my $filename = '';
if ($q->param('filename')) {
$filename = $q->param('filename');
}
my $width = '';
if ($q->param('width')) {
$width = $q->param('width');
}
else {
$width = '420';
}
my $height = '';
if ($q->param('height')) {
$height = $q->param('height');
}
else {
$height = '380';
}
my $title = '';
if ($q->param('title')) {
$title = $q->param('title');
}
else {
$title = $filename;
}

print "Content-type: text/html\r\n\r\n";
print "<html>
<head>
<title>$title</title>
<style type=\"text/css\" media=\"screen\">
body {
margin:0;
padding:0;
width:100%;
height:100%;
background:#000000;
}
</style>
</head>
<body>
<div align=\"center\" style=\"width:100%;height:100%;margin:0;padding:0\">
<object type=\"application/x-shockwave-flash\" width=\"$width\" height=\"$height\" wmode=\"transparent\"
data=\"../video/flvplayer.swf?file=$filename&autostart=true&stretchtofit=true&dock=fill\">
<param name=\"movie\" value=\"../video/flvplayer.swf?file=$filename&autostart=true&stretchtofit=true&dock=fill\">
<param name=\"stretchtofit\" value=\"true\">
</object>
</div>
</body>
</html>";