Active
Project:
ipAuthenticator
Version:
5.x-1.x-dev
Component:
Miscellaneous
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
8 May 2008 at 18:54 UTC
Updated:
12 May 2008 at 17:38 UTC
Jump to comment: Most recent file
I need a way to pull in data from an external source (probably use htp://hostip.info) in order to assign country specific IP ranges to roles.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | code snippet.php_.txt | 1.62 KB | jonfrancisskydiver |
Comments
Comment #1
jonfrancisskydiver commentedsirkitree,
I have included a code snippet that will pull data from the hostip.info site. Note the _get_url function--it may more precisely answer your question. the first function will pull the information from host.info and utilize Drupal's caching functions.
Jonathan
Comment #2
sirkitree commentedCool thanks. I drupalized it ;)
I'll commit this after I get a select box in that will allow a user to choose a country and it'll automatically fill in the range.
Comment #3
sirkitree commentedSo I just realized that a range for a country changes all the time and that hostip.info doesn't give that info out anyway.
My original idea was to be able to select a country from a dropdown and that would give you the IP ranges of that country. Turns out that list is GINORMOUS and would just be chaff.
Instead I think what I'm going to do is this:
When a visitor comes to the site, do a lookup in my hook_init() to get their country code and give them a role with the name of that country code. This assumes that Drupal already has a role with this country code's name. However, since I'm currently only dealing with one other country than US, it should be simple. I'll probably just use what this module has in it's hook_init() and modify it to get the country code instead of looking up any entries.
Does anyone want me to commit the function above to the module?
Comment #4
jonfrancisskydiver commentedIP to Country or IP2Nation modules may keep track of the changing IP address assignments. I haven't taken a look at those modules yet. I agree that hostip.info may not be reliable enough for some Drupal users because I've been noticing that hostip.info does provide country information (http://api.hostip.info/country.php
?), but there are still a number of IP address that hostip.info doesn't have information for. Perhaps "ip to country" or "IP2Nation" would help out.