#!/usr/bin/perl
#
# Original script written by Joel Hahn, 1997; modified 1998, 1999, 2000.

#use CGI::Carp qw(fatalsToBrowser);

# Get the input
$buffer=$ENV{'QUERY_STRING'};

$file=$buffer;

# Check for which product line was selected
if ($file eq "firsted1") {
 $prodline="First Edition";
 $part=", part 1";
}
elsif ($file eq "firsted2") {
 $prodline="First Edition";
 $part=", part 2";
}
elsif ($file eq "firsted3") {
 $prodline="First Edition";
 $part=", part 3";
}
elsif ($file eq "seced1") {
 $prodline="Second Edition";
 $part=", part 1";
}
elsif ($file eq "seced2") {
 $prodline="Second Edition";
 $part=", part 2";
}
elsif ($file eq "thirded") { $prodline="Third Edition"; }
elsif ($file eq "alq") {  $prodline="Al-Qadim";  }
elsif ($file eq "birth") {  $prodline="Birthright";  }
elsif ($file eq "dsun") {  $prodline="Dark Sun";  }
elsif ($file eq "dlance") {  $prodline="Dragonlance";  }
elsif ($file eq "eberron") {  $prodline="Eberron";  }
elsif ($file eq "forg1") {
 $prodline="Forgotten Realms";
 $part=", part 1";
}
elsif ($file eq "forg2") {
 $prodline="Forgotten Realms";
 $part=", part 2";
}
elsif ($file eq "forg3") {
 $prodline="Forgotten Realms";
 $part=", part 3";
}
elsif ($file eq "kara") {  $prodline="Kara-Tur";  }
elsif ($file eq "grey") {  $prodline="Greyhawk";  }
elsif ($file eq "lankh") {  $prodline="Lankhmar";  }
elsif ($file eq "myst") {  $prodline="Mystara";  }
elsif ($file eq "plane") {  $prodline="Planescape";  }
elsif ($file eq "rloft") {  $prodline="Ravenloft";  }
elsif ($file eq "sjam") {  $prodline="Spelljammer";  }
elsif ($file eq "dnd1") {
 $prodline="Dungeons &amp; Dragons";
 $part=", part 1";
}
elsif ($file eq "dnd2") {
 $prodline="Dungeons &amp; Dragons";
 $part=", part 2";
}
elsif ($file eq "dnd3") {
 $prodline="Dungeons &amp; Dragons";
 $part=", part 3";
}
elsif ($file eq "dnd4") {
 $prodline="Dungeons &amp; Dragons";
 $part=", part 4";
}
else {
 $file="firsted1";
 $prodline="First edition";
 $part=", part 1";
}

# Open the relevant datafile, dump all of the data into the @LINES array
open(FILEDAT,"$file.dat") || die "Can't Open $file.dat: $!\n";
@LINES=<FILEDAT>;
close(FILEDAT);
$SIZE=@LINES;

# Start printing the form page
print "Content-Type: text/html\n\n";
print "<html><head><title>Rate $prodline</title></head>\n";
print "<body text=#000000 bgcolor=#FFFFFF><h1>Rate $prodline$part</h1>\n";
print "<p>\n";
print "<i>Note: 0 is awful, 10 is excellent.  If you do not wish to vote\n";
print "for a particular product, either leave those buttons blank or vote\n";
print "'N/A'</i>\n";
#print "<hr>\n";
print "<form method=post action=\"http://www.hahnlibrary.net/rpgs/rate/dorate.cgi\">\n";
#print "<form method=post action=\"http://hoohoo.ncsa.uiuc.edu/cgi-bin/post-query\">\n";
print "<input type=hidden name=filename value=$file>\n";

# Get the product name, set up the radio buttons, using the product code for
# an identifier
for ($i=0;$i<=$SIZE-1;$i++) {
   $_=$LINES[$i];
   ($prodcode, $prodname, $rest)= split(/\|/, $_, 3);
   print "<hr>$prodname<br>\n";
   print "<input type=radio name=$prodcode value=11>N/A\n";
   print "<input type=radio name=$prodcode value=0>0\n";
   print "<input type=radio name=$prodcode value=1>1\n";
   print "<input type=radio name=$prodcode value=2>2\n";
   print "<input type=radio name=$prodcode value=3>3\n";
   print "<input type=radio name=$prodcode value=4>4\n";
   print "<input type=radio name=$prodcode value=5>5\n";
   print "<input type=radio name=$prodcode value=6>6\n";
   print "<input type=radio name=$prodcode value=7>7\n";
   print "<input type=radio name=$prodcode value=8>8\n";
   print "<input type=radio name=$prodcode value=9>9\n";
   print "<input type=radio name=$prodcode value=10>10\n";
#   for ($j=0;$j<=10;$j++) {
#      print "<input type=radio name=$prodcode value=$j>$j\n";
#   }
   print "<p>\n";
}

# Finish printing the form page
print "<p><input type=submit value=\"Send\">\n";
print "<input type=reset value=\"Clear All\">\n";
print "</form>\n";
print "<hr>\n";
print "Return to the <a href=\"http://www.hahnlibrary.net/rpgs/rate/rating.html\">rating index page</a>.<br>\n";
print "<a href=\"http://www.hahnlibrary.net/rpgs/rate/display.html\">View the ratings</a>.\n";
print "</body></html>";

