I have got the database, it's the code to make the check work that I need. I can't code php from scratch.
All I find is this code and it doesn't work for pages that are not loaded from root because the geoip.inc file won't accept any paths. I'd have to place the geoip.inc and GeoIP.dat files in every folder of the site to make it work (in theory)
Code:
if (isset($_COOKIE["geo"])) {
$country = $_COOKIE['geo'];
} else {
include("geoip.inc");
$gi = geoip_open("GeoIP.dat",GEOIP_STANDARD);
$ip = $_SERVER["REMOTE_ADDR"];
$country = geoip_country_code_by_addr($gi, $ip);
geoip_close($gi);
setcookie("geo", $country, time()+15552000, "/", ".yourdomain.com", 0); //6 month cookie
}
Code:
<?php
if ($country == "US")
echo 'MAIN CODE';
else
echo 'BACKUP CODE';
?>
|