format filesize into human_readable in generate video view

pull/3588/head
Isaac Connor 2022-09-06 11:41:53 -04:00
parent 6452f8127a
commit f9fddcb6ee
1 changed files with 10 additions and 10 deletions

View File

@ -18,7 +18,7 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
// //
if ( !canView('Events') ) { if (!canView('Events')) {
$view = 'error'; $view = 'error';
return; return;
} }
@ -29,7 +29,7 @@ $eid = validInt($_REQUEST['eid']);
$event = new ZM\Event($eid); $event = new ZM\Event($eid);
if ( ! canView('Monitors', $event->MonitorId() ) ) { if (!canView('Monitors', $event->MonitorId())) {
$view = 'error'; $view = 'error';
return; return;
} }
@ -61,11 +61,11 @@ foreach ( $ffmpegFormats as $ffmpegFormat ) {
} }
$videoFiles = array(); $videoFiles = array();
if ( $dir = opendir($event_path) ) { if ($dir = opendir($event_path)) {
while ( ($file = readdir($dir)) !== false ) { while (($file = readdir($dir)) !== false) {
$file = $event_path.'/'.$file; $file = $event_path.'/'.$file;
if ( is_file($file) ) { if (is_file($file)) {
if ( preg_match('/\.(?:'.join('|', $videoFormats).')$/', $file) ) { if (preg_match('/\.(?:'.join('|', $videoFormats).')$/', $file)) {
$videoFiles[] = $file; $videoFiles[] = $file;
} }
} }
@ -73,17 +73,17 @@ if ( $dir = opendir($event_path) ) {
closedir($dir); closedir($dir);
} }
if ( isset($_REQUEST['deleteIndex']) ) { if (isset($_REQUEST['deleteIndex'])) {
$deleteIndex = validInt($_REQUEST['deleteIndex']); $deleteIndex = validInt($_REQUEST['deleteIndex']);
unlink($videoFiles[$deleteIndex]); unlink($videoFiles[$deleteIndex]);
unset($videoFiles[$deleteIndex]); unset($videoFiles[$deleteIndex]);
} }
if ( isset($_REQUEST['downloadIndex']) ) { if (isset($_REQUEST['downloadIndex'])) {
// can't be output buffering, as this file might be large // can't be output buffering, as this file might be large
ob_end_clean(); ob_end_clean();
$downloadIndex = validInt($_REQUEST['downloadIndex']); $downloadIndex = validInt($_REQUEST['downloadIndex']);
ZM\Error("Download $downloadIndex, file: " . $videoFiles[$downloadIndex]); ZM\Debug("Download $downloadIndex, file: " . $videoFiles[$downloadIndex]);
header('Pragma: public'); header('Pragma: public');
header('Expires: 0'); header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
@ -195,7 +195,7 @@ if ( isset($_REQUEST['showIndex']) ) {
?> ?>
<tr> <tr>
<td><?php echo $matches[4] ?></td> <td><?php echo $matches[4] ?></td>
<td><?php echo filesize($file) ?></td> <td><?php echo human_filesize(filesize($file)) ?></td>
<td><?php echo $rateText ?></td> <td><?php echo $rateText ?></td>
<td><?php echo $scaleText ?></td> <td><?php echo $scaleText ?></td>
<td> <td>