#!/usr/bin/perl

$data = '/var/log/httpd/counter.mn.data';
$lockfile = '/tmp/counter.mn.LOCK';

&increment;

print << "STOP"
Content-Type: text/html

<html> <HEAD>
   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
   <META NAME="GENERATOR" CONTENT="Mozilla/4.05 [en] (X11; I; Linux 2.1.130 ppc) [Netscape]">
   <TITLE>Welcome to The Maelstrom!</TITLE>



</HEAD>
<BODY TEXT="#f0f0f0" BGCOLOR="#00007d" LINK="#ffffFF" VLINK="#c0c0c0" ALINK="#FF0000">
<center><br>
Be grateful for luck.  Pay the thunder no mind.  Listen to the birds.  And don't hate nobody.  - Eubie Blake
<!--Moral indignation is jealousy with a halo. - H G Wells-->
<!--When honesty overbalances refinement, crudeness results. When refinement overbalances honesty, there is superficiality. - Confucius -->
<!--Women are crazy and men are stupid.
<br>And the reason that women are crazy is that men are stupid. - Carlin-->
<!--I have a right not to keep count.
<br>And I have a right to forget about them - Hemingway-->
<!--We are talking about God.
<br>Which wonder do you think you understand?
<br>If you understand, it is not God.  -Augustine of Hippo-->
<!--How did I get away with it?
<br>It's very simple;
<br>I didn't.-->
<!--WRITE<p>IT<p>DOWN-->
<!--I should have said -the evidence is mounting.  The sad part is we have to die 
unless you happen to parlez francais mes amis; le petit mort anyone? The old 
stuff is still under /old for now if that's what you seek.-->
<!--I should have said -the evidence is mounting.  And abhorrent would have been a 
good word as well.  Still, I regret to say there is no language to help her see 
her wrong.-->
<!--<p>The old stuff is still under ~mmairs/old for now if that's what you seek.-->
<!--Expect change.  There is at least one regard in which I shall not disappoint.-->
<!--<br>The story goes on. By needs must I elaborate. Am I boring you? --> 
<HR WIDTH="90%" SIZE="8">
</center>
<table>
<tr>
<td width="33%">
<center>
<CENTER><A HREF="~mmairs/"><IMG SRC="bassclef1.gif"
ALT="[ What's Matt Up To Now? ]"><br>Matt's Place...</A> (last modified 11042006)</CENTER>
<br><a href=~mmairs/saga.html>About Mairs.Net (last modified 11222004)</a>
<br><a href=~mmairs/links.html>Links</a>
  <form method="post" action="http://www.kartoo.com/perso.php3" name="kartoo" alt="Wish yer browser supported forms, eh?">
    <div align="center">Kartoo is my (meta) search engine of choice:</div>
    <table border="0" cellpadding="0" cellspacing="0" bgcolor="00007D" width="32
6" align="center">
      <tr align="center" valign="middle">
        <td colspan="2" height="22"><b><font face="Arial, Helvetica, sans-serif"
 color="#FFFFFF" size="2">Search
          : </font></b>
          <input type="text" name="q" size="25">
          <input type="submit" name="submit" value="OK">
        </td>
      </tr>      <tr align="center">
        <td colspan="2" valign="middle" height="8"> <b><font face="Arial, Helvet
ica, sans-serif" color="#FFFFFF" size="2">
          <input type="radio" name="lg" value="1" checked>
          english web &nbsp;&nbsp;&nbsp;
        </td>
      </tr>      <tr align="center">
        <td colspan="2" valign="middle" height="8"> <b><font face="Arial, Helvet
ica, sans-serif" color="#FFFFFF" size="2">
          <input type="radio" name="lg" value="0">
          worldwide web </font></b></td>
      </tr>

    </table>
    <div align="center"></div>

<div align="center">
  <p>
    <input type="hidden" name="fd" value="1">
    <input type="hidden" name="tr" value="3">
    <input type="hidden" name="bo" value="4">
    <input type="hidden" name="langue" value="en">
  </p>
    </div>
  </form>
</center>
</td>
<td width="66%"><br><br>
<center>
<a href="http://www.yellowdoglinux.com"><img src="banner_left.jpg" 
alt="[ Yellow Dog ]"></a>
<br><a href="http://www.apple.com">Get a Mac.</a>  
<a href="http://www.yellowdoglinux.com">Get Yellow Dog.</a> 
<a href="http://www.nosepilot.com">Be happy!</a>

<p>This is a <a href="http://www.everymac.com/systems/apple/powermac/stats/powermac_6500_225.html">6500.</a>
<br>RISC performance at a dumpster price!

<p><a href="http://www.itsassure.com"><img src=banner1.gif width=480 height=70 alt="Net Assure"></a><br> was the best ISP!
</center>
<br>
This counter has biffed it approximately 20 times because we weren't paying 
attention and the disk filled up or for other very peculiar reasons I'd tell 
you about if you cared.
<br>
This page has been accessed approximately 
$accesses
 times since the last time I bothered to fix the damn counter.
<div align="right">Want email?  Need a website?  
<a href="mailto:mmairs\@.nospam.mairs.net">Talk</a> to me.</div>
</td></tr></table>
<EMBED id="sound1" SRC='~mmairs/fu_bebe.mp3' loop="true" autostart="true" hidden="false" ></EMBED>
</body> 
</html>
STOP
;
sub increment {
  # read the data
  open(DATA,$data) || die "Can't open data file.\n";
  $accesses = <DATA>;
  $accesses++;
  close(DATA);
  # check for lock file
  while (-e $lockfile) {
    sleep 2;   # wait 2 seconds
  }
  # create lockfile
  open(LOCK,">$lockfile") || die "Can't create lockfile.\n";
  close(LOCK);
  # write new value
  open(DATA,">$data") || die "Can't create lockfile.\n";
  print DATA "$accesses";
  close(DATA);
  # delete lockfile
  unlink($lockfile);
}
