#!/opt/gnu/bin/perl
#   Par Patrick Lapointe
#   7 aout 96
#   Module effectuant l'ecriture de COMT.PL
#
push (@INC,"/opt/httpd/cgi-bin");
require 'cgi-lib.pl';

######################################
# 
# Programme principal
#
     &ReadParse;
     &Ecrit;
#
#    Fin du programme  principal
#
######################################
sub Ecrit
    { 
      $Ecrit = 1;
      foreach $key (sort keys %in)
              {     
                if ( $in{$key} eq  "" ) { $Ecrit = 0; }
              }
  
     if ($Ecrit eq 1)
        {
         open (OUT, ">>comta.txt");
         foreach $key (sort keys %in)
              {     
               print OUT "$in{$key}";
               print OUT "\n";
              }
         print OUT "\n";
         close(OUT);
         &EcritOui;
        }
         else { &EcritNon }
    }
#
#    Module n'ecrit pas.
#
 sub EcritOui {
             print &PrintHeader;
             print "<HTML>\n";
             print "<BODY  BGCOLOR=#ebdedc TEXT=#b53934>\n";
             print " <H1>Your message has been sent.<\/H1><\/P>\n";
             print "<a href= \"comta.pl\"> Back </a><\/P>\n";
             print "</BODY>\n";
             print "</HTML>\n";
}

#
#   Module n'ecrit pas.
#
 sub EcritNon {
             print &PrintHeader;
             print "<HTML>\n";
             print "<BODY  BGCOLOR=#ebdedc TEXT=#b53934>\n";
             print " <H1> Your request has been refused: missing information<\/H1><\/P>\n";
 
             print "<a href= \"comta.pl\"> Back </a><\/P>\n";
             print "</BODY>\n";
             print "</HTML>\n";
}

