#!/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 "| 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 | \n";
$day_count = 1;
}
$prevday = $day;
}
print "| $prevday | $day_count | \n";
close (LOG);
print" |
|---|
";
} 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 "
";
}
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