Hello,
i was looking around to convert 127.0.0.1 to a number, something that all IP to Counry Databse left out, and stumbled upon your post.
i have some information that may be of help to you.
i have done a module do to what you are trying to do however it is for a particular CMS and in PHP language. You may wish to decode it into whatever language to you. In doing so, i went through the net looking for resources and here is one i found to be reliable and free.
IP-to-Country.com | 'Cause every I.P has a Home...
Here are the relevant info...
1. There is a free IP to Country Database
HERE. This is the dB i am using and is adequate as i want something simple and non commercial.
2.Converting IP address is done as shown
HERE. Your method maybe a little long, so you may wish to check out this recommended one. There are also several other easier and more efficient ways posted by others on the thread i gave above. Take your pick.
3. World Flags.
I found the flags by w ww.hahn-hotel.com to be the best, but you have many to choose from.
The FLAGS are all listed and downloadable
HERE
===============
The PHP example below is taken from the same website, where all the above info comes from. Note however, that IP to Number conversion is done using the mySQL "inet_aton" function which does the conversion, so if you use mySQL, you do not need to convert the IP, which is very convenient.
PHP Code:
<?
//---------------------------------------------------
// Sample code to display Visitor Country information
// PHP 4
//---------------------------------------------------
// Establishing a database connection
$dbh=mysql_connect("localhost:3306","$MYSQL_USERNAME","$MYSQL_PASSWORD");
mysql_select_db("$MYSQL_DBNAME");
// Query for getting visitor countrycode
$country_query = "SELECT country_code2,country_name FROM iptoc ".
"WHERE IP_FROM<=inet_aton('$REMOTE_ADDR') ".
"AND IP_TO>=inet_aton('$REMOTE_ADDR') ";
// Executing above query
$country_exec = mysql_query($country_query);
// Fetching the record set into an array
$ccode_array=mysql_fetch_array($country_exec);
// getting the country code from the array
$country_code=$ccode_array['country_code2'];
// getting the country name from the array
$country_name=$ccode_array['country_name'];
// Display the Visitor coountry information
echo "$country_code - $country_name";
// Closing the database connection
mysql_close($dbh);
?>
This PHP is of course using the free database provided on the website, but note that this example program is a little off because the database have been updated and the field names are no longer in existence. However, the example serves as a good example.
Hope this helps.