IP-based determination of a visitor's Country

Contrib type: 
Module
Status: 
Complete and working
Moderation: 
Limited approval
Latest version: 
1.05

Downloads


Compatibility: 
Ubercart 1.x

This module uses a visitor's IP address to identify the geographical location (country) of the user. The module makes this determination and stores the result as an ISO 3166 country code in the Drupal $user object, but otherwise has no effect on the operation of your site. The intent is simply to provide the information for use by other modules. Anonymous users are not identified by country.

A README.txt is included, containing detailed installation instructions and a discussion of what the module does and how it does it. Please consult the README.txt before posting questions/problems.


PreviewAttachmentSize
ip2country-1.05.tar.gz8.82 KB
himagarwal's picture
Offline
Joined: 06/24/2008
Juice: 302
Fatal error: Allowed memory
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 527017 bytes) in /home/himag/public_html/drupal/sites/all/modules/ip2country/uc_ip2country.inc on line 137

When I try to enable this module I get above error message and module doesn't get enabled. Is there solution for this problem?

TR
TR's picture
Offline
Bug FinderFAQ ModeratorGetting busy with the Ubercode.
Joined: 11/05/2007
Juice: 3300
Re: Fatal error: Allowed memory

That error has nothing to do with this module. You need to increase your server memory to run all the modules you have installed. How to do that is described in two FAQs and at least a dozen posts on this site, as well as countless posts on drupal.org.

<tr>.
himagarwal's picture
Offline
Joined: 06/24/2008
Juice: 302
Thanks. Memory limit in

Worked at memroy_limit = 64M. Thanks.

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15459
Re: IP-based determination of a visitor's Country

Awesome module, TR. I bet this one would be a good candidate for general Drupal usage... do you know of any similar projects already posted?

himagarwal's picture
Offline
Joined: 06/24/2008
Juice: 302
Re: Re: IP-based determination of a visitor's Country

The module was installed correctly and database tables were created after I increased the memory_limit to 64M. But now, when I click on update button it shows "Working......." with circular image rotating. I tried it several times and left it for an hour but nothing happens.

Does anyone had similar problem with it?

TR
TR's picture
Offline
Bug FinderFAQ ModeratorGetting busy with the Ubercode.
Joined: 11/05/2007
Juice: 3300
Re: Re: Re: IP-based determination of a visitor's Country

Does the automatic update run, or is it just the Update button which fails? Is there anything in the uc_ip2country table?

Also, do you have the devel module enabled? Devel interferes with AJAX calls, so you will have to turn it off for the button to work properly.

<tr>.
himagarwal's picture
Offline
Joined: 06/24/2008
Juice: 302
Re: Re: Re: Re: IP-based determination of a visitor's Country

I'm attaching uc_1p2country table which was created when I installed IP based module. I'm not using devel module.

I set the "database update frequency" to 1 day and ran cron manually which I think worked as the "update date" beside "Update button" changed. But when I click on "update" button manually the same "Working....." with a rotating circle comes up which never ends.

Should I need to bother about this, since I think I can manually do this and even poormanscron module will do the job automatically.

AttachmentSize
up_ic2country_tables.gif 42.45 KB
TR
TR's picture
Offline
Bug FinderFAQ ModeratorGetting busy with the Ubercode.
Joined: 11/05/2007
Juice: 3300
Re: Re: Re: Re: Re: IP-based determination of a visitor's Countr

Your attachment shows the table is the right size, which means it was properly built when cron ran manually. (There is no need to update the table frequently - I made the default 1 week.) You should check for JavaScript errors on that page that might be preventing the Update button from operating on your site.

<tr>.
pjriot's picture
Offline
Joined: 12/14/2008
Juice: 41
Blank confirm page?

Hi TR, just giving this a whirl now. When I attempt to enable the module from a siteground hosted site, I'm getting sent to a blank page (/admin/build/modules/list/confirm)

Any idea why? (server timeout or something?)

TR
TR's picture
Offline
Bug FinderFAQ ModeratorGetting busy with the Ubercode.
Joined: 11/05/2007
Juice: 3300
Re: Blank confirm page?

A blank screen is almost certainly a PHP memory issue. See the Ubercart FAQs for solutions.

<tr>.
ragavendra_bn's picture
Offline
Joined: 01/10/2009
Juice: 68
Re: IP-based determination of a visitor's Country

D6 Module needed

TR
TR's picture
Offline
Bug FinderFAQ ModeratorGetting busy with the Ubercode.
Joined: 11/05/2007
Juice: 3300
Moved to Drupal.org

This module is now hosted on Drupal.org at http://drupal.org/project/ip2country

Please post any issues or support requests on the above project page, not here.

<tr>.
CpILL's picture
Offline
Early adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/08/2007
Juice: 550
Re: Moved to Drupal.org

Umm, there is nothing to download there. No releases. Are the CVS details?

Uberdevelopment www.tsd.net.au/blog

TR
TR's picture
Offline
Bug FinderFAQ ModeratorGetting busy with the Ubercode.
Joined: 11/05/2007
Juice: 3300
Re: Re: Moved to Drupal.org

It's in CVS, currently the same code as you can get from the top of this thread. Just no release yet on the drupal.org page because I haven't set up the tags and branches yet.

Direct link to the CVS is http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/ip2country/, or you can just use the tarball above.

<tr>.
CpILL's picture
Offline
Early adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/08/2007
Juice: 550
Re: Re: Re: Moved to Drupal.org

I've just converted the module to Drupal 6 with the 'deadwood' & 'coder' modules helping me. Seems to be stable but I haven't done any testing yet. See the attachment. Perhaps you want to have a look and make it a release? I thought if you move all the common code to the .inc file then you can maintain D5 & D6 versions fairly easily, no? (or just dump D5 support?)

Anyway, tomorrow I'm going to start working on a module which uses it to redirection to certain URLs based on users country. This might be handy for people who want to block certain content from foreigners, I'm going to use it to setup multiple shops, each with its own domain and do the initial redirect when the user first arrives.

Thanks for contributing this by the way Eye-wink

AttachmentSize
ip2country.zip 13.03 KB

Uberdevelopment www.tsd.net.au/blog