fix : vérification écriture settings + script setup.sh #63

Merged
cedricAbonnel merged 7 commits from feat/wizard-multi-step into main 2026-05-14 22:50:37 +00:00
4 changed files with 17 additions and 12 deletions
Showing only changes of commit 9091a00a32 - Show all commits
+5 -4
View File
@@ -2293,6 +2293,7 @@ switch ($action) {
$tab = $_GET['tab'] ?? (isAdmin() ? 'dashboard' : 'articles');
$adminData = [];
$siteSettingsSaved = isset($_GET['saved']);
$siteSettingsError = ($_GET['error'] ?? '') === 'write';
if ($tab === 'dashboard') {
if (!isAdmin()) {
@@ -2549,7 +2550,7 @@ switch ($action) {
}
require_once BASE_PATH . '/src/SmtpSettings.php';
saveSmtpSettings([
$ok = saveSmtpSettings([
'host' => $_POST['smtp_host'] ?? '',
'port' => $_POST['smtp_port'] ?? '',
'secure' => $_POST['smtp_secure'] ?? '',
@@ -2558,7 +2559,7 @@ switch ($action) {
'from' => $_POST['smtp_from'] ?? '',
'from_name' => $_POST['smtp_from_name'] ?? '',
]);
header('Location: /admin/smtp?saved=1');
header('Location: /admin/smtp?' . ($ok ? 'saved=1' : 'error=write'));
exit;
case 'admin_smtp_test':
@@ -2774,7 +2775,7 @@ switch ($action) {
http_response_code(403);
exit;
}
saveSiteSettings([
$ok = saveSiteSettings([
'site_title' => $_POST['site_title'] ?? '',
'site_claim' => $_POST['site_claim'] ?? '',
'site_lang' => $_POST['site_lang'] ?? '',
@@ -2782,7 +2783,7 @@ switch ($action) {
'site_license_label' => $_POST['site_license_label'] ?? '',
'site_license_url' => $_POST['site_license_url'] ?? '',
]);
header('Location: /admin/site?saved=1');
header('Location: /admin/site?' . ($ok ? 'saved=1' : 'error=write'));
exit;
case 'admin_create_role':
+3 -3
View File
@@ -59,7 +59,7 @@ function siteLicenseUrl(): string
return siteSettings()['site_license_url'] ?? 'https://creativecommons.org/licenses/by/4.0/';
}
function saveSiteSettings(array $data): void
function saveSiteSettings(array $data): bool
{
$current = siteSettings();
$stringKeys = ['site_title', 'site_claim', 'site_lang', 'site_license_label', 'site_license_url'];
@@ -77,8 +77,8 @@ function saveSiteSettings(array $data): void
$current['posts_per_page'] = $val;
}
}
file_put_contents(
return file_put_contents(
siteSettingsPath(),
json_encode($current, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)
);
) !== false;
}
+3 -3
View File
@@ -35,7 +35,7 @@ function smtpCfg(string $key, string $envKey, string $default = ''): string
return ($v !== false && $v !== '') ? (string)$v : $default;
}
function saveSmtpSettings(array $data): void
function saveSmtpSettings(array $data): bool
{
$current = smtpSettings();
foreach (['host', 'port', 'secure', 'user', 'from', 'from_name'] as $key) {
@@ -46,8 +46,8 @@ function saveSmtpSettings(array $data): void
if (!empty($data['pass']) && trim((string)$data['pass']) !== '') {
$current['pass'] = trim((string)$data['pass']);
}
file_put_contents(
return file_put_contents(
smtpSettingsPath(),
json_encode($current, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)
);
) !== false;
}
+6 -2
View File
@@ -94,11 +94,11 @@ function adminStatusBadge(array $a, int $now): string
<!-- Version Folio ──────────────────────────────────────────────────────── -->
<?php
$_deployedVer = trim((string) @file_get_contents(BASE_PATH . '/public/version.txt'));
$_deployedLabel = $_deployedVer !== '' ? date('d/m/Y H:i', strtotime($_deployedVer)) : '—';
$_deployedLabel = $_deployedVer !== '' ? $_deployedVer : '—';
$_notices = isset($_updateChecker) ? $_updateChecker->adminNotices() : [];
$_remoteLabel = '—';
foreach ($_notices as $_n) {
if ($_n['type'] === 'info' && preg_match('/publiée le ([^)]+)/', $_n['message'], $_m)) {
if ($_n['type'] === 'info' && preg_match('/v([\d]+\.[\d]+\.[\d]+)/', $_n['message'], $_m)) {
$_remoteLabel = $_m[1];
}
}
@@ -464,6 +464,8 @@ function adminStatusBadge(array $a, int $now): string
<?php if (!empty($siteSettingsSaved)): ?>
<div class="alert alert-success py-2 mb-3">Paramètres enregistrés.</div>
<?php elseif (!empty($siteSettingsError)): ?>
<div class="alert alert-danger py-2 mb-3">Impossible d'enregistrer : le fichier n'est pas accessible en écriture.</div>
<?php endif; ?>
<div class="card" style="max-width:540px">
@@ -676,6 +678,8 @@ foreach (COLOR_PALETTE_16 as $_i => $_rgb):
<?php if (isset($_GET['saved'])): ?>
<div class="alert alert-success py-2 mb-3">Paramètres SMTP enregistrés.</div>
<?php elseif (($_GET['error'] ?? '') === 'write'): ?>
<div class="alert alert-danger py-2 mb-3">Impossible d'enregistrer : le fichier n'est pas accessible en écriture.</div>
<?php endif; ?>
<div class="row g-4">