i have a csv file the contents of this like
Database description
database in CSV format. It has 4 fields namely 'startip', 'endip', 'countrycode', and 'countryname'. Below is the description of each of the fields:
'startip'
Represents the starting IPv4 address in 32-bit decimal form.
'endip'
Represents the ending IPv4 address in 32-bit decimal form.
'countrycode'
ISO 3166-1 alpha-2 country code
'countryname'
Country name
Converting dot-decimal IP address notation to 32-bit decimal form
Let's assume that your IP address is : 12.34.56.78
The 32-bit decimal form value:
= (16777216 x 12) + (65536 x 34) + (256 x 56) + (7
= 203569230
OR
The 32-bit decimal form value:
= ( 12 <<24) + ( 34 <<16) + ( 56 << + 78
= 203569230
Therefore the 32-bit decimal value = 203569230
Below is a sample function in PHP that will do the convertion
can any one help me how to get the country code for every ip using this file?
Code:
startip,endip,countrycode,countryname 16777216,16777471,AU,Australia 16777472,16777727,CN,China 16777728,16778239,CN,China 16778240,16779263,AU,Australia 16779264,16781311,CN,China 16781312,16785407,JP,Japan 16785408,16793599,CN,China 16793600,16809983,JP,Japan 16809984,16842751,TH,Thailand 16842752,16843007,CN,China 16843008,16843263,AU,Australia 16843264,16843775,CN,China 16843776,16844799,CN,China .......................................
database in CSV format. It has 4 fields namely 'startip', 'endip', 'countrycode', and 'countryname'. Below is the description of each of the fields:
'startip'
Represents the starting IPv4 address in 32-bit decimal form.
'endip'
Represents the ending IPv4 address in 32-bit decimal form.
'countrycode'
ISO 3166-1 alpha-2 country code
'countryname'
Country name
Converting dot-decimal IP address notation to 32-bit decimal form
Let's assume that your IP address is : 12.34.56.78
The 32-bit decimal form value:
= (16777216 x 12) + (65536 x 34) + (256 x 56) + (7
= 203569230
OR
The 32-bit decimal form value:
= ( 12 <<24) + ( 34 <<16) + ( 56 << + 78
= 203569230
Therefore the 32-bit decimal value = 203569230
Below is a sample function in PHP that will do the convertion
PHP Code:
<?php
function convertIPtoInteger($ip)
{
$ipArr = explode('.',$ip);
return ($ipArr[0]<<24) + ($ipArr[1]<<16) + ($ipArr[2]<<8) + $ipArr[3];
}
?>
can any one help me how to get the country code for every ip using this file?
Comment