#!/usr/bin/perl require ("./Library/cgi-lib.pl"); &ReadParse(*form_data); # $Burl = "64.246.20.119/save/beacon.gif"; # dont lose- beacon location #$Burl = "www.figures.com/beacon.gif"; $Burl = "images2.figures.com/beacon.gif"; $dom = $form_data{'dom'}; $sys = $form_data{'sys'}; $url = $form_data{'url'}; $sponsor = $form_data{'sponsor'}; $size = $form_data{'size'}; $action = $form_data{'action'}; # exp,clicks,beacon $ad = $form_data{'ad'}; if($dom eq "") {$sys = "fig";} if($sys eq "") {$sys = "news";} if($action eq ""){$action = "exp";} $base = "./counts_S"; if(($action eq "beacon")||($action eq "clicks")||($size eq "popunder")||($action eq "eyeblaster")) { local ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst,$date); ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); if ($mday < 10) {$mday = "0$mday";} $mon++; if ($mon < 10) {$mon = "0$mon";} $year = 1900 + $year; $YMDdate = "$year$mon$mday"; if ($action eq "beacon"){$YMDdate = "$year$mon$mday$hour";} unless (-d "$base/$year") {mkdir("$base/$year",0777);} unless (-d "$base/$year/$mon") {mkdir("$base/$year/$mon",0777);} unless (-d "$base/$year/$mon/$mday") {mkdir("$base/$year/$mon/$mday",0777);} $counterfile = ""; $counterfile = "$base/$year/$mon/$mday/$YMDdate.$action.$dom.$sys.$sponsor.$size"; &get_file_lock("$counterfile.lok"); unless (-e "$counterfile") { open (COUNTER, "+>$counterfile"); print COUNTER "0"; close (COUNTER); } open (COUNTER, "$counterfile"); $count = ; close (COUNTER); $count++; open (COUNTER, ">$counterfile"); print COUNTER "$count"; close (COUNTER); &release_file_lock("$counterfile.lok"); } $url =~ s/~qm~/\?/gi; $url =~ s/~eq~/=/gi; $url =~ s/~am~/\&/gi; $url =~ s/~pl~/\+/gi; if($action eq "beacon") { print "Status: 302 Moved Temporarily\n"; print "Location: http://$Burl\n"; print "Pragma: no-cache\n"; print "Cache-Control: no-cache\n\n"; } else { print "Status: 302 Moved Temporarily\n"; print "Location: http://$url\n\n"; # print "Pragma: no-cache\n"; # print "Cache-Control: no-cache\n"; } exit; ######################################## sub get_file_lock { local ($lock_file) = @_; local ($timeout); $timeout=20; while (-e $lock_file && (stat($lock_file))[9]+$timeout>time) {sleep(1);} open(LOCK_FILE, ">$lock_file"); ### || &file_open_error ("$lock_file","Lock File Routine",__FILE__, __LINE__); } sub release_file_lock { local ($lock_file) = @_; close(LOCK_FILE); unlink($lock_file); }