What's wrong with the code (Sypex Geo API)?

Hello, I want to configure georievich. Googling found SypexGeo, and this code(which is below). All like as works, or rather does not give error but does not specify the country and the redirect occurs on the backup link(
Help Nuba) If there is an easier way, please share.


// Plugin and create an instance:

include("SxGeo.php");
$SxGeo = new SxGeo('SxGeo.dat');

// Optional step, trying to determine the IP of the user more precisely:

function getIP(){
if (!empty($_SERVER['HTTP_CLIENT_IP'])){
//check ip from share internet
$ip = $_SERVER['HTTP_CLIENT_IP'];
}elseif(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
//to check ip is pass from proxy
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
return $ip;
}

// Define a country and city:

$ip = getIP(); // or $_SERVER['REMOTE_ADDR'];
echo ($SxGeo->getCountry($ip));

echo ";
print_r($SxGeo->getCityFull($ip)); // All the information about the city
echo ";

// Ie if want to change the links for the people of Russia, something like this:

if($SxGeo->getCountry($ip) == 'AM') {
header('Location: https://ru.wikipedia.org/wiki/Армения');
exit;
}elseif($SxGeo->getCountry($ip) == 'DE') {
header('Location: https://ru.wikipedia.org/wiki/Германия');
exit;
} else {
header('Location: https://ru.wikipedia.org/wiki/ISO_3166-1');
exit;
}

//Country is defined in the ISO 3166-1 standard https://ru.wikipedia.org/wiki/ISO_3166-1

?>
June 8th 19 at 16:57
0 answer

Find more questions by tags PHP