isLoggedIn()) { echo json_encode([ 'error' => 'Unauthorized' ]); exit; } $selection_id = isset($_GET['id']) ? (int)$_GET['id'] : 0; if (!$selection_id) { echo json_encode([ 'error' => 'Invalid selection ID' ]); exit; } // Read the progress from the temp file $progress_file = sys_get_temp_dir() . '/syndia_progress_' . $selection_id . '.json'; if (file_exists($progress_file)) { $progress_data = json_decode(file_get_contents($progress_file), true); echo json_encode($progress_data); } else { echo json_encode([ 'progress' => 0, 'processed' => 0, 'success' => 0, 'error' => 0, 'total' => 0, 'status' => 'Initializing...', 'completed' => false ]); } ?>