the use of xsendfile can be set

This commit is contained in:
Uwe Steinmann 2019-01-18 13:05:10 +01:00
parent d3e265d1d1
commit 5353e28fae
3 changed files with 25 additions and 6 deletions

View File

@ -44,7 +44,13 @@ class SeedDMS_Preview_Base {
*/
protected $timeout;
function __construct($previewDir, $timeout=5) { /* {{{ */
/**
* @var boolean $xsendfile set to true if mod_xѕendfile is to be used
* @access protected
*/
protected $xsendfile;
function __construct($previewDir, $timeout=5, $xsendfile=true) { /* {{{ */
if(!is_dir($previewDir)) {
if (!SeedDMS_Core_File::makeDir($previewDir)) {
$this->previewDir = '';
@ -55,6 +61,7 @@ class SeedDMS_Preview_Base {
$this->previewDir = $previewDir;
}
$this->timeout = intval($timeout);
$this->xsendfile = $xsendfile;
} /* }}} */
static function execWithTimeout($cmd, $timeout=5) { /* {{{ */
@ -112,6 +119,18 @@ class SeedDMS_Preview_Base {
$this->converters = $arr;
} /* }}} */
/**
* Enable/Disable xsendfile extension
*
* Merges the list of passed converters with the already existing ones.
* Existing converters will be overwritten.
*
* @param boolean $xsendfile turn on/off use of xsendfile module in apache
*/
function setXsendfile($xsendfile) { /* {{{ */
$this->xsendfile = $xsendfile;
} /* }}} */
/**
* Add a list of converters
*
@ -144,7 +163,7 @@ class SeedDMS_Preview_Base {
* @param string $filename
*/
protected function sendFile($filename) { /* {{{ */
if(function_exists('apache_get_modules') && in_array('mod_xsendfile',apache_get_modules())) {
if($this->xsendfile && function_exists('apache_get_modules') && in_array('mod_xsendfile',apache_get_modules())) {
header("X-Sendfile: ".$filename);
} else {
/* Make sure output buffering is off */

View File

@ -24,8 +24,8 @@
*/
class SeedDMS_Preview_PdfPreviewer extends SeedDMS_Preview_Base {
function __construct($previewDir, $timeout=5) { /* {{{ */
parent::__construct($previewDir, $timeout);
function __construct($previewDir, $timeout=5, $xsendfile=true) { /* {{{ */
parent::__construct($previewDir, $timeout, $xsendfile);
$this->converters = array(
'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => "unoconv -d document -f pdf --stdout -v '%f' > '%o'",
'application/vnd.oasis.opendocument.text' => "unoconv -d document -f pdf --stdout -v '%f' > '%o'",

View File

@ -29,8 +29,8 @@ class SeedDMS_Preview_Previewer extends SeedDMS_Preview_Base {
*/
protected $width;
function __construct($previewDir, $width=40, $timeout=5) { /* {{{ */
parent::__construct($previewDir, $timeout);
function __construct($previewDir, $width=40, $timeout=5, $xsendfile=true) { /* {{{ */
parent::__construct($previewDir, $timeout, $xsendfile);
$this->converters = array(
'image/png' => "convert -resize %wx '%f' '%o'",
'image/gif' => "convert -resize %wx '%f' '%o'",