#!/usr/bin/perl # req-quote.cgi - handles online service requests $0=~s/.*\///; $next="dsl-req2.cgi"; # 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{'Service'} ne "" and !exists($PRICE{$FORM{'Service'}})) { # print <Products & Services | DSL - Invalid Service #We do not currently have pricing for that type of service.

#EOF # print join('',`cat $ENV{'DOCUMENT_ROOT'}/stdftr.html`); # print ""; # exit; #} if(scalar keys %FORM < 2) { print <Products & Services | $FORM{Service} DSL - PreQual Service

$FORM{Service} DSL Pre-Qualification Form:

To determine if your location qualifies for $FORM{Service} DSL service and if so what levels of that service, please complete the following web-based form.

EOF if($FORM{'Service'} eq '') { print < EOF } else { print ""; } print <
Phone: () -
Street Address:
City:
State:
Zip:
Business Residential

Note: Exact information is needed. If the phone number does not correspond to the street address provided, you will not get the proper results.

EOF print join('',`cat $ENV{'DOCUMENT_ROOT'}/stdftr.html`); print ""; exit; } # Check that required fields are filled in 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("FRM_NPA", "FRM_NXX", "FRM_XXXX") { &blank_response if(length($FORM{$_}) != length($_)-4); } $dsl=getDSL($FRM{"FRM_NPA"}, $FRM{"FRM_NXX"}, $FRM{"FRM_XXXX"}, $FRM{"FRM_ADDR"}, $FRM{"FRM_CITY"}, $FRM{"FRM_STATE"}, $FRM{"FRM_ZIP"}); print < EOF if($dsl==0) { print <Products & Services | DSL - Service Unavailable Based on your location, $FORM{Service} DSL is currently not available, we expect to have service to this area in the near future as the coverage for DSL grows. Please feel free to check back with us on a monthly basis.

EOF print <here.

EOF } else { my $serv=lc $FORM{'Service'}; my $table; print <Products & Services | DSL - $FORM{Service} Service Available Based on your location you qualify for our $serv service:
EOF foreach(sort keys %DSL) { my $type=$_; foreach(sort {$a<=>$b} @{$DSL{$_}}) { $table.="$type$_ Kbps"; push(@options, "$type $_ Kbps"); $FORM{$type}.="$_,"; } $FORM{$type}=~s/,$//; } print < $table
TypeSpeed

EOF $accts="$FORM{Service} DSL"; if($#options >= 0) { $accts=""; } print <
To sign up now for $accts service
To have a DSL representative phone you to further discuss your needs.
EOF $extras=''; foreach(sort keys %EXTRA) { $extras.="$_: $EXTRA{$_}\n"; } $extras=~s/([^0-9A-Za-z])/sprintf("%%%02x",ord($1))/ge; print "" if($extras ne ''); foreach(keys %FORM) { print ""; } print ""; } print join('',`cat $ENV{'DOCUMENT_ROOT'}/stdftr.html`); print ""; exit; # Insufficient Info Response # Put up a web page asking the user to complete the required fields. # Remember to put a literal escape (backslash) in front of all quotes in the HTML sub blank_response { print "Products & Services | Insufficient Information"; print "

Sorry, your DSL pre-qualification form was not properly completed.

"; print "In order to process your request, we need all the DSL location information.

"; print "Please use the \"Back\" command in your browser to return to the form and supply the necessary information.

"; print "If you wish to abandon the form, simply use the icons below to go on to any portion of the AIC Web Site or go back to the AIC Home Page

"; print join('',`cat $ENV{'DOCUMENT_ROOT'}/stdftr.html`); print ""; exit; } use Socket; sub getDSL { # adr1, city, state, zip, npa, nxx, lastfour # socket(SOCKET, PF_INET, SOCK_STREAM, getprotobyname('tcp')); # connect(SOCKET, sockaddr_in(80, inet_aton('dsl.netrail.net'))); # select(SOCKET); $|=1; select(STDOUT); # print SOCKET <) { # $cookie=$1 if(m/^Set-Cookie: (.*);/); # } # close(SOCKET); # s/([^A-Za-z0-9])/sprintf("%%%02x",ord($1)/ge foreach(@_); $postdata=sprintf(<) { $prov=$1 if(m/>(\S+) Availability([0-9]+ feet)//) { next if($prov eq 'NorthPoint'); next if($FORM{'Service'} eq 'Residential' and $1 eq 'SDSL'); next if($FORM{'Service'} eq 'Business' and $1 eq 'ADSL'); if(ref($DSL{$1}) ne 'ARRAY') { $DSL{$1}=[ $2 ]; } else { push(@{$DSL{$1}},$2); } } } close(SOCKET); return(keys %DSL); }