ertankoraltan
Newbie
- Dec 18, 2020
- 3
- 0
I need to block all of my non-mobile traffic from one spresific country. Can i do this with cloudflare?
// Save visitor statistics
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'];
}
$xml = simplexml_load_file("http://www.geoplugin.net/xml.gp?ip=". $ip);
// Country CODE
$sCountryCode = $xml->geoplugin_countryCode;
Actually i need something more spesific; i want to block direct traffic and allow only visitors from search engines. Some of my competitors doing this but idk how to do.
$referer = $_SERVER['HTTP_REFERER'];
if($referer == "")
{
// Redirect user away
}