To speed up my website in China I thought of hiding blocked services from Chinese users and wrote this and put it in functions.php
$isInChina = false; $ip = $_SERVER['REMOTE_ADDR']; // This will contain the ip of the request // This service tells me where the IP address is from and gives me more data than I need. $userData = json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=".$ip)); if (is_Null($userData) || empty($userData) || $userData->geoplugin_countryCode == "CN") { $isInChina = true; // Count no data as in China maybe to be paranoid. }
$isInChina = false;
$ip = $_SERVER['REMOTE_ADDR']; // This will contain the ip of the request
// This service tells me where the IP address is from and gives me more data than I need.
$userData = json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=".$ip));
if (is_Null($userData) || empty($userData) || $userData->geoplugin_countryCode == "CN")
{
$isInChina = true; // Count no data as in China maybe to be paranoid.
}
Sorry the code formatted strangely. Anyway shouldn'tShouldn't I store the result in some session level variable?