From be50ac5eb09d81caed39734e9ca6bac696dac848 Mon Sep 17 00:00:00 2001 From: Pontoporeia Date: Mon, 11 May 2026 03:18:03 +0200 Subject: [PATCH] fix(production): fix multiple remote server errors from nginx logs - Fix 413 Request Entity Too Large: bump client_max_body_size to 256M, PHP post_max_size/upload_max_filesize to 256M, fastcgi timeouts to 300s - Fix missing v_smtp_active view: add IF NOT EXISTS to all CREATE VIEW statements in schema.sql for idempotent migrates - Fix bars.svg 404: create animated SVG spinner in app/public/assets/img/ - Fix nginx rate limiting: increase admin zone from 60r/m (1 r/s) to 300r/m (5 r/s) with burst=30 to handle ~11 concurrent HTMX fragment GETs on contenus.php page load - Add deploy-nginx recipe to justfile for uploading nginx config to server - Database readonly issue mitigated by existing --chown + deploy-server.sh permissions fix - Add comprehensive PHP/JS debugging logs for settings checkboxes: per-field raw POST values in error_log, console.log on htmx:beforeSend, htmx:sendError, htmx:afterRequest, toast lifecycle - Fix toast auto-remove script: use getElementById with unique ID instead of querySelector which could remove wrong toast on rapid clicks --- TODO.md | 8 +++++++ app/public/admin/actions/settings.php | 33 +++++++++++++++++++++------ app/public/assets/img/bars.svg | 11 +++++++++ app/storage/schema.sql | 6 ++--- app/templates/admin/acces.php | 13 +++++++++++ app/templates/admin/contenus.php | 24 ++++++++++++++----- app/templates/admin/footer.php | 9 ++++++++ justfile | 13 +++++++++++ nginx/xamxam.conf | 32 ++++++++++++++------------ 9 files changed, 119 insertions(+), 30 deletions(-) create mode 100644 app/public/assets/img/bars.svg diff --git a/TODO.md b/TODO.md index 44cf614..b399708 100644 --- a/TODO.md +++ b/TODO.md @@ -5,6 +5,14 @@ - [x] Add `hx-target` response divs to the three fieldsets in contenus.php - [x] Update settings.php to return HTML toast on HTMX requests +## Production Error Fixes (2026-05-11 remote logs) + +- [x] **413 Request Entity Too Large** — bumped `client_max_body_size` to 256M, PHP post/upload to 256M, timeouts to 300s +- [x] **Missing `v_smtp_active` view** on server — made all `CREATE VIEW` statements idempotent with `IF NOT EXISTS` in schema.sql +- [x] **`bars.svg` 404** — created `app/public/assets/img/bars.svg` (animated SVG spinner) +- [x] **Nginx rate limiting too aggressive** — increased admin zone to 300r/m, burst=30 to handle ~11 concurrent HTMX fragment requests on contenus.php page load +- [ ] **Database readonly** — intermittent permission issue after deploy (added deploy-nginx recipe; permissions should be fixed by --chown + deploy-server.sh) + ## SQLite Backup & Data Integrity (docs/backup-plan.md) ### Phase 1 — WAL Mode diff --git a/app/public/admin/actions/settings.php b/app/public/admin/actions/settings.php index 367200f..e6e4d0a 100644 --- a/app/public/admin/actions/settings.php +++ b/app/public/admin/actions/settings.php @@ -6,6 +6,7 @@ AdminAuth::requireLogin(); if (!isset($_POST['csrf_token'], $_SESSION['csrf_token']) || !hash_equals($_SESSION['csrf_token'], $_POST['csrf_token'])) { + error_log('[settings.php] CSRF FAIL | session_token=' . ($_SESSION['csrf_token'] ?? 'none') . ' | post_token=' . ($_POST['csrf_token'] ?? 'none')); App::flash('error', "Erreur de sécurité : token invalide."); header('Location: /admin/parametres.php'); exit; @@ -27,29 +28,41 @@ error_log('[settings.php] PROCESS | section=' . $section . ' | post_keys=' . imp * The fragment auto-dismisses after 3 seconds via a script at the end. */ function hxToastSuccess(string $message): never { + $id = 'toast-' . bin2hex(random_bytes(4)); http_response_code(200); - echo '
' . + echo '
' . ' ' . htmlspecialchars($message) . '
' . - ''; + ''; exit; } function hxToastError(string $message): never { + $id = 'toast-' . bin2hex(random_bytes(4)); http_response_code(200); - echo '