mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
- Replace fetch(redirect:manual) with XMLHttpRequest in file-upload-queue.js. The previous fetch-based redirect detection was broken because opaque redirects hide the Location header. XHR's responseURL reliably exposes the final URL after server-side redirects. - Add console.log tracing at every decision point in submit interception: entry, hasFiles check, enctype check, double-submit guard, XHR status, redirect detection, error fallback. - Add error_log entry-point logging to all 16 admin action files plus the partage/index.php submission handler and password gate. Each logs: request method, content type/length, POST keys, file counts, and queue-specific file counts where applicable. - Add double-submit guard (_xamxamActiveSubmit) to prevent duplicate XHR sends when the native submit handler fires after interception.
39 lines
1.3 KiB
PHP
39 lines
1.3 KiB
PHP
<?php
|
|
require_once __DIR__ . '/../../../bootstrap.php';
|
|
require_once __DIR__ . '/../../../src/AdminAuth.php';
|
|
error_log('[maintenance.php] ENTRY | method=' . $_SERVER['REQUEST_METHOD'] . ' | action=' . ($_POST['action'] ?? 'none') . ' | post_keys=' . implode(',', array_keys($_POST)));
|
|
AdminAuth::requireLogin();
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] !== 'POST'
|
|
|| !isset($_POST['csrf_token'], $_SESSION['csrf_token'])
|
|
|| !hash_equals($_SESSION['csrf_token'], $_POST['csrf_token'])) {
|
|
http_response_code(403);
|
|
die("Accès refusé.");
|
|
}
|
|
|
|
require_once APP_ROOT . '/src/AdminLogger.php';
|
|
|
|
$action = $_POST['action'] ?? '';
|
|
|
|
if ($action === 'enable_maintenance') {
|
|
file_put_contents(MAINTENANCE_FLAG, date('c'));
|
|
AdminLogger::make()->logMaintenance(true);
|
|
App::flash('success', "Mode maintenance activé.");
|
|
} elseif ($action === 'disable_maintenance') {
|
|
if (file_exists(MAINTENANCE_FLAG)) {
|
|
unlink(MAINTENANCE_FLAG);
|
|
}
|
|
AdminLogger::make()->logMaintenance(false);
|
|
App::flash('success', "Mode maintenance désactivé.");
|
|
} else {
|
|
App::flash('error', "Action inconnue.");
|
|
}
|
|
|
|
$redirect = isset($_POST['redirect']) ? $_POST['redirect'] : '/admin/';
|
|
// Allow only internal admin redirects for safety
|
|
if (!preg_match('#^/admin/#', $redirect)) {
|
|
$redirect = '/admin/';
|
|
}
|
|
header('Location: ' . $redirect);
|
|
exit();
|