|
Database Downloads
Contents
|
GoNew's IP 2 Country database contains the full list of IP assignments for the entire IPv4 address range (0.0.0.0 - 255.255.255.255)
This database is updated automatically from the 5 official RIR sources.
With this database you can integrate Geo-Location of users into your web applications in an instant.
We can now offer this database as a download to our customers at a knockdown price. |
| |
|
In order to be able to download the database you need to have registered your free account at gonew and setup you IP 2 Database Access. [Click Here]
After that you can Purchase and download the database from your IP 2 Country Control Panel.
Downloads are avaible in ZIP format. Inside the archive will be the .sql file that you can execute as a mysql statement to you database server.
The table created in your desired database will be named ipv4_2country. It uses the MyISAM database engine.
Each row in the table represents a block of IP addresses that are assigned to a specific country. Countries have many of these blocks in the table.
The database table is completely contiguous in the IPv4 range of 0.0.0.0 to 255.255.255.255. Where a block of IP addresses have not been assigned to a country (EG: 0.0.0.0) the country code of ZZ and country of RESERVED is stored in the database. Uses can assume that these IP addresses are reserved by IANA.
The table contains the following fields:-
| Field Name |
Type |
Description |
| startlong |
INT(8) unsigned |
Numeric expression of the start IP address of the block. EG: 0 |
| endlong |
INT(8) unsigned |
Numberic expression of the end IP address of the block EG: 50331647 |
| startip |
varchar(15) |
String expression of the Start IP Address EG: 0.0.0.0 |
| endip |
varchar(15) |
String expression of the End IP Address EG: 2.255.255.255 |
| count |
INT(8) unsigned |
Number of IP addresses in the block. EG: 50331648 |
| countrycode |
char(2) |
The ISO 3166 country code of the country that has been assigned the block. (EG: US) (Unassigned IP blocks return ZZ) |
| country |
varchar(255) |
The full name of the country (EG: UNITED STATES)
Unassigned IP blocks return RESERVED EG: 0.0.0.0 |
Installing/Upgrading Your Database
Once you have downloaded the database you need to install the data into an exsting database of your choice.
Tools like phpMyAdmin can help you do this. Click on the import tab and upload the entire compressed archive. It will automatically extract and install the table and data.
If you are upgrading the follow the same proceedure as the SQL where in the download will drop the existing table before performing the update.
<?php
#
# Connect to the database
#
mysql_select_db($dbname,mysql_connect($dbhost,$dbuser,$dbpass));
#
# IP to query
#
$ip = $_SERVER['REMOTE_ADDR'];
#convert to long
$ipn = ip2long($ip);
#perform query
$qry = "SELECT * FROM ipv4_2country
WHERE
startlong <= $ipn && endlong >= $ipn
LIMIT 1;";
$sql = mysql_query($qry);
#get result
$row = mysql_fetch_array($sql);
echo("IP: $ip - CountryCode: $row[countrycode] - Country: $row[country]");
?>
The initial cost of accessing the database download is £10.00 and that price includes 1 months FREE updates.
Any subsequent monthly access costs will be £5.00 per month.
|