Article View: best.general
Article #156Fixing /cgi-bin/count-ssi.cgi to log referer.
From: Joe Smith
Date: Tue, 30 Oct 2001 01:12
Date: Tue, 30 Oct 2001 01:12
36 lines
2141 bytes
2141 bytes
I modified ~/www/cgi-bin/count-ssi.cgi to be a little faster (by removing
useless 'use CGI') and adding the ability to log HTTP_REFERER.
-Joe
inwap% diff -u www/cgi-bin/{vwh-count,count-ssi}.cgi
--- www/cgi-bin/vwh-count.cgi Sat Oct 13 20:19:56 2001
+++ www/cgi-bin/count-ssi.cgi Mon Oct 29 16:20:17 2001
@@ -2,7 +2,9 @@
use strict;
use Getopt::Std;
-use CGI qw/:standard/;
+sub header {"Content-type: text/html\n\n"}; # Replace 'use CGI qw/:standard/;'
+my $logfile="/usr/home/inwap/www/logs/referer_log";
+
use integer;
print header;
@@ -86,5 +88,14 @@
print COUNT $orig_val."\n";
close(COUNT);
}
+
+# Log REFERER for any document using /cgi-bin/count-ssi.cgi for counter.
+# Added by Joe.Smith@inwap.com 29-Oct-2001
+
+exit 0 unless $ENV{HTTP_REFERER};
+$_ = $ENV{DOCUMENT_URI} || $ENV{REQUEST_URI} || $ENV{COUNTER_INFO};
+open(OUT,">>$logfile") || exit 1;
+print OUT "$_ $ENV{HTTP_REFERER}\n"; # Document, space, referer (no quotes)
+close OUT;
exit(0);
--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.
Technical Details
Message-ID:
<9rkuq5$72i$1@nntp1.ba.best.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news-peer-west.sprintlink.net!news.sprintlink.net!enews.sgi.com!news2.best.com!nntp1.ba.best.com!inwapShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f9f6d,27bdea056212bbf6,start X-Google-Attributes: gidf9f6d,public X-Google-Thread: 11488e,27bdea056212bbf6,start X-Google-Attributes: gid11488e,public X-Google-Thread: fdc27,27bdea056212bbf6,start X-Google-Attributes: gidfdc27,public X-Google-ArrivalTime: 2001-10-29 17:12:48 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news-peer-west.sprintlink.net!news.sprintlink.net!enews.sgi.com!news2.best.com!nntp1.ba.best.com!inwap From: inwap@best.com (Joe Smith) Newsgroups: best.general,best.migration,best.www Subject: Fixing /cgi-bin/count-ssi.cgi to log referer. Date: Tue, 30 Oct 2001 01:12:37 +0000 (UTC) Organization: Chez Inwap Lines: 36 Distribution: best Message-ID: <9rkuq5$72i$1@nntp1.ba.best.com> NNTP-Posting-Host: shell3.ba.best.com X-Trace: nntp1.ba.best.com 1004404357 7250 206.184.139.134 (30 Oct 2001 01:12:37 GMT) X-Complaints-To: abuse@best.com NNTP-Posting-Date: Tue, 30 Oct 2001 01:12:37 +0000 (UTC)