File size: 7,424 Bytes
7f4f4a0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Artimis AI - فعال‌سازی ربات</title>
    <style>
        * { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }
        body { background: linear-gradient(135deg, #0f172a, #1e1b4b); color: #f8fafc; min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
        .card { background: rgba(30, 41, 59, 0.85); backdrop-filter: blur(12px); border: 1px solid rgba(255,255,255,0.1); padding: 30px; border-radius: 20px; width: 100%; max-width: 420px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
        h1 { font-size: 1.5rem; text-align: center; margin-bottom: 8px; color: #38bdf8; }
        p { text-align: center; font-size: 0.88rem; color: #94a3b8; margin-bottom: 20px; }
        .status-badge { display: block; text-align: center; padding: 10px; border-radius: 12px; font-weight: bold; margin-bottom: 20px; font-size: 0.85rem; }
        .status-active { background: rgba(34, 197, 94, 0.2); color: #4ade80; border: 1px solid #22c55e; }
        .status-inactive { background: rgba(234, 179, 8, 0.2); color: #fde047; border: 1px solid #eab308; }
        .form-group { margin-bottom: 15px; }
        label { display: block; margin-bottom: 6px; font-size: 0.85rem; color: #cbd5e1; }
        input { width: 100%; padding: 12px; border-radius: 10px; border: 1px solid #334155; background: #0f172a; color: #fff; font-size: 1rem; text-align: center; direction: ltr; }
        input:focus { outline: none; border-color: #38bdf8; }
        button { width: 100%; padding: 12px; border-radius: 10px; border: none; background: #0284c7; color: white; font-size: 1rem; font-weight: bold; cursor: pointer; transition: 0.3s; margin-top: 10px; }
        button:hover { background: #0369a1; }
        .hidden { display: none; }
        .alert { padding: 12px; border-radius: 10px; margin-top: 15px; font-size: 0.85rem; text-align: center; }
        .alert-error { background: rgba(239, 68, 68, 0.2); color: #f87171; border: 1px solid #ef4444; }
        .alert-success { background: rgba(34, 197, 94, 0.2); color: #4ade80; border: 1px solid #22c55e; }
    </style>
</head>
<body>
    <div class="card">
        <h1>هوش مصنوعی Artimis</h1>
        <p>پنل اختصاصی لاگین و فعال‌سازی ربات تلگرام</p>

        <div id="statusBadge" class="status-badge status-inactive">در حال بررسی وضعیت دیتابیس...</div>

        <!-- مرحله ۱: ارسال کد -->
        <div id="step1">
            <div class="form-group">
                <label>شماره تلفن اکانت تلگرام:</label>
                <input type="text" id="phoneInput" value="+989333992574" placeholder="+989123456789">
            </div>
            <button onclick="sendCode()">دریافت کد تایید</button>
        </div>

        <!-- مرحله ۲: ورود کد -->
        <div id="step2" class="hidden">
            <div class="form-group">
                <label>کد تایید ۵ رقمی تلگرام:</label>
                <input type="text" id="codeInput" placeholder="12345">
            </div>
            <div class="form-group hidden" id="passwordGroup">
                <label>رمز عبور دو مرحله‌ای (2FA):</label>
                <input type="password" id="passwordInput" placeholder="••••••••">
            </div>
            <button onclick="verifyCode()">ورود و ذخیره در دیتابیس</button>
        </div>

        <div id="alertBox" class="alert hidden"></div>
    </div>

    <script>
        async function checkStatus() {
            try {
                const res = await fetch('/api/status');
                const data = await res.json();
                const badge = document.getElementById('statusBadge');
                if (data.authorized) {
                    badge.className = 'status-badge status-active';
                    badge.innerText = '✅ ربات آنلاین، مجاز و به Neon DB متصل است!';
                    document.getElementById('step1').classList.add('hidden');
                    document.getElementById('step2').classList.add('hidden');
                } else {
                    badge.className = 'status-badge status-inactive';
                    badge.innerText = '⚠️ ربات غیرفعال است. لطفا کد ورود را بگیرید.';
                }
            } catch (e) {
                console.error(e);
            }
        }

        function showAlert(msg, isError = true) {
            const box = document.getElementById('alertBox');
            box.className = `alert ${isError ? 'alert-error' : 'alert-success'}`;
            box.innerText = msg;
            box.classList.remove('hidden');
        }

        async function sendCode() {
            const phone = document.getElementById('phoneInput').value;
            showAlert('در حال ارسال درخواست به تلگرام...', false);
            try {
                const res = await fetch('/api/send-code', {
                    method: 'POST',
                    headers: { 'Content-Type': 'application/json' },
                    body: JSON.stringify({ phone })
                });
                const data = await res.json();
                if (res.ok) {
                    showAlert('کد تایید به تلگرام شما فرستاده شد.', false);
                    document.getElementById('step1').classList.add('hidden');
                    document.getElementById('step2').classList.remove('hidden');
                } else {
                    showAlert(data.detail || 'خطا در ارسال کد');
                }
            } catch (e) {
                showAlert('خطا در ارتباط با سرور');
            }
        }

        async function verifyCode() {
            const code = document.getElementById('codeInput').value;
            const password = document.getElementById('passwordInput').value;
            showAlert('در حال بررسی و ذخیره سشن در دیتابیس...', false);
            try {
                const res = await fetch('/api/verify', {
                    method: 'POST',
                    headers: { 'Content-Type': 'application/json' },
                    body: JSON.stringify({ code, password })
                });
                const data = await res.json();
                if (res.ok) {
                    if (data.need_password) {
                        document.getElementById('passwordGroup').classList.remove('hidden');
                        showAlert('لطفاً رمز ورود دو مرحله‌ای (2FA) را وارد کنید');
                    } else {
                        showAlert('✅ ورود موفقیت‌آمیز بود! سشن ذخیره و ربات فعال گردید.', false);
                        setTimeout(checkStatus, 1500);
                    }
                } else {
                    showAlert(data.detail || 'کد وارد شده اشتباه است');
                }
            } catch (e) {
                showAlert('خطا در ارتباط با سرور');
            }
        }

        checkStatus();
    </script>
</body>
</html>