#!/usr/local/bin/perl
#
# Brad Donison bdonison@grmi.org
# 4 Aug 95
#
# updates the access count and prints it for a specified file
#
# usage:
# counter
#
# NOTE: it looks at the url that is running, and creates a counter file if
#       none exists.  Then it just appends a single character to the file,
#       and then prints the size of the file.

#unshift(@INC, '/local/www/tools');
unshift(@INC, '.');

require "digits.pl";
require "counter.pl";

$c = &counter;
&number($c);

#sub counter {
#  $base = "/local/www/tools/counters/";
#  $me = $ENV{'DOCUMENT_URI'};
#  $me =~ s/\//=/g;
#  $log = $base.$me.".count";
#
#  open (LOGFILE, ">> $log");
#  print LOGFILE "x";
#  close (LOGFILE);
#  @info = stat($log);
#  return ($info[7]);
#}

# Displays graphic odometer for web pages
sub number {
  local($number) = @_;

  local($base) = "/local/www/httpd/htdocs/pics/meter/";
  local($me) = $ENV{'DOCUMENT_URI'};
  $me =~ s/\//=/g;
  local($numfile) = $base.$me.".xbm";

  if (!$number) {
    exit;
  }

  &digits($number, $numfile);
  select STDOUT;
  print "ContentType: text/html\n\n";
  print "<IMG SRC=\"/pics/meter/", $me, ".xbm\" height=16 width=80>\n";
}

