#!/usr/bin/perl # AXS Script Set, Logging Module, Version 2.01b, BugFix 2 # Copyright 1997 by Fluid Dynamics . Please adhere to # the copyright notice and conditions of use which are described # in the attached help file and hosted at the URL below. # # For latest version and help files, visit: # http://www.xav.com/scripts/axs # __________________________________________________________________ # This fixes a common bug with the &Print_Image procedure, which had # resulted in a broken image in the script output. The fix involves # uploading the 'trans.gif' image from http://www.xav.com/images/trans.gif # and placing it on your server. The URL to that image should be # included in the variable below: $TransURL = 'http://www.lasierra.edu/psychology/cgi-bin/log/trans.gif'; # This script also fixes an occassional problem with each page being # logged twice (by ignoring HEAD requests). It also correlates with # the documentation by allowing ax.cgi?whatever.gif in addition to # ax.cgi?trans.gif. The ability to use random GIF names in logging is # very important since modern browsers like Netscape 4+ and MSIE 3+ # will tend to cache images even when they are told not to do so. # End o' bug fix. $logfile = 'log.txt'; $domain = 'http://www.www.lasierra.edu'; $header = "Content-type: text/html\n\n"; # Before running, scroll down 20 lines and look at the "Custom" # information for excluding servers. See the attached instruction # for help with variables above. # # __________________________________________________________________ if ($ENV{'QUERY_STRING'} =~ /^(\w+)\.gif$/) { &Print_Image; } elsif ($ENV{'DOCUMENT_URI'}) { print "$header\n \n"; } else { print "Location: $ENV{'QUERY_STRING'}\n\n"; } if ($ENV{'REMOTE_HOST'} =~ /(\d+)\.(\d+)\.(\d+)\.(\d+)/) { $Address = pack('C4', $1, $2, $3, $4); $DNS_Address = (gethostbyaddr($Address, 2))[0]; $ENV{'REMOTE_HOST'} = $DNS_Address if $DNS_Address; } $ENV{'REMOTE_HOST'} =~ tr/[A-Z]/[a-z]/; # CUSTOM1-Begin (see below) # # Now we ignore people who should be ignored. Usually webmasters # place their own server names in the set below so that their own # hits don't offset the log file. If you want to record every # single person, just delete everything between the CUSTOM1 flags. #@ignore = ('xav.com','.mil','.gov','.dci.net'); #foreach (@ignore) # {exit if ($ENV{'REMOTE_HOST'} =~ /$_/);} # # CUSTOM1-End (delete through this line if you delete) # Cache-ing fix - Netscape will tend to run a HEAD request first, to # see whether an image has changed it's last modified time, and will # then run a GET request. The old version would log both to these, # since either request causes the script to execute in full. Now # the script will execute & print out friendly output for either # request method, but will only write to the log file if it's a 'real' # GET or POST request. exit if ($ENV{'REQUEST_METHOD'} eq 'HEAD'); # End of that fix... $logline = "|$ENV{'REMOTE_HOST'}|$ENV{'REMOTE_ADDR'}|"; $ENV{'HTTP_REFERER'} =~ s/\|//g; $logline .= "$ENV{'HTTP_REFERER'}|"; $ENV{'QUERY_STRING'} = $ENV{'HTTP_REFERER'} if ($ENV{'QUERY_STRING'} =~ /^(\w+)\.gif$/); if ($ENV{'DOCUMENT_URI'}) {$logline .= "$domain$ENV{'DOCUMENT_URI'}|";} else {$logline .= "$ENV{'QUERY_STRING'}|";} $logline .= "$ENV{'HTTP_USER_AGENT'}|"; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) = localtime(time); $logline .= "$sec|$min|$hour|$mday|$mon|$year|$wday|$yday|"; $logline .= "export|" unless $ENV{'DOCUMENT_URI'}; $logline .= "\n"; open(LOG,">>$logfile"); print LOG $logline; close(LOG); sub Print_Image { print "Pragma: no-cache\n"; print "Location: $TransURL\n\n"; }