#!/usr/local/bin/perl

#
#Container for page's parts.
#

use CGI::Carp qw(fatalsToBrowser);
use CGI;
use CGI qw(:standard);

$query = new CGI;

$filename=$query->param('src');

$path="/home/yourid/public_html/store";
$user_ip=$ENV{'REMOTE_ADDR'};
($csec,$cmin,$chour,$cmday,$cmon,$cyear,$cwday,$cyday,$cisdst) =localtime(time);
$cyear=$cyear+1900;
$cmon=$cmon+1;


if (&outputSwf("$filename")<0){
	print "Content-type: text/html\r\n\r\n";
	print "<html><body>";
	print "<h1>Can't find specify source. Sorry.</h1>";
	print "</body></html>";
} else {
    open(INF,">> $path/downloadz.inf");
    print INF "$filename : $cmday/$cmon/$cyear : $user_ip\n";
    close INF;
};

exit;                 

sub outputSwf {
    local($file) = @_;
    local($data,$len);
    $fullpath="$path/$file";
    open(INF,$fullpath) or return -1;
    $len = (stat(INF))[7];
    binmode(INF);
    $filelen=read(INF,$data,$len);
    close(INF);

    print "Content-type: application/fla; name=\"$file\"\r\n";
    print "Content-length: $len\r\n";
    print "Content-Disposition: file; filename=\"$file\"\r\n\r\n";
    print $data;

    return 1;
}



