raimis100 Posted May 27, 2008 Share Posted May 27, 2008 How can I get know where the visitor is from ? Link to comment https://forums.phpfreaks.com/topic/107470-solved-getting-visitor-country/ Share on other sites More sharing options...
ILYAS415 Posted May 27, 2008 Share Posted May 27, 2008 <?php $two_letter_country_code= iptocountry($_SERVER['REMOTE_ADDR']); function iptocountry($ip) { $numbers = preg_split( "/\./", $ip); include("ip_files/".$numbers[0].".php"); $code=($numbers[0] * 16777216) + ($numbers[1] * 65536) + ($numbers[2] * 256) + ($numbers[3]); foreach($ranges as $key => $value){ if($key<=$code){ if($ranges[$key][0]>=$code){$country=$ranges[$key][1];break;} } } if ($country==""){$country="unkown";} return $country; } ?> tweaked version of the one at http://www.phptutorial.info/iptocountry/the_script.html#basic however only gets two letters identifying the country. Link to comment https://forums.phpfreaks.com/topic/107470-solved-getting-visitor-country/#findComment-550863 Share on other sites More sharing options...
raimis100 Posted May 27, 2008 Author Share Posted May 27, 2008 Seems solid Thanks so much! You saved me ! Link to comment https://forums.phpfreaks.com/topic/107470-solved-getting-visitor-country/#findComment-550869 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.