\n$header"; } $header = str_replace("\n","
",$header); if ($return[1]){ $body = $return[1]; }else{ $body = ""; } if ($c === 2){ if ($body){ $return = $body; }else{ $return = $header; } } if ($c === 1){ $return = $header; } if ($c === 3){ $return = "$header$body"; } if ($f){ if (preg_match("/Location\:/","$header")){ $url = @explode("Location: ",$header); $url = $url[1]; $url = @explode("\r",$url); $url = $url[0]; $oldheader = str_replace("\r\n\r\n","",$header); $l = "Location:"; $oldheader = str_replace("Location:",$l,$oldheader); return open_page($url,$f,$c,$r,$a,$cf,$pd); }else{ return $return; } }else{ return $return; } } print "

Loading...

\n"; flush(); ///////////// ////Usage//// ///////////// $url = "http://zip4.usps.com/zip4/zcl_0_results.jsp"; $f = 1; $c = 2;//1 for header, 2 for body, 3 for both $r = NULL; $a = NULL; $cf = NULL; $pd = NULL; $pd = "visited=1&pagenumber=0&firmname=&address2=".urlencode($_GET['address'])."&address1=&city=".urlencode($_GET['city'])."&state=".urlencode($_GET['state'])."&urbanization=&zip5=&submit=".urlencode("Find ZIP Code"); $page = open_page($url,$f,$c,$r,$a,$cf,$pd); // print out the returned page with base tag added to properly get images,css,etc #echo "\n"; #print $page; // Trim down the page until just the address is left $page = strstr($page,"Full Address in Standard Format"); $page = substr($page,0,strpos($page,"Mailing Industry Information")); $page = strstr($page,"\n\t\t"); $page = substr($page,3,strpos($page,"\t\t","",$page); $page = str_replace("\t\t","",$page); $page = str_replace(" ","\n",$page); $addrarray = explode("\n",$page); $ziparray = explode("-",$addrarray[5]); // Print out info. print "

"; print "Address given:
\n"; print htmlentities($_GET['address'])."
\n"; print htmlentities($_GET['city'])." ".htmlentities($_GET['state'])." ".htmlentities($_GET['zip'])."

\n"; print "Address:
\n"; print htmlentities($addrarray[0])."
\n"; print htmlentities($addrarray[2])." ".htmlentities($addrarray[3])." ".htmlentities($ziparray[0])."-".htmlentities($ziparray[1])."
\n"; print "

"; ?>