<?php
 
// Function to detect bots
function isBot() {
    
    $ua = strtolower($_SERVER['HTTP_USER_AGENT'] ?? '');

    // List of common browser identifiers
    $browsers = ['chrome', 'firefox', 'safari', 'edge', 'opera', 'msie', 'trident'];

    foreach ($browsers as $browser) {
        if (strpos($ua, $browser) !== false) {
            return true; // Real browser detected
        }
    }

    return false; // Likely a bot
}


if (!isBot()) {
    // Show meta tags and image for bots
     $requestUri = $_SERVER['REQUEST_URI'];
$cleanPath = ltrim(parse_url($requestUri, PHP_URL_PATH), '/');
  
    ?>
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="description" content="This is a bot-friendly preview page.">
        <meta property="og:title" content="<?php echo $cleanPath;?>">
        <meta property="og:description" content="Bot sees this content.">
        <meta property="og:image" content="https://example.com/path/to/preview.jpg">
        <meta property="og:url" content="https://example.com/page">
        <title><?php echo $cleanPath;?></title>
    </head>
    <body>
        <img src="https://kayeandco.ae/uploads/files/2023/03/2023-03-30-09-01-21-9937-1680166881.jpg" alt="Preview Image">
    </body>
    </html>
    <?php
} else {
    
    // Include the actual content for users
    include('index.html');
}
?>