#!/usr/bin/perl # spy.cgi by Meryll Larkin # Written January 10, 2004 # Last update August 13, 2006 # Sets and retrieves browser cookies from index.html on Alwanza # Parses user stats and puts user stats into database # Generates spy.cgi page as a debugging page # Displays the visitor count in the iframe on index.html # Increments the visitor count # update 8/13/06 - parses HTTP_USER_AGENT into PLATFORM # (PLATFORM added as a column to alwanza_site database, all_stat table # changed regex for "host" (for ip address) to multiline use strict; use Cwd; use DBI; use CGI qw(:standard); use SPYDB; # custom module by Meryll Larkin use SPYCOUNT; # custom module by Meryll Larkin my $C_MAX_COUNT = 4; # maximum number of count numbers to keep in a cookie my $V_DIGITS = 5; # number of digits in visitor count my $C_SZ_LIMIT; # cookie size limit = # number of visitor numbers collected plus 1 for each comma, # minus 1 because no comma at end of string $C_SZ_LIMIT = (($V_DIGITS + 1) * $C_MAX_COUNT) - 1; my $SPYDB = SPYDB->new; my $COUNTER = SPYCOUNT->new; my $debug = 0; my $backgroundColor = "black"; my $textColor="white"; my $pg = new CGI(); my $url= $pg->url(-path_info=>1); my $hed_back="black"; # header background color my $table_back="black"; # table cell background color my $Default_URL = url; my $boo_silentSurfer = 0; my ($longDate, $day_sort, $wk_day, $timeHM) = &GetSetDate; my $visitCount = $COUNTER->get_count(); my $surfer = $ENV{REMOTE_ADDR} || "192.168.1.30"; $surfer =~ s/\b(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\b/$1/; # Remove home and work IPs so as not to fill up database with # my own IPs if (($surfer !~ /^192\.168/) && ($surfer !~ /^216\.39\.185\.1\d$/) && ($surfer !~ /^128\.95\.73/)) # add any requested omits here { $visitCount++; $COUNTER->set_count($visitCount); } else { $boo_silentSurfer = 1; } my $displayCount = $COUNTER->get_display($visitCount); my ($cookie, $c_value, $headvisitor, $count) = &BakeCookie($visitCount, $C_SZ_LIMIT, $C_MAX_COUNT); #set new cookie print header(-cookie => $cookie); # print "Content-type: text/html\n\n"; not needed we are using print header instead print qq|
|;
print "Visit Count = $visitCount\n";
print " Cookie = $cookie\n"; print " Cookie value for display = $c_value\n"; print " headvisitor = $headvisitor\n"; print " count = $count\n"; print " ENV{HTTP_COOKIE} = $ENV{HTTP_COOKIE}\n"; print " ENV{REMOTE_ADDR} = $surfer\n"; print " ENV{HTTP_USER_AGENT} = $ENV{HTTP_USER_AGENT}\n"; print " ENV{HTTP_REFERER} = $ENV{HTTP_REFERER}\n"; print " ENV{HTTP_HOST} = $ENV{HTTP_HOST}\n"; print " The email address for the webmaster of your server (or the webmaster of your ISP):\n"; print " ENV{SERVER_ADMIN} = $ENV{SERVER_ADMIN}\n"; print " The full qualified domain name of the server hosting your internet connection:\n"; print " ENV{SERVER_NAME} = $ENV{SERVER_NAME}\n"; print " The software used by the server hosting your internet connection\n"; print " ENV{SERVER_SOFTWARE} = $ENV{SERVER_SOFTWARE}\n"; print "\n \n"; print "\n |