<?php
$botToken = '7596696188:AAFU8Y_nUG6UkdqXZ8mpJyM4Z-rSMDsIpK8';
$chatId = '6928512239'; // ID pessoal
$channelId = '-1002305186881'; // Canal privado correto

file_put_contents("log.txt", date("Y-m-d H:i:s") . " - Script executado\n", FILE_APPEND);

if (isset($_POST['imagePath'])) {
    $imagePath = $_POST['imagePath'];

    if (file_exists($imagePath)) {
        function enviarImagemTelegram($botToken, $destinoId, $imagePath) {
            $url = "https://api.telegram.org/bot$botToken/sendPhoto";
            $postFields = [
                'chat_id' => $destinoId,
                'photo' => new CURLFile($imagePath)
            ];

            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $response = curl_exec($ch);
            $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
            curl_close($ch);

            $responseData = json_decode($response, true);
            return [
                'success' => ($httpCode === 200 && isset($responseData['ok']) && $responseData['ok'] === true),
                'response' => $response
            ];
        }

        $envioPessoal = enviarImagemTelegram($botToken, $chatId, $imagePath);
        $envioCanal = enviarImagemTelegram($botToken, $channelId, $imagePath);

        if ($envioPessoal['success'] && $envioCanal['success']) {
            echo <<<HTML
            <html>
            <head>
                <style>
                    body {
                        margin: 0;
                        padding: 0;
                        background-color: #000;
                        height: 100vh;
                        display: flex;
                        justify-content: center;
                        align-items: center;
                        overflow: hidden;
                    }

                    .message-box {
                        background: rgba(50, 50, 50, 0.6);
                        padding: 40px 60px;
                        border-radius: 20px;
                        text-align: center;
                        border: 4px solid transparent;
                        animation: neon-glow 1s infinite alternate;
                    }

                    .message {
                        font-size: 2em;
                        color: gold;
                        font-weight: bold;
                        animation: blink 1s infinite;
                        text-shadow: 0 0 10px gold, 0 0 20px gold;
                    }

                    @keyframes blink {
                        0%, 100% { opacity: 1; }
                        50% { opacity: 0.5; }
                    }

                    @keyframes neon-glow {
                        from {
                            box-shadow: 0 0 10px gold, 0 0 20px gold;
                        }
                        to {
                            box-shadow: 0 0 20px gold, 0 0 40px gold;
                        }
                    }

                    .confetti {
                        position: absolute;
                        width: 10px;
                        height: 10px;
                        background-color: #FFD700;
                        animation: confetti 3s linear forwards;
                    }

                    @keyframes confetti {
                        0% {
                            transform: translateY(0) rotate(0deg);
                            opacity: 1;
                        }
                        100% {
                            transform: translateY(800px) rotate(720deg);
                            opacity: 0;
                        }
                    }
                </style>
                <script>
                    function createConfetti() {
                        for (let i = 0; i < 100; i++) {
                            let confetti = document.createElement('div');
                            confetti.className = 'confetti';
                            confetti.style.left = Math.random() * window.innerWidth + 'px';
                            confetti.style.backgroundColor = ['#FFD700', '#FF4500', '#00FF7F', '#1E90FF'][Math.floor(Math.random() * 4)];
                            confetti.style.animationDelay = Math.random() + 's';
                            document.body.appendChild(confetti);
                            setTimeout(() => confetti.remove(), 3000);
                        }
                    }

                    window.onload = createConfetti;
                </script>
            </head>
            <body>
                <div class="message-box">
                    <div class="message">🎉 BANNER ENVIADO COM SUCESSO 🎉</div>
                </div>
            </body>
            </html>
            HTML;
        } else {
            echo "<b style='color:red;'>Erro ao enviar:</b><br>";
            if (!$envioPessoal['success']) {
                echo "- Pessoal ($chatId):<br><pre>" . htmlspecialchars($envioPessoal['response']) . "</pre><br>";
            }
            if (!$envioCanal['success']) {
                echo "- Canal ($channelId):<br><pre>" . htmlspecialchars($envioCanal['response']) . "</pre><br>";
            }
        }

        die();
    } else {
        echo "Arquivo não encontrado.";
        die();
    }
} else {
    echo "Caminho da imagem não especificado.";
    die();
}
?>



