Archive

Posts Tagged ‘geoip’

IP to country conversion

October 18, 2010 1 comment

Though there are a lot of available solutions to tackle this problem but the one reside in the Google Code is the perfect one with simplicity and ease of use. Below is the work around to setup a test case; –

Explore the code:

Visit the project’s profile and read about the documentation.

Download the code;

Get the latest code from the repo and extract it to the root directory of the web server. Linux – /var/www/phpip2country Windows – C:\xampp\htdocs\phpip2country

Test the code:

Browse the directory in the browser. http://localhost/phpip2country/index.php

You need to upload the sql file which is actually a mapper for IP and Countries.

Results:

IP: 127.0.0.1
IP numerical Value: 2130706433
IP registry: IANA
IP assigned (Y-m-d H:i:s): 1983-01-01 05:00:00
IP country RIR (Regional Internet Registry) representation: ZZ
IP Country Abbreviation: ZZZ
IP country name: RESERVED
IP range: array (
‘FROM’ => ‘127.0.0.0’,
‘TO’ => ‘127.255.255.255’,
)
IP range numerical: array (
‘FROM’ => ‘2130706432’,
‘TO’ => ‘2147483647’,
)
full IP informations array: array (
‘IP_FROM’ => ‘2130706432’,
‘IP_TO’ => ‘2147483647’,
‘REGISTRY’ => ‘IANA’,
‘ASSIGNED’ => ‘410227200’,
‘CTRY’ => ‘ZZ’,
‘CNTRY’ => ‘ZZZ’,
‘COUNTRY’ => ‘RESERVED’,
‘IP_STR’ => ‘127.0.0.1’,
‘IP_VALUE’ => 2130706433,
‘IP_FROM_STR’ => ‘127.0.0.0’,
‘IP_TO_STR’ => ‘127.255.255.255’,
)

Below is the output when the code has been set on a live server.

IP: 116.58.42.211
IP numerical Value: 1949969107
IP registry: APNIC
IP assigned (Y-m-d H:i:s): 2007-03-27 19:00:00
IP country RIR (Regional Internet Registry) representation: PK
IP Country Abbreviation: PAK
IP country name: PAKISTAN
IP range: array (
‘FROM’ => ‘116.58.0.0’,
‘TO’ => ‘116.58.127.255’,
)
IP range numerical: array (
‘FROM’ => ‘1949958144’,
‘TO’ => ‘1949990911’,
)
full IP informations array: array (
‘IP_FROM’ => ‘1949958144’,
‘IP_TO’ => ‘1949990911’,
‘REGISTRY’ => ‘APNIC’,
‘ASSIGNED’ => ‘1175040000’,
‘CTRY’ => ‘PK’,
‘CNTRY’ => ‘PAK’,
‘COUNTRY’ => ‘PAKISTAN’,
‘IP_STR’ => ‘116.58.42.211’,
‘IP_VALUE’ => 1949969107,
‘IP_FROM_STR’ => ‘116.58.0.0’,
‘IP_TO_STR’ => ‘116.58.127.255’,
)

Advertisements
Categories: Web Tools Tags: , ,
%d bloggers like this: