#!/usr/bin/perl #***** # fname: img.pl # (c) 1996, 1997, 2003 Resource Marketing, Inc. Ft. Thomas KY #***** # log info #open (LOG, ">>rotate.log"); #while (($key,$record) = each %ENV) { print LOG "$key = $record\n"; } #print LOG "=================\n"; my @images = `ls *.jpg`; my $number_images = @images; my $random = int ( rand ($number_images)); $random .= ".jpg"; #open (FILE, ">>rotate.log"); #print FILE "$random\n"; #close (FILE); ############################################### # affiliate processing # get the cookie, find out what was read my %CookieJar; my @cookie_jar = split /; /, $ENV{'HTTP_COOKIE'}; foreach my $k (@cookie_jar) { my ($key, $record)= split /=/,$k; $CookieJar{$key}=$record; } my $client=$CookieJar{'client'}; chomp $client; ############################################### #print LOG "client = $client\n"; #print LOG "sending /vhosts/resource-marketing.com/httpdocs/affiliate_art/$client.jpg"; if ($client) { # first update hit counter, if valid $client use strict; use DBI; my $dbh = DBI->connect ("DBI:mysql:host=localhost;database=resmark_affiliate", "resmark", "vamstutz_1951", {PrintError => 0, RaiseError => 1}); $dbh->do (qq{ UPDATE counter SET hits = hits +1 WHERE id = $client}); $dbh->disconnect (); # now send image if (-f "/vhosts/resource-marketing.com/httpdocs/affiliate_art/$client.jpg") { send_image("/vhosts/resource-marketing.com/httpdocs/affiliate_art/$client.jpg"); } else { send_image($random); } #} elsif ($ENV{HTTP_REFERER} =~ /kb/) { # send special image for recruiting # send_image("/vhosts/resource-marketing.com/httpdocs/images/auth_best_buys_2.jpg"); #} elsif ($ENV{HTTP_REFERER} =~ /contactrm/) { # send special image for recruiting # send_image("/vhosts/resource-marketing.com/httpdocs/images/kbhome.jpg"); } elsif ($ENV{'HTTP_REFERER'} =~ /kaeser/) { send_image("/vhosts/resource-marketing.com/httpdocs/images/auth_best_buys_2.jpg"); } else { send_image($random); } #close (LOG); sub send_image { my $image = shift; open (FILE, "<$image"); print "Content-type: image/jpg\n\n"; print ; close (FILE); }