#!/bin/perl require "adtracklib.pl"; #Parse incoming name=value pairs &ReadFormInput; $ip_addr = $ENV{'REMOTE_ADDR'}; if ($ip_addr) { $referer = $ENV{'HTTP_REFERER'} || $INPUT{"template"} || "-"; $sponsor = $INPUT{"sponsor"}; $ad = $INPUT{"ad"}; $site = $INPUT{"site"}; $numdate = time(); $hit = "$numdate $referer $ad $sponsor\n"; if ($hit) { &InitSiteVars($site); $ip_logfile = "$logs_dir/$ip_addr.reap"; &RecordClick; } } exit; sub RecordClick { print "Location: " . $gsPagerCgiUrl . "?site=$site&template=exit.html","\n\n"; &LogUnique; } sub LogUnique { if (-e $ip_logfile) { open (LOG, ">>" . $ip_logfile) || &ReturnCGIError (500, "Ad Log Error","Cannot read or write log file $ip_logfile"); seek LOG, 2, 0; #@ end of log print LOG $hit; close LOG; exit; } else { open (LOG, ">" . $ip_logfile) || &ReturnCGIError (500, "Ad Log Error", "Cannot create log file $ip_logfile."); print LOG $hit; close LOG; chmod 0666, $ip_logfile; exit; } }