#!/usr/bin/perl

eval {
use GD;
use CGI;

my $q = new CGI;
my $hiddenhitfile = $q->param("hiddenhitfile") || ".hiddenhitnumber";
#my $hiddenhitfile = "html/cgi/.hiddenhitnumber";
#$hiddenhitfile = "html/cgi/$hiddenhitfile";

# read hit number file, increment by 1 and write it back
open (H, "+<$hiddenhitfile") or die "no open: $!";
$hitno = <H>;
$hitno++;
seek H, 0, 0;
print H $hitno;

# create a new image
$width = 100;
$height = 20;
$im = new GD::Image($width,$height);

# first color allocated will be background
$lavender = $im->colorAllocate(230, 230, 250);
$white = $im->colorAllocate(255, 255, 255);
$black = $im->colorAllocate(0, 0, 0);

# the x, y coords indicate upper left
# Giant font is 8x16 fixed width
$w = length($hitno) * gdGiantFont->width;
$l = ($width - $w)/2;				# to center text
$im->string(gdGiantFont, $l, 2, $hitno, $black);

# newer lib GD will not create gifs, use png
print "Content-type: image/x-png\n\n";
print $im->png;

};
if ($@) {
    print "Content-type: text/html\n\n";
    print "\n\perl error: $@";
    exit;
}
