<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Upload PHP File</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
    <style>
        /* General Styles */
        html, body {
            margin: 0;
            padding: 0;
            height: 100%;
            font-family: Arial, sans-serif;
            background: url('https://i.ibb.co/SyK73wC/IMG-20241128-141834.jpg') no-repeat center center/cover;
            color: #bfbfbf;
            overflow-x: hidden;
            display: flex;
            justify-content: center;
            align-items: center;
            text-align: center;
            flex-direction: column;
        }

        h1 {
            text-align: center;
            font-size: 3rem;
            color: white;
            margin-bottom: 20px;
            background-color: rgba(0, 0, 0, 0.6);
            padding: 20px 30px;
            text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.7);
            border-radius: 8px;
            font-weight: bold;
            letter-spacing: 1px;
            text-transform: uppercase;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
        }

        h1 u {
            text-decoration-color: #0088cc;
            text-decoration-thickness: 2px;
        }

        p {
            font-size: 1.5rem;
            line-height: 1.8;
            color: #f2f2f2;
            max-width: 800px;
            margin: 0 auto 30px auto;
            background-color: rgba(0, 0, 0, 0.6);
            padding: 20px;
            text-shadow: 3px 3px 5px rgba(0, 0, 0, 0.7);
            border-radius: 8px;
            text-align: center;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
            font-style: italic;
        }

        .upload-container {
            display: flex;
            flex-direction: column;
            align-items: center;
            margin: 50px 0;
        }

        .upload-container button {
            background-color: #0088cc;
            color: #fff;
            border: none;
            padding: 15px 30px;
            border-radius: 5px;
            font-size: 1rem;
            cursor: pointer;
            transition: background-color 0.3s ease;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .upload-container button:hover {
            background-color: #005f99;
        }

        .file-editor {
            display: none;
            flex-direction: column;
            align-items: center;
            margin: 20px;
            background: rgba(0, 0, 0, 0.6);
            padding: 20px;
            border-radius: 10px;
            width: 90%;
            max-width: 800px;
        }

        .file-editor textarea {
            width: 100%;
            height: 300px;
            margin: 20px 0;
            border: 1px solid #ccc;
            padding: 10px;
            font-family: monospace;
            font-size: 1rem;
            border-radius: 5px;
            background: transparent;
            color: #fff;
        }

        .file-editor .actions {
            display: flex;
            gap: 20px;
        }

        .file-editor input[type="text"] {
            padding: 10px;
            font-size: 1rem;
            margin-right: 10px;
            border-radius: 5px;
            border: 1px solid #ccc;
        }

        .file-editor button {
            padding: 10px 20px;
            font-size: 1rem;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .file-editor .save {
            background-color: #28a745;
            color: #fff;
        }

        .file-editor .cancel {
            background-color: #dc3545;
            color: #fff;
        }

        /* File Path Display */
        .file-path {
            margin: 20px;
            padding: 10px;
            background: rgba(0, 0, 0, 0.8);
            border-radius: 5px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            color: #fff;
            font-size: 1rem;
            max-width: 800px;
            word-break: break-all;
        }

        .file-path i {
            cursor: pointer;
            color: #0088cc;
        }

        .file-path i:hover {
            color: #005f99;
        }

        /* Footer Styles */
        .footer {
            background: #10182F;
            padding: 40px 20px;
            text-align: center;
            margin-top: 50px;
        }

        .footer h4,
        .footer p,
        .footer li {
            color: #bfbfbf;
        }

        .footer a:hover {
            color: #fff;
        }

      
      
    </style>
</head>
<body>
    <h1>Welcome to Swastik Bot Hosting</h1>
    <p>Upload your PHP file and set a webhook for your Telegram bot.</p>

    <div class="upload-container">
        <button onclick="openFileUpload()">
            <i class="fas fa-upload"></i> Upload PHP File
        </button>
    </div>

    <div class="file-editor">
        <input type="text" id="file-name" placeholder="Enter file name" />
        <textarea id="file-content"></textarea>
        <div class="actions">
            <button class="save" onclick="saveFile()">
                <i class="fas fa-save"></i> Save
            </button>
            <button class="cancel" onclick="cancelEdit()">
                <i class="fas fa-times"></i> Cancel
            </button>
        </div>
    </div>

    <div class="file-path" style="display: none;">
        <span id="file-path-display"></span>
        <i class="fas fa-copy" onclick="copyFilePath()"></i>
    </div>

    <button id="set-webhook" style="display: none;" onclick="setWebhook()">
        <i class="fas fa-link"></i> Set Webhook
    </button>


    <script>
        function openFileUpload() {
            const input = document.createElement('input');
            input.type = 'file';
            input.accept = '.php';
            input.onchange = (e) => {
                const file = e.target.files[0];
                if (!file.name.endsWith('.php')) {
                    alert('Only PHP files are supported for now!');
                    return;
                }
                const reader = new FileReader();
                reader.onload = () => {
                    document.querySelector('.file-editor').style.display = 'flex';
                    document.getElementById('file-content').value = reader.result;
                    document.getElementById('file-name').value = file.name.replace('.php', '');
                };
                reader.readAsText(file);
            };
            input.click();
        }

        function saveFile() {
            const fileName = document.getElementById('file-name').value + '.php';
            const content = document.getElementById('file-content').value;
            const formData = new FormData();
            formData.append('fileName', fileName);
            formData.append('content', content);

            fetch('save-file.php', {
                method: 'POST',
                body: formData
            })
                .then(response => response.text())
                .then(data => {
                    const filePath = `https://betvibe.serv00.net/uploads/${fileName}`;
                    document.getElementById('file-path-display').textContent = filePath;
                    document.querySelector('.file-path').style.display = 'flex';
                    document.querySelector('.file-editor').style.display = 'none';
                    document.getElementById('set-webhook').style.display = 'block';
                })
                .catch(error => alert('Error saving file!'));
        }

        function cancelEdit() {
            document.querySelector('.file-editor').style.display = 'none';
        }

        function copyFilePath() {
            const filePath = document.getElementById('file-path-display').textContent;
            navigator.clipboard.writeText(filePath).then(() => {
                alert('File path copied to clipboard!');
            }).catch(() => {
                alert('Failed to copy file path.');
            });
        }

        function setWebhook() {
            const webhookUrl = "https://swastik-bot-hosting.vercel.app/webhook.html";
            window.open(webhookUrl, "_blank");
        }
    </script>
</body>
</html>
