Spaces:
Running
Running
File size: 12,527 Bytes
dc0d0b1 c2a7f11 dc0d0b1 c2a7f11 dc0d0b1 c2a7f11 dc0d0b1 c2a7f11 dc0d0b1 c2a7f11 dc0d0b1 c2a7f11 dc0d0b1 c2a7f11 dc0d0b1 c2a7f11 dc0d0b1 c2a7f11 dc0d0b1 c2a7f11 dc0d0b1 c2a7f11 dc0d0b1 c2a7f11 dc0d0b1 c2a7f11 dc0d0b1 | 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 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | <!DOCTYPE html>
<html lang="tr"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title>NOXBALL Admin</title>
<style>
:root{color-scheme:dark}
*{box-sizing:border-box}body{margin:0;background:#0c1017;color:#e8eef7;font-family:system-ui,sans-serif;padding:16px;max-width:1100px;margin:auto}
h1{font-size:20px;margin:0 0 14px}input,button{font:inherit;border-radius:8px;border:1px solid #2a3547;background:#151c28;color:#fff;padding:9px 12px}
button{cursor:pointer;background:#1e90ff;border:0;font-weight:700}button.k{background:#ff4757}button.g{background:#2ed573;color:#06210f}button.n{background:#2a3547}button.m{background:#9b59ff}button.o{background:#ff9f1a;color:#2a1700}
button.s{padding:5px 9px;font-size:12px}
.kart{display:grid;grid-template-columns:repeat(auto-fit,minmax(130px,1fr));gap:10px;margin:14px 0}
.kutu{background:#151c28;border-radius:12px;padding:12px}.kutu b{display:block;font-size:24px;color:#ffd54a}.kutu small{color:#8b97a8}
.satir{display:flex;gap:8px;flex-wrap:wrap;margin:10px 0;align-items:center}.satir input[type=text],.satir input[type=search],.satir input:not([type]){flex:1;min-width:140px}
.tablo{overflow-x:auto}table{width:100%;border-collapse:collapse;font-size:14px}th,td{padding:8px;border-bottom:1px solid #1f2837;text-align:left;white-space:nowrap}
.banli{color:#ff6b81}.on{color:#2ed573}#hata{color:#ff6b81;min-height:20px}
.gk{background:linear-gradient(90deg,#ff4757,#ffa502,#ffd32a,#2ed573,#1e90ff,#9b59ff,#ff4757);background-size:200% 100%;-webkit-background-clip:text;background-clip:text;color:transparent;-webkit-text-fill-color:transparent;animation:gk 3s linear infinite;font-weight:800}
@keyframes gk{to{background-position:200% 0}}
.bulut{font-size:13px;color:#8b97a8;margin:4px 0 0}.bulut b{color:#e8eef7}
.modal{position:fixed;inset:0;background:rgba(0,0,0,.65);display:none;align-items:center;justify-content:center;z-index:9;padding:16px}
.modal .ic{background:#151c28;border:1px solid #2a3547;border-radius:14px;padding:18px;max-width:380px;width:100%}
.modal h3{margin:0 0 12px;font-size:16px}.modal .satir{margin:8px 0}
.onizle{font-size:22px;margin:8px 0;min-height:30px}
.sifre-kutu{background:#0c1017;border:1px dashed #ffd54a;border-radius:8px;padding:10px;font:700 18px 'Courier New',monospace;color:#ffd54a;text-align:center;user-select:all;margin:10px 0}
.not{font-size:12px;color:#8b97a8;line-height:1.5}
</style></head><body>
<h1>⚽ NOXBALL Yönetim Paneli</h1>
<div id="giris"><div class="satir"><input id="key" type="password" placeholder="ADMIN_KEY"><button onclick="gir()">Giriş</button></div></div>
<div id="hata"></div>
<div id="panel" style="display:none">
<div class="kart" id="stat"></div>
<div class="bulut" id="bulut"></div>
<div class="satir">
<button class="g s" onclick="yedekAl()">☁ Şimdi buluta yedekle</button>
<button class="n s" onclick="yedekIndir()">⬇ Yedeği indir</button>
<button class="o s" onclick="document.getElementById('dosya').click()">⬆ Yedekten geri yükle</button>
<input type="file" id="dosya" accept=".json" style="display:none" onchange="geriYukle(this)">
</div>
<div class="satir"><input id="q" placeholder="Oyuncu ara…" oninput="yukle()"><button class="n" onclick="yukle();istat()">Yenile</button></div>
<div class="tablo"><table><thead><tr><th>Ad</th><th>Kupa</th><th>Maç</th><th>🪙</th><th>💎</th><th>Durum</th><th>İşlem</th></tr></thead><tbody id="liste"></tbody></table></div>
</div>
<!-- Renk penceresi -->
<div class="modal" id="renkM"><div class="ic">
<h3>Nick rengi: <span id="renkAd"></span></h3>
<div class="onizle" id="renkOn"></div>
<div class="satir"><input type="color" id="renkSec" value="#ffd54a" style="padding:2px;height:42px;width:60px" oninput="renkOnizle(this.value)">
<input id="renkHex" placeholder="#RRGGBB" maxlength="7" oninput="renkHexYaz()"></div>
<div class="satir">
<button class="m s" onclick="renkOnizle('gk')">🌈 Gökkuşağı</button>
<button class="n s" onclick="renkOnizle('')">Rengi kaldır</button>
</div>
<div class="satir"><button class="g" onclick="renkKaydet()">Kaydet</button><button class="n" onclick="kapatM('renkM')">İptal</button></div>
</div></div>
<!-- Şifre penceresi -->
<div class="modal" id="sifreM"><div class="ic">
<h3>Şifre sıfırla: <span id="sifreAd"></span></h3>
<p class="not">Şifreler güvenlik için <b>hash'lenerek</b> saklanır; geri okunamaz (düz metin tutmak, oyuncuların başka sitelerdeki şifrelerini de riske atar).
Bunun yerine buradan yeni şifre atayabilirsin. Boş bırakırsan rastgele şifre üretilir. Oyuncu oturumu kapanır.</p>
<div class="satir"><input id="sifreYeni" placeholder="Yeni şifre (boş = rastgele)" maxlength="64"></div>
<div id="sifreSonuc"></div>
<div class="satir"><button class="o" id="sifreBtn" onclick="sifreKaydet()">Şifreyi sıfırla</button><button class="n" onclick="kapatM('sifreM')">Kapat</button></div>
</div></div>
<script>
let KEY = sessionStorage.getItem('ak') || '';
const $ = id => document.getElementById(id);
const esc = s => String(s).replace(/[&<>"']/g, c => ({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]));
function nickHtml(ad, nr) {
if (nr === 'gk') return '<span class="gk">' + esc(ad) + '</span>';
if (/^#[0-9a-fA-F]{6}$/.test(nr || '')) return '<span style="color:' + nr + ';font-weight:800">' + esc(ad) + '</span>';
return esc(ad);
}
async function api(yol, govde) {
let r;
try { r = await fetch(yol, { method: govde ? 'POST' : 'GET', headers: { 'content-type': 'application/json', 'x-admin-key': KEY }, body: govde ? JSON.stringify(govde) : undefined }); }
catch (e) { $('hata').innerText = 'Sunucuya ulaşılamadı. Space çalışıyor mu? (' + e.message + ')'; throw e; }
if (r.status === 401) { $('hata').innerText = 'Yetkisiz: ADMIN_KEY yanlış ya da Space ayarlarında hiç tanımlı değil.'; $('panel').style.display = 'none'; $('giris').style.display = ''; throw new Error('yetkisiz'); }
if (r.status === 503) { $('hata').innerText = 'Sunucu veriyi yüklüyor, birkaç saniye sonra tekrar dene.'; throw new Error('503'); }
const d = await r.json().catch(() => ({}));
if (!r.ok) { const e = new Error(d.hata || ('http ' + r.status)); e.kod = d.hata; throw e; }
return d;
}
async function gir() {
KEY = $('key').value.trim(); sessionStorage.setItem('ak', KEY); $('hata').innerText = 'Bağlanıyor…';
try { await istat(); $('hata').innerText = ''; $('giris').style.display = 'none'; $('panel').style.display = ''; yukle(); } catch (e) {}
}
async function istat() {
const s = await api('/admin/stats');
$('stat').innerHTML = [['Toplam hesap', s.toplam], ['Çevrimiçi', s.cevrimici], ['Aktif maç', s.aktifMac], ['Son 24 saat', s.son24saat], ['Banlı', s.banli], ['RAM (MB)', s.bellekMB], ['Disk yedeği', s.disk ? 'AÇIK' : 'YOK']]
.map(a => '<div class="kutu"><b>' + a[1] + '</b><small>' + a[0] + '</small></div>').join('');
const b = s.bulut || {};
$('bulut').innerHTML = b.aktif
? '☁ Bulut yedeği: <b style="color:#2ed573">AÇIK</b> • son yedek: <b>' + (b.son ? new Date(b.son).toLocaleString('tr-TR') : 'henüz yok') + '</b>' + (b.bekliyor ? ' • <b style="color:#ffa502">değişiklik bekliyor</b>' : '') + (b.hata ? ' • <span class="banli">hata: ' + esc(b.hata) + '</span>' : '')
: '☁ Bulut yedeği: <b class="banli">KAPALI</b> — HF_TOKEN ve HF_DATASET tanımlı değil; Space yeniden başlarsa veri silinebilir!';
}
async function yukle() {
const d = await api('/admin/users?q=' + encodeURIComponent($('q').value));
$('liste').innerHTML = d.liste.map(u => { const n = esc(u.ad); return '<tr><td>' + nickHtml(u.ad, u.nr) + '</td><td>' + u.kupa + '</td><td>' + u.mac + '</td><td>' + u.altin + '</td><td>' + u.elmas + '</td><td>' +
(u.ban ? '<span class="banli">BANLI' + (u.ban.sebep ? ' (' + esc(u.ban.sebep) + ')' : '') + '</span>' : u.cevrimici ? '<span class="on">çevrimiçi</span>' : '-') + '</td><td>' +
(u.ban ? '<button class="g s" data-a="unban" data-n="' + n + '">Banı Kaldır</button>' : '<button class="k s" data-a="ban" data-n="' + n + '">Banla</button>') +
' <button class="n s" data-a="duz" data-n="' + n + '">Düzenle</button>' +
' <button class="m s" data-a="renk" data-n="' + n + '" data-r="' + esc(u.nr || '') + '">🎨 Renk</button>' +
' <button class="s" data-a="nick" data-n="' + n + '">✏ Nick</button>' +
' <button class="o s" data-a="sifre" data-n="' + n + '">🔑 Şifre</button>' +
' <button class="k s" data-a="sil" data-n="' + n + '">Sil</button></td></tr>'; }).join('');
}
function kapatM(id) { $(id).style.display = 'none'; }
function hataGoster(e) { if (e && e.kod) alert('İşlem başarısız: ' + e.kod); }
/* ---- renk ---- */
let renkAd = '', renkDeger = '';
function renkOnizle(v) {
renkDeger = v;
$('renkOn').innerHTML = v ? nickHtml(renkAd, v) : esc(renkAd);
if (/^#[0-9a-fA-F]{6}$/.test(v)) { $('renkSec').value = v; $('renkHex').value = v; } else if (!v) $('renkHex').value = '';
}
function renkHexYaz() { const v = $('renkHex').value.trim(); if (/^#[0-9a-fA-F]{6}$/.test(v)) renkOnizle(v); }
async function renkKaydet() {
try { await api('/admin/renk', { ad: renkAd, renk: renkDeger }); kapatM('renkM'); yukle(); } catch (e) { hataGoster(e); }
}
/* ---- şifre ---- */
let sifreAd = '';
async function sifreKaydet() {
try {
const d = await api('/admin/sifre', { ad: sifreAd, sifre: $('sifreYeni').value });
$('sifreSonuc').innerHTML = '<div class="not">Yeni şifre (bir daha gösterilmez, oyuncuya ilet):</div><div class="sifre-kutu">' + esc(d.sifre) + '</div>';
$('sifreBtn').style.display = 'none';
} catch (e) { hataGoster(e); }
}
/* ---- yedek ---- */
async function yedekAl() { try { await api('/admin/yedek-al', {}); alert('Buluta yedeklendi.'); istat(); } catch (e) { alert('Yedek alınamadı: ' + (e.message || '')); istat().catch(() => {}); } }
async function yedekIndir() {
const r = await fetch('/admin/yedek', { headers: { 'x-admin-key': KEY } });
if (!r.ok) { alert('İndirilemedi'); return; }
const b = await r.blob(), a = document.createElement('a');
a.href = URL.createObjectURL(b); a.download = 'noxball-db-' + new Date().toISOString().slice(0, 10) + '.json'; a.click();
setTimeout(() => URL.revokeObjectURL(a.href), 5000);
}
async function geriYukle(inp) {
const f = inp.files[0]; inp.value = ''; if (!f) return;
if (!confirm('DİKKAT: Şu anki TÜM veri, "' + f.name + '" dosyasındaki veriyle DEĞİŞTİRİLECEK. Devam edilsin mi?')) return;
try { const veri = JSON.parse(await f.text()); const d = await api('/admin/geri-yukle', { onay: 'EVET', veri }); alert(d.hesap + ' hesap geri yüklendi.'); yukle(); istat(); }
catch (e) { alert('Geri yükleme başarısız: ' + (e.message || '')); }
}
$('liste').addEventListener('click', async e => {
const b = e.target.closest('button'); if (!b) return; const ad = b.dataset.n, a = b.dataset.a;
try {
if (a === 'ban') { const s = prompt(ad + ' için ban sebebi:', ''); if (s === null) return; await api('/admin/ban', { ad, sebep: s }); }
else if (a === 'unban') await api('/admin/unban', { ad });
else if (a === 'sil') { if (!confirm(ad + ' hesabı KALICI olarak silinsin mi?')) return; await api('/admin/sil', { ad }); }
else if (a === 'duz') { const k = prompt('Yeni kupa (boş = değişmesin):'); const al = prompt('Yeni altın (boş = değişmesin):'); const el = prompt('Yeni elmas (boş = değişmesin):'); const o = { ad }; if (k) o.kupa = k; if (al) o.altin = al; if (el) o.elmas = el; await api('/admin/duzenle', o); }
else if (a === 'nick') { const y = prompt(ad + ' için yeni nick (3-16 karakter: harf, rakam, . _ -):', ad); if (!y || y === ad) return; await api('/admin/nick', { ad, yeni: y }); }
else if (a === 'renk') { renkAd = ad; renkOnizle(b.dataset.r || ''); $('renkAd').innerText = ad; $('renkM').style.display = 'flex'; return; }
else if (a === 'sifre') { sifreAd = ad; $('sifreAd').innerText = ad; $('sifreYeni').value = ''; $('sifreSonuc').innerHTML = ''; $('sifreBtn').style.display = ''; $('sifreM').style.display = 'flex'; return; }
} catch (er) { if (er.kod === 'ad_alinmis') alert('Bu nick başkası tarafından kullanılıyor.'); else if (er.kod === 'karakter') alert('Geçersiz nick.'); else hataGoster(er); }
yukle(); istat();
});
if (KEY) { $('key').value = KEY; gir().catch(() => {}); }
setInterval(() => { if ($('panel').style.display !== 'none') istat().catch(() => {}); }, 10000);
</script></body></html> |