fix for video download

If you've made a patch to quick fix a bug or to add a new feature not yet in the main tree then post it here so others can try it out.
Post Reply
W.
Posts: 108
Joined: Tue Apr 10, 2007 5:06 pm
Location: Latvia

fix for video download

Post 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++;
if common sense is so uncommon, why is it called common then?
Post Reply