#!/usr/bin/perl
#  ^
# / \
#  |   Modify the line the arrow is pointing to, to the correct
#  |   location of Perl v5 or better.
#Uninet######################################################################
#   w  w  w  .  u  n  i  n  e  t  s  o  l  u  t  i  o  n  s  .  c  o   m    #
# UNINET PERL COMPANY(TM) PRESENTS                                          #
# Count+Stat 1.5.2                                                          #
# Graphical Web Site Counter and Statistics Program                         #
# ------------------------------------------------------------------------- #
# (C)1997-99 Uninet Communications Co., All Rights Reserved.                #
#                                                                           #
# 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.                              # 
#                                                                           #
# You should have received a copy of the GNU General Public License         #
# along with this program; if not, write to the                             #
#                Free Software Foundation, Inc.                             #
#                59 Temple Place - Suite 330                                #
#                Boston, MA  02111-1307, USA.                               #
#                                                                           #
# -->A full copy of the GNU General Public License is included in gpl.txt   #
# ------------------------------------------------------------------------- #
# Need Support? We offer FREE technical support!                            #
# Email us at support@uninetsolutions.com for quick, free support today!    #
# ------------------------------------------------------------------------- #
# Modification History:                                                     #
# 1.0: 4/4/1997   Count+Stat released. Product based on Uninet Countran 1.0 #
# 1.5: 6/1998     Enhanced logging, updated link to Uninet Perl Co.         #
# 1.5.1: 8/4/98   New documentation, Now licensed under GNU GPL.            #
# 1.5.2: 3/8/1999 Bugs Fixes.                                               #
#######################################################################Uninet 


#Just follow the instructions:
#When typing type inside " and ". 
#Setup Part 1/2 - Steps 1 to 7
#1/7 Type The absolute of the the LOG file.
$log = "log.txt";

#2/7 Type the absolute path to the counter file.
$count = "num.txt";

#3/7 Type the path to the date command
$datecommand = "/bin/date/";

#4/7 Type name of your site
$name = "Evaldo HP";

#5/7 Type the absolute path to the statistic page. (The page that views the log)
$stat = "stat.htm";

#6/7 What is the ending of the digits (you need to get a full set of 10 images to 
#represent the digits)?
$end = ".gif";

#7/7 Where is the directory located with the digits? Images must be 
#x.gif or x.jpg (so if your counter is at 20 it would load 2.gif and 0.gif).
#Tip: Don't have any digits? Try http://www.digitmania.holowww.com 
#they have over 100!
$path = "http://www.elnet.lt/cgi-bin/vija/img/";

#########################################################
#Manual Installation Instructions:
#Setup Part 2/2 - Steps 1 to 3
#Place all files in their respective directory.
#1/3 Now chmod 'cstat.pl' 775
#2/3 Then chmod 'log.txt', 'num.txt', and 'stat.htm' 777
#3/3 Now add <!--#exec cgi="cgi-bin/cstat.pl" --> to the location in your
#    webpage where you want the counter.
#To see your stats run the page you specified (by default stat.html). 
#  ##    ##    #   #   ###
#  # #  #  #   ##  #   # 
#  # #  #  #   # # #   ###
#  # #  #  #   #  ##   #  
#  ##    ##    #   #   ###    #
#########################################################
#Remember to upload the files in ASCII.
#
#Your done REALLY... So go save this file and leave!
#
#You just don't give up do you? :-) 
#########################################################
#Testing Date
@months = ('Jan','Feb','Mar','Apr','May','June',
		 'July','Aug','Sept','Oct','Nov','Dec');

@days = ('Sun','Mon','Tue','Wed','Thu','Fri','Sat');

($sec,$min,$hour,$mday,$mon,$year,$wday) = (localtime(time))[0,1,2,3,4,5,6];
$date = " $days[$wday], $months[$mon]/$mday/$year $hour:$min:$sec";
# Get Count
open (CD, "$count");
$counter = <CD>;
close (CD);
chop ($counter) if $count =~ /\n$/;
# Increase Count
$counter += 1;
open (CD, ">$count");
print CD ("$counter");
close (CD);
print ("Content-type: text/html\n\n");
@digits = split(//, $counter);
$howmany = @digits;
$spline = '%0' . $howmany . 'd';
$counter = sprintf("$spline", $counter);
@digit = split(//, $counter);
# Print Counter
foreach $digit (@digit) {
$i = "<img src=$path" . "$digit" . "$end >";
print ("$i");
}
#Logging
open (datk, ">>$log");
print datk "<td>$counter</td><td><a href=\"$ENV{'HTTP_REFERER'}\">$ENV{'HTTP_REFERER'}</a></td><td>$ENV{'REMOTE_ADDR'}</td><td>$date</td><td>$ENV{'HTTP_USER_AGENT'}</td><TR>"; close (datk); open (datk, "$log");
$data = <datk>;
close (datk);
#Print Sheet
open (logs,">$stat");
print logs "<html><head><title>Statistics for $name.</title></head><body>You currently have had $counter hits.<BR><table border = 1><td>Hit No.</td><td>Referer</td><td>IP address</td><td>date</td><td>client</td><TR>$data</table><BR>(C)1997-99 <a href=\"http://twn.perlscripts.com\">Uninet Perl Company</a>. Count Stat V1.5.2.<BR><i>$ENV{'SERVER_SOFTWARE'}</i> </body></html>"; 
close (logs);   
