#!/usr/local/bin/perl -w


#both left or right ajustiment, when length is 0, will print the string
#put extra :: at the end of .def file to avoid 
# to print out last field as trash


if (@ARGV) {
   print "Content-Type: text/html \n\n";
   print "<p>$ARGV[0]\n";
}
else {
 print "Content-Type: text/html \n\n";
}
print "<HTML>\n";

print '<body bgcolor="#66FFFF">'; 
print '<font color="#660066">'; 

open(def_file,"</home/plee/jws/cgi-bin/eid.def") || print "die<p>";

@lines = <def_file>;
@colnames = split(":",$lines[0]);
close(def_file);

open(FILE, "</home/plee/jws/cgi-bin/eid.dat");

@values = <FILE>;

close(FILE);

print "<FORM ACTION=\"http://school.hzclake.net:8888/cgi-bin/seteid.pl\">\n";

$i=0;
while (($colnames[${i}]) && ($colnames[${i}] ne "Date")) {
  if ($colnames[${i}] eq "eid") {
    print "From: <INPUT NAME=\"$colnames[${i}]\" VALUE=\"you\@domain.com\"><p>\n";
  }
  elsif ($colnames[${i}] eq "MsgBody") {
    print $colnames[${i}],':<br>', '<textarea align=middle cols=50 rows=8 NAME=',$colnames[${i}], " VALUE=\"\"", "<p></textarea>\n";
  }
  else {
    print "$colnames[${i}] <INPUT NAME=\"$colnames[${i}]\" VALUE=\"\"><p>\n";
  }
  $i += 1;
}
print "<p><INPUT TYPE=\"submit\" name=\"submit\" value=\"Send\"> </FORM>";

print "</HTML>";
