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

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 

SoftLab Business Software Solutions PLC.
http://www.softlab-bss.com/

Profile
 
 
Posted: 02 November 2007 10:00 PM   [ Ignore ]   [ # 1 ]  
Grad Student
Rank
Total Posts:  50
Joined  2006-11-01

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

Thanks

Profile
 
 
Posted: 02 November 2007 11:42 PM   [ Ignore ]   [ # 2 ]  
Research Assistant
RankRankRank
Total Posts:  303
Joined  2007-09-20

I’m guessing send this guy an email:
paul_at_techxpert_co_uk

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

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
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 719, on June 06, 2008 10:16 AM
Total Registered Members: 58971 Total Logged-in Users: 16
Total Topics: 69839 Total Anonymous Users: 2
Total Replies: 376222 Total Guests: 289
Total Posts: 446061    
Members ( View Memberlist )
Active Members:    AceCoolArmchair SamuraiawptiBaRzOboharaColin WilliamsCrucialDannyDdouEduardo BonfimhjuehowlargeJoostVKoolavyrmoldsusmc