#!/usr/bin/perl ############################################################################## # Website Reporter v2.11 # # Copyright (c) 1998 by Chad Casselman. All Rights Reserved. # # http://www.websitereporter.com # # You should carefully read all of the following terms and conditions # # before using this software. Your use of this software indicates # # your acceptance of this license agreement and warranty. # # # # Contact Information: # # Chad Casselman # # 2266 I Huntingdon Dr # # Surfside Beach, SC 29575 # # c2@websitereporter.com # # # # Please send questions and comments to webmaster@websitereporter.com # # # #WARNING: This software is protected by copyright law and international # # treaties, as well as other intellectual property laws and treaties. # # # #You may only install and use one copy of the Website Reporter with one # # site on the computer. This software may not be used for multiple sites # # on the same server without purchasing a seperate licenses for each! # # # #All materials contained in the websitereporter.com web site at # # http://www.websitereporter.com/ are copyright © 1998 Chad Casselman. The # # content presented herein may not under any circumstances be distributed # # in any way or form without prior written permission from Chad Casselman. # # # #In no event shall websitereporter.com, Chad Casselman, or any affiliates be # # liable for any direct, consequential, indirect, incidental, or special # # damages whatsoever, including without limitaitions, damages for loss of # # business profits, business interruption, loss of business information, # # and the like, arising out of the use of or inability to use the counters # # provided on this web site. # # # ############################################################################## ############################################################################## ###### YOU CAN NOT LEGALLY CHANGE OR ALTER ANYTHING BELOW THIS POINT ###### ###### !!!! DO NOT CHANGE ANYTHING BELOW THIS LINE !!!! ###### ############################################################################## eval{ require "siteinfo.dat"; }; $lock = "2"; $unlock = "8"; &gettime; &check_referer; &log_access; exit(0); ####################################################################### # Checks for valid call # sub check_referer { $ref = 0; $page = $ENV{'HTTP_REFERER'}; foreach $referer (@referers) { if($page =~ m/^$referer/) { $ref = 1; last; } } if ($page =~ /wysiwyg/){ $ref = 0; } if ($page =~ /^file/){ $ref = 0; } if ($ref == 0) { open(ERROR, ">>WR_error.log"); print ERROR "Bad Referrer from: $page\n"; close(ERROR); exit(0); } } # # ####################################################################### ####################################################################### # Logs the accesses to a site access log! # sub log_access { $from = $ENV{'QUERY_STRING'}; $from1 = $from; $t1; $t2; $from =~ s/\%3A/\:/gi; $from =~ s/\%2C/\+/gi; $from =~ s/\%2F/\//gi; $from =~ s/\%2B/\+/gi; $from =~ s/\%20/\+/gi; $from =~ s/\%7C/\+/gi; $from =~ s/[\+]+/\+/gi; $from =~ s/\%21//gi; $from =~ s/\%22//gi; $from =~ s/\%29//gi; $from =~ s/\%28//gi; $from =~ s/\%3D/=/gi; $from =~ s/\%3F/\?/gi; $from =~ s/^file.*//; $from =~ s/undefined//; $from =~ s/www\.//; $from =~ s/(^http\:\/\/[\w|\.|\-]+\/)(.*)/$1 $2/s; ($t1, $t2) = split(/ /, $from); $t1 =~ tr/A-Z/a-z/; $from = $t1.$t2; $from =~ s/wtv\-//; $from =~ s/^mail.*/E-Mail_Link/; $from =~ s/.*news:.*/Newsgroup_Link/; $from =~ s/^favorite.*/Bookmark_Link/; if($from =~ m/.*document.referrer.*/){ $from = ""; } @searches = ("keyword=","searchtext=","text=","searchstring=","query=","keywords=","general=","search=","\&q=","qt=","MT=","p=","q=","oq="); foreach (@searches){ if($from =~ /$_/){ $from =~ s/(^http:\/\/[\w|\.|\-]+)(\/[.*\/]*.*$_)([\w+|\-*|\+*]+)(&.*)/$1 $3/is; } } if($from =~ m/\?/){ foreach (@searches){ if($from =~ m/$_/){ $from =~ s/(^http:\/\/[\w|\.|\-]+)(\/[.*\/]*.*$_)([\w+|\-*|\+*]+)/$1 $3/is; } } } ($from, $keywords) = split(/ /, $from); $keywords =~ tr/A-Z/a-z/; $from =~ s/(.*)(\?.*)/$1/; foreach $referer (@referers) { if($from =~ m/^$referer/) { $from = ""; } } $user_agent = $ENV{'HTTP_USER_AGENT'}; if ($user_agent ne 'No User_Agent' && $user_agent ne ' ' && $user_agent ne '') { ($agent, $list) = split(/\(/, $user_agent); ($agent, $t) = split(' ', $agent); $list =~ s/\(//; $list =~ s/\)//; ($a1, $a2, $a3, $a4, $a5) = split(/\;/,$list); @browsers = ("AOL","MSIE"); for($i=0;$i<2;$i++){ if($a1 =~ m/$browsers[$i]/){ $agent = $a1; last; } } for($i=0;$i<2;$i++){ if($a2 =~ m/$browsers[$i]/){ $agent = $a2; last; } } for($i=0;$i<2;$i++){ if($a3 =~ m/$browsers[$i]/){ $agent = $a3; last; } } for($i=0;$i<2;$i++){ if($a4 =~ m/$browsers[$i]/){ $agent = $a4; last; } } for($i=0;$i<2;$i++){ if($a5 =~ m/$browsers[$i]/){ $agent = $a5; last; } } $agent =~ s/AOL/A/; $agent =~ s/MSIE/M/; $agent =~ s/Mozilla/N/; $agent =~ s/\// /; @opsys = ("Win","Ma","OS/","Lin","Sun","HP","Fre","IRIX","AIX","alpha"); for($i=0;$i<10;$i++){ if($a1 =~ m/$opsys[$i]/){ $a1 =~ s/ //; $opsys = $a1; last; } } for($i=0;$i<10;$i++){ if($a2 =~ m/$opsys[$i]/){ $a2 =~ s/ //; $opsys = $a2; last; } } for($i=0;$i<10;$i++){ if($a3 =~ m/$opsys[$i]/){ $a3 =~ s/ //; $opsys = $a3; last; } } for($i=0;$i<10;$i++){ if($a4 =~ m/$opsys[$i]/){ $a4 =~ s/ //; $opsys = $a4; last; } } for($i=0;$i<10;$i++){ if($a5 =~ m/$opsys[$i]/){ $a5 =~ s/ //; $opsys = $a5; last; } } } $opsys =~ s/Win95/95/; $opsys =~ s/Windows 95/95/; $opsys =~ s/WinNT/NT/; $opsys =~ s/Windows NT/NT/; $opsys =~ s/Windows 98/98/; ($opsys, $dump) = split(" via", $opsys); $ref = $ENV{'HTTP_REFERER'}; foreach $referer (@referers) { $ref =~ s/$referer//; } $ref =~ s/#/ /; ($ref, $dump) = split(/ /,$ref); $_ = $ref; if(m/\/$/){ $ref =~ s/\/$/\/index\.html/s; } $ref =~ s/\.shtml/\.html/; if ($ENV{'REMOTE_ADDR'} =~ /(\d+)\.(\d+)\.(\d+)\.(\d+)/) { $Address = pack('C4', $1, $2, $3, $4); $DNS_Address = (gethostbyaddr($Address, 2))[0]; $host = $DNS_Address if $DNS_Address; $host =~ tr/[A-Z]/[a-z]/; $_=$host; if(/com$/ || /org$/ || /net$/ || /edu$/ || /gov$/ || /mil$/){ $host =~ s/(.*\.)(\w+\.\w+)/$2/g; }else{$host =~ s/.*\.//g;} } if($host =~ m/\d+/){ $host = "nk"; } if(!$host){ $host = "nk"; } $sitelog = "site.log"; if(-e $sitelog) { open(LOG,">>$sitelog") || die "Can't open $sitelog!\n" ; } else { open(LOG,">$sitelog") || die "Can't open $sitelog!\n" ; } flock(LOG,$lock); print LOG "[$date $wday] $ref - $host - $ENV{'REMOTE_ADDR'} - $agent - $opsys - $from $keywords\n"; flock(LOG,$unlock); close(LOG); } # # ####################################################################### ####################################################################### # Calculate the time, day, date, and month # sub gettime { print "Location: $image_dir/dot.gif\n\n"; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); $date = sprintf("%02d:%02d:%02d %02d/%02d/%02d", $hour,$min,$sec,$mon+1,$mday,$year); $day = sprintf("%02d/%02d/%02d",$mon+1,$mday,$year); $today = sprintf("%02d",$mday); $month = sprintf("%02d",$mon+1); } # # #######################################################################