#!/usr/local/bin/perl # SET THE FOLLOWING VARIABLES: $mydir = "webvert"; $baseref = "/home/web/glamazon/cgi-bin/$mydir"; $gotoad = "http://www.glamazon.com/cgi-bin/$mydir/ads.pl"; $admincgi = "http://www.glamazon.com/cgi-bin/$mydir/admin.pl"; $adcount = $baseref ."/adcount.txt"; $adbanners = $baseref ."/adbanners.txt"; $ads_dir = $baseref ."/ads"; $logs_dir = $baseref ."/logs"; #Parse incoming name=value pairs if ($ENV{'QUERY_STRING'}) { @pairs = split(/&/, $ENV{'QUERY_STRING'}); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $INPUT{$name} = $value; #debug here #print "name = $name value = $value\n"; } } $displayad = $INPUT{"displayad"}; # Name of the ad to display - empty if rotating banner ad. #Turn off buffering so that output is displayed in correct order. $| = 1; print "Content-type: text/html\n\n"; print "Click Log Page for $displayad"; print "

Click Log Page for $displayad

\n"; &printad; &print_click_table; &print_ad_info; print "
\n\n\n\n\n"; exit(0); sub print_ad_info { print "

Check stats from advertiser
"; print "Your user name is $userid and password is $passcode
"; print "Get new banners from advertiser
" if $bannersurl; } sub print_click_table { if (open (LOG, "<$logs_dir\/$displayad.log")) { print "\n"; $day_count = 1; } $prevday = $day; } print "\n"; close (LOG); print"
Day<\/TH>Uniques<\/TH><\/TR>"; $day_count = 0; $prev_day = ""; while () { ($ip_addr_logged, $ip_time_logged,$referer_logged) = split(' ', $_ ,3); # now get the time ($sec,$min,$hour,$mday,$mon,$year,$unused)=localtime($ip_time_logged); $mon++; $day = sprintf("%.2d/%.2d/%2d",$mon,$mday,$year); if (($day_count == 0 ) or ($day eq $prevday)) { $day_count++; } else { print "
$prevday$day_count
$prevday$day_count
"; } else { print "No Log File Yet."; } } sub printad { &read_display_vars($displayad); print qq?\n\n
\n?; # Print out the tag. if ($text) { # print STDOUT "Text is $text.
"; print STDOUT "$text
\n"; } if ($image) { # print STDOUT "Image is $image.
"; print STDOUT "\n"; print STDOUT "\"$text\""; } print qq?

\n?; } sub return_error { local ($status, $keyword, $message) = @_; print "Content-type: text/html\n"; print "Status: $status $keyword\n\n"; print < CGI Program Error

$keyword


$message
End_of_Error exit(1); } sub read_display_vars { local ($filename) = @_; open (DISPLAY, "<$ads_dir/$filename.txt") || &return_error (500, "Ad Log Error", "Could not open ad file $ads_dir/$filename.txt in read_display_vars ."); # Read in the whole DISPLAY file. Chop return chars if necessary. if ($UseLocking) { flock (DISPLAY, $exclusive_lock);} @lines = ; if ($UseLocking) { flock (DISPLAY, $unlock_lock);} close (DISPLAY); foreach $line (@lines) { chop ($line) if ($line =~ /\n$/); } # Name each of the variables in the DISPLAY file. ($cents, $url,$text,$image,$height, $width,$target,$javascript,$statsurl,$userid,$passcode,$bannersurl ) = @lines; }