mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
feat: upload progress bar — fieldset layout, accent colors, file name display, completion animation, 800ms redirect delay; decorelate formats from fichiers; server-side poll via token; bump PeerTube embed audio player
This commit is contained in:
@@ -32,7 +32,12 @@ require_once APP_ROOT . '/src/ErrorHandler.php';
|
||||
|
||||
try {
|
||||
$ctrl = ThesisEditController::create();
|
||||
$ctrl->save($thesisId, $_POST, $_FILES);
|
||||
$progressToken = $_POST['progress_token'] ?? bin2hex(random_bytes(8));
|
||||
$ctrl->save($thesisId, $_POST, $_FILES, $progressToken);
|
||||
|
||||
// Clean up progress file
|
||||
require_once APP_ROOT . '/src/PeerTubeService.php';
|
||||
PeerTubeService::clearProgress($progressToken);
|
||||
|
||||
// Regenerate CSRF token after successful save
|
||||
$_SESSION['csrf_token'] = bin2hex(random_bytes(32));
|
||||
|
||||
43
app/public/admin/actions/upload-progress.php
Normal file
43
app/public/admin/actions/upload-progress.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* upload-progress.php
|
||||
*
|
||||
* Returns the current upload/processing progress for a given token.
|
||||
* Called by the client-side upload-progress.js while the form XHR is in flight.
|
||||
*
|
||||
* GET /admin/actions/upload-progress.php?token=<token>
|
||||
*
|
||||
* Response: JSON
|
||||
* { "stage": "upload"|"processing"|"done", "pct": 45, "file": "video.mp4" }
|
||||
*
|
||||
* Progress data is written by ThesisEditController / ThesisCreateController
|
||||
* to a temp file during processing.
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/../../../bootstrap.php';
|
||||
require_once __DIR__ . '/../../../src/AdminAuth.php';
|
||||
AdminAuth::requireLogin();
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$token = $_GET['token'] ?? '';
|
||||
if (!preg_match('/^[a-f0-9]{16}$/', $token)) {
|
||||
echo json_encode(['stage' => 'error', 'error' => 'Invalid token']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$progressFile = sys_get_temp_dir() . '/xamxam_upload_' . $token . '.json';
|
||||
|
||||
if (!file_exists($progressFile)) {
|
||||
// No progress file yet — still in upload phase (or token invalid)
|
||||
echo json_encode(['stage' => 'upload', 'pct' => 0, 'file' => '']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$data = json_decode(file_get_contents($progressFile), true);
|
||||
if (!$data) {
|
||||
echo json_encode(['stage' => 'upload', 'pct' => 0, 'file' => '']);
|
||||
exit;
|
||||
}
|
||||
|
||||
echo json_encode($data);
|
||||
Reference in New Issue
Block a user