#!/usr/local/bin/perl $path = "/www/content/ads/cgi-bin/gototrack/"; $datfile = $path . "gotolog.txt"; $id = $ENV{'QUERY_STRING'}; $frompage = $ENV{'HTTP_REFERER'}; if ($frompage eq "") { $frompage = "Not available"; } $host = $ENV{'REMOTE_HOST'}; chop($date= `/usr/bin/date +"%Y%m%d"`); print "Content-type: text/html\n"; $readdat = `cat $datfile`; @lines = split("\n", $readdat); @items = split("\t", $lines[$id]); $desturl = $items[1]; $newline = "$host\t$frompage"; $file = $path . $id . "/" . $date; if(-e $file) { open(FILE, ">> $file"); flock(FILE, 2); print FILE "$newline\n"; close(FILE); flock(FILE, 8); } else { open(FILE, "> $file"); print FILE "$newline\n"; close(FILE); } print "Location: $desturl\n\n";