mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 11:09:18 +02:00
add structured logging for admin/partage form submissions + migration system
- AppLogger: JSON-line logger in storage/logs/form-submissions.log - Logs submissions (admin + partage) with IP, UA, thesis ID, author - Logs errors with context (post keys, share slug) - Migration runner (app/migrations/run.php) handles schema drift - 001_add_objet_column.sql fixes production DB missing 'objet' column - ThesisCreateController::getIdentifier() helper for logging
This commit is contained in:
@@ -19,17 +19,29 @@ if (!isset($_POST['csrf_token'], $_SESSION['csrf_token'])
|
||||
error_log('FILES array: ' . print_r($_FILES, true));
|
||||
|
||||
require_once APP_ROOT . '/src/Controllers/ThesisCreateController.php';
|
||||
require_once APP_ROOT . '/src/AppLogger.php';
|
||||
|
||||
$logger = new AppLogger();
|
||||
$authorName = $_POST['auteurice'] ?? 'unknown';
|
||||
|
||||
try {
|
||||
$ctrl = ThesisCreateController::make();
|
||||
$thesisId = $ctrl->submit($_POST, $_FILES);
|
||||
|
||||
$identifier = $ctrl->getIdentifier($thesisId);
|
||||
$logger->logSubmission('admin', $thesisId, $identifier, $authorName);
|
||||
|
||||
unset($_SESSION['csrf_token']);
|
||||
|
||||
header('Location: ' . $redirect);
|
||||
exit();
|
||||
|
||||
} catch (Exception $e) {
|
||||
$logger->logError('admin', $e->getMessage(), [
|
||||
'author' => $authorName,
|
||||
'post_keys' => array_keys($_POST),
|
||||
]);
|
||||
|
||||
error_log('ThesisCreateController error: ' . $e->getMessage());
|
||||
|
||||
App::flash('error', $e->getMessage());
|
||||
|
||||
Reference in New Issue
Block a user