Get Stats, access.log, error.log, phperr.log

I really need view stats for my website. I’ve devised some decent ways of getting stats for myself using htaccess and some cgi scripts available on the internet. I’ll do my best at explaining what I do to get the stats I need.

For people using Tiger Technologies you can use all of these methods. For others you can make use of most of these methods although you’ll need a email form script.

You’ll need:

  1. If TigerTech user get the email form provided in settings
  2. Stats Log Viewer (below) from PerlScriptsJavaScripts
  3. text.cgi(pl) (below) Code from Dirk Brockhausen – co-founder and principal of fantomaster.com Ltd

Viewing stats log

  1. Download available log files (/logs/web/)
  2. Extract log files and upload all files (text.cgi, logviewer.cgi and website.log) to cgi-bin
  3. Enter name of file to view at – $LOG = “yourwebsite.log”;

Never remove author copyright text from files

Name cgi file for task ( Access Log Viewer, Error Log Viewer, phperr Log Viewer ). As long as a log file is there to read you’ll see it and different titles allow you to bookmark your pages. I’ve most likely left something out so ask, or add correction in comments.

CGI FILE
———————————

############################################
#
# Log Viewer
# ©2000, PerlScriptsJavaScripts.com
#
# Requires: Perl5+
# Created: December, 2001
# Author: John Krinelos
# Contact: john@perlscriptsjavascripts.com
#
#
##################################################

# Log File Path:
# Set this variable to the absolute path to your server’s log and
# your done! WINDOWS Servers should use two backslashes to seperate
# folders. Eg. $LOG = “logsaccess”;

$LOG = “/var/www/html/yourwebsite/cgi-bin/access.log”;

####################################################
#
# THERE IS NO NEED TO EDIT ANYTHING ELSE
#
#################################################

Now for the text.cgi file…

Author: cgiconnection.com/articles

ADJUSTED CODE
——————————————–

#!/usr/bin/perl
# If required, adjust line above to point to Perl 5.
#####################################################
# (c) Copyright 2000 by fantomaster.com #
# All rights reserved. #
######################################################

$stats_dir = “stats”;
$log_file = “stats.log”;

$remote_host = “$ENV{‘REMOTE_HOST’}”;
$remote_addr = “$ENV{‘REMOTE_ADDR’}”;
$user_agent = “$ENV{‘HTTP_USER_AGENT’}”;
$referer = “$ENV{‘HTTP_REFERER’}”;
$document_name = “$ENV{‘QUERY_STRING’}”;

open (FILE, “/”);
@TEXT = ;
close (FILE);

&get_date;

&log_hits
(“$date $remote_host $remote_addr $user_agent $referer $document_namen”);

print “Content-type: text/plainnn”;
print @TEXT;

exit;

sub get_date {
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime();
$mon++;
$sec = sprintf (“%02d”, $sec);
$min = sprintf (“%02d”, $min);
$hour = sprintf (“%02d”, $hour);
$mday = sprintf (“%02d”, $mday);
$mon = sprintf (“%02d”, $mon);
$year = scalar localtime;
$year =~ s/.*?(d{4})/$1/;
$date=”$year-$mon-$mday, $hour:$min:$sec”;
}

sub log_hits {
open (HITS, “>>$stats_dir/$log_file”);
print HITS @_;
close (HITS);
}

ACCESS FORM & SSI TAG
————————————————————–
Create folder and log file – /cgi-bin/stats/stats.log
download any log file, paste it into stats.log
open – yoursite/cgi-bin/logviewer.cgi