Spaces:
Paused
Paused
Create templates/index.html
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291<!DOCTYPE html><html lang="ar" dir="rtl"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> <title>APK Deep Analyzer</title> <style> * { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; } body { background-color: #0f172a; color: #f8fafc; padding: 12px; max-width: 100vw; overflow-x: hidden; } .card { background: #1e293b; border-radius: 12px; padding: 16px; margin-bottom: 16px; border: 1px solid #334155; width: 100%; } h2 { font-size: 1.1rem; margin-bottom: 12px; color: #38bdf8; border-bottom: 1px solid #334155; padding-bottom: 6px; } .btn { width: 100%; background: #2563eb; color: white; border: none; padding: 12px; border-radius: 8px; font-weight: bold; font-size: 0.95rem; cursor: pointer; margin-top: 8px; touch-action: manipulation; } .btn:disabled { background: #475569; } input[type="file"] { display: none; } .file-label { display: block; background: #0f172a; border: 2px dashed #475569; padding: 16px; text-align: center; border-radius: 8px; font-size: 0.85rem; color: #94a3b8; margin-bottom: 8px; } .progress-container { margin-top: 10px; display: none; } .progress-bar { width: 100%; height: 10px; background: #334155; border-radius: 5px; overflow: hidden; } .progress-fill { height: 100%; width: 0%; background: #10b981; transition: width 0.2s; } .info-grid { display: grid; grid-template-columns: 1fr; gap: 8px; font-size: 0.85rem; } .info-item { background: #0f172a; padding: 8px 12px; border-radius: 6px; word-break: break-all; } .info-item span { color: #94a3b8; display: block; font-size: 0.75rem; } #log-window { background: #020617; border: 1px solid #1e293b; border-radius: 8px; height: 220px; overflow-y: auto; padding: 8px; font-family: monospace; font-size: 0.75rem; display: flex; flex-direction: column; gap: 4px; } .log-line { line-height: 1.3; } .log-INFO { color: #38bdf8; } .log-SUCCESS { color: #4ade80; } .log-WARNING { color: #facc15; } .log-ERROR { color: #f87171; } .log-CRITICAL { color: #c084fc; font-weight: bold; } .log-actions { display: flex; gap: 8px; margin-top: 8px; } .btn-small { flex: 1; background: #334155; color: #f8fafc; border: none; padding: 8px; border-radius: 6px; font-size: 0.75rem; } </style></head><body>
<!-- Stage 1: File Upload --> <div class="card" id="stage1"> <h2>المرحلة الأولى: رفع APK</h2> <label for="apkFile" class="file-label" id="fileLabel">إضغط لاختيار ملف APK</label> <input type="file" id="apkFile" accept=".apk"> <button class="btn" id="uploadBtn" onclick="startUpload()">بدء الرفع</button>
<div class="progress-container" id="uploadProgressBox"> <div class="progress-bar"><div class="progress-fill" id="uploadFill"></div></div> <div class="info-grid" style="margin-top: 8px;"> <div class="info-item">التقدم: <b id="uploadPerc">0%</b></div> <div class="info-item">الحجم: <span id="uploadSize">0 / 0 MB</span></div> <div class="info-item">السرعة: <span id="uploadSpeed">0 MB/s</span></div> <div class="info-item">الوقت المتبقي (ETA): <span id="uploadEta">--</span></div> </div> </div> </div>
<!-- Stage 2: Quick Info --> <div class="card" id="stage2" style="display: none;"> <h2>المرحلة الثانية: البيانات الأساسية</h2> <div class="info-grid" id="quickInfoGrid"></div> <button class="btn" style="background:#10b981;" id="deepAnalysisBtn" onclick="startDeepAnalysis()">بدء التحليل العميق</button> </div>
<!-- Live Logs --> <div class="card"> <h2>سجلات العمليات (Live Logs)</h2> <div id="log-window"></div> <div class="log-actions"> <button class="btn-small" onclick="copyLogs()">نسخ السجلات</button> <button class="btn-small" onclick="clearLogs()">مسح السجلات</button> </div> <a id="downloadBtn" style="display:none;" href="/download-result" download> <button class="btn" style="background:#8b5cf6; margin-top:10px;">تحميل حزمة التحليل الكاملة (ZIP)</button> </a> </div>
<script> const fileInput = document.getElementById('apkFile'); const fileLabel = document.getElementById('fileLabel'); let ws;
fileInput.onchange = () => { if (fileInput.files.length > 0) { fileLabel.innerText = fileInput.files[0].name; } };
// إعداد WebSocket للسجلات function setupWebSocket() { const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'; ws = new WebSocket(`${protocol}//${window.location.host}/ws/logs`);
ws.onmessage = (event) => { const log = JSON.parse(event.data); appendLog(log); if (log.progress === 100 && log.stage === "اكتمل التحليل") { document.getElementById('downloadBtn').style.display = 'block'; } }; } setupWebSocket();
function appendLog(log) { const win = document.getElementById('log-window'); const line = document.createElement('div'); line.className = `log-line log-${log.level}`; line.innerText = `[${log.timestamp}] [${log.level}] ${log.message}`; win.appendChild(line); win.scrollTop = win.scrollHeight; }
function clearLogs() { document.getElementById('log-window').innerHTML = ''; }
function copyLogs() { const text = document.getElementById('log-window').innerText; navigator.clipboard.writeText(text); alert("تم نسخ السجلات إلى الحافظة"); }
// رفع الملف وحساب السرعة والوقت الحقيقي function startUpload() { const file = fileInput.files[0]; if (!file) return alert("الرجاء اختيار ملف APK أولاً");
document.getElementById('uploadProgressBox').style.display = 'block'; document.getElementById('uploadBtn').disabled = true;
const formData = new FormData(); formData.append("file", file);
const xhr = new XMLHttpRequest(); let startTime = Date.now();
xhr.upload.onprogress = (e) => { if (e.lengthComputable) { const percent = Math.round((e.loaded / e.total) * 100); const elapsedTime = (Date.now() - startTime) / 1000; const speed = (e.loaded / (1024 * 1024)) / elapsedTime; // MB/s const remainingBytes = e.total - e.loaded; const eta = remainingBytes / (e.loaded / elapsedTime);
document.getElementById('uploadFill').style.width = percent + '%'; document.getElementById('uploadPerc').innerText = percent + '%'; document.getElementById('uploadSize').innerText = `${(e.loaded/(1024*1024)).toFixed(1)} / ${(e.total/(1024*1024)).toFixed(1)} MB`; document.getElementById('uploadSpeed').innerText = `${speed.toFixed(2)} MB/s`; document.getElementById('uploadEta').innerText = `${Math.round(eta)} ثانية`; } };
xhr.onload = () => { if (xhr.status === 200) { const res = JSON.parse(xhr.responseText); if (res.status === "success") { showQuickInfo(res.info); } else { alert(res.message); } } else { alert("حدث خطأ أثناء الرفع"); } };
xhr.open("POST", "/upload"); xhr.send(formData); }
function showQuickInfo(info) { document.getElementById('stage2').style.display = 'block'; const grid = document.getElementById('quickInfoGrid'); grid.innerHTML = ` <div class="info-item"><span>اسم التطبيق</span>${info.app_name}</div> <div class="info-item"><span>Package Name</span>${info.package_name}</div> <div class="info-item"><span>الإصدار</span>${info.version_name} (${info.version_code})</div> <div class="info-item"><span>حجم APK</span>${info.file_size}</div> <div class="info-item"><span>Android SDK</span>Target: ${info.target_sdk} | Min: ${info.min_sdk}</div> <div class="info-item"><span>المعمارية المدمجة</span>${info.architectures.join(', ')}</div> <div class="info-item"><span>عدد الملفات الداخلية</span>${info.file_count} ملف</div> <div class="info-item"><span>عدد الأذونات</span>${info.permissions.length} أذن</div> `; }
function startDeepAnalysis() { document.getElementById('deepAnalysisBtn').disabled = true; fetch('/start-deep-analysis', { method: 'POST' }); } </script></body></html>templates/index.htmlAdded+291