function real_ip_all_server($block_country){
# БЛОКИРУЕМ IP
# Роскомнадзор Пишем их IP
$arrayBanIP = array(
'198.37.148.63', # ruprotect
'176.38.244.90', # AXGHOUSE
'188.116.36.253', # Anti-Piracy Protection Legal
'35.231.112.156', # Hacker - (Pidar)
'217.64.42.100', # Hacker - (Pidar)
'191.43.47.191' # Hacker - (Pidar)
);
#########################################
$block_country = mb_strtolower($block_country);
$client = @$_SERVER['HTTP_CLIENT_IP'];
$forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
$remote = $_SERVER['REMOTE_ADDR'];
if(filter_var($client, FILTER_VALIDATE_IP)){$ip = $client;}elseif(filter_var($forward, FILTER_VALIDATE_IP)){$ip = $forward;}else{$ip = $remote;}
if(in_array($ip, $arrayBanIP)){die('And it all belongs to corporation google...');}
# отправка на сервер ip
$details = json_decode(file_get_contents("http://ipinfo.io/{$ip}"));
# ответ сервера даные по ip
$country = mb_strtolower($details->country);
$data = array();
# Реальный IP
$data['ip'] = $ip;
# Страна реальная
$data['country_real'] = $country;
# Страна заблокирована
$data['block_country'] = $block_country;
if($country==$block_country){
$data['country']=true;
# Запись в setcookie
setcookie('check_zone','block',time() + (86400 * 5)); // 86400 = 1 день в секундах
}else{
# проверка setcookie
if($_COOKIE['check_zone']=='block'){$data['country']=true;}else{$data['country']=false;}
}
return $data;
}
#########################################
## Проверка
$block = real_ip_all_server('ru');
if($block['country']==true){
echo'Блок';
}else{
print_R($block);
}