Many shared hosting environments will be configured like this… Especially as by default PHP 5 is shipping with allow_url_fopen set to off. This means this script will fail - through no fault of its own, just security measures many hosts would insist upon.
Many hosts will allow you to override this setting via a php.ini file, or a .htaccess file, or even by setting this value within PHP - 1and1 will not (surprise!).
Therefore, i came across this nice little function which i have used in the following way to make this all work…
1. add this new function to the bottom of mod.geofinder.php
REPLACE
return $query; }
} // END CLASS
?>
WITH
return $query; }
function curl_get_contents($url, $timeout=60) { $timeout = abs((int)$timeout); $curl = curl_init(); $opts = array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => $timeout ); curl_setopt_array($curl, $opts); $result = curl_exec($curl); if($result === false) { user_error(curl_error($curl)); return false; } $response = curl_getinfo($curl, CURLINFO_HTTP_CODE); if($response != 200) { user_error("Received HTTP response of $response."); } return $result; }
} // END CLASS
?>
THEN… at around line 765 of the mod.geofinder.php file:
REPLACE
$xml = simplexml_load_file($request_url) or FALSE;
WITH
// $xml = simplexml_load_file($request_url) or FALSE; $mygeostring = $this->curl_get_contents($request_url); $xml = simplexml_load_string($mygeostring) or FALSE;
And… well it worked for me… hopefully might save someone else some time, N
|