#!/usr/bin/perl # # Print a team sheet from database # # both team-query.pl?1 (plain) and team-query?teamno=1 (GET method) are okay # # Also accepts header, format and footer from form fields # # 3v@iki.fi and rpr@iki.fi (Fall 99) # require "/home/bb/renabble-data/renabble-common.pl"; lock_init("$DIR/lock"); $teamno = $ENV{QUERY_STRING}; unless ($teamno > 0) { #was it a GET? for (split /&/,$ENV{QUERY_STRING}) { ($key,$value) = split (/=/); $hash{$key}=$value; } $teamno = &decode($hash{"teamno"}); $header = &decode($hash{"header"}); $format = &decode($hash{"format"}); $footer = &decode($hash{"footer"}); } print "Content-type: text/html\n\n"; if ($teamno <= 0) { print "Error!\ Invalid team number!

\ \n"; exit 0; } sharelock(); unless (open FILE,"$DIR/team.$teamno") { print "Error!Team $teamno not found.

Try this.\n"; exit 0; } @stat=stat FILE; $stamp=localtime $stat[9]; @file=; close FILE; #fetch from file if not included in query string unless (open FILE,"$TEAMFILE") { print "Fatal error: master team database could not be opened!\n"; # exit 0; } $found=0; while () { if (/^($teamno)\t/) { $found=1; last } } if (not $found) { print "Error! Data for team $teamno not found.

Try this.\n"; # exit 0; } close FILE; unlock(); chomp; ($teamno,$teamname,$race,$player,$email,$www,$rating,$spp,$status,$reroll,$ff,$treasury,$usr1,$usr2,$usr3,$usr4,$usr5,$head,$form,$foot,$bod) = split /\t/; $header=&decode($head) unless ($header); $format=&decode($form) unless ($format); $footer=&decode($foot) unless ($footer); $body=&decode($bod) unless ($body); $_=$header; s/_TEAMNAME_/$teamname/g; s/_RACE_/$team_race_name{$race}/g; s/_PLAYER_/$player/g; s/_EMAIL_/$email/g; s/_WWW_/$www/g; s/_RATING_/$rating/g; s/_TOTALSPP_/$spp/g; s/_REROLL_/$reroll/g; s/_FF_/$ff/g; s/_TREASURY_/$treasury/g; s/_USR1_/$usr1/g; s/_USR2_/$usr2/g; s/_USR3_/$usr3/g; s/_USR4_/$usr4/g; s/_USR5_/$usr5/g; s/_STAMP_/$stamp/g; s/_BODY_/$body/g; print; foreach $line (@file) { chomp $line; local(@_) = split /\t/,$line,16; $i++; for (@_) { $_ = $_ ? $_ : ' ' }; $_=$format; s/_NUMBER_/$i/g; s/_NAME_/$_[0]/g; s/_POSITION_/$_[1]/g; s/_STATS_/$_[2]/g; s/_SKILLS_/$_[3]/g; s/_NOTES_/$_[4]/g; s/_PLD_/$_[5]/g; s/_COMP_/$_[6]/g; s/_TD_/$_[7]/g; s/_INT_/$_[8]/g; s/_CAS_/$_[9]/g; s/_MVP_/$_[10]/g; s/_SPP_/$_[11]/g; s/_COST_/$_[12]/g; s/_USRA_/$_[13]/g; s/_USRB_/$_[14]/g; s/_USRC_/$_[15]/g; print; } $_=$footer; s/_TEAMNAME_/$teamname/g; s/_RACE_/$team_race_name{$race}/g; s/_PLAYER_/$player/g; s/_EMAIL_/$email/g; s/_WWW_/$www/g; s/_RATING_/$rating/g; s/_TOTALSPP_/$spp/g; s/_REROLL_/$reroll/g; s/_FF_/$ff/g; s/_TREASURY_/$treasury/g; s/_USR1_/$usr1/g; s/_USR2_/$usr2/g; s/_USR3_/$usr3/g; s/_USR4_/$usr4/g; s/_USR5_/$usr5/g; s/_STAMP_/$stamp/g; print; print $DISCLAIMER; exit 0;