Skip to content

Commit

Permalink
Handle when no videos found a little more gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
Isaac Connor committed Sep 9, 2024
1 parent a2e06fe commit d30a0ae
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions web/skins/classic/views/video.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,28 +73,34 @@
closedir($dir);
}



if (isset($_REQUEST['deleteIndex'])) {
$deleteIndex = validInt($_REQUEST['deleteIndex']);
$deleteIndex = validCardinal($_REQUEST['deleteIndex']);
unlink($videoFiles[$deleteIndex]);
unset($videoFiles[$deleteIndex]);
} else if (isset($_REQUEST['downloadIndex'])) {
$downloadIndex = validInt($_REQUEST['downloadIndex']);
ZM\Debug("Download $downloadIndex, file: " . $videoFiles[$downloadIndex]);
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private', false); // required by certain browsers
header('Content-Description: File Transfer');
header('Content-disposition: attachment; filename="'.basename($videoFiles[$downloadIndex]).'"'); // basename is required because the video index contains the path and firefox doesn't strip the path but simply replaces the slashes with an underscore.
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();
if (!count($videoFiles)) {
ZM\Warning("No video files found for $eid. Downloading not possible.");
} else {
$downloadIndex = validInt($_REQUEST['downloadIndex']);
ZM\Debug("Download $downloadIndex, file: " . $videoFiles[$downloadIndex]);
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private', false); // required by certain browsers
header('Content-Description: File Transfer');
header('Content-disposition: attachment; filename="'.basename($videoFiles[$downloadIndex]).'"'); // basename is required because the video index contains the path and firefox doesn't strip the path but simply replaces the slashes with an underscore.
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]);
}
set_time_limit(0);
readfile($videoFiles[$downloadIndex]);
exit;
}

Expand Down

0 comments on commit d30a0ae

Please sign in to comment.