#!/usr/bin/perl # tell the web browser we're going to send it HTML text it needs to process # instead of plain text which it can display without processing print "Content-Type: text/html\n\n"; # variables $debug = 0; $linenumber = 0; $error = 0; # refresh how often? $refreshhours = 0; $refreshminutes = 6; $refreshseconds = 0; $refreshtime = ((($refreshhours*60)+$refreshminutes)*60)+$refreshseconds; # Version history # 1.0.0 Original program written # 1.1.0 Changed the output to HTML 4.01 compliant # 2.0.0 Changed the IP addresses to 4 sets of 3 numbers for ease of readability # 2.1.0 Added the ability of checking whois to the IP addresses with a single click # 2.1.1 Added comments and version number for addition to the CPAN archives # 2.1.2 Added better error handling # 2.2.0 changed the local net address selection and added both local net selections. # 3.0.0 Added a new feature to the get log program to allow it to work with logcleaner (strips out the overloads, updated the counter files) # skips 0.0.0.0 IP address. # Also fixed a minor bug in the local IP address filters. # 3.1.0 added a refresh to ensure acurateness of an access log if it's kept on. # $version = "GetLog version 3.1.0"; # The location of an apache log file in the following format # # 10.0.1.1 - - [15/Jan/2005:01:09:18 -0500] "GET /cgi-bin/getagentlog.cgi HTTP/1.1" 200 59734 # $mylogfilename = "/private/var/log/httpd/access_log"; # $mylogfilename = "/access.log"; $mytitle = "Access log"; # Create an error message if ($debug == 1) { $errormessage = join( "", "
\n";
print "",$mytitle,"\n"; print "",$version,"\n"; print "\n line number - IP address - date/time - method - file - protocol - result code - bytes served \n"; print "
\n\n\n"; # Open up the log file open(LOGFILE, $mylogfilename) or $error = 1; if ($error == 1) { print $errormessage; } else { # get the data @data = ",$linenumber,": ",$ip," ",$line," \n"; }; }; }; close(LOGFILE); if ($linenumber == 0) { print "No log entries at this time. The log has just been freshly cleaned. \n"; }; }; # print the HTML footer print "\n"; print " The End\n\n"; print " | \n