Page 1 of 1

fix for video download

Posted: Mon Sep 22, 2008 3:35 pm
by W.
zm_html_view_video.php is a bit broken as it is (both 1.22.3 and 1.23.3)

Code: Select all

--- ZoneMinder-1.23.3/web/zm_html_view_video.php	2008-02-25 11:49:53.000000000 +0200
+++ ZoneMinder-1.23.3.NV/web/zm_html_view_video.php	2008-09-22 18:14:47.000000000 +0300
@@ -77,9 +77,10 @@
 	closedir( $dir );
 }
 
-if ( !empty($download) )
+if ( isset($download) )
 {
-	header( "Content-disposition: attachment; filename=".$video_files[$download]."; size=".filesize($video_files[$download]) );
+	header( "Content-Type: ".mime_content_type($video_files[$download]) );
+	header( "Content-Disposition: attachment; filename=".$video_files[$download]."; size=".filesize($video_files[$download]) );
 	readfile( $video_files[$download] );
 	exit;
 }
@@ -104,6 +105,10 @@
 {
 	location.replace( '<?= $PHP_FILE ?>?view=<?= $view ?>&eid=<?= $eid ?>&delete='+index );
 }
+function downloadVideo( index )
+{
+	location.replace( '<?= $PHP_FILE ?>?view=<?= $view ?>&eid=<?= $eid ?>&download='+index );
+}
 </script>
 </head>
 <body>
@@ -251,8 +256,8 @@
   <td class="text" align="center"><?= $matches[4] ?></td>
   <td class="text" align="center"><?= filesize( $file ) ?></td>
   <td class="text" align="center"><?= $rate_text ?></td>
-  <td class="text" align="center"><?= $scale_text ?></td
-  <td class="text" align="center"><a href="javascript:newWindow( '<?= $PHP_SELF ?>?view=<?= $view ?>&eid=<?= $eid ?>&width=<?= $width ?>&height=<?= $height ?>&show=<?= $index ?>', 'zmVideo<?= $eid ?>-<?= $scale ?>', <?= 24+$width ?>, <?= 48+$height ?> );"><?= $zmSlangView ?></a>&nbsp;/&nbsp;<a href="<?= $file ?>" onClick="window.location='<?= $PHP_SELF ?>?view=<?= $view ?>&eid=<?= $eid ?>&download=<?= $index ?>'"><?= $zmSlangDownload ?></a>&nbsp;/&nbsp;<a href="javascript: deleteVideo( <?= $index ?> )"><?= $zmSlangDelete ?></a></td>
+  <td class="text" align="center"><?= $scale_text ?></td>
+  <td class="text" align="center"><a href="javascript:newWindow( '<?= $PHP_SELF ?>?view=<?= $view ?>&eid=<?= $eid ?>&width=<?= $width ?>&height=<?= $height ?>&show=<?= $index ?>', 'zmVideo<?= $eid ?>-<?= $scale ?>', <?= 24+$width ?>, <?= 48+$height ?> );"><?= $zmSlangView ?></a>&nbsp;/&nbsp;<a href="javascript: downloadVideo( <?= $index ?> )"><?= $zmSlangDownload ?></a>&nbsp;/&nbsp;<a href="javascript: deleteVideo( <?= $index ?> )"><?= $zmSlangDelete ?></a></td>
 </tr>
 <?php
 					$index++;