ted_chou12 Posted February 1, 2007 Share Posted February 1, 2007 PLease visit the site below: http://tedchou12.110mb.com/ip.php it finds out the country you are living in by your ip address, my position happens to be correct, so i wonder how accurate it is, please give me some feedbacks. Thanks Ted Link to comment https://forums.phpfreaks.com/topic/36628-ip-to-country-test/ Share on other sites More sharing options...
kucing Posted February 1, 2007 Share Posted February 1, 2007 Hi.. Works fine for me Right Ip and Country.. Link to comment https://forums.phpfreaks.com/topic/36628-ip-to-country-test/#findComment-174571 Share on other sites More sharing options...
ted_chou12 Posted February 1, 2007 Author Share Posted February 1, 2007 Thanks, thats one good news Link to comment https://forums.phpfreaks.com/topic/36628-ip-to-country-test/#findComment-174573 Share on other sites More sharing options...
SharkBait Posted February 1, 2007 Share Posted February 1, 2007 Woo I'm living in Canada! I use IP2Country for one of my sites too. Seems mostly accurate, well haven't had anyone complain yet about it anyway Link to comment https://forums.phpfreaks.com/topic/36628-ip-to-country-test/#findComment-174660 Share on other sites More sharing options...
redbullmarky Posted February 1, 2007 Share Posted February 1, 2007 It told me I was living in squalor. Just kidding. Works ok for me Link to comment https://forums.phpfreaks.com/topic/36628-ip-to-country-test/#findComment-174664 Share on other sites More sharing options...
ted_chou12 Posted February 1, 2007 Author Share Posted February 1, 2007 Thanks btw, this doesnt trace antartica, and some oceanic islands... Ted Link to comment https://forums.phpfreaks.com/topic/36628-ip-to-country-test/#findComment-174668 Share on other sites More sharing options...
Daniel0 Posted February 1, 2007 Share Posted February 1, 2007 Works for me as well. You could also make it tell people what city they are in... Link to comment https://forums.phpfreaks.com/topic/36628-ip-to-country-test/#findComment-174674 Share on other sites More sharing options...
ted_chou12 Posted February 1, 2007 Author Share Posted February 1, 2007 thanks, , yeah, thats true, but cities requires a lot more details, , im too lazy. thanks anyways! Ted Link to comment https://forums.phpfreaks.com/topic/36628-ip-to-country-test/#findComment-174676 Share on other sites More sharing options...
alpine Posted February 1, 2007 Share Posted February 1, 2007 Norway OK too... Link to comment https://forums.phpfreaks.com/topic/36628-ip-to-country-test/#findComment-174734 Share on other sites More sharing options...
ShogunWarrior Posted February 1, 2007 Share Posted February 1, 2007 Ireland, A ok. Link to comment https://forums.phpfreaks.com/topic/36628-ip-to-country-test/#findComment-174824 Share on other sites More sharing options...
trecool999 Posted February 1, 2007 Share Posted February 1, 2007 Aw yeah... Go UK . Works for me . Link to comment https://forums.phpfreaks.com/topic/36628-ip-to-country-test/#findComment-174852 Share on other sites More sharing options...
AXiSS Posted February 1, 2007 Share Posted February 1, 2007 United States, works fine for me. Link to comment https://forums.phpfreaks.com/topic/36628-ip-to-country-test/#findComment-175033 Share on other sites More sharing options...
ted_chou12 Posted February 2, 2007 Author Share Posted February 2, 2007 Thanks, lots of good news! any more? Ted Link to comment https://forums.phpfreaks.com/topic/36628-ip-to-country-test/#findComment-175120 Share on other sites More sharing options...
EagerWolf Posted February 3, 2007 Share Posted February 3, 2007 Works in Slovenia! Link to comment https://forums.phpfreaks.com/topic/36628-ip-to-country-test/#findComment-175827 Share on other sites More sharing options...
ted_chou12 Posted February 3, 2007 Author Share Posted February 3, 2007 Thanks Link to comment https://forums.phpfreaks.com/topic/36628-ip-to-country-test/#findComment-175956 Share on other sites More sharing options...
Wuhtzu Posted February 3, 2007 Share Posted February 3, 2007 Works fine here - Denmark Link to comment https://forums.phpfreaks.com/topic/36628-ip-to-country-test/#findComment-176084 Share on other sites More sharing options...
ted_chou12 Posted February 3, 2007 Author Share Posted February 3, 2007 Thanks Link to comment https://forums.phpfreaks.com/topic/36628-ip-to-country-test/#findComment-176102 Share on other sites More sharing options...
RobinTibbs Posted February 3, 2007 Share Posted February 3, 2007 works in uk! Link to comment https://forums.phpfreaks.com/topic/36628-ip-to-country-test/#findComment-176112 Share on other sites More sharing options...
ted_chou12 Posted February 3, 2007 Author Share Posted February 3, 2007 (Since some people asked): IP is just like an internet address, so it depends on the country, the start value will be different for each country, I remember seen this somewhere, and the IP number is a geolical global position... below is a php script that does this: <?php $ip = $_SERVER['REMOTE_ADDR'];//gets user's ip address $explode = explode(".", $ip); $ipno = ($explode[0] * 16777216) + ($explode[1] * 65536) + ($explode[2] * 256) + $explode[3]; //up to here, the script converts the IP address to an ip number $txtfile = file("ipcountries.txt");//get the information from the long ip to country text file foreach ($txtfile as $line) {$explodetxt = explode(",", $line); $fip = $explodetxt[0]; $sip = $explodetxt[1]; $country = $explodetxt[2]; $country = str_replace("\r\n","",$country); $country = str_replace(" ","",$country); if ($ipno > $fip && $ipno < $sip) {$located = $country;}}//sorts out your ip range, and thus find out the range of your country's ip position, giving the result as country. $countries = file("countries.txt");//get the country text file, and convert it to country name. foreach ($countries as $ccountry) {$parts = explode(",", $ccountry); $part1 = str_replace("\r\n","",$parts[1]); if ($located == $part1) { echo "You are living in ".$parts[0]."! And your ip adress is $ip!";}} ?> This is basically the php script, because the actual hard work is the ipcountry.txt file, which is a database storing up to ten thousands of information, therefore, instead of the country name itself, I converted to country symbol which not just make it easier to look, organized, as well as saving the time and space when uploading. However, what i believe is that the ip will change, and my guess is that the number will always increase, so these database will need to be updated once some time. The countries txt file which includes the country name and short abbreviation is attached, but the ipcountries.txt is to large to attach, so download it at: http://tedchou12.110mb.com/ipcountries.txt feel free to use this on your website. Ted Ted [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/36628-ip-to-country-test/#findComment-176121 Share on other sites More sharing options...
ShogunWarrior Posted February 3, 2007 Share Posted February 3, 2007 If you are looking for a really efficient way to do IP->Country lookups then check out the source code in the Firestats PHP visitor tracker. They have implemented a binary search in PHP and it is very fast and has less overhead than text searching. Link to comment https://forums.phpfreaks.com/topic/36628-ip-to-country-test/#findComment-176140 Share on other sites More sharing options...
ted_chou12 Posted February 3, 2007 Author Share Posted February 3, 2007 cool , do you have a link for it? Thanks Ted Link to comment https://forums.phpfreaks.com/topic/36628-ip-to-country-test/#findComment-176149 Share on other sites More sharing options...
ShogunWarrior Posted February 3, 2007 Share Posted February 3, 2007 Yeah - http://firestats.cc Download it and in the php/ip2c directory you will find the IP2C class, the binary database and some test files. Link to comment https://forums.phpfreaks.com/topic/36628-ip-to-country-test/#findComment-176166 Share on other sites More sharing options...
ted_chou12 Posted February 3, 2007 Author Share Posted February 3, 2007 thanks Link to comment https://forums.phpfreaks.com/topic/36628-ip-to-country-test/#findComment-176170 Share on other sites More sharing options...
tauchai83 Posted February 4, 2007 Share Posted February 4, 2007 ted, it's working...haha.. working for southeast asia...lolx.... Link to comment https://forums.phpfreaks.com/topic/36628-ip-to-country-test/#findComment-176595 Share on other sites More sharing options...
ted_chou12 Posted February 4, 2007 Author Share Posted February 4, 2007 HEY there, thanks Ted Link to comment https://forums.phpfreaks.com/topic/36628-ip-to-country-test/#findComment-176599 Share on other sites More sharing options...
Recommended Posts