#!/usr/local/bin/perl ################################################################################ # links.cgi # Track outbound links by URL, Referring Page, Source of Link (i.e. fans only) # Author: Craig Rosenshein (modified by Ken Riess) # 8/5/98 ################################################################################ ################################################################################ ##### get the correct time ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdat) = localtime(time); $mon++; $date = $mon . $year; ################################################################################ use CGI qw(:standard); $out_dir = "/var/db/links/"; $dates = "linktrack_by_day$date"; $master = "linktrack$date"; $vendors = "vendors$date"; $form = new CGI; #### # Assign each form value into a variable named for the field name #### @names = $form->param; foreach $item(@names){ $$item = $form->param($item); } #################### # If the src name is unusually long then skip the program and just redirect # the browser if (length($src) > 30) { print $form->redirect($uri); exit(0); } ##### build hash key according to date and vendor ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdat) = localtime(time); $mon++; if (length($mon) == 1) {$mon = '0' . $mon}; if (length($mday) == 1) {$mday = '0' . $mday}; $time = $mon . '/' . $mday . '/' . $year; $vendorByDay = $src . '|' . $time; ##### this is necessary for uri's with ? and = characters $uri =~ s/__mark__/?/g; $uri =~ s/__equal__/=/g; $uri =~ s/__amp__/&/g; #### # Increment the count for the uri in MASTER #### dbmopen(%MASTER, "$out_dir$master", 0644) || die "Can't Open $out_dir$master"; ++$MASTER{$uri}; dbmclose %MASTER; #### # Increment the count for hits to a certain vendor according to the date #### dbmopen(%DATES, "$out_dir$dates", 0644) || die "Can't Open $out_dir$dates"; ++$DATES{$vendorByDay}; dbmclose %DATES; #### # If not already defined, associate the uri with the Vendor #### dbmopen(%VENDORS, "$out_dir$vendors",0644) || die "Can't Open $out_dir$vendors"; unless (defined $VENDORS{$uri}){ $VENDORS{$uri} = $src; } dbmclose %VENDORS; print $form->redirect($uri);