#! /usr/bin/perl

$form= <<EOF;
<CENTER>
<FORM METHOD=POST ACTION="/cgi-bin/pops.cgi">
Enter phone:&nbsp;
<SELECT NAME=ac>
<OPTION>408
<OPTION>510
<OPTION>650
</SELECT>&nbsp;-&nbsp;
<INPUT TYPE=test SIZE=3 MAXLENGTH=3 NAME=prefix>&nbsp;-&nbsp;####&nbsp;
<INPUT TYPE=submit VALUE="Look-Up">
</FORM>
</CENTER>
EOF

if ($ENV{"REQUEST_METHOD"} eq "GET") {
	print <<EOF;
Content-type: text/html

$form
EOF
	exit(0);
}

grep({
	(y/+/ /),
	(s/%([0-9a-fA-F]{2})/pack("c",hex($1))/ge),
	(s/^ac=([0-9]{3})$//		and $ac=$1) or
	(s/^prefix=([0-9]{3}|aic)$//	and $prefix=$1)
							},split('&',<STDIN>));

$source="$ac-$prefix";

$found=0;
open(FILE,"pops");
while (<FILE>) {
	chomp;
	/^$/ and next;
	if (/^([A-Za-z].*)$/) {
	  $found and last;
	  $desc=$1;
	}
	($_ eq $source) and $found=1;
	/^[0-9]{3}-[0-9]{3}-[0-9]{4}.*$/ and ($found==1) and s/^000-000-0000\s*//, push(@numbers,"$_<BR>");
}
close(FILE);

print <<EOF;
Content-type: text/html

<TITLE>News &amp; Announcements</TITLE>
<BODY BGCOLOR="#FFFFFF" TEXT="#222222">
EOF
if (!$found) {

### Numbers Not Found ###

	print `cat /var/www/stdhdr.html`;
	print <<EOF;

<H2>Local POPs</H2>
<P>
<B>Note</B>: All of our current customers do have a local access number to use after the switch.  If you notice that your phone number is not a local call to any of the new POPs please call our office A.S.A.P.
<P>
We currently do not have a point of presence (POP) in your area.  Before you use any dial-up number, we recommend that you contact your local phone service provider, and verify if the number in question has a toll charge.  To reach your local operator, just dial &quot;0&quot;, give them the telephone number that you are dialing from and the number that you are dialing to, and the operator will verify whether or not the number is a toll-charge call for you.  It only takes a few moments, and can save you hundreds of dollars in toll-call charges.  It is the customer's sole responsibility to verify this information.  Access Internet is not responsible for any charges you incur.
<P>
Please check back with us as we plan in the near future to expand our POPs to cover the entire Bay area from Santa Rosa to Livermore.  You may still sign-up with us but using any of our dial-up numbers would result in <A HREF="/system/local_charges.html">toll charges</A>.
<P>
The Dial-Up Numbers for the POPs will be:
<P>
EOF
	print `cat /var/www/system/pops-list.html`;
	print <<EOF;
<P>
$form
<P>
<BR>
EOF
	print `cat /var/www/stdftr.html`;
	exit(0);
}

### Numbers Found ###

	print `cat /var/www/stdhdr.html`;
print <<EOF;

<H2>Local POPs</H2>
<P>
The POPs listed below are local to you.
<P>
<TABLE>
<TR><TD ALIGN="right" VALIGN="top" BGCOLOR="#C6D6C6">Calling Area:</TD><TD><B>$desc</B></TD></TR>
<TR><TD ALIGN="right" VALIGN="top" BGCOLOR="#C6D6C6">Prefix:</TD><TD><B>$prefix</B></TD></TR>
<TR><TD ALIGN="right" VALIGN="top" BGCOLOR="#C6D6C6" VALIGN="TOP">POPs:</TD><TD>@numbers</TD></TR>
</TABLE>
$form
<P>
<BR>
<B>Note</B>: Before you use any dial-up number, we recommend that you contact your local phone service provider, and verify if the number in question has a toll charge.  To reach your local operator, just dial &quot;0&quot;, give them the telephone number that you are dialing from and the number that you are dialing to, and the operator will verify whether or not the number is a toll-charge call for you.  It only takes a few moments, and can save you hundreds of dollars in toll-call charges.  It is the customer's sole responsibility to verify this information.  Access Internet is not responsible for any charges you incur.
<P>
EOF
	print `cat /var/www/stdftr.html`;
