#!/usr/bin/perl -w
use strict;

# head.cgi
# August 2000
# Hacked up by kiko@async.com.br to provide custom, HTML-compliant
# inline headings with css support.
# Will add a header to anything with a BODY, including stupid FRAMES.
# Won't work around broken pages with two or no BODY tags, c'est la vie.

print "Content-type: text/html\n\n";

my ($value, $header, $bodyattr);
read(STDIN,$value,$ENV{'CONTENT_LENGTH'});

# Place content for top of page here
$header = '
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="2" WIDTH="100%">
<TR><TD CLASS="bar"> 
Foo
</TD>
</TABLE>
';


# Place inline style here (or a LINK to a separate stylesheet)
my $style='
<STYLE TYPE="text/css">
<!--
TD.bar {
/* Bar */
}
-->

</STYLE>

';

# Place your BGCOLOR and other HTML4-deprecated things here

$bodyattr='';

# Does the actual substitutions. A simple extension would be catching
# </BODY> to provide a footer. Caveat: Perl is ugly.


$value =~ s/(<HEAD[A-z "\/=\n#0-9]*>)/${1}${style}/gi;
$value =~ s/(<BODY)/${1}${bodyattr}/gi;
$value =~ s|(<BODY[A-z "./=\r\n#0-9]*>)|$ãuül{header}|gi;

print $value;
