Part of the EllisLab Network
   
1 of 2
1
GeoIP Lookup Plugin
Posted: 06 September 2007 11:26 AM   [ Ignore ]  
Summer Student
Avatar
Total Posts:  17
Joined  09-06-2007

Hi,

Here is a GeoIP plugin for CI. The import does hang until complete but i wanted to keep it as a plugin rather than making a Ajax frontend and making possible integration a nightmare.

Instructions are below and the code can be downloaded from http://code.google.com/p/ci-geoip/

Any questions or comments please post to this thread.

/*
     * GeoIP Plugin for CodeIgniter/Blueflame - Version 1
     * Writted By Paul Trippett (ptrippett_at_gmail.com)
     *
     * To use this plugin you must create a table in your database with
     * the following schema: -
     *
     * CREATE TABLE  `geoip` (
     *   `id` int(10) unsigned NOT NULL auto_increment,
     *   `ip_start` varchar(15) NOT NULL,
     *   `ip_end` varchar(15) NOT NULL,
     *   `ipnum_start` float NOT NULL,
     *   `ipnum_end` float NOT NULL,
     *   `country_code` char(2) NOT NULL,
     *   PRIMARY KEY  (`id`),
     *   KEY `geoip_lookup` USING BTREE (`ipnum_start`,`ipnum_end`)
     * ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
     *
     *
     * Place this file in your application/plugins/ directory and download the
     * following files in to the {ci_root}/updates/geoip/ directory.
     *
     *      ftp://ftp.afrinic.net/pub/stats/afrinic/delegated-afrinic-latest
     *      ftp://ftp.apnic.net/pub/stats/apnic/delegated-apnic-latest
     *      ftp://ftp.arin.net/pub/stats/arin/delegated-arin-latest
     *      ftp://ftp.lacnic.net/pub/stats/lacnic/delegated-lacnic-latest
     *      ftp://ftp.ripe.net/ripe/stats/delegated-ripencc-latest
     *      ftp://ftp.apnic.net/pub/stats/iana/delegated-iana-latest
     *
     * You should then be able to use the following code in your controller: -
     * 
     *      Import:
     *      $this->load->plugin('geoip');
     *      geoip_update();
     * 
     *      Country Lookups:
     *      $this->load->plugin('geoip');
     *      geoip_lookup('xxx.xxx.xxx.xxx');
     *
     * geoip_update() needs only to be called _once_ after you update the files
     * from the RIR FTP sites.
     *
     * Should you wish to place the files in a different directory or use a
     * different table name you can put the following code in your
     * /application/config/config.php file: -
     *
     *      define('GEOIP_TABLENAME', 'geoip');
     *      define('GEOIP_FILESOURCE', 'updates/geoip/');
     * 
     */ 

UPDATED:
Sorry my ex employer deleted the code :( Better late than never but the code is now hosted at Google Code. The original link in this post has been updated.

 Signature 

Agent Storm - http://www.agentstorm.com/

“If it seems too complicated, your probably doing it wrong!”

Profile
 
 
Posted: 02 November 2007 11:00 PM   [ Ignore ]   [ # 1 ]  
Summer Student
Total Posts:  30
Joined  11-01-2006

Does anyone have the plugin files? I would die for those right now and the link is broken! :(

Thanks

Profile
 
 
Posted: 03 November 2007 12:42 AM   [ Ignore ]   [ # 2 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  408
Joined  09-20-2007

I’m guessing send this guy an email:
paul_at_techxpert_co_uk

 Signature 

Twitter

Profile
 
 
Posted: 03 November 2007 01:24 PM   [ Ignore ]   [ # 3 ]  
Research Assistant
RankRankRank
Total Posts:  530
Joined  07-10-2006
yello - 03 November 2007 03:00 AM

Does anyone have the plugin files? I would die for those right now and the link is broken! :(

Thanks

I believe that Felice Ostuni (felix) used a similar approach for automatic language (locale) selection in Rapyd. Rapyd is available on CiForge and on the Rapyd site. There should be links on the wiki page.

Profile
 
 
Posted: 04 April 2009 07:18 PM   [ Ignore ]   [ # 4 ]  
Summer Student
Total Posts:  3
Joined  01-31-2009

*    ftp://ftp.afrinic.net/pub/stats/afrinic/delegated-afrinic-latest
    *    ftp://ftp.apnic.net/pub/stats/apnic/delegated-apnic-latest
    *    ftp://ftp.arin.net/pub/stats/arin/delegated-arin-latest
    *    ftp://ftp.lacnic.net/pub/stats/lacnic/delegated-lacnic-latest
    *    ftp://ftp.ripe.net/ripe/stats/delegated-ripencc-latest
    *    ftp://ftp.apnic.net/pub/stats/iana/delegated-iana-latest

where can I download it now?

Profile
 
 
Posted: 04 April 2009 08:06 PM   [ Ignore ]   [ # 5 ]  
Summer Student
Avatar
Total Posts:  17
Joined  09-06-2007

The ftp links originally posted are still valid.

 Signature 

Agent Storm - http://www.agentstorm.com/

“If it seems too complicated, your probably doing it wrong!”

Profile
 
 
Posted: 05 April 2009 04:38 PM   [ Ignore ]   [ # 6 ]  
Summer Student
Total Posts:  3
Joined  01-31-2009

oops. sorry.
did’t work day ago

Profile
 
 
Posted: 05 April 2009 06:10 PM   [ Ignore ]   [ # 7 ]  
Summer Student
Avatar
Total Posts:  17
Joined  09-06-2007

I would be suprised if the links above ever changed, there are probably thousands of applications that use those files for various tools and use automatic import routines to fetch the files. smile

FFR: Most of the ftp’s listed do carry a mirror of other nic’s files also

smile

 Signature 

Agent Storm - http://www.agentstorm.com/

“If it seems too complicated, your probably doing it wrong!”

Profile
 
 
Posted: 22 August 2009 08:59 PM   [ Ignore ]   [ # 8 ]  
Lab Assistant
RankRank
Total Posts:  276
Joined  03-21-2007

K, I have a couple quesitons. There are two major players maxmind and ip2location that sell geoip databases for a few hundred dollars.

So where does this plugin and ftp downlaods fit into this sorta thing?

Profile
 
 
Posted: 13 December 2009 02:46 PM   [ Ignore ]   [ # 9 ]  
Research Assistant
RankRankRank
Total Posts:  400
Joined  09-18-2007

Your code generates errors: undefined variable $type on line 149. If I’m not mistaken it should probably be changed to $data[2].

Using http://codeigniter.com/wiki/Geo_Locater/ instead.

 Signature 

Attended EECI2009

Profile
 
 
Posted: 17 February 2010 10:02 AM   [ Ignore ]   [ # 10 ]  
Summer Student
Total Posts:  7
Joined  03-16-2008

This is great - but does anyone know of a similar plugin that allows geoip lookup at city level?

Profile
 
 
   
1 of 2
1