#!/usr/bin/perl # version 2.020323, coded by MrRat - http://www.mrrat.com, GPL licensed - http://www.opensource.org/licenses/gpl-license.html # you can make a donation at http://s1.amazon.com/exec/varzea/pay/T3M26803DZOCMK # 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. # ## Edit the following # change the value of $logfilepath to the full path of the directory where the log file will be $logfilepath = "../ratlog/"; # change the value of $homepageurl to your home page url (duh) $homepageurl = "http://www.mrrat.com/"; # guess what you change $sitename to $sitename = "MrRat's World"; # if you use #exec to call this script you must comment out the next line if ($ENV{'SCRIPT_NAME'} =~ /ratlog\.cgi/) { print "Content-type: text/html\n\n"; } # # that's all you have to change # # defaults $httpcode = 200; # ErrorDocument handling if ($ENV{'REDIRECT_STATUS'} >= 400) { $httpcode = $ENV{'REDIRECT_STATUS'}; $ENV{'DOCUMENT_URI'} = $ENV{'REDIRECT_URL'}; $ENV{'DOCUMENT_URI'} .= "?$ENV{'REDIRECT_QUERY_STRING'}"; print "$httpcode Error\n

$httpcode Error

\nOops, had some trouble returning the page you asked for.

\nPlease try the $sitename Home Page

\n\n"; }; # main ($day,$month,$date,$time,$year) = split(/\s+/,localtime(time),5); if ($date < 10) { $date = "0$date" }; if ($ENV{'HTTP_REFERER'} eq "") { $ENV{'HTTP_REFERER'} = "-" }; if ("@ARGV" =~ /\D/ | "@ARGV" eq "") { @ARGV = "-"; } $logentry = "$ENV{'REMOTE_ADDR'} - - [$date/$month/$year:$time +0000] \"GET $ENV{'REQUEST_URI'} HTTP/1.1\" $httpcode @ARGV \"$ENV{'HTTP_REFERER'}\" \"$ENV{'HTTP_USER_AGENT'}\"\n"; # write log $logfile = "$logfilepath$date$month$year.log"; open (LOG, ">>$logfile"); flock(LOG, 2); print LOG "$logentry"; flock(LOG, 8); close (LOG);