From 4446224c19648c9dcda635c11ede0337f22cb08b Mon Sep 17 00:00:00 2001 From: andre Date: Fri, 9 Oct 2026 19:41:01 +0100 Subject: [PATCH] feat(settings): save uploaded logos to uploads/public/logo Co-Authored-By: Claude Sonnet 5.5 --- CLAUDE.md | 2 +- views/sysadmin/system_settings.php | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 0a2f3bb..f385e30 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -131,4 +131,4 @@ or adapted for production, and these accounts must never exist in a production d ## Brand feed (2026-10-09) - `api/brand.php` is a one-line stub to `shared/platform-tools/api/brand.php` (public JSON: name, logos, colours; README "Brand feed"). Declared in `platform_connect(['brand' => ...])` in `config/db.php`; colours are the `:root` tokens (`--fitme-accent` #c2d500, `--fitme-dark` #0b0b0d, `--fitme-accent-dark` #a6b600). `logo_light` = light-coloured logo (`logo_crossfit_white.svg`), `logo_dark` = `logo_crossfit.svg`. -- `site_logo_rel()` (config/functions.php) resolves logos for both the feed and `load_email_template()`: setting file in `uploads/public/logo/` (convention), then legacy `assets/img/logo/`, then the static logo. Gotcha: `views/sysadmin/system_settings.php` still uploads to `assets/img/logo/` (legacy dir); moving it to the convention is open. +- `site_logo_rel()` (config/functions.php) resolves logos for both the feed and `load_email_template()`: setting file in `uploads/public/logo/` (convention), then legacy `assets/img/logo/`, then the static logo. `views/sysadmin/system_settings.php` now uploads logos to `uploads/public/logo/` (dir created on demand, 0755; `uploads/.htaccess` blocks script execution); old files in `assets/img/logo/` still resolve as fallback and in the settings preview. Brand block in `config/db.php` already prefers the setting file via `site_logo_rel()`, else the static SVGs. diff --git a/views/sysadmin/system_settings.php b/views/sysadmin/system_settings.php index 3b31a7f..7bfb019 100644 --- a/views/sysadmin/system_settings.php +++ b/views/sysadmin/system_settings.php @@ -3,7 +3,7 @@ require __DIR__ . '/../../config/db.php'; require __DIR__ . '/../../config/functions.php'; $user = require_sysadmin(); // zona de sysadmin: o link só aparece a sysadmin e o servidor tem de concordar -$logo_dir = __DIR__ . '/../../assets/img/logo/'; +$logo_dir = __DIR__ . '/../../uploads/public/logo/'; // convenção da plataforma (uploads/.htaccess bloqueia PHP) $allowed_ext = ['png', 'jpg', 'jpeg', 'svg', 'webp']; $max_upload = 2 * 1024 * 1024; // 2 MB $errors = []; @@ -61,6 +61,10 @@ function _settings_handle_logo_upload(array $file, string $dir, array $allowed, $errors[] = "Tipo de ficheiro não permitido (ou SVG com conteúdo ativo) para o logo {$kind}."; return null; } + if (!is_dir($dir) && !@mkdir($dir, 0755, true) && !is_dir($dir)) { + $errors[] = "Não foi possível criar a pasta do logo {$kind}."; + return null; + } $name = bin2hex(random_bytes(16)) . '.' . $ext; if (!move_uploaded_file($file['tmp_name'], $dir . $name)) { $errors[] = "Não foi possível guardar o logo {$kind}."; @@ -166,7 +170,7 @@ include __DIR__ . '/../../includes/navbar.php';
- Logo claro + Logo claro
@@ -176,7 +180,7 @@ include __DIR__ . '/../../includes/navbar.php';
- Logo escuro + Logo escuro