|
|
#!/usr/bin/perl
# rotator.cgi
#########################################
# Banners Pro v2.5
# By David Parker
# Copyright @ 1999-2004
# All Rights Reserved
#########################################
# ***************************************
use strict;
# ===== Setup
my %setup;
open(FILE, "){chomp;my($n,$v)=split(/=/,$_);$setup{$n} = $v;}
close(FILE);
my ($cat_name,$types) = split(/-/,$ENV{'QUERY_STRING'});
my $cat = category_name($cat_name);
my $rdate = dates($setup{'timeoffset'});
$rdate =~ s/\-//g;
my ($hour,$wday)=(localtime(time+(3600*$setup{'timeoffset'})))[2,6];
$hour = 24 if ($hour == 0);
$wday = 7 if ($wday == 0);
# ---------------------- File banners.data --------------- #
open (FILE,"){
chomp;
unless ($_){next;}
my @temp = split(/\|/,$_);
$temp[16] =~ s/\-//g;
$temp[17] =~ s/\-//g;
$temp[17] = $rdate unless ($temp[17]);
if ($rdate >= $temp[16] and $rdate <= $temp[17] and $temp[3] and $temp[18] =~ /\:$wday\:/ and $temp[19] =~ /\:$hour\:/){
$hash1{$temp[0]} = $temp[3];
}
$hash2{$temp[0]} = $_;
}
close(FILE);
# -------------------------------------------------------- #
my ($id,$banner,$max_imp,$max_clk);
unless (%hash1){$banner = ' ';}
else {
my $g_hash = weight_to_dist(%hash1);
my $id = wieghted_ran(%{$g_hash});
my (undef,undef,$type,$weight,$name,$site_name,$iurl,$width,$height,$surl,$alt,$max_imps,$max_clks,$ifile,$version,$target,undef,undef,undef,undef,$text,$text_url) = split(/\|/,$hash2{$id});
$max_imp = $max_imps;
$max_clk = $max_clks;
my @ifile = split(/\:/,$ifile);
$ifile = $ifile[int(rand(@ifile))];
my @iurl = split(/\;/,$iurl);
$iurl = @iurl[int(rand(@iurl))];
my $t_text;
if ($text and !$text_url){$t_text = " $text";}
elsif ($text and $text_url){$t_text = qq~ $text~;}
if ($type == 1){
my $image = $iurl;
$image = "$setup{'html_url'}/data/$ifile" if ($ifile);
my $size = '';
$size = qq~width="$width" height="$height" ~ if ($width and $height);
$banner = qq~$t_text~;
}
elsif ($type == 2){
$banner = qq~$site_name $alt $t_text~;
}
elsif ($type == 3){
my $flash = $iurl;
$flash = "$setup{'html_url'}/data/$ifile" if ($ifile);
my $size = qq~WIDTH="100%" HEIGHT="100%"~;
$size = qq~WIDTH="$width" HEIGHT="$height"~ if ($width and $height);
if ($version == 5){$banner = qq~ |