#!/usr/local/bin/perl # *********************************************************************** # # * * # # * Copyright (c) 1996-1999 Scott Crevier * # # * All Rights Reserved Worldwide * # # * * # # * This program product material is the property of Scott Crevier. * # # * This program may be used and modified by anyone free of charge, * # # * as long as this copyright notice remains in tact. By using this * # # * code, you agree to indemnify Scott Crevier from any liability * # # * that might arise from its use. * # # * * # # * scott@crevier.org - Scott M. Crevier - www.crevier.org * # # *********************************************************************** # # * smcAdTrack.pl v2.0 21-Dec-1998 * # # * * # # * This program is called when a user clicks on a graphic image. * # # * * # # * The concept here is that, when you display an image, instead of * # # * making that image a link directly to the other web site, make the * # # * image a link to this script. Pass to this script the URL of the * # # * web site. This script will send the user to that URL, and then * # # * add an entry to the log file so that you know that the click * # # * happened. * # # * * # # * Syntax example: * # # * * # # * * # # * Yahoo Logo * # # * * # # * If you are in a different time zone than the machine where your * # # * web site resides, you can set the $hours_to_add variable to tell * # # * this script to log the times in your local time zone. * # # * * # # *********************************************************************** # # *********************************************************************** # # * Set some variables. * # # *********************************************************************** # $logfile = '/usr/path/to/your/log/file'; $sep = '|'; $hours_to_add = -3; $now = &getNow; # *********************************************************************** # # * Send the user to the sponsor's web site. * # # *********************************************************************** # print "Location: $ENV{'QUERY_STRING'}\n\n"; # *********************************************************************** # # * Log this instance. * # # *********************************************************************** # open(L,">> $logfile") || die "$! \'$logfile\'"; print L $now, $sep, $ENV{'QUERY_STRING'}, $sep, $ENV{'REMOTE_HOST'}, $sep, $ENV{'REMOTE_ADDR'}, $sep, $ENV{'HTTP_USER_AGENT'}, "\n"; close(L); exit(0); # *********************************************************************** # # * Subroutine to return the current date/time. You can customize * # # * this so that it uses whatever format you are most comfortable * # # * with. * # # *********************************************************************** # sub getNow { ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time + ($hours_to_add * 3600)); $year += 1900; $mon = sprintf("%02d", $mon); $mday = sprintf("%02d", $mday); $hour = sprintf("%02d", $hour); $min = sprintf("%02d", $min); $sec = sprintf("%02d", $sec); return "${year}-${mon}-${mday} ${hour}:${min}:${sec}"; }