#!/usr/local/bin/perl ####################################################### # Advertisement Banner Rotator V2.0 # # This program is distributed as freeware. We are not # responsible for any damages that the program causes # to your system. It may be used and modified free of # charge, as long as the copyright notice # in the program that give me credit remain intact. # If you find any bugs in this program. It would be thankful # if you can report it to us at cgifactory@cgi-factory.com. # However, that email address above is only for bugs reporting. # We will not respond to the messages that are sent to that # address. If you have any trouble installing this program, # olease feel free to post a message on our CGI Support Forum. # Selling this script is absolutely forbidden and illegal. ################################################################## # # COPYRIGHT NOTICE: # # Copyright 1999-2000 CGI-Factory.com TM # A subsidiary of SiliconSoup.com LLC # # # Web site: http://www.cgi-factory.com # E-Mail: cgifactory@cgi-factory.com # # Advertisement Banner Rotator V2.0 is protected by the copyright # laws and international copyright treaties, as well as other # intellectual property laws and treaties. ################################################################### # Nothing more need to be modified below this line, unless you feel # like doing it. require "cfg.cgi"; print "Content-type: text/html\n\n"; $currenttime=time(); ##################### open count data and total banners record data open (count, "<$datalocation/count.txt") or &error("Unable to open the count data"); if ($flock eq "y") { flock count, 2; } $count=; close(count); open (total, "<$datalocation/tcount.txt") or &error("Unable to open the count data"); if ($flock eq "y") { flock tcount, 2; } $total=; close(total); if ($total==0) { print "Nothing was found in the database"; exit; } ########################################################### decide which banner to show &selectbanner; $redo=0; sub selectbanner{ $count++; $redo++; if ($redo>50) { print "Something is wrong with the database. Wrong path?"; exit; } if ($count > $total) { $count=1; } if ($count=~ tr/;<>*|`&$!#()[]{}:'"//) { print "Security Alert! Action canceled.
\n"; print "Please don't use weird symbols\n"; exit; } open (banner, "<$datalocation/$count.txt") or &selectbanner; @banner=; close(banner); $expire=@banner[7]; &showbanner; &record; exit; } ######################### show banner sub showbanner { print "\"@banner[6]\"
@banner[3]
"; } ########################################################## Record the last banner showed sub record { open (record, ">$datalocation/count.txt") or &error("Unable to open the count data for writing"); if ($flock eq "y") { flock record, 2; } print record"$count"; close(record); open (bdata, "<$datalocation/$count.txt") or &error("Unable to open the banner data for reading"); if ($flock eq "y") { flock bdata, 2; } @bdata=; close(bdata); $expo = @bdata[8]; $expo++; @exposures=("$expo\n"); splice(@bdata, 8,1, @exposures); $displayed= @bdata[8]; $hits= @bdata[9]; if ($displayed == 0) { $percent=0; } else { $percent= $hits/$displayed; } @percent= ("$percent"); splice(@bdata, 10, 1, @percent); open (bdata2, ">$datalocation/$count.txt") or &error("Unable to open the banner data for reading"); if ($flock eq "y") { flock bdata2, 2; } print bdata2 @bdata; close(bdata2); } sub error{ $errors = $_[0] ; print "An error has occured, the error is $_[0]
\n"; print "$!\n"; exit; }