#!/usr/local/bin/perl -w use strict; # Where Are They Coming From? # A Small but Useful (tm) perl script to see how people got here. # Truly awful, but what the hell. Version 1.0 -- Ph1rs+ r3l35s3! # December 18, 2004 # Copyright 2004 Hugh Brown # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # $Id: referers.cgi,v 1.5 2004/12/19 01:55:02 aardvark Exp aardvark $ # # $Log: referers.cgi,v $ # Revision 1.5 2004/12/19 01:55:02 aardvark # First release! Also, no longer depends on get_referers.sh. # # Revision 1.4 2004/12/19 01:41:18 aardvark # Add deyahoo section. # # Revision 1.3 2004/01/21 15:16:14 aardvark # *** empty log message *** # # You'll want to customize these two: my $website = "saintaardvarkthecarpeted.com"; my $logfile = "/home/aardvark/logs/aardvark.access.log"; # And maybe check the paths on these. I use gawk and the GNU versions # of grep, sort and uniq; I haven't tested them with other versions (like FreeBSD's, say) # but I don't think I'm using any options that are too weird. my $grep = "/usr/bin/grep"; my $awk = "/usr/bin/awk"; my $sort = "/usr/bin/sort"; my $uniq = "/usr/bin/uniq"; my $date = `tail -1 $logfile | awk '{print \$4}' | awk -F":" '{print \$1}' | tr -d "["`; chomp $date; #grep "$DATE" $LOG | awk '{print $11}' | grep -v '"-"' | grep -v "saintaardvarkthecarpeted.com/" open (IN, "$grep $date $logfile | $awk '{print \$11}' | $grep -v '\"-\"' | $grep -v $website | $sort | $uniq -c | $sort -n|"); print "Content-type: text/html\n\n"; print "
\n"; print "
| Number of times | URL | \n"; while (
|---|---|
| $number | "; print ""; $url =~ y/"//d; if ($url =~ /google/) { $url = °oogle($url); } elsif ($url =~ /yahoo/) { $url = &deyahoo($url); } print "$url |