MyBB Community Forums

Full Version: Code question - Usermap plugin
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Attempting to enable to Usermap plugin on my forum, I'm getting the "Warning [2] file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration - Line: 182 - File: usermap.php" which from my research is telling me that something is disabled on the host's end and I'm going to have to go through heck to get it changed, if it's even possible.

I found a page that talks about a work around on this problem.

http://www.computertechtalk.com/showthread.php?tid=52

I know 0% about programming - nothing. Can someone that understands programming take a quick look at this and tell me if it is something not wise to implement. By looking at the code, I can't tell exactly what is being altered or what actions are taking place. Thanks in advance.

Can you link me the Usermap plugin you are using there ?
This is the plugin that I'm talking about...

http://mods.mybb.com/view/usermap

I hope this is what you were asking for Smile
Did you added your API Key for Google Map in Your API-key for Google Maps. option?
(2011-04-23, 03:14 AM)Yaldaram Wrote: [ -> ]Did you added your API Key for Google Map in Your API-key for Google Maps. option?

Yes. I simply followed the instructions. The API key was generated today and entered immediately. It has been active for about 4 hours and I still get the error. If I remove the API key from the field in the configuration, the board tells me that I need an API key. If I enter the API key, I get the error.

I had this problem about a year ago and just gave up on it because I had too many other things going on at the time. Now that I have the time to mess with it, I decided to do a little more research. The problem described in the link that I posted in my first message is identical to the problem that I'm having. Also, searching for errors that are similar but not exactly like the errors I am getting reveal that something on the host's server PHP config is disabled.

I want someone to tell me what the change in code the link is suggesting does. I just want to make sure it's not going to do something malicious. I know that many would just implement the change and not worry about it, but I don't want to run code when I don't know what it does. If the suggestion was from these forums, I wouldn't hesitate. With it coming from another site, I just wanted to run it by the people here to see what the comments would be.

Open usermap.php file (Present in your forum's root folder) and find the following line;
$lookup_file = file_get_contents("http://maps.google.com/maps/geo?q=".urlencode($mybb->input['adress'])."&output=xml&key=".$mybb->settings['usermap_apikey']);
and Change it to;
$lookup_file = @file_get_contents("http://maps.google.com/maps/geo?q=".urlencode($mybb->input['adress'])."&output=xml&key=".$mybb->settings['usermap_apikey']);

Does it suppress the error ?
Hey Yaldaram,

Thank you for your attention. The original error is now supressed, but now I get a message that says "Coordinates not found". It's apparently still not able to access Google maps but the original error message is gone.
It appears that your host doesn't allow URLs to be passed to file_get_contents. This is advisable in most situations because you are at the mercy of the other site (ex: what if they get hacked and the hacker changes the content?).

I found a tutorial which explains different ways of loading external content. I would suggest using curl if it's installed on your host.
(2011-04-23, 04:08 PM)laie_techie Wrote: [ -> ]It appears that your host doesn't allow URLs to be passed to file_get_contents. This is advisable in most situations because you are at the mercy of the other site (ex: what if they get hacked and the hacker changes the content?).

I found a tutorial which explains different ways of loading external content. I would suggest using curl if it's installed on your host.

Thanks for the explanation. The code that I was asking everyone to review before I implemented it is written in cURL. I just didn't understand enough about what it was doing before I decided to use it. I suppose I'll just activate the section of code and see what happens. I'm sure it's not going to be the end of the world but even if it was, I have my whole site backed up anyway LOL.



it's same with my problem... so what should I do? I just contact my host for this problem , but they explained to me that my host allowed file_get_content

sorry for my english...Smile