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.
Till Fri August 10, 2007 @ 5:41 pm
Awesome!