LuminaWebsite/includes/settings.php
Maaxxs e4f23fcde4 Audit log, abuse protection, gallery comments with moderation, safe image uploads, 404 page
- Audit log: every admin_log entry is also stored permanently in the database (admin/audit.php, audit.view)
- Rate limits per account, login throttling per IP (not per account), emergency lock after mass deletions, force logout / lock in user management
- Comments under gallery pictures (picture page, report button, owner can disable them)
- Moderation: new members, links, reported content and a "moderate everything" switch go to the approval list (moderation.php)
- Every uploaded image is re-encoded (strips appended code and EXIF data)
- Custom 404 page, also shown for pages without permission

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-21 21:57:34 +02:00

57 lines
1.9 KiB
PHP

<?php
declare(strict_types=1);
/**
* Einstellungen der Website, die die Leitung in der Oberflaeche aendert (Tabelle settings).
* Fehlt ein Eintrag, gilt der Standardwert aus dem Code.
*/
// Einstellungen, die ueber admin/settings_action.php geaendert werden duerfen: Schluessel => Standardwert.
const SETTINGS_DEFAULTS = [
'discord_unlink_allowed' => '1',
'contributions_history_public' => '1',
// Moderation: alle neuen Bilder/Kommentare warten auf Freigabe (z.B. bei einer Spam-Welle)
'moderation_all' => '0',
];
// Wer eine Einstellung aendern darf und wohin es danach zurueckgeht.
const SETTINGS_ACCESS = [
'discord_unlink_allowed' => ['users.edit', '/admin/users.php'],
'contributions_history_public' => ['contributions.manage', '/contributions.php#verlauf'],
'moderation_all' => ['comments.moderate', '/moderation.php'],
];
function setting_get(string $key): string
{
static $cache = null;
if ($cache === null) {
$cache = [];
try {
foreach (db()->query('SELECT `key`, value FROM settings')->fetchAll() as $row) {
$cache[$row['key']] = (string) $row['value'];
}
} catch (PDOException $e) {
// Tabelle (noch) nicht vorhanden - Standardwerte verwenden.
}
}
return $cache[$key] ?? (SETTINGS_DEFAULTS[$key] ?? '');
}
function setting_set(string $key, string $value): void
{
db()->prepare('INSERT INTO settings (`key`, value) VALUES (?, ?) ON DUPLICATE KEY UPDATE value = VALUES(value)')
->execute([$key, $value]);
}
/** Ist der Verlauf der Lumipunkte fuer alle sichtbar oder nur fuer contributions.manage? */
function contributions_history_public(): bool
{
return setting_get('contributions_history_public') === '1';
}
/** Duerfen Mitglieder ihre Discord-Verknuepfung selbst loesen? */
function discord_unlink_allowed(): bool
{
return setting_get('discord_unlink_allowed') === '1';
}