File size: 13,628 Bytes
dc0d0b1
 
 
 
 
b18ba24
 
 
456e29d
dc0d0b1
456e29d
 
dc0d0b1
b18ba24
456e29d
b18ba24
456e29d
 
 
 
 
dc0d0b1
 
 
 
 
 
456e29d
45b0eb3
456e29d
dc0d0b1
b18ba24
 
 
 
 
dc0d0b1
c2a7f11
456e29d
 
 
c2a7f11
456e29d
c2a7f11
 
456e29d
 
 
 
c2a7f11
456e29d
c2a7f11
 
dc0d0b1
 
 
 
 
c2a7f11
 
 
 
456e29d
 
 
 
 
 
 
 
c2a7f11
 
 
b18ba24
dc0d0b1
 
 
45b0eb3
dc0d0b1
456e29d
 
 
 
45b0eb3
 
 
 
456e29d
 
 
dc0d0b1
 
 
b18ba24
dc0d0b1
456e29d
b18ba24
456e29d
b18ba24
456e29d
 
 
c2a7f11
b18ba24
 
 
 
 
 
 
 
 
 
 
 
456e29d
 
 
 
 
 
c2a7f11
456e29d
c2a7f11
 
456e29d
 
c2a7f11
456e29d
 
c2a7f11
456e29d
c2a7f11
dc0d0b1
 
c2a7f11
 
 
 
