* * 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);