#!/usr/local/bin/perl4
###########################################################################
# Program:       homecounter.cgi
# Version:       1.01 June 22, 1995
# Revisions:     1.0 June 05, 1995
#                1.01 June 22, 1995--Added $Data_Dir
# Description:   Yet another page hit counter.
# Requirements:  perl (4 or 5), a webserver that allows user cgi
#                $Count_File must exist in same directory and contain a number
# Author:        Matt Leonard
#                mattl@pobox.com
#                http://www.pobox.com/~mattl
# Comments:      Really basic, only handles one page.
#                You need something like:
#                <!--#exec cmd="/yourcgibindir/homecounter.cgi"-->
#                in the page you want to count.
# Copyright:     This program is copyright 1995 Matt Leonard.
#                
###########################################################################

#
# variables
#

# Change $Data_Dir to reflect where $Count_File lives on your system.
$Data_Dir = "/home/leonarm/public_html";

# Change $Count_File to be whatever you want to call the countfile
$Count_File = "countfile";

#
# begin script
#
open (COUNT, "$Data_Dir\/$Count_File");

# get count from file
$Counter = <COUNT>;

# close count file
close (COUNT);

# open count file for writing
open (COUNT, "> $Data_Dir\/$Count_File");

# increment count & write out
$Counter += 1;
print COUNT "$Counter";
close (COUNT);

# output the count
print $Counter;
