#!/usr/local/bin/perl
require '/home/todd/toddweb.env';
require "weblib.lib";
$base="$PAGEHOMEDIR/www";
($mime,$type,$file)=split(m#/#,substr($ENV{PATH_INFO},1),3);
&ReadParse;
if($in{Mime}){
	$mime=$in{Mime} if $in{Mime};
	$type=$in{Type} if $in{Type};
}
if($in{URL}){
	$file=$in{URL};
	@f=split(m#/#,$file);
	$tag=$f[$#f];
}
if($mime eq ""){
	&htmlopen("Send Multimedia Object");
	print <<EOF;
<form action=/todd/mime/$$ method=POST>
MIME Type <input name=Mime> Sub-type <input name=Type><br>
URL <input size=60 name=URL><br>
<input type=submit name="Send me Multimedia!">
</form>
EOF
&htmlclose;
exit;
}
if($file =~ m#^http://|^ftp://#){
	$file=~s/ /%20/g;
	#open(BIN,"/usr/bin/lynx -dump $file|");
	open(BIN,"/home/todd/bin/hcat -d $file|");
}
elsif(-r "$base/$file"){
	open(BIN,"$base/$file");
}
else{
	&htmlopen("File not found");
	print "The file specified ($ENV{PATH_INFO}) is not available\n";
	&htmlclose;
	exit;
}
#print "Content-length: $s\n";
&htmlopen("$mime/$type=");
while(read(BIN,$_,1024)){ print; }
