YAC (Yet Another Counter) 0.6.3 Documentation

YAC is a web counter and logger written in Perl

Copyright (C) 2001-2002 Roland "Robelix" Obermayer

YAC Homepage


< Features / Requirements / Usage / Log Analyzer / License >


Features

YAC only counts "real" visits - it only increases the counter if there was no request from the same IP within one hour, but logs every page hit.

It has 3 modes (text, graphic and quiet) and a configurable minimum number of digits.

It's fine for free/cheap servers where you have no access to the server-logs.

It uses flock() for all file-operations to avoid courrupt data.

Log-analyzer-script that produces (maybe too) detailed statistics about visits/day, accessed pages, browsers and operating systems


< Features / Requirements / Usage / Log Analyzer / License >


Requirements

An Apache server running on Unix (so far tested with Linux only) with SSI (server side includes) enabled.

Perl 5 with the CGI and Fnctl modules (should be on every Unix machine)

The Right to run own cgi-scripts on the server

If you want graphic output you need a set of digit-images, a more than complete collection can be found here


< Features / Requirements / Usage / Log Analyzer / License >


Usage

Edit the Config part at the beginning of yac.pl:

# the directory where the data-files are stored
# (the full unix-system-path!!) 
my $data_dir    = "/full/path/to/your/data/directory";

# the filenames
my $count_file  = "count.txt";
my $latest_file = "latest.txt";
my $log_file    = "log.txt";

# the path to the digit pictures (the url!)
my $graph_path = "/pix/counter";

# the ending of the graphics
# will be .gif, .png or .jpg 
my $graph_end  = ".gif";

Upload yac.pl to the cgi-directory (ASCII-Mode!) of your server and make sure that the permission is set to 755 (rwxr-xr-x)

Create a data-directory on the server and upload count.txt, log.txt and latest.txt (ASCII-Mode!) into it. Make sure that the permissions are set to 666 (rw-rw-rw-)

Add to your web-pages:

<!--#include virtual="/cgipath/yac.pl?mode=graphic;length=5"-->

replace "/cgipath/" with the path of your cgi-directory, often "cgi-bin" or "cgi", but can be anything - Ask your Server-admin, not me!

the mode may be "graphic", "text" or "quiet", default is "quiet".

lenght is the minimum number of digits to be displayed. In quiet mode this does nothing, of course. Default is "1".

On most servers you will have to rename your pages to *.shtml (server parsed html)! - And don't forget to update the links...

On some server configurations you may need to rename yac.pl to yac.cgi

Since I have no clue about other servers than Apache on Unix please don't bother me with questions about these!


< Features / Requirements / Usage / Log Analyzer / License >


The log-analyzer

Provides detailed access-statistics

You can view an example of its output

First you need to edit the config part at the beginning of the file:

# the directory where the data-files are stored and the filenames
# (the full unix-system-path!!)
# of course the same as used in yac.pl
  my $data_dir    = "/full/path/to/the/data/directory";
  my $count_file  = "count.txt";
  my $log_file    = "log.txt";

# path/filename to the picture used for the graphical bars
# (the url!)
# schould be 1x1 px Images - in the output they are expanded with the
# "height" and "width" options - gives a nice diagram
# If you use diffrent pix, you can give the bars diffrent colors.
  my @bar_pics  = ("/pix/counter/bar.gif", "/pix/counter/bar.gif", "/pix/counter/bar.gif", "/pix/counter/bar.gif");

# the pictures that are added to the bar if it's longer than
# the maximum (some kind of arrow that fits to the bar)
  my @more_pics = ("/pix/counter/more0.gif","/pix/counter/more0.gif","/pix/counter/more0.gif","/pix/counter/more0.gif");

# the width of a 100% bar [pixel]
  my $width = 2000;

# the maximum width a bar is displayed
# if it would be longer it's cut to that length with the
# "more-picture" attachted
  my $bar_max = 400;

# the height of the bars [px]
 my @bar_heights = (22,16,12,9);

# the maximun lenght of the output-string
# (the full string is always set as "alt" to the bar-image.
# Most Browsers show it as mouseover-tooltip)
  my @max_strg_l = (24,35,42,52);

The script should be called with ssi from a page that defines some stylesheets - like this:

<html>
<head>
<title>Counter Statistics</title>
<style type="text/css">
<!--
.comment              {font-size:14pt;}
.d0, .d1, .d2, .d3,
.b0, .b1, .b2, .b3,
.c0, .c1, .c2, .c3    {whitespace:pre;}
.d0, .c0, .b0         {font-size:24pt; padding-left:0px; color:#920204; font-weight:bold;}
.d1, .c1, .b1         {font-size:16pt; padding-left:20px;}
.d2, .c2, .b2         {font-size:12pt; padding-left:40px;}
.d3, .c3, .b3         {font-size:10pt; padding-left:60px;}
.t0                   {background-color:#FFFFFF;}
.t1                   {background-color:#EEEEEE;}
.t2                   {background-color:#DDDDDD;}
.t3                   {background-color:#CCCCCC;}
-->
</style>
</head>
<body bgcolor="#CAB293">

<!--#exec cgi="/cgidir/yac-stat.pl"-->

</body>
</html>

The Styles:
.d0, .d1, .d2, .d3 - used for the left column that contains the data
.c0, .c1, .c2, .c3 - the middle column that contains the count
.b0, .b1, .b2, .b3 - the right column with the bar
.t0, .t1, .t2, .t3 - used to format the table-backgrounds
The numbers represent the depth in the hierachy

So far yac-stat.pl does not use any options

Warning!

This is beta software! Expect problems! (and report it) Do not use on mission-critical systems!

It definitely has some problems:
- speed: the browser- and os-detection need loads of pattern-detection which are slow. The main speed problem should be solved in Vers. 0.6.2. Now Netscape needs much more time to render the table than yac-stat to create it ;-) - but it's still not the fastest script on earth...
- memory usage is not optimized
- browser and system detection is far away from perfect - expect some strange things!

I usally download the log to my test-server at home and run yac-stat.pl there


< Features / Requirements / Usage / Log Analyzer / License >


License

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

[an error occurred while processing this directive]

< YAC Homepage >


Guaranteed to be 100% X-MAS free! A System that deserves the prefix 'Operating' Created with Quanta+ WebEditor Graphix made with The GIMP