Compare commits

4 Commits

6 changed files with 5 additions and 78 deletions
-7
View File
@@ -6,7 +6,6 @@
APP_URL=https://example.com
APP_ENV=prod
APP_DEBUG=0
APP_TIMEZONE=Europe/Paris
# Authentification admin (email de l'administrateur principal)
ADMIN_EMAIL=
@@ -41,12 +40,6 @@ 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
-4
View File
@@ -6,10 +6,6 @@ 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');
+1 -15
View File
@@ -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', 'admin_save_folio_config', 'run_engine_update'];
$_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', 'run_engine_update'];
$metaRobots = in_array($action, $_noindexActions, true) ? 'noindex, nofollow' : null;
unset($_noindexActions);
@@ -2903,20 +2903,6 @@ 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/site?notice=' . ($ok ? 'folio_saved' : 'folio_error'));
exit;
case 'admin_save_site':
requireAuth();
if (!isAdmin() || $_SERVER['REQUEST_METHOD'] !== 'POST') {
+1 -19
View File
@@ -68,24 +68,6 @@ 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<array{label:string,patterns:list<string>}> */
function asGroups(): array
{
@@ -96,7 +78,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', 'folio_repo_url', 'folio_update_branch'];
$stringKeys = ['site_title', 'site_claim', 'site_lang', 'site_license_label', 'site_license_url', 'apache_access_log'];
foreach ($stringKeys as $key) {
if (array_key_exists($key, $data)) {
$val = trim((string)$data[$key]);
+2 -2
View File
@@ -67,7 +67,7 @@ class UpdateChecker
*/
private function checkRemoteVersion(): ?string
{
$repoUrl = folioRepoUrl();
$repoUrl = rtrim((string) ($_ENV['FOLIO_REPO_URL'] ?? getenv('FOLIO_REPO_URL') ?: ''), '/');
if ($repoUrl === '') {
return null;
}
@@ -91,7 +91,7 @@ class UpdateChecker
public function getBranch(): string
{
return folioUpdateBranch();
return (string) ($_ENV['FOLIO_UPDATE_BRANCH'] ?? getenv('FOLIO_UPDATE_BRANCH') ?: 'main');
}
public function getLastChecked(): ?int
+1 -31
View File
@@ -106,7 +106,6 @@ 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 = folioRepoUrl() !== '';
$_remoteLabel = '—';
foreach ($_notices as $_n) {
if ($_n['type'] === 'info' && preg_match('/v([\d]+\.[\d]+\.[\d]+)/', $_n['message'], $_m)) {
@@ -131,12 +130,10 @@ function adminStatusBadge(array $a, int $now): string
<form method="POST" action="/?action=run_engine_update" class="d-inline">
<button type="submit" class="btn btn-primary btn-sm">Mettre à jour vers v<?= htmlspecialchars($_remoteLabel) ?></button>
</form>
<?php elseif ($_repoConfigured): ?>
<?php else: ?>
<form method="POST" action="/?action=force_update_check" class="d-inline">
<button type="submit" class="btn btn-outline-secondary btn-sm py-0">Vérifier</button>
</form>
<?php else: ?>
<span class="text-muted small">(<code>FOLIO_REPO_URL</code> non configuré)</span>
<?php endif; ?>
</td>
</tr>
@@ -547,33 +544,6 @@ function adminStatusBadge(array $a, int $now): string
</div>
</div>
<?php if (($_GET['notice'] ?? '') === 'folio_saved'): ?>
<div class="alert alert-success py-2 mt-3 small">Configuration Folio enregistrée.</div>
<?php elseif (($_GET['notice'] ?? '') === 'folio_error'): ?>
<div class="alert alert-danger py-2 mt-3 small">Impossible d'enregistrer.</div>
<?php endif; ?>
<div class="card mt-4" style="max-width:540px">
<div class="card-header bg-transparent py-2 small fw-semibold">Mises à jour du moteur</div>
<div class="card-body">
<form method="POST" action="/?action=admin_save_folio_config">
<div class="mb-3">
<label class="form-label small fw-semibold mb-1">URL du dépôt Folio</label>
<input type="url" name="folio_repo_url" class="form-control form-control-sm font-monospace"
placeholder="https://git.abonnel.fr/cedricAbonnel/folio"
value="<?= htmlspecialchars(folioRepoUrl()) ?>">
<div class="form-text">Sans slash final. Laissez vide pour utiliser <code>FOLIO_REPO_URL</code> du .env.</div>
</div>
<div class="mb-3">
<label class="form-label small fw-semibold mb-1">Branche suivie</label>
<input type="text" name="folio_update_branch" class="form-control form-control-sm font-monospace"
placeholder="main"
value="<?= htmlspecialchars(folioUpdateBranch()) ?>">
</div>
<button type="submit" class="btn btn-primary btn-sm">Enregistrer</button>
</form>
</div>
</div>
<?php endif; ?>
<!-- ─────────────────────────── CATÉGORIES & TAGS ─────────────────── -->