Hi,
I’ve been searching Google to see how I could detect if someone living outside of the US. I would like to not display certain html if the website viewer lives outside the US. Specifically the contiguous US if that is possible.
I found something like this that might work but there might be an easier way:
<?php
/*
* ip__allocation.php
*
*/
$MyClient=FALSE;
if (isset($_SERVER['REMOTE_ADDR']))
{
include 'ip_in_range.php';
$clientIP=$_SERVER["REMOTE_ADDR"];
$IPAllocation = array(
'192.168.1.0-192.168.1.255',
'192.168.2.0-192.168.2.255',
);
foreach ($IPAllocation as $addressRange) {
if (ip_in_range($clientIP, $addressRange))
{
$MyClient=TRUE;
break;
}
}
}
?>
Thanks