From 16afec30392a2268adfc3c68bbde837e152e2f02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drix?= Date: Fri, 15 May 2026 09:40:10 +0200 Subject: [PATCH 1/4] =?UTF-8?q?fix=20:=20APP=5FTIMEZONE=20configurable=20(?= =?UTF-8?q?d=C3=A9faut=20Europe/Paris),=20FOLIO=5FREPO=5FURL=20dans=20.env?= =?UTF-8?q?.example?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- .env.example | 7 +++++++ bootstrap.php | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/.env.example b/.env.example index 478ec7b..bfab55f 100644 --- a/.env.example +++ b/.env.example @@ -6,6 +6,7 @@ APP_URL=https://example.com APP_ENV=prod APP_DEBUG=0 +APP_TIMEZONE=Europe/Paris # Authentification admin (email de l'administrateur principal) ADMIN_EMAIL= @@ -40,6 +41,12 @@ SMTP_FROM_NAME= CONTACT_EMAIL= CONTACT_FROM_EMAIL= +# Dépôt Folio pour le vérificateur de mises à jour (UpdateChecker) +# URL de base du dépôt Gitea (sans slash final) +FOLIO_REPO_URL=https://git.abonnel.fr/cedricAbonnel/folio +# Branche suivie pour les mises à jour (défaut : main) +# FOLIO_UPDATE_BRANCH=main + # Chemin absolu vers le répertoire des articles (data/) # Par défaut : BASE_PATH/data (dans le répertoire de l'application) # Recommandé en production : chemin hors du répertoire web, ex. /srv/data/folio diff --git a/bootstrap.php b/bootstrap.php index adc19e1..66bc054 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -6,6 +6,10 @@ if (!defined('BASE_PATH')) { define('BASE_PATH', __DIR__); } +$__tz = $_ENV['APP_TIMEZONE'] ?? getenv('APP_TIMEZONE') ?: 'Europe/Paris'; +date_default_timezone_set($__tz); +unset($__tz); + if (!defined('DATA_PATH')) { $__dataPath = $_ENV['DATA_PATH'] ?? getenv('DATA_PATH') ?: ''; define('DATA_PATH', $__dataPath !== '' ? rtrim($__dataPath, '/') : BASE_PATH . '/data'); From a552f105cddacb9f1d0cc00b6fd774abe6f3ec77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drix?= Date: Fri, 15 May 2026 09:42:30 +0200 Subject: [PATCH 2/4] =?UTF-8?q?fix=20:=20masquer=20bouton=20V=C3=A9rifier?= =?UTF-8?q?=20si=20FOLIO=5FREPO=5FURL=20non=20configur=C3=A9,=20message=20?= =?UTF-8?q?explicatif?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- templates/admin.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/templates/admin.php b/templates/admin.php index 73c19da..f67f3be 100644 --- a/templates/admin.php +++ b/templates/admin.php @@ -106,6 +106,7 @@ function adminStatusBadge(array $a, int $now): string $_notices = isset($_updateChecker) ? $_updateChecker->adminNotices() : []; $_branch = isset($_updateChecker) ? $_updateChecker->getBranch() : 'main'; $_lastChecked = isset($_updateChecker) ? $_updateChecker->getLastChecked() : null; + $_repoConfigured = (($_ENV['FOLIO_REPO_URL'] ?? getenv('FOLIO_REPO_URL') ?: '') !== ''); $_remoteLabel = '—'; foreach ($_notices as $_n) { if ($_n['type'] === 'info' && preg_match('/v([\d]+\.[\d]+\.[\d]+)/', $_n['message'], $_m)) { @@ -126,9 +127,13 @@ function adminStatusBadge(array $a, int $now): string Dernière version disponible Mise à jour disponible' : '' ?> +
+ + (FOLIO_REPO_URL non configuré) + From 4b5943c0a4b19eca886180a74d1f14d11a36fd35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drix?= Date: Fri, 15 May 2026 09:44:52 +0200 Subject: [PATCH 3/4] feat : FOLIO_REPO_URL et branche configurables depuis l'admin (dashboard) Co-Authored-By: Claude Sonnet 4.6 --- public/index.php | 16 +++++++++++++++- src/SiteSettings.php | 20 +++++++++++++++++++- src/UpdateChecker.php | 4 ++-- templates/admin.php | 29 ++++++++++++++++++++++++++++- 4 files changed, 64 insertions(+), 5 deletions(-) diff --git a/public/index.php b/public/index.php index 4b2b797..168437d 100644 --- a/public/index.php +++ b/public/index.php @@ -45,7 +45,7 @@ $action = $_GET['action'] ?? 'list'; $uuid = $_GET['uuid'] ?? ''; $slug = $_GET['slug'] ?? ''; -$_noindexActions = ['create', 'edit', 'admin', 'categories', 'diff', 'add_files', 'import_image', 'import_image_step2', 'sources', 'profile', 'delete_file', 'delete_external_link', 'rename_category', 'delete_category', 'toggle_private_category', 'admin_save_site', 'not_found', 'add_feed', 'delete_feed', 'add_link', 'delete_link', 'reorder_links', 'react', 'comment', 'verify_comment', 'comment_moderate', 'comment_delete', 'comment_resend', 'create_tag_type', 'delete_tag_type', 'edit_tags', 'book_save', 'book_delete', 'admin_save_as_groups']; +$_noindexActions = ['create', 'edit', 'admin', 'categories', 'diff', 'add_files', 'import_image', 'import_image_step2', 'sources', 'profile', 'delete_file', 'delete_external_link', 'rename_category', 'delete_category', 'toggle_private_category', 'admin_save_site', 'not_found', 'add_feed', 'delete_feed', 'add_link', 'delete_link', 'reorder_links', 'react', 'comment', 'verify_comment', 'comment_moderate', 'comment_delete', 'comment_resend', 'create_tag_type', 'delete_tag_type', 'edit_tags', 'book_save', 'book_delete', 'admin_save_as_groups', 'admin_save_folio_config']; $metaRobots = in_array($action, $_noindexActions, true) ? 'noindex, nofollow' : null; unset($_noindexActions); @@ -2826,6 +2826,20 @@ switch ($action) { header('Location: /admin?tab=dashboard'); exit; + case 'admin_save_folio_config': + requireAuth(); + if (!isAdmin() || $_SERVER['REQUEST_METHOD'] !== 'POST') { + http_response_code(403); + exit; + } + $ok = saveSiteSettings([ + 'folio_repo_url' => $_POST['folio_repo_url'] ?? '', + 'folio_update_branch' => $_POST['folio_update_branch'] ?? '', + ]); + $_updateChecker->clearCache(); + header('Location: /admin?tab=dashboard¬ice=' . ($ok ? 'folio_saved' : 'folio_error')); + exit; + case 'admin_save_site': requireAuth(); if (!isAdmin() || $_SERVER['REQUEST_METHOD'] !== 'POST') { diff --git a/src/SiteSettings.php b/src/SiteSettings.php index 37d187b..ad6d270 100644 --- a/src/SiteSettings.php +++ b/src/SiteSettings.php @@ -68,6 +68,24 @@ function apacheAccessLog(): string return (string)($_ENV['APACHE_ACCESS_LOG'] ?? getenv('APACHE_ACCESS_LOG') ?: '*-access.log'); } +function folioRepoUrl(): string +{ + $fromSettings = siteSettings()['folio_repo_url'] ?? ''; + if ($fromSettings !== '') { + return rtrim($fromSettings, '/'); + } + return rtrim((string)($_ENV['FOLIO_REPO_URL'] ?? getenv('FOLIO_REPO_URL') ?: ''), '/'); +} + +function folioUpdateBranch(): string +{ + $fromSettings = siteSettings()['folio_update_branch'] ?? ''; + if ($fromSettings !== '') { + return $fromSettings; + } + return (string)($_ENV['FOLIO_UPDATE_BRANCH'] ?? getenv('FOLIO_UPDATE_BRANCH') ?: 'main'); +} + /** @return list}> */ function asGroups(): array { @@ -78,7 +96,7 @@ function asGroups(): array function saveSiteSettings(array $data): bool { $current = siteSettings(); - $stringKeys = ['site_title', 'site_claim', 'site_lang', 'site_license_label', 'site_license_url', 'apache_access_log']; + $stringKeys = ['site_title', 'site_claim', 'site_lang', 'site_license_label', 'site_license_url', 'apache_access_log', 'folio_repo_url', 'folio_update_branch']; foreach ($stringKeys as $key) { if (array_key_exists($key, $data)) { $val = trim((string)$data[$key]); diff --git a/src/UpdateChecker.php b/src/UpdateChecker.php index 3962b4b..cad72e4 100644 --- a/src/UpdateChecker.php +++ b/src/UpdateChecker.php @@ -67,7 +67,7 @@ class UpdateChecker */ private function checkRemoteVersion(): ?string { - $repoUrl = rtrim((string) ($_ENV['FOLIO_REPO_URL'] ?? getenv('FOLIO_REPO_URL') ?: ''), '/'); + $repoUrl = folioRepoUrl(); if ($repoUrl === '') { return null; } @@ -91,7 +91,7 @@ class UpdateChecker public function getBranch(): string { - return (string) ($_ENV['FOLIO_UPDATE_BRANCH'] ?? getenv('FOLIO_UPDATE_BRANCH') ?: 'main'); + return folioUpdateBranch(); } public function getLastChecked(): ?int diff --git a/templates/admin.php b/templates/admin.php index f67f3be..8237bd4 100644 --- a/templates/admin.php +++ b/templates/admin.php @@ -106,7 +106,7 @@ function adminStatusBadge(array $a, int $now): string $_notices = isset($_updateChecker) ? $_updateChecker->adminNotices() : []; $_branch = isset($_updateChecker) ? $_updateChecker->getBranch() : 'main'; $_lastChecked = isset($_updateChecker) ? $_updateChecker->getLastChecked() : null; - $_repoConfigured = (($_ENV['FOLIO_REPO_URL'] ?? getenv('FOLIO_REPO_URL') ?: '') !== ''); + $_repoConfigured = folioRepoUrl() !== ''; $_remoteLabel = '—'; foreach ($_notices as $_n) { if ($_n['type'] === 'info' && preg_match('/v([\d]+\.[\d]+\.[\d]+)/', $_n['message'], $_m)) { @@ -164,6 +164,33 @@ function adminStatusBadge(array $a, int $now): string + +
Configuration Folio enregistrée.
+ +
Impossible d'enregistrer.
+ +
+
Configuration des mises à jour
+
+
+
+ + +
Sans slash final. Laissez vide pour utiliser FOLIO_REPO_URL du .env.
+
+
+ + +
+ +
+
+
+
Activité récente
From de8785d088434f5d531e10f3eb87ed7f32b1c12c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drix?= Date: Fri, 15 May 2026 09:48:03 +0200 Subject: [PATCH 4/4] =?UTF-8?q?fix=20:=20d=C3=A9placer=20config=20mises=20?= =?UTF-8?q?=C3=A0=20jour=20Folio=20dans=20l'onglet=20Site?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- public/index.php | 2 +- templates/admin.php | 54 ++++++++++++++++++++++----------------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/public/index.php b/public/index.php index 168437d..b57a1dc 100644 --- a/public/index.php +++ b/public/index.php @@ -2837,7 +2837,7 @@ switch ($action) { 'folio_update_branch' => $_POST['folio_update_branch'] ?? '', ]); $_updateChecker->clearCache(); - header('Location: /admin?tab=dashboard¬ice=' . ($ok ? 'folio_saved' : 'folio_error')); + header('Location: /admin/site?notice=' . ($ok ? 'folio_saved' : 'folio_error')); exit; case 'admin_save_site': diff --git a/templates/admin.php b/templates/admin.php index 8237bd4..41e3488 100644 --- a/templates/admin.php +++ b/templates/admin.php @@ -164,33 +164,6 @@ function adminStatusBadge(array $a, int $now): string - -
Configuration Folio enregistrée.
- -
Impossible d'enregistrer.
- -
-
Configuration des mises à jour
-
-
-
- - -
Sans slash final. Laissez vide pour utiliser FOLIO_REPO_URL du .env.
-
-
- - -
- - -
-
-
Activité récente
@@ -574,6 +547,33 @@ function adminStatusBadge(array $a, int $now): string + +
Configuration Folio enregistrée.
+ +
Impossible d'enregistrer.
+ +
+
Mises à jour du moteur
+
+
+
+ + +
Sans slash final. Laissez vide pour utiliser FOLIO_REPO_URL du .env.
+
+
+ + +
+ + +
+
+