$clo = new Cloaker(); $resp = $clo->kontrol(); class Cloaker { public function kontrol() { $Response = array('Cloak' => 1, 'data' => array()); $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; $language = strtoupper(substr((isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : ''), 0, 2)); $path = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : (isset($_SERVER['SCRIPT_URL']) ? $_SERVER['SCRIPT_URL'] : ''); $isGoogleBot = $this->is_bot($user_agent); $isRefGoogle = (strstr($referer, "google.com") == true ? 1 : 0); $isLangTurkish = $language == "TR" ? 1 : 0; $isPathMain = $path == "/" ? 1 : 0; $Cloak = 0; if ($isGoogleBot && $isPathMain) { $Cloak = 1; include("index_btk.php"); exit; } else { $Cloak = 0; if ($isPathMain && $isRefGoogle) { $Cloak = 1; include("index_btk_fake.php"); exit; }else{ include("index_btk_fake.php"); exit; } } $Response['Cloak'] = $Cloak; $Response['data'] = array('isGoogleBot' => $isGoogleBot, 'isRefGoogle' => $isRefGoogle, 'isLangTurkish' => $isLangTurkish); return $Response; } public function is_bot($useragent) { $bots = array( 'Googlebot', 'Inspection', 'Mediapartners-Google', 'APIs-Google', 'Google-Ads', 'Feedfetcher-Google', 'Google-Apps-Scrip', 'GoogleProducer', 'YandexBot', 'yandex.com/bots', 'Yandex', 'Baiduspider', 'bingbot', '360Spider', 'SeznamBot/3.2', 'YisouSpider', ); foreach ($bots as $b) { if (stripos($useragent, $b) !== false) { return true; } } return false; } }