1 (edited by Justice 2011-10-15 04:46)

Topic: [release] IP Geolocation

This extension will display the geographic location of users on their profile to administrators. It determines the geographic location based on the users IP address, using the free geoPlugin web service.

Changelog

  • ver 1.3 "maxtestedon" updated to 1.3.6 (no other changes).

  • ver 1.2 "Geolocate" link to fetch geolocation of users who registered before the extension was installed.

  • ver 1.1 Uses cURL if available, and includes some other small improvements.

  • ver 1.0 Initial release

Download

Screenshots
Profile of user before geolocation has been fetched
http://dl.dropbox.com/u/6516117/punbb/screenshot1.png

Profile of user after geolocating
http://dl.dropbox.com/u/6516117/punbb/screenshot2.png

Re: [release] IP Geolocation

Good Extension, This was what I needed cool

Re: [release] IP Geolocation

Thx for ext. - I'm running on 1.3.2 / 1.3.4 and get this.... when registering new user

Warning: file_get_contents() [function.file-get-contents.php]: URL file-access is disabled in the server configuration in /home/..../register.php(225) : eval()'d code on line 29

Warning: file_get_contents(http://www.geoplugin.net/php.gp?ip=2xx.1xx.1xx.xx) [function.file-get-contents.php]: failed to open stream: no suitable wrapper could be found in /home/...../register.php(225) : eval()'d code on line 29

(1.3.2 above)

same error in 1.3.4 but on line 24 not 29 .....
(xx in ip added by me)

EDIT: guess my host has this PHP function called Http wrapper disabled... any workaround?

4 (edited by Justice 2009-11-04 19:22)

Re: [release] IP Geolocation

KeyDog wrote:

EDIT: guess my host has this PHP function called Http wrapper disabled... any workaround?

Can you check if your host allows cURL? I can make the extension check for either file_get_contents support or cURL support, and use whichever is available.

You can test for both of these functions like this:

if ( function_exists('curl_init')) {
   echo('cURL supported');
} else if ( ini_get('allow_url_fopen')) {
   echo('file_get_contents supported');
} else {
   echo('Neither cURL or file_get_contents supported. Sorry.');
}

Re: [release] IP Geolocation

Hey
I tried what that code you suggested and turns out my host has cURL (cURL supported)

so; do I need to change this:
<hook id="rg_register_pre_add_user"><![CDATA[
            $geo_location = unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip='.$user_info['registration_ip']));

to this ?

<hook id="rg_register_pre_add_user"><![CDATA[
            $geo_location = unserialize(cURL('http://www.geoplugin.net/php.gp?ip='.$user_info['registration_ip']));


thx again

6 (edited by Justice 2009-11-05 19:56)

Re: [release] IP Geolocation

No, the code for using cURL will not be as simple as a function call. I think I'm actually going to update the extension to use the GeoPlugin PHP class, which will handle the cURL and file_get_contents() checking, and should simplify the extension code a bit.

In the meantime, if you simply want to get the current extension working with cURL, you can do the following:

Change

$geo_location = unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip='.$user_info['registration_ip']));

to

$geoplugin_host = 'http://www.geoplugin.net/php.gp?ip='.$user_info['registration_ip'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $geoplugin_host);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$geo_response = curl_exec($ch);
curl_close ($ch);

$geo_location = unserialize($geo_response);

Re: [release] IP Geolocation

Thx that worked, no warnings on registration any more;
however when I'm on the new users profile (as admin)
I get this on bottom of page:

cURL supported Notice: Undefined variable: cur_post in /.../profile.php(1588) : eval()'d code on line 10

Don't worry about it too much if you're working on a improved release anyway...

Re: [release] IP Geolocation

Actually, PunBB has the get_remote_file(...) function. It uses curl or sockets if enabled.

You may use this function in your extensions.

Re: [release] IP Geolocation

Parpalak wrote:

Actually, PunBB has the get_remote_file(...) function. It uses curl or sockets if enabled.

You may use this function in your extensions.

Wow, thanks Parpalak, that is great to know. I was about to write a fsockopen() implementation to fall back on, but you just saved me the trouble!

Re: [release] IP Geolocation

Ok, version 1.1 is available (see my original post above for download). This version uses PunBB's built in get_remote_file() function as Parpalak suggested. Suggestions and other feedback welcome.

11 (edited by Justice 2009-11-11 04:40)

Re: [release] IP Geolocation

Version 1.2 available. This version displays a "Geolocate" link which allows you to populate the geolocation for preexisting users.

Re: [release] IP Geolocation

excellent work works very well the new version  big_smile

13

Re: [release] IP Geolocation

Works like a charm now for me. Thx.

Re: [release] IP Geolocation

I am un big probem where IP Geo in 1.2 and PunBB in 1.3.2 :

Notice: unserialize() [function.unserialize]: Argument is not a string in /mnt/126/free.fr/0/2/7iemecie/forum/include/common.php(129) : eval()'d code on line 135

Thank for you respond

Re: [release] IP Geolocation

Up !

16 (edited by Justice 2010-07-01 20:37)

Re: [release] IP Geolocation

cirle78 wrote:

I am un big probem where IP Geo in 1.2 and PunBB in 1.3.2 :

Notice: unserialize() [function.unserialize]: Argument is not a string in /mnt/126/free.fr/0/2/7iemecie/forum/include/common.php(129) : eval()'d code on line 135

I guess this could happen if your server is unable to retrieve the geolocation data from geoplugin.net. You might need to troubleshoot by doing some tests with the punbb get_remote_file() function, perhaps adjusting the timeout (the plugin uses a timeout of 8 seconds, which should be more than enough).

Example:

$geoplugin_response = get_remote_file('http://www.geoplugin.net/php.gp',8);
echo($geoplugin_response);

That should shed some light on what is going on with your server.

Re: [release] IP Geolocation

Thank for your Aids.

My provider of my Forum has closed the external acces : get_remote_file

i write him to charge 'http://www.geoplugin.net/php.gp' in WhileList and it's good now.

18

Re: [release] IP Geolocation

@Justice
Any possibility you can take a look at integrating your geolocation with pun_approval on registration process?
http://punbb.informer.com/forums/topic/ … napproval/

19

Re: [release] IP Geolocation

@Justice (or any other ext developer)

Would be cool if this extension could be adapted/updated for 1.4.x

At the moment it seems to cause problems on 1.4.1 (as per this report)

Re: [release] IP Geolocation

Nice extension. Thank you for your continue support to community. However, on other websites I am using the API from ipgp.net and I find it more accurate than the one you are using. Is there any change so you can add it as an alternative way in your plugin ?

Re: [release] IP Geolocation

KeyDog wrote:

@Justice (or any other ext developer)

Would be cool if this extension could be adapted/updated for 1.4.x

At the moment it seems to cause problems on 1.4.1 (as per this report)

KeyDog,

The extension has been updated for 1.4, and can be found here. Please let me know if you have any problems with it.