diff --git a/home-bg.php b/home-bg.php new file mode 100644 index 0000000..6da1d0e --- /dev/null +++ b/home-bg.php @@ -0,0 +1,18 @@ +'image/jpeg','jpeg'=>'image/jpeg','png'=>'image/png','webp'=>'image/webp'][$ext] ?? 'image/jpeg'; + +header('Content-Type: ' . $mime); +header('Cache-Control: private, max-age=3600'); +readfile($file); diff --git a/index.php b/index.php index 9f848c5..b7f4ada 100644 --- a/index.php +++ b/index.php @@ -15,7 +15,16 @@ $bodyClass = "pf-home"; // Important pour l'image de fond définie dans home.cs $pageCss = "/modules/home/home.css"; require __DIR__ . '/header.php'; -?> + +// Override background si image personnalisée uploadée +$_fid = $_SESSION['user']['family_id'] ?? null; +$_has_custom_bg = false; +if ($_fid) { + foreach (glob('/uploads/home_bg_' . $_fid . '.*') as $_f) { $_has_custom_bg = true; break; } +} +if ($_has_custom_bg): ?> + +
diff --git a/settings.php b/settings.php index 804ed92..5d49d7f 100644 --- a/settings.php +++ b/settings.php @@ -86,6 +86,32 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { ->execute([$new_code, $family_id]); $success = "Nouveau code d'invitation généré."; } + + if ($action === 'upload_home_bg' && $family_id) { + $upload_dir = '/uploads/'; + if (!is_dir($upload_dir)) @mkdir($upload_dir, 0755, true); + $file = $_FILES['home_bg'] ?? null; + if ($file && $file['error'] === 0) { + $ext = strtolower(pathinfo($file['name'], PATHINFO_EXTENSION)); + if (!in_array($ext, ['jpg','jpeg','png','webp'])) { + $error = "Format non supporté (jpg, png, webp)."; + } else { + $dest = $upload_dir . 'home_bg_' . $family_id . '.' . $ext; + // Supprimer anciens fichiers de ce family + foreach (glob($upload_dir . 'home_bg_' . $family_id . '.*') as $old) @unlink($old); + if (move_uploaded_file($file['tmp_name'], $dest)) { + $success = "Image d'accueil mise à jour."; + } else { + $error = "Erreur lors de l'upload."; + } + } + } + } + + if ($action === 'reset_home_bg' && $family_id) { + foreach (glob('/uploads/home_bg_' . $family_id . '.*') as $old) @unlink($old); + $success = "Image d'accueil réinitialisée."; + } } // ─── Chargement données ─────────────────────────────────────────────────────── @@ -181,6 +207,42 @@ require __DIR__ . '/header.php'; + + +
+

🖼️ Image d'accueil

+

Photo de fond affichée sur la page d'accueil (partagée avec tous les membres).

+ + +
+ Fond actuel + Image personnalisée +
+ + +
+ +
+ + +
+ +
+ + +
+ + +
+ +
+ +

👤 Mon profil