Skip to content

Commit

Permalink
Handle more than one level of output buffering when cleaning and endi…
Browse files Browse the repository at this point in the history
…ng them so we can send the video file so we don't run out of ram. Fixes #4110
  • Loading branch information
Isaac Connor committed Aug 11, 2024
1 parent 8a5d008 commit 248625c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions web/skins/classic/views/video.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,7 @@
$deleteIndex = validInt($_REQUEST['deleteIndex']);
unlink($videoFiles[$deleteIndex]);
unset($videoFiles[$deleteIndex]);
}

if ( isset($_REQUEST['downloadIndex']) ) {
// can't be output buffering, as this file might be large
ob_end_clean();
} else if (isset($_REQUEST['downloadIndex'])) {
$downloadIndex = validInt($_REQUEST['downloadIndex']);
ZM\Debug("Download $downloadIndex, file: " . $videoFiles[$downloadIndex]);
header('Pragma: public');
Expand All @@ -93,6 +89,11 @@
header('Content-Transfer-Encoding: binary');
header('Content-Type: application/force-download');
header('Content-Length: '.filesize($videoFiles[$downloadIndex]));
// can't be output buffering, as this file might be large
while (ob_get_level()) {
ob_end_clean();
}
set_time_limit(0);
readfile($videoFiles[$downloadIndex]);
exit;
}
Expand Down

0 comments on commit 248625c

Please sign in to comment.