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

Info *NOTE* This page is NOT the actual weblog entry. The purpose for this page is to provide extra background information on how this particular entry is constructed, by using custom markups and tags. To read the actual content of this entry, please go to here.

The Raw Structure:

Markup | Tag used: BBCode


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 !

[h=3]IP2Country binary database maker (PHP)[/h]
[i]Note: It's now added to my dev list [url=/dev/ip2country/|local]here[/url], always check there for latest news.[/i]

The [b]IP2Country binary database maker[/b] in PHP that I written is a port from the original Python script from L. Petersen in [url=http://weirdsilence.net/software/ip2c/]Weird Silence[/url], or a [url=http://weirdsilence.net/software/86/112]direct link[/url] to the source code zip file (inside [i]makedb.py[/i] 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 [url=http://weirdsilence.net/software/ip2c/]Weird Silence - IP to Country[/url]. They have several languages for the implementation (eg. C#, PHP, Python, C, Delphi).

[code=nojs]
// +----------------------------------------------------------------------+
// | 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. |
// | |
// +----------------------------------------------------------------------+
[/code]

[h=3]Download[/h]
[list]
[*][url=/downloads/ip_csv2dat v1.0.rar]ip_csv2dat.rar[/url] - PHP Source code rarred (CSV database included) (748 KB)
[*][url=/downloads/ip_csv2dat v1.0.zip]ip_csv2dat.zip[/url] - PHP Source code zipped (CSV database included) (1 MB)
[/list]

[i]*Edit 2007.5.9* Added zipped file source code for download[/i]
[i]*Edit 2007.5.30* Added to my [url=/dev/|local]dev[/url] list.[/i]

Live Rendering:

The real-time rendered result...

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.
$ view_blog.php 2009.09.17 18:16:41 $
Lost? | XML/HTML sitemap | Contact
38.107.191.86 , 23 queries , 0.051s
Gzip enabled , CSS compressed , JS compressed
Copyright © 2005-2009 Darren's Outpost