#!/usr/bin/perl
# req-quote.cgi - handles online service requests
$0="dsl-req2.cgi";
# These entries define the fairly-constants
# $mailprog = the name of the mail program
# $recipient = the email address to send the output to
$mailprog = '/usr/sbin/sendmail';
$recipient = 'info@accesscom.com';
# This line prepares the server to parse HTML style output
print "Content-type: text/html\n\n";
print "
";
print join('',`cat $ENV{'DOCUMENT_ROOT'}/stdhdr.html`)."";
# Get input from the form
if($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
} else {
$buffer=$ENV{'QUERY_STRING'};
}
$buffer =~ s/\000//g;
# Split the buffer into name-value pairs
@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;
$FORM{$name} = $value;
}
##################################################################
if($FORM{'your_name'} eq '') {
$button="Request call back";
$button="Submit Order" if($FORM{'form'} eq 'Order');
print <Products & Services | $FORM{Service} DSL - $FORM{form} form
";
exit;
}
##################################################################
##################################################################
##################################################################
##################################################################
##################################################################
##################################################################
# Check that required fields are filled in
# Requires name plus phone, fax or e-mail
&blank_response unless length($FORM{'your_name'})>1;
&blank_response unless length($FORM{'phone_number'})>1;
# &blank_response unless length($FORM{'email_address'})>1;
foreach("FRM_ADDR", "FRM_CITY", "FRM_STATE", "FRM_ZIP",
"FRM_NPA", "FRM_NXX", "FRM_XXXX") {
&blank_response if($FORM{$_} eq '');
$FRM{$_}=$FORM{$_};
$FRM{$_}=~s/([^0-9A-Za-z])/sprintf("%%%02x",ord($1))/ge;
}
foreach(keys %FORM) {
next if(!m/DSL$/);
$FORM{$_}=~s/,/, /;
$dsl.=sprintf("%21.21s %s\n",$_."---------------------", $FORM{$_});
}
chomp $dsl;
# Send mail to $recipient
# The first three lines and the last line of this section are important
# Everything else is customized to the particular form
# and how you want the message to look
open (MAIL, "|$mailprog $recipient") || die "Can't open $mailprog!\n";
print MAIL "Reply-to: $FORM{'your_name'} <$FORM{'email_address'}>\n";
print MAIL "To: $recipient\n";
print MAIL "Subject: $FORM{Service} DSL $FORM{form}\n";
print MAIL "X-DSL: \n";
print MAIL "--------------------------------------------------------------------\n";
print MAIL "Technical info:\n";
print MAIL "Server protocol: $ENV{'SERVER_PROTOCOL'}\n";
print MAIL "Host browsed from: $ENV{'REMOTE_HOST'}\n";
print MAIL "IP browsed from: $ENV{'REMOTE_ADDR'}\n";
print MAIL "--------------------------------------------------------------------\n";
print MAIL "Contact Information:\n";
print MAIL "Customer name-------- $FORM{'your_name'}\n" if($FORM{'your_name'} ne '');
print MAIL "Email address-------- $FORM{'email_address'}\n" if($FORM{'email_address'} ne '');
print MAIL "Best phone number---- $FORM{'phone_number'}\n" if($FORM{'phone_number'} ne '');
print MAIL "Best time------------ $FORM{'time'}\n" if($FORM{'time'} ne '');
print MAIL "--------------------------------------------------------------------\n";
print MAIL "DSL Location Information:\n";
print MAIL "Requested Speed------ $FORM{'speed'}\n" if($FORM{'speed'} ne '');
print MAIL "Street Address------- $FORM{'FRM_ADDR'}\n" if($FORM{'FRM_ADDR'} ne '');
print MAIL "City----------------- $FORM{'FRM_CITY'}\n" if($FORM{'FRM_CITY'} ne '');
print MAIL "State---------------- $FORM{'FRM_STATE'}\n" if($FORM{'FRM_STATE'} ne '');
print MAIL "Zip------------------ $FORM{'FRM_ZIP'}\n" if($FORM{'FRM_ZIP'} ne '');
print MAIL "Phone---------------- ($FORM{'FRM_NPA'}) $FORM{'FRM_NXX'} - $FORM{'FRM_XXXX'}\n" if($FORM{'FRM_NPA'} ne '');
print MAIL "--------------------------------------------------------------------\n";
print MAIL "$FORM{Service} DSL Available speeds:\n";
print MAIL "$dsl\n";
print MAIL "--------------------------------------------------------------------\n";
if($FORM{'extras'} ne '') {
print MAIL "Extra Information:\n";
foreach(split("\n", $FORM{'extras'})) {
s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
m/^([^:]*): (.*)$/;
printf MAIL "%21.21s %s\n", $1."---------------------", $2;
}
print MAIL "--------------------------------------------------------------------\n";
}
close (MAIL);
print "Products & Services | Thank you";
# Assuming the user provided the necessary info,
# put up a web page to acknowledge receipt of request
# Remember to put a literal escape (backslash) in front of all quotes in the HTML
print "Your DSL order has been submitted
" if($FORM{'form'} eq 'Order');
print "Your DSL request has been submitted
" if($FORM{'form'} eq 'Call Back');
print "";
print "Thank you for choosing AIC for your internet service needs. A DSL representative will follow up with you to obtain aditional information about your installation." if($FORM{'form'} eq 'Order');
print "Thank you for choosing AIC for your internet service needs. A DSL representative will follow up with you to further discuss your needs." if($FORM{'form'} eq 'Call Back');
print "
";
print "Use the icons below to go on to any portion of the AIC Web Site or go back to the AIC Home Page";
print "
";
print join('',`cat $ENV{'DOCUMENT_ROOT'}/company/form.html`);
print "
";
print join('',`cat $ENV{'DOCUMENT_ROOT'}/stdftr.html`);
print "