Skip to content
Snippets Groups Projects
Commit 16666c26 authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

ersion 1.5.4: Fix large downloads,

-) Send file size in http header
-) Check if the file exists and is readable on disk
-) Don't flush the queue before trying to change the header (will break if the header was already set before)
parent 6a04f2ca
No related branches found
No related tags found
No related merge requests found
...@@ -184,16 +184,16 @@ class plgVmCustomDownloads_for_Sale extends vmCustomPlugin { ...@@ -184,16 +184,16 @@ class plgVmCustomDownloads_for_Sale extends vmCustomPlugin {
JFactory::getApplication()->enqueueMessage(JText::sprintf('VMCUSTOM_DLSALE_ERROR_MEDIA_NOT_CONFIGURED', $media_id), 'error'); JFactory::getApplication()->enqueueMessage(JText::sprintf('VMCUSTOM_DLSALE_ERROR_MEDIA_NOT_CONFIGURED', $media_id), 'error');
return false; return false;
} }
flush(); if (!is_file($media->file_url) || !is_readable($media->file_url)) {
ob_flush(); JFactory::getApplication()->enqueueMessage(JText::sprintf('VMCUSTOM_DLSALE_ERROR_NO_FILE_SET', $media_id, $media->file_url), 'error');
return false;
}
header("Content-Type: " . $media->file_mimetype); header("Content-Type: " . $media->file_mimetype);
header("Content-Disposition: attachment; filename=\"".JFile::getName($media->file_url)."\""); header("Content-Disposition: attachment; filename=\"".JFile::getName($media->file_url)."\"");
header("Content-Length: ".filesize($media->file_url));
if (@$this->readfile_chunked($media->file_url)) { if (@$this->readfile_chunked($media->file_url)) {
return true; return true;
} else { } else {
header_remove("Content-Type");
header_remove("Content-Disposition");
JFactory::getApplication()->enqueueMessage(JText::sprintf('VMCUSTOM_DLSALE_ERROR_NO_FILE_SET', $media_id, $media->file_url), 'error');
return false; return false;
} }
} else { } else {
......
...@@ -11,4 +11,4 @@ ...@@ -11,4 +11,4 @@
defined('_JEXEC') or die(); defined('_JEXEC') or die();
?> ?>
<p><img style="vertical-align:middle; display: inline;" src="<?php echo JURI::root().VMDLSALE_PLUGINWEBROOT.'/downloads_for_sale/assets/download_small.png'; ?>" alt=""/> <a href="<?php echo $viewData[0]; ?>"><?php echo $viewData[2]->file_title; ?></a></p> <p><img style="vertical-align:middle; display: inline;" src="<?php echo JURI::root().VMDLSALE_PLUGINWEBROOT.'/downloads_for_sale/assets/download_small.png'; ?>" alt=""/>&nbsp;<a href="<?php echo $viewData[0]; ?>"><?php echo $viewData[2]->file_title; ?></a></p>
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment