I have no idea where to begin - my web host does not allow fopen, but my geocoding script below uses it. So, since no fopen - no lat & long - so no google maps on my pages.
Can anyone redo this in curl?
http://paste.ly/4HU (since the code is breaking up below)
$mapaddress=str_replace(' ', '%20', $_REQUEST['street_num'] . ' ' . $_REQUEST['address2'] . ', ' . $loccity . ', ' . $ststate . ', ' . $_REQUEST['postcode'] . ', ' . $cncount);
$key=$er_mapapi;
$file = "http://maps.google.com/maps/geo?q=$mapaddress&output=xml&key=$key";
$longitude='';
$latitude='';
if ($fp = fopen($file, "r")) {
$coord='<coordinates>';
$coordlen=strlen($coord);
$r = "";
while ($data = fread($fp, 32768)) {
$r .= $data;
} do {
$foundit=stristr($r,$coord);
$startpos=strpos($r,$coord);
if (strlen($foundit) > 0) {
$mypos=strpos($foundit,"</coordinates>");
$mycoord=trim(substr($foundit,$coordlen,$mypos-$coordlen));
list($longitude, $latitude) = split(',', $mycoord);
$r=substr($r,$startpos+10);
}
}
while (strlen($foundit) > 0);
fclose($fp);
}
if ($latitude != '') $row->declat = $latitude; if ($longitude != '') $row->declong = $longitude;