|
Server : Apache/2.4.62 System : FreeBSD fbsdweb2.web.rcn.net 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC amd64 User : www ( 80) PHP Version : 8.3.8 Disable Function : NONE Directory : /domains/awyethgalleryweb/order/ |
Upload File : |
#!/usr/bin/perl
use CGI:: Carp qw(fatalsToBrowser);
# =========================================
# FORM to email script.
# =========================================
$| = 1;
print "Content-type: text/html\n\n";
# =========================================
# Get input from the Web via the content length
# =========================================
if ($ENV{'REQUEST_METHOD'} eq "POST") {
read(STDIN,$buffer,$ENV{'CONTENT_LENGTH'});
} else {
$buffer = $ENV{'QUERY_STRING'};
}
@pairs= split(/&/,$buffer);
foreach $pair (@pairs) {
($name,$value) = split(/=/,$pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
$contents{$name} = $value;
}
# =========================================
# If you want to limit mail to be sent only
# on local machine use this value for the
# regular expression:
# $regexp = "[\<\>\|\;\@\!\%\,\`]";
# The default shown below allows mail to be
# sent on the internet
# =========================================
$regexp = "[\<\>\|\;\,\`]";
# =========================================
# Create an array of responses to use.
# =========================================
%responses = %contents;
# =========================================
# Get the mail information here and take
# away all suspect characters
# =========================================
$mfrom = $contents{'mfrom'};
$mfrom =~ s/$regexp//g; # remove suspect chars
# ($mfrom = $contents{'mfrom'}) =~ s/$regexp//g; # remove suspect chars
$mailto = $contents{'[email protected]'};
$mailto =~ s/$regexp//g; # remove suspect chars
$msub = $contents{'msub'};
$msub =~ s/$regexp//g; # remove suspect chars
$sendvar = $contents{'sendvar'};
# =========================================
# Remove those fields that you do not need
# from the responses in the FORM. You have
# to edit these fields for yourself.
# =========================================
delete $responses{'mfrom'};
delete $responses{'mailto'};
delete $responses{'msub'};
delete $responses{'sortby'};
delete $responses{'sendvar'};
# =========================================
# Remove items from %contents array into
# the body of the message based on keys in
# the $sortby variable.
# =========================================
$sortby = $contents{'sortby'}; # get keys;
@usekeys = split(' ',$sortby);
@body = ();
$count = 0;
foreach $key (@usekeys) {
if ($sendvar eq "TRUE") {
$body[$count++] = $key . " " . $responses{$key};
} else {
$body[$count++] = $responses{$key};
}
delete $responses{'$key'}; # remove.
}
# =========================================
# Use rest of items in %contents array into
# the body of the message in an alphanumeric
# sort and append to those used via $sortby.
# =========================================
foreach $key (sort keys %responses) {
if ($sendvar eq "TRUE") {
$body[$count++] = $key . " " . $responses{$key};
} else {
$body[$count++] = $responses{$key};
}
}
# =========================================
# Now create the message itself and send it
# out with the headers if $mailto is not empty
# otherwise just print a response back.
# =========================================
$message = "";
foreach (@body) {
$message .= $_ . "\n";
}
$time = time;
$echoback = "";
if ($mailto eq "") {
$echoback = "<HR>$time: Debug Echo Back<HR>";
foreach (@body) {
$echoback .= $_ . "<BR>"
}
$echoback .= "<HR>";
}
# ==================================
# Send message via email if $mailto
# ==================================
if ($mailto ne "") { # A mailto! respond with email
format MAILCOMMENT =
To : @*
$mailto
From: @*
$mfrom
Subject: @*
$msub
This message is sent from our mailbot in response
to the following questions:
=================================================
@*
$message
==================End of Message=================
.
open (MAILCOMMENT,"| /usr/sbin/sendmail -t") || die "Cannot open sendmail $!\n";
write (MAILCOMMENT);
close (MAILCOMMENT);
}
# ==================================
# Always acknowledge to browser....
# ==================================
print <<"HTMLHEAD";
<HTML>
<HEAD>
<TITLE> Ack for Request for Info </TITLE>
</HEAD>
<BODY>
<HR>
$echoback
<HR>
<P>
<PRE>
To : $mfrom
From: $mailto
Subject: $msub
This message is sent from our mailbot in response
to the following questions:
=================================================
$message
==================End of Message=================
</PRE>
</BODY>
</HTML>
HTMLHEAD