#!/usr/bin/perl -w
#display.cgi W. Alan Day 6/6/2014
#use CGI qw(:standard);
print "Content-type:text/html\n\n";
my ($Fname, $Lname, $email, $Phone, $Line, $File, $LnameFile, $FnameFile, $emailFile, $PhoneFile, @dirs, $outfile, $infile, $i, $Action, $Picture, $time);

$Fname = param('firstname'); $Fname = substr($Fname, 0, 30);
$Lname = param('lastname'); $Lname = substr($Lname, 0, 30);
$email = param('email'); $email = substr($email, 0, 30);
$Phone = param('phone'); $Phone = substr($Phone, 0, 30);
$Action = param('level'); $Action = substr($Action, 0, 11);
$Picture = param('picture');

if( $ARGV[0]) {$Picture = $ARGV[0]};

#foreach $key (sort(keys %ENV)) {
#    print "$key = $ENV{$key}<br>\n";
#}

@dirs = split('/', $ENV{HTTP_REFERER});
$File = "$ENV{HTTP_HOST}/$dirs[$#dirs - 2]/$dirs[$#dirs - 1]";

@dirs = split('/', $ENV{HTTP_REFERER});

$Line ="$ENV{DOCUMENT_ROOT}/$dirs[$#dirs - 2]/$dirs[$#dirs - 1]";
$infile = "$Line/$dirs[$#dirs - 1].csv";

open(PART, $infile);

$i = 0;
$time = `date`;

print <<EndOfHTML0;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <body bgcolor="#99CCFF">
      <title>Signed up for $dirs[$#dirs - 1] </title>
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      <style type="text/css">
<!--
body {
	background-image: url(/images/bkgd_rag_tile.jpg);
}
-->
</style>
      <link href="/css/booger.css"
        rel="stylesheet" type="text/css">
      <style type="text/css">
<!--
.style2 {font-style: normal; line-height: 1em; font-weight: normal; text-decoration: none; font-size: 20px;}
-->
</style>
      <left>
        <p style="margin-top: 0; margin-bottom: 0">&nbsp;</p>
      </left>
      <table align="left" border="0" cellpadding="0" cellspacing="0"
        height="423" width="629">
        <!--DWLayoutTable--> <tbody>
          <tr>
              <td aligh="right" width="173"><img alt=""
                src="/images/logoBlueGray_Sm.jpg"
                height="120" width="182"> <br>
            </td>

            <td align="center" valign="top" width="731">
            <img alt=""
            #src="http://$File/images/$Picture"
            src="http://$File/images/$Picture"
            <br>
              <div align="center">
                <p style="margin-top: 0"><br>
                </p>
                <p style="margin-top: 0; margin-bottom: 0"><font
                    face="Arial"><span class="textArial"></span><span
                      class="style2">Participants signed up for the
                      $dirs[$#dirs - 1] tour<br><br>
                        <font color="#000099"><small><small>as of $time
                        </small></small></font><br>
                    </span></font></p>
                <p><font face="Arial"><span class="style2"><small></small><strong><br>
                      </strong></span> </font></p>
                
                </td>
              </div>
               <td align="center" height="300" width="50%">&nbsp;</td>
          </tr>
          <tr>
            <td height="1" width="20%"><br>
            </td>
            <td align="center" height="80%" valign="middle" width="80%">
                <img src="/images/spacer.gif"
                alt="" height="1" width="731">
              <table border="1" cellpadding="2" cellspacing="2"
                width="80%">
                <tbody>
                  <tr>
                    <td align="center" valign="middle"><big><b></b><b><br>
                        </b> </big></td>
                    <td align="center" valign="top"><big><b>Last Name</b><b><br>
                        </b> </big></td>
                    <td align="center" valign="middle"><big><b>First
                          Name</b><b><br>
                        </b> </big></td>
                  </tr>
EndOfHTML0

while (<PART>) {
    $i++;
    ($LnameFile,$FnameFile,$emailFile, $PhoneFile) = split("\t");
    print <<TABLE2;
    <tr>
    <td align="center">&nbsp;$i</td>
    <td class="style8">&nbsp;$LnameFile</td>
    <td class="style8">&nbsp;$FnameFile</td>
    </tr>
TABLE2
}
print <<TABLE3;
                </tbody>
              </table>
              <br>
            </td>
          </tr>
        </tbody>
      </table>
TABLE3

close(PART);
print "</body>";
print "</html>";
