#!/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                                          #
# StatsPlus 1.25                                                            #
# A simple statistical solution.                                            #
# ------------------------------------------------------------------------- #
# (C)1997-98 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? Email support@uninetsolutions.com                           #
# ------------------------------------------------------------------------- #
# Modification History:                                                     #
# 1.0: 4/8/1997  StatsPlus released. Product based on Uninet Countran 1.0   #
# 1.25: 4/30/97    Updated to have easy links to the referer.               #
#######################################################################Uninet 
#Just follow the instructions:
#When typing type inside " and ". 
#Setup Part 1/2 - Steps 1 to 7
#1/5 Type The absolute of the the LOG file.
$log = "../data/log.txt";

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

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

#4/5 Type name of your site
$name = "RTSI";

#5/5Where will the statistics page be?
$stat = "../stat.html";
#########################################################
#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/stat.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");
print "<!-- Processed by StatPlus on $date-->";
#Logging
open (datk, ">>$log");
print datk "<td>$counter</td><td>$ENV{'HTTP_REFERER'}</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);
#Should tell user about update
open (UP,"http://www.serve.com/twn/upd.html");
$upd = <UP>;
close (up);
#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 TWN Perl Company. Count Stat V1.0 .<BR>$upd<BR><i>$ENV{'SERVER_SOFTWARE'}</i> </body></html>"; 
close (logs);



