File: /home/awaldron/www/archive/bdv/cgi-bin/mailadmin.cgi
#!/usr/bin/perl
$basedir = "/9158";
$mailfile = "E:/Webs/9158/cgi-bin/sendmail.asp";
# Get Form Information
&parse_form;
if ($FORM{'email'} =~ /.*\@.*\..*/) {
$email = "$FORM{'email'}";
}
else {
&error(no_name);
}
if ($FORM{'type'}) {
$type = "$FORM{'type'}";
}
open(TEMP,"$mailfile") || die $!;
@temp = <TEMP>;
close(TEMP);
open(TEMP,">$mailfile") || die $!;
foreach $main_line (@temp) {
if ($type == 1) {
if ($main_line =~ / \"john\@bigdogvending.com\"\)/) {
print TEMP " \"$email\", _\n";
print TEMP " \"john\@bigdogvending.com\")\n";
} # END IF MAIN_LINE
else {
print TEMP "$main_line";
}
}
else {
if ($main_line =~ / \"$email\", _/) {
print TEMP "";
} # END IF MAIN_LINE
else {
print TEMP "$main_line";
}
}
} # END FOREACH
print "Content-type: text/html\n\n";
print "<html>\n";
print "<head>\n";
print "<title>Processing...</title>\n";
if ($type == 1) {
print "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"0\;URL=http://www.bigdogvending.com/thankyou.htm\">\n";
}
else {
print "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"0\;URL=http://www.bigdogvending.com/sorry.htm\">\n";
}
print "</head>\n";
print "<body>\n";
print "</body></html>\n";
#######################
# Parse Form Subroutine
sub parse_form {
# Get the input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# Split the name-value pairs
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
# Un-Webify plus signs and %-encoding
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<!--(.|\n)*-->//g;
if ($allow_html != 1) {
$value =~ s/<([^>]|\n)*>//g;
}
else {
unless ($name eq 'body') {
$value =~ s/<([^>]|\n)*>//g;
}
}
$FORM{$name} = $value;
}
######################################
# Writes Error Messages When Necessary
sub error {
$error = $_[0];
print "Content-type: text/html\n\n";
if ($error eq 'no_name') {
print "<html><head><title>$title ERROR: No Name</title></head>\n";
print "<center><h1>ERROR: No Name</h1></center>\n";
print "You forgot to fill in the 'Name' field in your posting. Correct it below and re-submit. The necessary fields are: Name, Subject and Message.<p><hr size=7 width=75%><p>\n";
}
}
}