Initial commit: OMSORG website + Mitarbeiter-App

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Felix Kemmler
2026-06-13 20:03:22 +02:00
co-authored by Claude Sonnet 4.6
commit 8beb0fcf52
103 changed files with 7384 additions and 0 deletions
+58
View File
@@ -0,0 +1,58 @@
<?php
require_once __DIR__ . '/../lib/auth.php';
require_once __DIR__ . '/../lib/upload.php';
require_login();
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
header('Location: ../pages/settings.php');
exit;
}
$back = '../pages/settings.php';
$username = current_username();
$user = current_user();
$dir = dirname(__DIR__) . '/assets/avatars/';
// Remove avatar
if (!empty($_POST['remove_avatar'])) {
if (!empty($user['avatar'])) {
$old = $dir . basename($user['avatar']);
if (is_file($old)) {
unlink($old);
}
}
db()->prepare('UPDATE users SET avatar = NULL WHERE username = ?')->execute([$username]);
redirect_ok($back, 'avatar_saved');
}
$up = handle_upload($_FILES['avatar'] ?? [], [
'allowed' => UPLOAD_TYPES_IMAGES,
'dir' => $dir,
'naming' => 'plain',
'max_bytes' => 3 * 1024 * 1024,
'messages' => [
'missing' => 'Bitte ein Bild auswählen.',
'upload' => 'Fehler beim Hochladen des Bildes.',
'ext' => 'Nur Bilder erlaubt (JPG, PNG, GIF, WebP).',
'mime' => 'Nur Bilder erlaubt (JPG, PNG, GIF, WebP).',
'size' => 'Bild ist zu groß (max. 3 MB).',
'move' => 'Fehler beim Speichern des Bildes.',
],
]);
if (!$up['ok']) {
redirect_error($back, $up['error']);
}
$safe_name = $up['filename'];
// Delete old avatar after successful upload
if (!empty($user['avatar'])) {
$old = $dir . basename($user['avatar']);
if (is_file($old)) {
unlink($old);
}
}
db()->prepare('UPDATE users SET avatar = ? WHERE username = ?')->execute([$safe_name, $username]);
redirect_ok($back, 'avatar_saved');