b18ba24
 
 
 
 
 
 
 
 
456e29d
 
 
 
 
 
 
dc0d0b1
 
 
b18ba24
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
<!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}h2{font-size:16px;margin:22px 0 8px}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.s{background:#a55eea}button.y{background:#ffa502;color:#1d1200}
button.m{padding:6px 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:22px;color:#ffd54a}.kutu small{color:#8b97a8}
.satir{display:flex;gap:8px;flex-wrap:wrap;margin:10px 0}.satir input{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}.bilgi{color:#8b97a8;font-size:12px;margin:6px 0}.uyari{color:#ffa502;font-size:12px;margin:6px 0}
.gok{background:linear-gradient(90deg,#ff4757,#ffa502,#ffd32a,#2ed573,#1e90ff,#a55eea);-webkit-background-clip:text;background-clip:text;color:transparent;font-weight:800}
.et{color:#8b97a8;font-size:12px;margin-right:4px}
.perde{position:fixed;inset:0;background:rgba(0,0,0,.65);display:none;align-items:center;justify-content:center;z-index:9}
.kutuM{background:#151c28;border:1px solid #2a3547;border-radius:14px;padding:18px;width:min(360px,92vw)}
.kutuM h3{margin:0 0 12px;font-size:16px}.kutuM .satir{margin:12px 0 0}
#renkInp{width:64px;height:44px;padding:2px}.onizle{font-size:20px;margin:10px 0;min-height:28px}
.sf{font-family:monospace;font-size:22px;color:#ffd54a;user-select:all;background:#0c1017;padding:10px;border-radius:8px;text-align:center;margin:10px 0}
</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="bilgi" id="bulutBilgi"></div>
  <div class="uyari" id="macBilgi"></div>
  <div class="satir"><input id="q" placeholder="Oyuncu ara…" oninput="yukle()"><button class="n" onclick="yukle();istat()">Yenile</button><button class="g" onclick="yedekle()">☁ Şimdi yedekle</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 class="bilgi">Şifreler tek yönlü şifrelenmiş (hash) saklanır, görüntülenemez. Unutan oyuncuya "Şifre" butonuyla yeni şifre belirleyip iletebilirsin. "Düzenle" ile kupa/altın/elmas değiştirince oyuncuda anında güncellenir ve "Admin şunu değiştirdi" bildirimi çıkar.</div>

  <h2>🛡 Klanlar</h2>
  <div class="satir"><button class="n" onclick="klanYukle()">Klan listesini yenile</button></div>
  <div class="tablo"><table><thead><tr><th>#</th><th>Etiket</th><th>Ad</th><th>Lider</th><th>Üye</th><th>🏆 Toplam</th><th>İşlem</th></tr></thead><tbody id="klanListe"></tbody></table></div>
</div>

<div class="perde" id="renkM"><div class="kutuM">
  <h3 id="renkBaslik">Nick rengi</h3>
  <div class="satir" style="margin-top:0"><input type="color" id="renkInp" value="#ff4757"><button class="s" onclick="renkSec('rainbow')">🌈 Gökkuşağı</button><button class="n" onclick="renkSec('')">Rengi kaldır</button></div>
  <div class="onizle" id="renkOn"></div>
  <div class="satir"><button class="g" onclick="renkKaydet()">Kaydet</button><button class="n" onclick="mKapat('renkM')">İptal</button></div>
</div></div>

<div class="perde" id="sifreM"><div class="kutuM">
  <h3 id="sifreBaslik">Şifre belirle</h3>
  <div class="bilgi">Boş bırakırsan rastgele güçlü bir şifre üretilir. Oyuncunun açık oturumları kapanır.</div>
  <div class="satir"><input id="yeniSifre" placeholder="Yeni şifre (en az 6)"></div>
  <div id="sifreSonuc"></div>
  <div class="satir"><button class="g" id="sifreBtn" onclick="sifreKaydet()">Uygula</button><button class="n" onclick="mKapat('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 => ({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[c]));
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.ok) { let h = ''; try { h = (await r.json()).hata || ''; } catch (_) {} const e = new Error(h || 'http ' + r.status); e.kod = r.status; e.hata = h; throw e; }
  return r.json();
}
/* nick gösterimi: renk '#rrggbb' | 'rainbow' | '' */
function nickHtml(ad, nr) {
  if (nr === 'rainbow') return '<span class="gok">' + esc(ad) + '</span>';
  if (/^#[0-9a-fA-F]{6}$/.test(nr || '')) return '<span style="color:' + nr + ';font-weight:700">' + esc(ad) + '</span>';
  return esc(ad);
}
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(); klanYukle(); } catch (e) {}
}
async function istat() {
  const s = await api('/admin/stats');
  $('stat').innerHTML = [['Toplam hesap', s.toplam], ['Çevrimiçi', s.cevrimici], ['Maç arayan', s.aramada], ['Aktif maç', s.aktifMac], ['Klan', s.klan], ['Son 24 saat', s.son24saat], ['Banlı', s.banli], ['RAM (MB)', s.bellekMB], ['Bulut yedeği', s.bulut], ['Maç sunucusu', s.macSunucu]]
    .map(a => '<div class="kutu"><b>' + a[1] + '</b><small>' + a[0] + '</small></div>').join('');
  let b = s.bulut === 'AÇIK' ? '☁ Son bulut yedeği: ' + (s.bulutSon ? new Date(s.bulutSon).toLocaleString('tr-TR') : 'henüz alınmadı (değişiklik olunca 2 dk içinde alınır)')
        : s.bulut === 'YOK' ? '⚠ Bulut yedeği KAPALI: Space > Settings > Secrets içine HF_TOKEN (Write yetkili) ekle, yoksa yeni sürümde veriler silinir.'
        : '⚠ Bulut yedeğine bağlanılamadı: ' + esc(s.bulutHata || '');
  $('bulutBilgi').innerHTML = b;
  $('macBilgi').innerHTML = s.macSunucu === 'AYARSIZ'
      ? '⚠ Maç sunucusu ayarsız: Space > Settings içine MAC_SECRET (Secret) ve RENDER_URL (Variable) ekle. Yoksa online maçlar ÇALIŞMAZ. (MAC_SECRET: ' + (s.macSecret ? 'var' : 'YOK') + ', RENDER_URL: ' + (s.renderUrl ? 'var' : 'YOK') + ')'
    : s.macSunucu === 'ULAŞILAMADI' ? '⚠ Render maç sunucusuna ulaşılamadı (uyuyor olabilir, ilk istek ~50 sn sürebilir): ' + esc(s.macSunucuHata || '')
    : '';
}
async function yedekle() {
  try { const r = await api('/admin/yedekle', {}); alert(r.ok ? 'Bulut yedeği alındı ✔' : 'Yedek alınamadı: ' + (r.hata || r.bulut)); istat(); } catch (e) { alert('Hata: ' + e.message); }
}
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>' + (u.adm ? '👑 ' : '') + (u.klan ? '<span class="et">[' + esc(u.klan) + ']</span>' : '') + 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 m" data-a="unban" data-n="' + n + '">Banı Kaldır</button>' : '<button class="k m" data-a="ban" data-n="' + n + '">Banla</button>') +
    ' <button class="n m" data-a="duz" data-n="' + n + '" data-k="' + u.kupa + '" data-al="' + u.altin + '" data-e="' + u.elmas + '">Düzenle</button>' +
    ' <button class="s m" data-a="renk" data-n="' + n + '" data-r="' + esc(u.nr || '') + '">🎨 Renk</button>' +
    ' <button class="' + (u.adm ? 'y' : 'n') + ' m" data-a="yetkili" data-n="' + n + '" data-v="' + (u.adm ? 0 : 1) + '">👑 ' + (u.adm ? 'Admin✔' : 'Admin') + '</button>' +
    ' <button class="n m" data-a="nick" data-n="' + n + '">✏ Nick</button>' +
    ' <button class="n m" data-a="sifre" data-n="' + n + '">🔑 Şifre</button>' +
    ' <button class="k m" data-a="sil" data-n="' + n + '">Sil</button></td></tr>'; }).join('');
}
async function klanYukle() {
  try {
    const d = await api('/admin/klanlar');
    $('klanListe').innerHTML = d.liste.map(k => '<tr><td>' + k.sira + '</td><td>' + esc(k.et) + '</td><td>' + esc(k.ad) + '</td><td>' + esc(k.lider) + '</td><td>' + k.say + '</td><td>' + k.puan + '</td><td><button class="k m" data-id="' + esc(k.id) + '" data-n="' + esc(k.ad) + '">Klanı Sil</button></td></tr>').join('') || '<tr><td colspan="7" class="bilgi">Henüz klan yok.</td></tr>';
  } catch (e) {}
}
$('klanListe').addEventListener('click', async e => {
  const b = e.target.closest('button'); if (!b) return;
  if (!confirm('"' + b.dataset.n + '" klanı silinsin mi? (üyeler klansız kalır)')) return;
  try { await api('/admin/klan-sil', { id: b.dataset.id }); } catch (er) { alert('Hata: ' + er.message); return; }
  klanYukle(); yukle(); istat();
});
let HEDEF = '', RENK = '';
function mAc(id) { $(id).style.display = 'flex'; }
function mKapat(id) { $(id).style.display = 'none'; }
function renkOnizle() { $('renkOn').innerHTML = RENK ? nickHtml(HEDEF, RENK) : '<span style="color:#8b97a8">' + esc(HEDEF) + ' (renksiz)</span>'; }
function renkSec(r) { RENK = r; if (/^#/.test(r)) $('renkInp').value = r; renkOnizle(); }
$('renkInp').addEventListener('input', e => { RENK = e.target.value; renkOnizle(); });
async function renkKaydet() {
  try { await api('/admin/renk', { ad: HEDEF, renk: RENK }); mKapat('renkM'); yukle(); } catch (e) { alert('Renk kaydedilemedi: ' + e.message); }
}
async function sifreKaydet() {
  const s = $('yeniSifre').value.trim();
  if (s && s.length < 6) { alert('Şifre en az 6 karakter olmalı.'); return; }
  try {
    const r = await api('/admin/sifre', { ad: HEDEF, sifre: s });
    $('sifreSonuc').innerHTML = '<div class="bilgi">' + esc(HEDEF) + ' için yeni şifre (oyuncuya ilet):</div><div class="sf">' + esc(r.sifre) + '</div>';
    $('sifreBtn').style.display = 'none';
  } catch (e) { alert('Şifre değiştirilemedi: ' + 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(ad + ' • yeni kupa (şu an ' + b.dataset.k + '):', b.dataset.k); if (k === null) return;
      const al = prompt(ad + ' • yeni altın (şu an ' + b.dataset.al + '):', b.dataset.al); if (al === null) return;
      const el = prompt(ad + ' • yeni elmas (şu an ' + b.dataset.e + '):', b.dataset.e); if (el === null) return;
      const o = { ad }; if (k !== '') o.kupa = k; if (al !== '') o.altin = al; if (el !== '') o.elmas = el;
      const r = await api('/admin/duzenle', o);
      if (!r.degisen) alert('Değişen bir değer yok.');
    }
    else if (a === 'yetkili') await api('/admin/yetkili', { ad, admin: b.dataset.v === '1' });
    else if (a === 'renk') { HEDEF = ad; RENK = b.dataset.r || ''; $('renkBaslik').innerText = ad + ' • nick rengi'; if (/^#/.test(RENK)) $('renkInp').value = RENK; renkOnizle(); mAc('renkM'); return; }
    else if (a === 'nick') {
      const y = prompt(ad + ' için yeni nick (3-16 karakter: harf, rakam, . _ -):', ad); if (!y || y === ad) return;
      try { await api('/admin/nick', { ad, yeni: y.trim() }); } catch (er) { alert(er.hata === 'ad_alinmis' ? 'Bu nick başkası tarafından kullanılıyor.' : er.hata === 'karakter' ? 'Nick geçersiz karakter içeriyor ya da uzunluğu uygun değil.' : 'Hata: ' + er.message); return; }
    }
    else if (a === 'sifre') { HEDEF = ad; $('sifreBaslik').innerText = ad + ' • şifre belirle'; $('yeniSifre').value = ''; $('sifreSonuc').innerHTML = ''; $('sifreBtn').style.display = ''; mAc('sifreM'); return; }
  } catch (er) { alert('Hata: ' + er.message); return; }
  yukle(); istat();
});
if (KEY) { $('key').value = KEY; gir().catch(() => {}); }
setInterval(() => { if ($('panel').style.display !== 'none') { istat().catch(() => {}); yukle().catch(() => {}); } }, 10000);
</script></body></html>