asterisk.cgi

 


#!/usr/bin/perl

if ($ENV{'REQUEST_METHOD'} eq 'GET')
{
        @pairs = split(/&/, $ENV{'QUERY_STRING'});
}
elsif ($ENV{'REQUEST_METHOD'} eq 'POST')
{
    read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
    @pairs = split(/&/, $buffer);

    if ($ENV{'QUERY_STRING'})
    {
        @getpairs =split(/&/, $ENV{'QUERY_STRING'});
        push(@pairs,@getpairs);
    }
}
else
{
    print "Content-type: text/html\n\n";
    print "<P>Use Post or Get";
}

print "Content-type: text/html\n\n";

$phone = $formdata{'phone'};

if ($phone =~ /^((\(\d\d\d\))? *\d\d\d-\d\d\d\d,? *)+$/) {
	print "You entered the phone number(S) <B>$phone</B>";
} else {
	print "Please enter the phone number(s) in the form <P>(123) 456-7899<P>(The area code is optional.)";
}