ChevyTeam


#!/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~$alt$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~$t_text~;} elsif ($version == 6){$banner = qq~$t_text~;} } elsif ($type == 4){ # --------- File banner body open (FILE,"){$banner .= $_;} close(FILE); $banner = "$banner $t_text"; } my $impr; # ---------------------- File imp.data --------------- # my $j=1; my @imp = (); open (FILE,"+){ chomp; my ($id1,$imp) = split(/\|/,$_); if ($id == $id1){ $j++; $imp++; $impr = $imp; push @imp,"$id|$imp|\n"; } else {push @imp,"$_\n";} } if ($j > 1){ seek FILE,0,0; print FILE @imp; truncate (FILE,tell(FILE)); } else { $impr = 1; seek FILE,0,2; print FILE "$id|1|\n"; } close(FILE); # -------------------------------------------------------- # stats($cat,$id); if ($impr >= $max_imp and $max_imp > 0){ # ---------------------- File banners.data --------------- # my @data = (); open (FILE,"+){ chomp; my @temp = split(/\|/,$_); if ($id == $temp[0]){ $temp[3] = 0; my $tt = join('|',@temp); $tt = "$tt|"; push @data,"$tt\n"; } else {push @data,"$_\n";} } seek FILE,0,0; print FILE @data; truncate (FILE,tell(FILE)); close(FILE); # -------------------------------------------------------- # } } print "Content-type: text/html\n\n"; if ($types eq 's'){ $banner =~ s/\"/\\"/g; $banner =~ s/\r\n/ /g; print qq~document.write("$banner");~; } else {print $banner;} sub wieghted_ran{ my %dist = @_; my ($key, $weight); while (1){ my $rand = rand; while (($key, $weight) = each %dist){ return $key if ($rand -= $weight) < 0; } } } sub weight_to_dist { my %weights = @_; my %dist = (); my $total = 0; my ($key, $weight); local $_; foreach (values %weights){$total += $_;} while (($key,$weight) = each %weights){$dist{$key} = $weight/$total;} return \%dist; } sub category_name { my $cat_name = shift; # ------------ File categories.data ------------- # open (FILE,"){ my ($id,$cn) = split(/\|/,$_); if ($cat_name eq $cn){$cat = $id;} } close(FILE); # ----------------------------------------------- # return $cat; } sub stats { my $cat = shift; my $id = shift; my $date = dates(); open (FILE,"+; my ($date1,$imp,$clk) = split(/\|/,$data[$#data]); if ($date eq $date1){ $imp++; $data[$#data] = "$date|$imp|$clk|\n"; } else {push @data, "$date|1|0|\n";} if (scalar(@data) > 93){shift @data;} seek FILE,0,0; print FILE @data; truncate (FILE,tell(FILE)); close(FILE); } sub dates { my $timeoffset = $_[0]; my $time = time(); if ($_[1]){$time = $_[1];} my($sec,$min,$hours,$mday,$month,$year,$wday,$yday,$isdst)=localtime($time+(3600 * $timeoffset)); $month=$month+1; if ($mday < 10) {$mday="0$mday";} if ($month <10) {$month="0$month";} $year=2000+($year-100); my $date="$year-$month-$mday"; return ($date); }
What's happening on the other Team Sites?
camaro_link.jpg - 2815 Bytes
Camaro Tech
chevelle_link.jpg - 3062 Bytes
Chevelle Tech
nova_link.jpg - 2412 Bytes
Nova Tech
impala_link.jpg - 3140 Bytes
Impala Tech
chevyteam.jpg - 3140 Bytes
Chevy Team


Google
 
Web Chevelle Camaro Nova Impala
[an error occurred while processing this directive]