protected function CheckIP(){
$ch = curl_init();
$timeout = 5;
$ip = $_SERVER['HTTP_HOST'];
$url = "http://ip-api.com/json/{$ip}?fields=country";
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$fileContents = curl_exec($ch);
curl_close($ch);
$fileContents = json_decode($fileContents, true);
if($fileContents["country"] == 'Taiwan') show_404();
}
第三方ip-api : https://ip-api.com/docs/api:json
請先 登入 以發表留言。