#!/usr/bin/perl ############################################################################## # Website Reporter version 3.06 Beta # # by: Chad Casselman # # email: webmaster@websitereporter.com # # # # Copyright (c) 1998-1999 Casselware Incorporated. 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 can be found at: # # http://www.websitereporter.com # # support@websitereporter.com # # # # Please send questions and comments to support@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! A # # site is considered one domain name and all its contents. # # # # All materials contained in the websitereporter.com web site at # # http://www.websitereporter.com/ are copyright © 1998-1999 Casselware. 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. # # # ############################################################################## $Directory="./"; ############################################################################## ###### YOU CAN NOT LEGALLY CHANGE OR ALTER ANYTHING BELOW THIS POINT ###### ###### IF YOU DO ALTER ANYTHING BELOW THIS POINT, YOUR LICENSE ###### ###### WILL BE REVOKED AND ALL SUPPORT DISCONTINUED! ###### ############################################################################## ###### !!!! DO NOT CHANGE ANYTHING BELOW THIS LINE !!!! ###### ############################################################################## $TimeZoneOffset = "0";eval{ require $Directory."siteinfo.dat"; };&gettime;&check_referer;&log_access;exit(0);sub check_referer {$ref = 0;$page = $ENV{'HTTP_REFERER'};foreach $referer (@referers) {if($page =~ m/^$referer/i) {$ref = 1;last;}}if ($page =~ /wysiwyg/){$ref = 0;} if ($page =~ /^file/){$ref = 0;} if ($ref == 0) {$file = $Directory."WR_error.log";if(-e $file) { open(ERROR ,">>$file") || die "Can't open $file!\n" ;}else { open(ERROR ,">$file") || die "Can't open $file!\n" ; }print ERROR "Bad Referrer from: $page\n";close(ERROR);exit(0);}}sub log_access {($_, $color, $size) = split (/\|\|/,$ENV{'QUERY_STRING'});if($color == 24){$color = 1;}elsif($color == 16){$color = 2;}elsif($color == 32){$color = 3;}else{$color = 0;}if($size == 640){$size = 1;}elsif($size == 800){$size = 2;}elsif($size == 1024){$size = 3;}elsif($size == 1152){$size = 4;}else{ $size = 5;}$_ =~ s/\*//gi;$_ =~ s/\%7C/\+/gi;$_ =~ s/\%20/\+/gi;$_ =~ s/\%21//gi;$_ =~ s/\%22//gi;$_ =~ s/\%28//gi;$_ =~ s/\%27//gi;$_ =~ s/\%29//gi;$_ =~ s/\%2B/\+/gi;$_ =~ s/\%2C/\+/gi;$_ =~ s/\%2E/\./gi;$_ =~ s/\%2F/\//gi;$_ =~ s/\%3A/\:/gi;$_ =~ s/\%3D/=/gi;$_ =~ s/\%3F/\?/gi;$_ =~ s/[\+]+/\+/gi;$_ =~ s/undefined//;$_ =~ s/www\.//;$_ =~ s/.*news:.*/Newsgroup_Link/;$_ =~ s/^[favorite|file].*/Bookmark_Link/;if(/mail\./ || /mailbox:/){$_ = "E-Mail_Link";}if(/.*document.referrer.*/){$_ = "CALL_TAG_ERROR!!";}if(/\.yahoo/){if(/&p[\d]*=/ || /\?p[\d]*=/){$_ =~ s/(^http:\/\/[\w|\.|\-]+)(\/[.*\/]*.*p[\d]*=)([\w+|\-*|\+*|\.*]+)(.*)/1 $3/is;}else{$_ =~ s/(^http:\/\/[\w|\.|\-]+)(\/[.*\/]*.*p[\d]*=)([\w+|\-*|\+*|\.*]+)(&.*)/1 $3/is;}}elsif(/infoseek/){if(/oq=/){$_ =~ s/(^http:\/\/[\w|\.|\-]+)(\/[.*\/]*.*[?|&]oq=)([\w+|\-*|\+*|\.*]+)(.*)/6 $3/is;}elsif(/qt=/){$_ =~ s/(^http:\/\/[\w|\.|\-]+)(\/[.*\/]*.*[?|&]qt=)([\w+|\-*|\+*|\.*]+)(.*)/6 $3/is;}elsif(/query=/){$_ =~ s/(^http:\/\/[\w|\.|\-]+)(\/[.*\/]*.*[?|&]query=)([\w+|\-*|\+*|\.*]+)(.*)/6 $3/is;}else{$_ =~ s/(^http:\/\/[\w|\.|\-]+)(\/[.*\/]*.*[?|&]fs=)([\w+|\-*|\+*|\.*]+)(.*)/6 $3/is;}}elsif(/altavista/){if(/&[q|r]=/){$_ =~ s/(^http:\/\/[\w|\.|\-]+)(\/[.*\/]*.*&[q|r]=)([\w+|\-*|\+*|\.*]+)(.*)/2 $3/is;}else{$_ =~ s/(^http:\/\/[\w|\.|\-]+)(\/[.*\/]*.*?[q|r]=)([\w+|\-*|\+*|\.*]+)(&.*)/2 $3/is;}}elsif(/netfind/){if(/search=/){$_ =~ s/(^http:\/\/[\w|\.|\-]+)(\/[.*\/]*.*[?|&]search=)([\w+|\-*|\+*|\.*]+)(.*)/3 $3/is;}else{$_ =~ s/(^http:\/\/[\w|\.|\-]+)(\/[.*\/]*.*[?|&]s=)([\w+|\-*|\+*|\.*]+)(.*)/3 $3/is;}}elsif(/excite/){if(/search=/){$_ =~ s/(^http:\/\/[\w|\.|\-]+)(\/[.*\/]*.*[?|&]search=)([\w+|\-*|\+*|\.*]+)(.*)/4 $3/is;}else{$_ =~ s/(^http:\/\/[\w|\.|\-]+)(\/[.*\/]*.*[?|&]s=)([\w+|\-*|\+*|\.*]+)(.*)/4 $3/is;}}elsif(/hotbot/){$_ =~ s/(^http:\/\/[\w|\.|\-]+)(\/[.*\/]*.*[?|&]mt=)([\w+|\-*|\+*|\.*]+)(.*)/5 $3/is;}elsif(/lycos/){$_ =~ s/(^http:\/\/[\w|\.|\-]+)(\/[.*\/]*.*[?|&]query=)([\w+|\-*|\+*|\.*]+)(.*)/7 $3/is;}elsif(/webcrawler/){if(/searchtext=/i){$_ =~ s/(^http:\/\/[\w|\.|\-]+)(\/[.*\/]*.*[?|&]searchtext=)([\w+|\-*|\+*|\.*]+)(.*)/8 $3/is;}elsif(/search=/i){$_ =~ s/(^http:\/\/[\w|\.|\-]+)(\/[.*\/]*.*[?|&]search=)([\w+|\-*|\+*|\.*]+)(.*)/8 $3/is;}else{$_ =~ s/(^http:\/\/[\w|\.|\-]+)(\/[.*\/]*.*webquery\?)([\w+|\-*|\+*|\.*]+)(.*)/8 $3/is;}}elsif(/msn/){$_ =~ s/(^http:\/\/[\w|\.|\-]+)(\/[.*\/]*.*[?|&]mt=)([\w+|\-*|\+*|\.*]+)(.*)/9 $3/is;}elsif(/[?|&]+/){$_ = $_;@searches = ("general=","keyword=","keywords=","category=","ask=","query=","q=","qry=","key=","request=","search=");foreach $start (@searches){if(/$start/){$_ =~ s/(^http:\/\/[\w|\.|\-]+)(\/[.*\/]*.*[?|&]$start)([\w+|\-*|\+*|\.*]+)(.*)/$1 $3/is;} }}if(/\?/){$_ =~ s/(.*)(\?.*)/$1/;}$_ =~ s/(.*)(\+$)/$1/;foreach $referer (@referers) {if($_ =~ m/^$referer/i) {$_ =~ s/$referer//i;}}if($_ eq "/"){$_ = "/$default_page";}$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);if($agent =~ /WebTV/){$agent = $t;}else{$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/\// /;$agent =~ s/AOL/A/;$agent =~ s/MSIE/M/;$agent =~ s/Mozilla/N/;$agent =~ s/WebTV/W/;@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, $dump) = split(" via", $opsys);$opsys =~ s/.*95/95/;$opsys =~ s/.*NT/NT/;$opsys =~ s/.*98/98/;$ref = $ENV{'HTTP_REFERER'};foreach $referer (@referers) {$ref =~ s/$referer//i;}if($ref eq ""){$ref="/$default_page"};$ref =~ s/(.*)(#.*)/$1/;$_ = $ref;if(m/\/$/){$ref =~ s/\/$/\/$default_page/s;}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 = $Directory."site.log";$lock = "2";$unlock = "8";if(-e $sitelog) { open(LOG,">>$sitelog") || die "Can't open $sitelog!\n" ;} else { open(LOG,">$sitelog") || die "Can't open $sitelog!\n" ; }print LOG "$date, $wday, $ref, $host, $ENV{'REMOTE_ADDR'}, $agent, $opsys, $size, $color, $from\n";close(LOG);}sub gettime {print "Location: $image_dir/clear.gif\n\n";$adjustTime = time() + ($timeoffset * 3600);($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime ($adjustTime);$year += 1900;$date = sprintf("%02d:%02d:%02d %04d/%02d/%02d",$hour,$min,$sec,$year,$mon+1,$mday);$day = sprintf("%02d/%02d/%04d",$mon+1,$mday,$year);$today = sprintf("%02d",$mday);$month = sprintf("%02d",$mon+1);}