Saturday September 4, 2010 @ 20:45:15 GMT+10    ( Weather:  21°C / 70°F  -  Mostly Cloudy )
Home » Weblog Archives

Powered byD's Bloggie
Weblog » Archive » 2007 » May » Day 08
Browse by day ...
 28 April, 200730 May, 2007 

Last edited: Wed 2007-05-30 @ 15:58 , by DaRen 2 time(s)

IP2Country binary database maker - 2:48 pm
Now in PHP....
Coding , PHP  -  poster 

Half way through the site updates with lots of new codes and I thought the below script might be useful to some people... so, here you go !

IP2Country binary database maker (PHP)

Note: It's now added to my dev list here, always check there for latest news.

The IP2Country binary database maker in PHP that I written is a port from the original Python script from L. Petersen in Weird Silence, or a direct link to the source code zip file (inside makedb.py file).

The binary database created by this script can be used for IP to country lookup. If you need the script on how to use the database, visit Weird Silence - IP to Country. They have several languages for the implementation (eg. C#, PHP, Python, C, Delphi).

// +----------------------------------------------------------------------+
// | IP2Country binary database maker                                     |
// | Copyright (C) 2007  Darren (http://ahkuan.com/weblog/199.html)       |
// |                                                                      |
// | File    : ip_csv2dat.php                                             |
// | Started : Monday, May 7, 2005                                        |
// | Version : 1.0                                                        |
// +----------------------------------------------------------------------+
// |                                                                      |
// | This is a PHP port with little modification from original            |
// | Python script coded by                                               |
// |        L. Petersen , visit http://weirdsilence.net/software/ip2c/    |
// |                                                                      |
// | What this script does is it converts the CSV database from           |
// | IP-to-Country and GeoIP into binary database for quicker lookup      |
// |                                                                      |
// | Websites:                                                            |
// | IP-to-Country  http://ip-to-country.webhosting.info                  |
// | Maxmind: GeoIP  http://www.maxmind.com/app/ip-location               |
// |                                                                      |
// | Download latest CSV database:                                        |
// | http://ip-to-country.webhosting.info/downloads/ip-to-country.csv.zip |
// | http://www.maxmind.com/download/geoip/database/GeoIPCountryCSV.zip   |
// |                                                                      |
// | *NOTE*                                                               |
// | Let me know if there is anything wrong with the code, especially     |
// | whether the formatting code used in PHP's pack() function is the     |
// | same as the Python or not. I have no Python coding experience at     |
// | all when I'm porting the original Python script to PHP... so only    |
// | God knows what mistake I've made unless you tell me ;)               |
// |                                                                      |
// | Also, I'm happy to hear if you have any improvements/suggestions.    |
// | Use the 'Contact me' link on my page to contact me.                  |
// |                                                                      |
// +----------------------------------------------------------------------+


Download

  • ip_csv2dat.rar - PHP Source code rarred (CSV database included) (748 KB)
  • ip_csv2dat.zip - PHP Source code zipped (CSV database included) (1 MB)

*Edit 2007.5.9* Added zipped file source code for download
*Edit 2007.5.30* Added to my dev list.
 28 April, 200730 May, 2007 
$ view_blog.php 2009.09.17 18:16:41 $
Lost? | XML/HTML sitemap | Contact
38.107.191.88 , 19 queries , 0.0479s
Gzip enabled , CSS compressed , JS compressed
Copyright © 2005-2009 Darren's Outpost