#!/usr/bin/perl #################################################################### # # All Count # ©2002, PerlScriptsJavaScripts.com # # Requires: Perl5+ # Created: January, 2002 # Author: John Krinelos # Contact: john@perlscriptsjavascripts.com # # This script / program is copyright material! # # Agent for copyright : # Gene Volovich # Law Partners, # 140 Queen St. # Melbourne # Ph. +61 3 9602 2266 # gvolovich@lawpartners.com.au # http://www.lawpartners.com.au/ # #################################################################### # used to concatenate admin and cfg file. # Also makes up the first part of the data folder's name my $ScriptName = "counter"; # Determine OS and set a seperator $OS = $^O; if($OS =~ /win/i) { $isWIN = 1; } else {$isUNIX = 1;} if($isWIN){ $S{S} = "\\\\"; } else { $S{S} = "/";} # get config file if($isWIN){ $absPath = $ENV{PATH_TRANSLATED}; $relPath = $ENV{PATH_INFO}; $relPath =~ s/\//$S{S}/g; $ENV{DOCUMENT_ROOT} = $absPath; $ENV{DOCUMENT_ROOT} =~ s/$relPath//i; $ConfigPath = $ENV{PATH_TRANSLATED}; $ConfigPath =~ s/\.cgi/\_cfg\.cgi/; } else { $ConfigPath = "$ScriptName\_cfg\.cgi"; } require $ConfigPath; # Determine if we are on a secure server. if($SecureServer) { if($SecureServer =~ /\/$/){chop($SecureServer);} } else { $ScriptURL = "http://$ENV{'SERVER_NAME'}$ENV{'SCRIPT_NAME'}"; } # Add the folder pass and create a data path $ScriptName .= $FolderPass; # get the path to data files if($DefaultData){ $DefaultData =~ s/(\/|\\)$//g; $Data = qq~$DefaultData$S{S}psjs_datalogs$S{S}$ScriptName~; } else { $Data = qq~$ENV{DOCUMENT_ROOT}$S{S}psjs_datalogs$S{S}$ScriptName~; } &Initialize; &Date; &write_it; ############################################################################## ############################################################################## sub write_it { my $epoch = time + ($CONFIG{hour_off} * 3600) + ($CONFIG{min_off} * 60); my ($no_js,$www); # remove serv_name even if www. was not entered $www = $ENV{SERVER_NAME}; $www =~ s/www\.//i; $ENV{HTTP_REFERER} =~ s/http:\/\/$www//; $ENV{HTTP_REFERER} =~ s/http:\/\/$ENV{'SERVER_NAME'}//; $ENV{HTTP_REFERER} =~ s/http:\/\/$CONFIG{serv_ip}//; $ENV{HTTP_REFERER} =~ s/https:\/\/$www//; $ENV{HTTP_REFERER} =~ s/https:\/\/$ENV{'SERVER_NAME'}//; $ENV{HTTP_REFERER} =~ s/https:\/\/$CONFIG{serv_ip}//; $ENV{HTTP_REFERER} ||= '/'; $host = &gethostname; $host =~ s/\|//ig; $host =~ s/^.*\.//; $ENV{QUERY_STRING} =~ tr/+/ /; $ENV{QUERY_STRING} =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; my (@str,$new_str); if($ENV{QUERY_STRING} eq ''){ $new_str = '|||||'; $no_js = 1; } else { @str = split(/\|/, $ENV{QUERY_STRING}); # color unless($str[0] =~ /^\d+$/){ $str[0] = ''; } # width unless($str[1] =~ /^\d+$/){ $str[1] = ''; } # height unless($str[2] =~ /^\d+$/){ $str[2] = ''; } # referrer $str[3] =~ s/\|//ig; # js unless($str[4] =~ /^\d+$/){ $str[4] = ''; } # java unless($str[5] =~ /^\d+$/){ $str[5] = ''; } $new_str = "$str[0]|$str[1]|$str[2]|$str[3]|$str[4]|$str[5]"; } if(open(UA, ">>$Data$S{S}data$S{S}users_agents\_$THISYEAR\_$MONTH\_$DAY.txt")){ flock(UA, 2); print UA "$epoch|$ENV{REMOTE_ADDR}|$ENV{HTTP_USER_AGENT}|"; print UA "$ENV{HTTP_REFERER}|$new_str|$host|$no_js\n"; flock(UA, 8); close(UA); backup("$Data$S{S}data$S{S}users_agents\_$THISYEAR\_$MONTH\_$DAY.txt"); } } print "Location: $CONFIG{image}\n\n"; ####################################################################################### #######################################################################################