#!/usr/bin/perl 
use CGI::Carp qw(fatalsToBrowser);
use CGI qw(:standard);
print "Content-type: text/html\n\n";

$step    = param('step');

if ( (!defined $step) || ($step ne '2') ) {
    open(FILE, "ballot.htm") || die("This file will not open");
        while(<FILE>) {
            print $_ ;
        }
    close(file);
 exit;
}


# --------------
$who     = param('who');
$repaint = param('repaint');
$custom  = param('custom');
$scratch = param('scratch');
$rookie  = param('rookie');
$theme   = param('theme'); 

if ($step eq '2')  {
    if ( $who eq 'Beek') { 
      $return = 'beek@cdc.net'; 
    }
    elsif ( $who eq 'BigDogge') { 
      $return = 'ZOtm_BigDOGGe@yahoo.com';
    }
    elsif ( $who eq 'Cope') { 
      $return = 'cope@mtm2.com';
    }
    elsif ( $who eq 'Drive2Survive') { 
      $return = 'd2smtm2@email.com';
    }
    elsif ( $who eq 'legwon') { 
      $return = 'LeGraham@shaw.ca'; 
    }
    elsif ( $who eq 'Malibu350') { 
      $return = 'malibu350@karf.net'; 
    }
    elsif ( $who eq 'Phineus') { 
      $return = 'phineus@karf.net'; 
    }
    elsif ( $who eq 'Rep Fan') { 
      $return = 'bigblock66@hotmail.com'; 
    }
    elsif ( $who eq 'RobbyH14') { 
      $return = 'robbyh14@yahoo.com'; 
    }
    elsif ( $who eq 'Winterkill') { 
      $return = 'wkmtm@hotmail.com';
    }
    elsif ( $who eq 'ZooN') { 
      $return = 'zoon@ifrance.com'; 
    }
    else {
      $return = 'expo@mtm2.com'; 
    }
}

@times = localtime(time); 
          $year =  sprintf("%04d",($times[5] + 1900)); 
          $month = sprintf("%02d",($times[4]+1)); 
          $day =   sprintf("%02d",($times[3])); 
$date = $year . "-" . $month . "-" . $day ;

# --------------
   $sendmail = '/usr/sbin/sendmail';
   $to = 'eayers@sympatico.ca , '  . $return ; 
   $from = 'expo@mtm2.com';
   $ip = $ENV{REMOTE_ADDR} ;
   $subject = "Expo 2003 - Ballot" ;
# --------------

$CONTENT = <<CONTENT;
         The following message was sent 
         to        :  $from 
         subject   :  $subject

         Truck vote
         repaint   :  $repaint
         custom    :  $custom
         scratch   :  $scratch

         Track vote
         rookie    :  $rookie
         advanced  :  $theme

         Date:     :  $date

         IP        :  $ip
CONTENT

 open(MAIL,"| $sendmail $to") || die("Could not send mail!") ;
     print( MAIL "To: $to \n"); 
     print( MAIL "From: $from\n"); 
     print( MAIL "Subject: $subject\n"); 
     print( MAIL "\n\n"); 
    print( MAIL "$CONTENT");
 close(MAIL); 

print <<EOM;
<html>
  <head>
    <META HTTP-EQUIV="no-cache">
  </head>
    <BODY text=silver bgcolor=black>
      <div style="margin-left: 80px;margin-right: 80px">
        <p>
          <pre>
$CONTENT

         <a href="http://rhinoseros.com/~mtmg/contests/expo2003/">Back to the Expo page</a>
          </pre>
        </p>
     </div>
  </body>
</html>
EOM



# EOF




