Sicherheit: - Bulk-Erstellung serverseitig auf eingeloggte Nutzer beschränkt; expire_minutes wird validiert (anonym: nur Default/Template-Werte, eingeloggt: max. 1 Jahr) - IP-basiertes Rate-Limit über neue Tabelle request_throttle (Voucher-Erstellung + Passwort-Reset-Anfragen), Session-Fallback für Alt-Installationen; Migration 0002 - session_regenerate_id() nach Login, Secure-Cookie-Flag bei HTTPS - Admin-/Aktiv-Status wird pro Request live aus der DB geprüft (Rechteentzug & Deaktivierung wirken sofort); Schutz vor Selbst-Degradierung im Benutzer-Edit - Alle state-ändernden Admin-Aktionen von GET auf POST umgestellt (kein CSRF-Token mehr in URLs) - login_simple.php (Legacy, Debug-Leak) entfernt; cron_test.php nur noch für Admins; .htaccess auf Apache-2.4-Syntax inkl. cron_test.php - M365 Client Secret wird nicht mehr ins Formular zurückgegeben - Updater: Zip-Slip-/Pfad-Traversal-Schutz, Backup vor dem Anwenden mit automatischem Rollback bei Fehlern, AuditLogger-Bug behoben - cron_sync: Token-Vergleich mit hash_equals; login_attempts-Pruning - CSV-Export gegen Excel-Formula-Injection abgesichert Bugfixes: - M365-Login: Fallback auf userPrincipalName, wenn Graph kein 'mail' liefert (Nutzer ohne Exchange-Postfach konnten sich nie anmelden) - PRG-Pattern überall: F5 erzeugt keine Duplikat-Voucher und wiederholt keine Admin-Aktionen (Session-Flash-Messages) - QR-Code nicht mehr invertiert (schwarz auf weiß, scanbar) - Bulk-Erstellung nutzt den UniFi 'n'-Parameter: 1 API-Call statt n× Login + Voucherlisten-Abruf; exaktes Code-Matching per create_time statt "global neuester Voucher" - Mailer: doppelte Zeilenumbrüche behoben, AUTH nur mit Credentials, SMTP-Dot-Stuffing, CLI-sicherer EHLO-Host - forgot_password: System-URL-Auto-Detect (Reset-Link war sonst relativ/kaputt) + Rate-Limit - Audit-Log-Labels an tatsächliche Action-Keys angepasst; Voucher-Erstellung (einzeln & bulk) wird jetzt auditiert - Site-Edit testet die Verbindung auch ohne Passwortänderung UX/UI: - Alert-/Badge-Styles zentral in global.css mit Dark-Mode-Variablen (vorher 7× dupliziert mit hart codierten Hellfarben) - Sticky-Formulare + Tab-Erhalt nach Validierungsfehlern (Bulk), Settings kehren nach dem Speichern zum aktiven Tab zurück - Gültigkeit menschenlesbar (z.B. "8 Stunden" statt "480 Minuten") - Voucher-Name-Default "Gast/Guest" im öffentlichen Modus - Favicon auch auf Login-/öffentlichen Seiten - Verbindungstest-Button pro Site-Karte (Health-Check) - i18n-Pass: Confirm-Dialoge, Toasts, Fehl-/Erfolgsmeldungen in de/en - Sprachumschalter ohne fetch+reload (kein Re-Submit-Dialog) - A11y: Esc schließt Modals, aria-live für Toasts, aria-labels auf Icon-Buttons; APP_KEY-Warnbanner im Dashboard - Dashboard-Sync: set_time_limit passend zur Site-Anzahl; Voucher-Sync mit Map statt SELECT pro Voucher Tooling: - GitHub-Actions-Workflow: PHP-Lint aller Dateien + de/en-Key-Parität https://claude.ai/code/session_01KKVpVPJjrTKGoRgpJcySD4
128 lines
4.3 KiB
JavaScript
128 lines
4.3 KiB
JavaScript
/* === DARK MODE === */
|
||
(function() {
|
||
const saved = localStorage.getItem('theme') || 'light';
|
||
document.documentElement.setAttribute('data-theme', saved);
|
||
})();
|
||
|
||
function toggleDarkMode() {
|
||
const html = document.documentElement;
|
||
const current = html.getAttribute('data-theme') || 'light';
|
||
const next = current === 'dark' ? 'light' : 'dark';
|
||
html.setAttribute('data-theme', next);
|
||
localStorage.setItem('theme', next);
|
||
updateDarkModeBtn();
|
||
}
|
||
|
||
function updateDarkModeBtn() {
|
||
const btn = document.getElementById('darkModeBtn');
|
||
if (!btn) return;
|
||
const isDark = document.documentElement.getAttribute('data-theme') === 'dark';
|
||
btn.textContent = isDark ? '☀️' : '🌙';
|
||
btn.title = isDark ? 'Light Mode' : 'Dark Mode';
|
||
}
|
||
|
||
document.addEventListener('DOMContentLoaded', updateDarkModeBtn);
|
||
|
||
/* === TOAST NOTIFICATIONS === */
|
||
(function() {
|
||
let container = null;
|
||
|
||
function getContainer() {
|
||
if (!container) {
|
||
container = document.getElementById('toast-container');
|
||
if (!container) {
|
||
container = document.createElement('div');
|
||
container.id = 'toast-container';
|
||
document.body.appendChild(container);
|
||
}
|
||
// Screenreader ueber neue Toasts informieren
|
||
container.setAttribute('role', 'status');
|
||
container.setAttribute('aria-live', 'polite');
|
||
}
|
||
return container;
|
||
}
|
||
|
||
const icons = {
|
||
success: '✓',
|
||
error: '✕',
|
||
info: 'ℹ',
|
||
warning: '⚠'
|
||
};
|
||
|
||
window.showToast = function(type, title, message, duration) {
|
||
duration = duration || 4000;
|
||
const c = getContainer();
|
||
const el = document.createElement('div');
|
||
el.className = 'toast ' + type;
|
||
el.innerHTML = `
|
||
<span class="toast-icon">${icons[type] || 'ℹ'}</span>
|
||
<div class="toast-body">
|
||
<div class="toast-title">${title}</div>
|
||
${message ? `<div class="toast-msg">${message}</div>` : ''}
|
||
</div>
|
||
<button class="toast-close" onclick="this.parentElement.remove()">×</button>
|
||
`;
|
||
c.appendChild(el);
|
||
requestAnimationFrame(() => {
|
||
requestAnimationFrame(() => el.classList.add('show'));
|
||
});
|
||
setTimeout(() => {
|
||
el.classList.remove('show');
|
||
setTimeout(() => el.remove(), 350);
|
||
}, duration);
|
||
return el;
|
||
};
|
||
})();
|
||
|
||
/* === MOBILE SIDEBAR === */
|
||
function toggleMobileSidebar() {
|
||
const sidebar = document.querySelector('.sidebar');
|
||
const overlay = document.querySelector('.sidebar-overlay');
|
||
if (!sidebar) return;
|
||
sidebar.classList.toggle('mobile-open');
|
||
if (overlay) overlay.classList.toggle('active');
|
||
}
|
||
|
||
function closeMobileSidebar() {
|
||
const sidebar = document.querySelector('.sidebar');
|
||
const overlay = document.querySelector('.sidebar-overlay');
|
||
if (sidebar) sidebar.classList.remove('mobile-open');
|
||
if (overlay) overlay.classList.remove('active');
|
||
}
|
||
|
||
document.addEventListener('DOMContentLoaded', function() {
|
||
const overlay = document.querySelector('.sidebar-overlay');
|
||
if (overlay) overlay.addEventListener('click', closeMobileSidebar);
|
||
|
||
document.addEventListener('keydown', function(e) {
|
||
if (e.key === 'Escape') {
|
||
closeMobileSidebar();
|
||
// Offene Modals per Esc schliessen (Accessibility)
|
||
document.querySelectorAll('.modal.active').forEach(m => m.classList.remove('active'));
|
||
}
|
||
});
|
||
});
|
||
|
||
/* === LANGUAGE SWITCHER === */
|
||
function switchLanguage(lang) {
|
||
// Direkter Navigationswechsel statt fetch+reload: vermeidet den
|
||
// "Formular erneut senden?"-Dialog und erhaelt bestehende URL-Parameter.
|
||
const url = new URL(window.location.href);
|
||
url.searchParams.set('set_lang', lang);
|
||
window.location.href = url.toString();
|
||
}
|
||
|
||
/* === CLIPBOARD === */
|
||
function copyToClipboard(text, successMsg) {
|
||
navigator.clipboard.writeText(text).then(() => {
|
||
showToast('success', successMsg || 'Kopiert!', '');
|
||
}).catch(() => {
|
||
const ta = document.createElement('textarea');
|
||
ta.value = text;
|
||
document.body.appendChild(ta);
|
||
ta.select();
|
||
document.execCommand('copy');
|
||
document.body.removeChild(ta);
|
||
showToast('success', successMsg || 'Kopiert!', '');
|
||
});
|
||
}
|