I have a site that was happily outputting variables based upon a user's IP address. I was using code that looked to see if a cookie for a user's region was already set and if not, looking up the user's country and then setting said cookie and the appropriate variables.
My code was in a PHP enabled template parsing on output and included the following…
$sql = 'SELECT country FROM exp_ip2nation WHERE ip < INET_ATON("'.$_SERVER['REMOTE_ADDR'].'") ORDER BY ip DESC LIMIT 0,1'; list($country) = mysql_fetch_row(mysql_query($sql));
But since updating the site in question I find that EE now uses maxmind.com data instead of ip2nation.com, and that what was a single ip field is now 2: ip_range_low and ip_range_high. As a consequence my code no longer works.
Can anyone suggest how to fix my code or suggest a better way of achieving the same end?