Web Hosting Info

Search:

featured partner

The IP to Country Database

  Forum Topics : Bug Reports / 80.111.40.0 - 80.111.71.255 is in Norway, Not Austria
Submitted by torbjok on Wed, 04/14/2004 - 08:51.
Also applies
* 62.179.240.0 - 62.179.247.255
Comment viewing options:
Select your preferred way to display the comments and click 'Save settings' to submit your changes.
210.86.148.140 is showing US.... but its from Thailand
Posted by anupam on Fri, 04/23/2004 - 07:18.
I have written the following PHP code to get the Location from the ip-to-country.csv file:
<?php
$ip = $_SERVER['REMOTE_ADDR'];
$ip_long = ip2long($ip);
$country = 'unkown' ;

$fl = fopen("ip-to-country.csv", "r") ;
if (!$fl) {
die("Error") ;
} else {
while ( !feof($fl) ) {
$line = fgets($fl);

list($start_ip, $end_ip, $letter_2_code, $letter_3_code, $full_name) = explode(",", $line) ;
$start_ip = str_replace("\"", "", $start_ip) ;
$end_ip = str_replace("\"", "", $end_ip) ;
$letter_2_code = strtolower(str_replace("\"", "", $letter_2_code)) ;
$letter_3_code = strtolower(str_replace("\"", "", $letter_3_code)) ;
$full_name = str_replace("\"", "", $full_name) ;
if ($ip_long >= $start_ip && $ip_long <= $end_ip) {
$country = $full_name ;
break ;
}
}
fclose($fl) ;
}
if ( $country <> 'unknown' ) {
$two_three = $letter_2_code . "-" . $letter_3_code ;
if ( file_exists("nation_flags/$letter_2_code.gif") ) {
$img_flag = '<img src="nation_flags/' . $letter_2_code . '.gif" border="0">' ;
} else if ( file_exists("nation_flags/$letter_3_code.gif") ) {
$img_flag = '<img src="nation_flags/' . $letter_3_code . '.gif" border="0">' ;
} else if ( file_exists("nation_flags/$two_three.gif") ) { $img_flag = '<img src="nation_flags/' . $two_three . '.gif" border="0">' ;
} else {
$img_flag = '' ;
}
print '<table width="100%" cellspacing="0" cellpadding="0" border="0" class="textinfo">';
print '<tr>';
print '<td width="100%" align="center"><strong>Your IP Address : </strong>' . $ip . '</td>';
print '</td>';
print '</tr>';
print '<tr>';
print '<td width="100%" align="center"><strong>Your Location : </strong>' . $country . '</td>';
print '</tr>';
print '<tr>';
print '<td width="100%" align="center">' . $img_flag . '</td>';print '</tr>';
print '</tr>';
print '</table>';
}
?>
When this code is accessed from the IP: 210.86.148.140, its showing Location as United States and Flag of US. Is there any problem with the code or the IP? Whats the actual problem? Can anyone please help me out?
 
210.86.148.140 is showing US.... but its from Thailand - Fixed
Posted by anupam on Fri, 04/23/2004 - 08:28.
The problem is fixed by myself.

Thanks