Dreamhost Gotcha
I have moved a lot of my sites over to Dreamhost and have been pretty satisfied so far. The control panel is very good and you can do some neat one-click installs of popular open-source packages like WordPress.
Today I had my first PHP Gotcha on Dreamhost.
I am working on a site that uses Google Maps and I decided to try out Phoogle Maps, a PHP script that integrates Google Maps with your PHP application and also does GeoCoding based on an address. I tested the script on my dev server and everything worked great. I then started working on the rest of the app.
After uploading the scripts to Dreamhost I got an error that file_get_contents() was not allowed. After looking into it I found out that Dreamhost has disabled file_get_contents() for security reasons. Phoogle calls the Yahoo Geocoding API (since Google doesn’t provide one) and used the file_get_contents() method of doing the REST call to Yahoo. I checked out Yahoo’s developer site and found out that they also support curl() but after banging my head against the wall trying to retrofit Phoogle to use that method I looked elsewhere.
First I tried using XML-RPC to call the geocoder.us database but that was extremely slow. Then I stumbled upon ontok.com which provides a geocoding API. I grabbed their example code using SOAP and it was pretty fast and I then proceeded to hack Phroogle to call ontok.com for it’s geocoding.
So, I’m still on Dreamhost until something else doesn’t work.
![]()
Does your website need an extreme makeover? My advice is "keep it simple". Get an affordable facelift and use WordPress to free you up to manage your own content.
My name is Rick Tuttle. I'm a web developer living in Miami Beach, Florida. After working in the corporate IT industry for over 15 years I ventured out to start my own little web shop, Papasoft in 2005.
Comments (2)
Did you ever get a solution? I’m attempting the same thing on Dreamhost (with WordPress and Phoogle) and was wondering if you solved the problem…
As far as I know there is no solution using Phoogle without modification since it uses file_get_contents (which Dreamhost does not allow).
I was able to use ontok.com and nusoap.php as described at http://www.ontok.com/wiki/index.php/Geocode#PHP.
I modified the addAddress() function in Phoogle as follows (make sure to get nusoap.php and include it in the file). This replaces the same code that used file_get_contents:
$server = "www.ontok.com"; // subscribers are emailed a private server with faster response times $key = ""; // free users do not need key (limit 10 addresses), subscribers w/key (limit 200 addresses) $q = array($address); $soapclient = new soapclient("http://$server/geocode/soap"); $result = $soapclient->call("geocode", array('key'=> $key, 'q'=> $q), "", ""); $pointer = count($this->validPoints); $this->validPoints[$pointer]['lat']= $result[0]['lat']; $this->validPoints[$pointer]['long']= $result[0]['long']; $this->validPoints[$pointer]['passedAddress'] = $address; $this->validPoints[$pointer]['htmlMessage'] = $htmlMessage;