From 248625c67665423abbe653fb3c9c7449a31af094 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sun, 11 Aug 2024 09:16:36 -0400 Subject: [PATCH] Handle more than one level of output buffering when cleaning and ending them so we can send the video file so we don't run out of ram. Fixes #4110 --- web/skins/classic/views/video.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/web/skins/classic/views/video.php b/web/skins/classic/views/video.php index 3758c0681a..76aad680c0 100644 --- a/web/skins/classic/views/video.php +++ b/web/skins/classic/views/video.php @@ -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'); @@ -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; }