#!/usr/bin/perl
#############################################################################
#
# Program umozliwia wyslanie listu via WWW
# (c) 1997 Piotr Wasilewski
#
# Tak ma wygladac kod HTML wstawiony na stronie wywolujacej ten formularz:
#
#
#
#############################################################################
&ReadEntry;
&SendMessage;
##############################################################################
#
# INPUT
#
##############################################################################
sub ReadEntry {
&ReadParse;
$email = $in{'e-mail'};
$adres = $in{'adres'};
return 1;
}
# Read and parse the data passed from fill-out form:
sub ReadParse {
local ($i, $loc, $key, $val);
# else-block added for command-line debugging:
if ( $ENV{'REQUEST_METHOD'} eq "GET" ) {
$in = $ENV{'QUERY_STRING'};
} elsif ( $ENV{'REQUEST_METHOD'} eq "POST" ) {
for ( $i = 0; $i < $ENV{'CONTENT_LENGTH'}; $i++ ) {
$in .= getc;
}
} else {
$in = ;
print "$in\n";
}
# Split input string into an array of strings:
@in = split(/&/,$in);
# Process each array element individually:
foreach $i ( 0 .. $#in ) {
# Convert plus signs to spaces:
$in[$i] =~ s/\+/ /g;
# Convert %nn from hex to alphanumeric:
$in[$i] =~ s/%(..)/pack("c",hex($1))/ge;
# Determine the location of the equals sign:
$loc = index($in[$i], "=");
# Extract the key:
$key = substr($in[$i],0,$loc);
# Extract the value:
$val = substr($in[$i],$loc+1);
# Multiple values are separated by a null character:
$in{$key} .= '\0' if ( defined($in{$key}) );
$in{$key} .= $val;
}
return 1;
}
#############################################################################
#
# OUTPUT
#
#############################################################################
sub SendMessage {
if ( open(MAIL, "|/usr/sbin/sendmail -t -n") ) {
print MAIL "To: \\n";
print MAIL "From: \<$email\>\n\n";
print MAIL "Prosze o informacje n/t partnerstwa z AF-em.\n";
print MAIL "Adres: $adres\n\n";
print MAIL "[WWWmail by Piotr Wasilewski \]\n\n";
close(MAIL);
&SendConfirm;
} else {
&SendError;
}
return 1;
}
sub SendConfirm {
print "Content-type: text/html\n\n
Potwierdzenie wyslania zamowienia
Witaj!
Twoje zamowienie zostalo wyslne.
E-mail: $email
Adres: $adres
Powrót do strony glownej
";
return 1;
}
sub SendError {
print "Content-type: text/html\n\n
Nastapil blad, w trakcie wysylania zamowienia!
Witaj!
Przykro mi, ale twoje zamowienie nie moze zostac wyslane.
Kontakt z administratorem
Powrót do poprzedniej strony
";
return 1;
}