#!/usr/bin/perl -- require 5; =item overview AXS Script Set, Logging Module Copyright 1997-2003 by Fluid Dynamics Please adhere to the copyright notice and conditions of use as described at the URL below. For latest version and help files, visit: http://www.xav.com/scripts/axs/
$0 - working okay - no logging command received - use ?debugme query string for more info.
"; } # decide whether or not to log this visit: my $err = ''; Err: { last Err if ($mode eq 'debug'); last Err if (&query_env('HTTP_COOKIE') =~ m!axs_no_log=1!); last Err if (($NoLogHead) and (&query_env('REQUEST_METHOD') eq 'HEAD')); my ($vhost, $vaddr) = &resolve_host($resolve_dns_names); my $ighost = ''; foreach $ighost (@IgnoreHosts) { $ighost = quotemeta($ighost); next unless ($ighost); last Err if ($vhost =~ m!$ighost!); last Err if ($vaddr =~ m!$ighost!); } # Note: you can filter on other things as well. If you want to ignore people # arriving from a certain site, like Yahoo, you can write the following (note # that HTTP_REFERER is used instead of REMOTE_HOST): # # @ignore = ('yahoo.com', 'av.yahoo.com'); # foreach (@ignore) { # exit if ($ENV{'HTTP_REFERER'} =~ m!$_!); # } # don't fill up the file system: my $LogSize = -s $LogFile || 0; last Err if (($MaxLogSize) and ($MaxLogSize < $LogSize)); # cleanse the data: my ($clean_url, $host, $port, $path, $is_valid) = &parse_url($ref); if ($is_valid) { $ref = $clean_url; } ($clean_url, $host, $port, $path, $is_valid) = &parse_url($to); if ($is_valid) { $to = $clean_url; } # Apply the mappings: foreach (keys %Maps) { $to =~ s!$_!$Maps{$_}!ig; $ref =~ s!$_!$Maps{$_}!ig; } &log_visit($vhost,$vaddr,$ref,$to); last Err; } sub Print_Image { print "HTTP/1.0 200 OK\015\012" if ($::private{'PRINT_HTTP_STATUS_HEADER'}); print "Pragma: no-cache\015\012"; print "Expires: Saturday, February 15, 1997 10:10:10 GMT\015\012"; print "Content-Type: image/gif\015\012\015\012"; binmode(STDOUT); foreach (71,73,70,56,57,97,1,0,1,0,128,255,0,192,192,192,0,0,0,33,249,4,1,0,0,0,0,44,0,0,0,0,1,0,1,0,0,1,1,50,0,59) { print pack('C',$_); } } # ___________________________________________________________________________ # This runs a filesystem test against $LogFile and dumps a ton of (hopefully) # useful information to the screen: sub SpawnDebugger { print "HTTP/1.0 200 OK\015\012" if ($::private{'PRINT_HTTP_STATUS_HEADER'}); print "Content-Type: text/html\015\012\015\012"; unless ($AllowDebug) { print 'Error: no output available because $AllowDebug = 0 in this script.
'; return 0; } my $filesys_test = ''; my $filesys_ok = 0; TEST: { if (-e $LogFile) { my ($LogSize,$LastModT) = (stat($LogFile))[7,9]; $LastModT = scalar localtime($LastModT); $filesys_test .= "The log file, $LogFile, exists with size $LogSize bytes. It was last modified on $LastModT. "; if (open(FILE,">>$LogFile")) { binmode(FILE); close(FILE); $filesys_test .= "The log file is writable.
The filesystem test passed!
"; $filesys_ok = 1; } else { $filesys_test .= <<"EOM"; However, the log file is not writable. The filesystem returned "$!" when this script tried to write to it. You need to change the file permissions to make it script-writable.The filesystem test failed.
EOM last TEST; } } elsif (open(FILE,">>$LogFile")) { binmode(FILE); close(FILE); $filesys_test .= <<"EOM";The log file, $LogFile, did not exist when this script started. However, this script attempted to create it for you, and the server responded that this was successful. So everything should be fine now. Reload this web page, and hopefully you will see a message that the file system test has passed. If it does not pass, and instead you get an error or you get this message again, then you will have to manually create the log file and set it's permissions.
The filesystem test needs to be run again. (reload this page)
EOM last TEST; } else { $filesys_test .= <<"EOM";The log file, $LogFile, doesn't exist. You need to create one and give it writable permissions. Alternately, the log file may exist but the \$LogFile variable might not point to the correct location, in which case you will need to change your variable.
The filesystem test failed.
EOM last TEST; } } my $homelink = ''; my @ext = ('pl', 'cgi'); if ($0 =~ m!\.cgi$!) { @ext = ('cgi','pl'); } foreach (@ext) { my $file = 'ax-admin.' . $_; if (-e $file) { $homelink = qq!Click here to return to $file.
\n!; last; } } my $cookie = &he($ENV{'HTTP_COOKIE'} || ''); my $cookie_info = ''; if ($cookie =~ m!axs_no_log=1!) { $cookie_info = "Your visits will NOT be logged because the 'axs_no_log=1' cookie was detected.
\n"; } else { $cookie_info = "Your visits will be logged, because the 'axs_no_log=1' cookie was NOT detected.
\n"; } my $ignore_host_info = ''; IgnoreHostInfo: { if (not @IgnoreHosts) { $ignore_host_info .= "The \@IgnoreHosts
array is empty. No logging overrides will occur due to IP address or hostname.
The \@IgnoreHosts
array contains:
\n";
my $b_ignored = 0;
foreach (@IgnoreHosts) {
$ignore_host_info .= " '$_'";
if ($_) {
my $qm = quotemeta($_);
if ($vhost =~ m!$qm!) {
$ignore_host_info .= " logging disabled for you because $vhost matches\n";
$b_ignored = 1;
}
elsif ($vaddr =~ m!$qm!) {
$ignore_host_info .= " logging disabled for you because $vaddr matches\n";
$b_ignored = 1;
}
}
$ignore_host_info .= "
\n";
}
$ignore_host_info .= "
Your client address ($vhost/$vaddr) will cause your visits to not be logged.
\n"; } else { $ignore_host_info .= "Your client address ($vhost/$vaddr) does not match any of these entries. Logging will not be disabled based on \@IgnoreHosts
values.
Review the AXS help file if you need more help.
Filesystem Test:
Usage Instructions:
Add this "AXS tracking code" to any HTML pages that you want to have tracked. This text should be placed within the <body>
section of the document, towards the bottom of the page. You can place the text almost anywhere, so feel free to move it around if it causes problems with your layout:
Note that this text only works on normal HTML pages, not in frameset documents.
After entering that HTML code on your pages, transfer the pages up to the server. Then clear your browser cache and visit the pages. Use your browser's "view-source" command to look at the HTML source code. Confirm that the above Javascript appears in your pages *exactly* as it appears above. Make sure that the line breaks appear in the right places.
This is important because some HTML editor programs will corrupt the text that you try to insert into your pages. You are responsible for entering the Javascript logging code correctly and for verifying that it appears correctly. If you do not do this, then the product will not work.
Code your off-site links (links to pages/files that don't already contain the AXS tracking code) like this:
<a href="$ENV{'SCRIPT_NAME'}?http://yahoo.com/">http://yahoo.com/</a>
Here is an example link.
If any of your HTML pages reside on a different website than AXS, then you should use:
$axpath
instead of:
$ENV{'SCRIPT_NAME'}
in the examples above.
Standard Debugging Information:
This is AXS Logging Module version $VERSION in debug mode.
The file name of this script is $0.
This script is executing under Perl version $].
The critical file system variable is \$LogFile = "$LogFile";.
\$MaxLogSize = $MaxLogSize; (bytes)
Webmaster Logging Override
You can disable the logging of your own visits by having the "axs_no_log=1" cookie, or by having your IP address or hostname present in the \@IgnoreHosts
array.
See this help file for more information about not tracking your own visits.
Cookie Override
Your browser sent the following cookie header:
HTTP_COOKIE: $cookie$cookie_info
IP or Hostname Override
$ignore_host_infoEnvironment Variables: