#!/usr/bin/perl -w

#<TITLE>Footer short</TITLE>
#<META name="description" content="This perl script prints a footer for a html page, with some stats.">
#<META name="icon" content="/~jipp/melk/perlt.jpg,66,38">
#made by: pip@dds.nl

$WWWdir = "/www/Casema/I/";
$Rwww = "http://www.casema.net/~jip/";
 
$name = $ARGV[0];
$fullname = "$WWWdir$name.html";

$Renc = "http%3a%2f%2fwww%2ecasema%2enet%2f%7ejip%2f";
$page_begun = lookup_page_begun($fullname);

$babelfish = "http://babelfish.altavista.digital.com/cgi-bin/translate?urltext=";
$babelfish .= $Renc.$name;
$babelfish .= "%2ehtml&language=en";

$validate = "http://validator.w3.org/check?uri=";
$validate .= $Renc.$name;
$validate .= ".html";

$altal = "http://www.altavista.digital.com/cgi-bin/query?pg=q&what=web&fmt=.&q=link%3A";
$altal .= $Renc.$name;
$altal .= "&r=&d0=&d1=";

$sname=$name;
$sname =~ s/\.//g;
$sname =~ s/\-//g;

$date = `ls -lc $fullname`;
($moddate) = $date =~  /(\W\w+\s+\d+\s\d+\:\d+)/;
#stat ($fullname);
#$moddate = -M _;
#($date) = $date =~ /.+([A-Z].+)\/www.+/;

$nowdate= `date`;
chop ($nowdate);


print <<GROK;
GROK

&printstat;

exit(1);

sub printstat{
$backsearch = $altal;

print <<GROK;
<!--  begin footer for: $name 
      see http://www.casema.net/~jip/perl.html for more info
-->
<br clear="all">
<p align="right"><a href="http://www.opencontent.org/home.shtml"
 ><font size="-3">All rights reserved.</font></a>
<br><a href="http://www.opencontent.org/opl.shtml"
 ><font size="-3">All</font></a><font size="-3"><a 
 href="mailto:pip\@dds.nl?subject=copywrong $name"> wrongs </a></font><a 
 href="http://www.opencontent.org/opl.shtml"><font 
 size="-3">reversed.</font></a></p>

<table width="100%" border="0" cellpadding="0" cellspacing="0">
 <tr>
  <td align="left" width="40%">
   <font size="-2">
   <a 
	href="$backsearch"
	onMouseOver="window.status='Search for pages linking to $name.html' ; return true" 
   >Page </A><a href="$validate"
	onMouseOver="window.status='Validate this page.' ; return true"
   >by </a><a 
	href="mailto:pip\@dds.nl?subject=This ~/jip/$name.html thingie is wowzers!"
	onMouseOver="window.status='Mail me about $name.html' ; return true"    
>Jip</A>

 <img src="http://kwark.ddns.org/htbin/ip.gif" height="1" width="1" alt="">  
 <br>
 <a href="$babelfish"
  onMouseOver="window.status='Try babelfish on this page.' ; return true"
 >Page</a> started: $page_begun
 <br>
 <a href="/~jip/latest.html#$name.html"
  onMouseOver="window.status='View pages sorted by newestness.' ; return true"	
 >Last modified</A>: $moddate
 <br>
 </font>
</td>
<td align="center" valign="bottom" width="20%">
 <font size="-2">
 <a href="siteindex.html"
     onMouseOver="window.status='Index of /~jip/' ; return true"
	 target="_top"
 >Index</a>
 </font>
</td>
<td align="right" width="40%">
<a 
	href="http://www.nedstat.nl/cgi-bin/viewstat?name=jip$sname"
	onMouseOver="window.status='Nedstat statistics for $name.html';return true"
><img src="http://www.nedstat.nl/cgi-bin/nedstat.gif?name=jip$sname" border=0
align="right" width="32" height="32" alt="NedStat"></a>



      <script language="JavaScript">
      <!--
      document.write("<img src=\\"http://www.nedstat.nl/cgi-bin/referstat.gif?name=jip$sname&refer="+escape(top.document.referrer)+"\\" width=1 height=1 alt=\\"R\\">");
      // -->
      </script>


</td></tr></table>
<!-- end footer for: $name -->
GROK
}


sub lookup_page_begun{
        local($file) = @_;
        local($head,$begun);
        if (open(IN, "<$file")) {
                line: while (<IN>) {
                        $head .= $_;
                        if ( m!</head!i ){
                                        last line;
                        }
                }
        }
        ($begun) = $head =~ m!<meta name=\"begun\" content=\"(.+)\">!i;
        return $begun;
}  
