#!/local/std/bin/perl # # v 0.70 # push @INC, "/home/discovery/simra/public_html/counter/"; require "counter.config"; print < Page Hit Statistics for http://www.cim.mcgill.ca/~simra/

Page Hit Stats

These stats are collected using a modified verions of the Milanovic, Wagner and Havlik web counter. The source is available here.

EOI ; &make_logfile; #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% # # Hits per page - File format: page|hits%date # File name: hits_per_page.dat # open (HPP, "<$data_dir/hits_per_page.dat") && do { while () { @entry=split('\|',$_); # $entry[0]=~s/$strip_uri/~/; # $entry[0]=~s/~/$unstrip_uri/; $hpp{$entry[0]}=$entry[1]; } close (HPP); }; #foreach $key (keys %ENV) { # print "$key=$ENV{$key}
\n"; #} print < PageHits Since EOI ; foreach $var (sort { $hpp{$b} <=> $hpp{$a} } keys %hpp) { @hitday=split('%', $hpp{$var}); $shrt=$var; $shrt=~s/~/$unstrip_uri/; if ($shrt eq "") { $var="Unknown"; $shrt="http://www.cim.mcgill.ca/~simra"; } # print STDERR "\"$shrt\"\n"; if ($var=~/^~/ or $var eq "Unknown") { print " $var "; print "$hitday[0]$hitday[1]\n"; } } print "\n"; #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% # # Hits per domain, per day per Browser and per OS # open (LOG, "$mwh_logfile"); open (UNKONOWN, ">$data_dir/unrecognized.log"); while () { my @entry = (); @entry=split('#',$_); #address my $ignore=0; my $host; foreach $host (@ignore_hosts) { $ignore=1 if ($entry[2]=~/$host/i); } print STDERR "Entry5: $entry[5]\n"; $ignore=1 if ($entry[5]=~/1/); if (!$ignore) { @addr = split(/[.]/, $entry[2]); if ($addr[$#addr] == 0) { $count{$addr[$#addr]}++; $domain_count{$addr[$#addr-1].".".$addr[$#addr]}++; } else { $count{"??"}++; } $host_count{$entry[2]}++; #date @date_ent=split(',', $entry[0]); $date="$date_ent[0]-$date_ent[1]-$date_ent[2]"; $day_count{$date}++; #OS $OS = OS_recognize($entry[3]); ($OS eq "Unknown") && (print UNKONOWN "OS:\t$entry[3]\n"); $OS_count{$OS}++; #Browser $BR = BR_recognize($entry[3]); ($BR eq "Unknown") && (print UNKONOWN "browser:\t$entry[3]\n"); $BR_count{$BR}++; $PG = $entry[1]; $PG_count{$PG}++; $entry[4]=~s/(\%3A)/:/g; $entry[4]=~s/(\%3D)/=/g; $entry[4]=~s/(\%3F)/\&/g; my ($RF)=$entry[4]=~/(\S+)/; $RF||="None"; $RF_count{$RF}++; } } close (LOG); close (UNKONOWN); # # Hits per tld # print "
\n"; print"\n"; print "\n"; foreach $var (sort { $count{$b} <=> $count{$a} } keys %count) { print " "; } print "
Top-Level DomainHits
$dns{$var}"; print " ($var)$count{$var}

\n"; # # Hits per domain # print "
\n"; print"\n"; print "\n"; foreach $var (sort { $domain_count{$b} <=> $domain_count{$a} } keys %domain_count) { print " "; } print "
DomainHits
$var"; print "$domain_count{$var}

\n"; # # Hits per host # print "
\n"; print"\n"; print "\n"; foreach $var (sort { $host_count{$b} <=> $host_count{$a} } keys %host_count) { if (!($var=~/sympatico/) && !($var=~/videotron/) && $host_count{$var}>1) { print " "; } } print "
HostHits
$var"; print "$host_count{$var}

\n"; # # Hits per day # print < DayHits EOI ; $cnt=0; foreach $day (reverse sort keys %day_count) { if ($cnt >= $display_days) { last; } if($cnt!=0) { print "".$day."".$day_count{$day}."\n"; } else { print "".$day.""; print "".$day_count{$day}.""; print "\n"; } $cnt++; } # # Hits per Page # #print <
# # #EOI #; #foreach $PG (sort { $PG_count{$b} <=> $PG_count{$a} } keys %PG_count) { # $pp=$PG; # $pp="Unknown" if $pp eq ""; # $pp=~s/~/$unstrip_uri/; # print "\n"; #} # # Hits per Referrer # print <
PageHits
".$pp."".$PG_count{$PG}."
EOI ; foreach $RF (sort { $RF_count{$b} <=> $RF_count{$a} } keys %RF_count) { # $RF=~s/%7E/\~/; $url=unescape($RF); # $url=~s/(.{120})(.*?)/$1
$2/; my @splurl=split //, $url; splice(@splurl, 40, $#splurl-80, "...") if $#splurl>80; my $jsplurl=join '', @splurl; print "\n" unless $url=~/porn/i; } # # Hits per Browser # print <
ReferrerHits
".$jsplurl."".$RF_count{$RF}."
EOI ; foreach $BR (sort { $BR_count{$b} <=> $BR_count{$a} } keys %BR_count) { print "\n"; } # # Hits per OS # print <

BrowserHits
".$BR."".$BR_count{$BR}."
EOI ; #print < # #
OSHits
# #EOI #; foreach $OS (sort { $OS_count{$b} <=> $OS_count{$a} } keys %OS_count) { print "\n"; } print "
OSHits
".$OS."".$OS_count{$OS}."
\n"; #print "
\n"; # # # print "\n"; sub unescape { $url=shift; $url=~s/\%7E/\~/g; $url=~s/\%26/\&/g; $url=~s/\%20/ /g; $url=~s/\%25/\%/g; $url=~s/\%22/\"/g; my @codes= $url=~/\%(..)/g; foreach $code (@codes) { $unc=pack("c",unpack("H", $code)); $url=~s/%$code/$unc/; } return $url; }