ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilFileDelivery Class Reference

Class ilFileDelivery. More...

+ Collaboration diagram for ilFileDelivery:

Public Member Functions

 __construct ($path_to_file)
 
 stream ()
 
 deliver ()
 
 deliverVirtual ()
 not supported More...
 
 setGeneralHeaders ()
 
 setCachingHeaders ()
 
 generateEtag ()
 
 close ()
 
 getDeliveryType ()
 
 setDeliveryType ($delivery_type)
 
 getMimeType ()
 
 setMimeType ($mime_type)
 
 getPathToFile ()
 
 setPathToFile ($path_to_file)
 
 getDownloadFileName ()
 
 setDownloadFileName ($download_file_name)
 
 getDisposition ()
 
 setDisposition ($disposition)
 
 isSendMimeType ()
 
 setSendMimeType ($send_mime_type)
 
 isExitAfter ()
 
 setExitAfter ($exit_after)
 
 isConvertFileNameToAsci ()
 
 setConvertFileNameToAsci ($convert_file_name_to_asci)
 
 getEtag ()
 
 setEtag ($etag)
 
 getShowLastModified ()
 
 setShowLastModified ($show_last_modified)
 
 isHasContext ()
 
 setHasContext ($has_context)
 
 hasCache ()
 
 setCache ($cache)
 
 hasHashFilename ()
 
 setHashFilename ($hash_filename)
 
 checkCache ()
 
 clearBuffer ()
 
 isDeleteFile ()
 
 setDeleteFile ($delete_file)
 
 isUrlencodeFilename ()
 
 setUrlencodeFilename ($urlencode_filename)
 

Static Public Member Functions

static deliverFileAttached ($path_to_file, $download_file_name=null, $mime_type=null, $delete_file=false)
 
static streamVideoInline ($path_to_file, $download_file_name=null)
 
static deliverFileInline ($path_to_file, $download_file_name=null)
 
static isDEBUG ()
 
static setDEBUG ($DEBUG)
 
static returnASCIIFileName ($original_name)
 

Data Fields

const DIRECT_PHP_OUTPUT = 'php://output'
 
const DELIVERY_METHOD_NONE = 'cache'
 
const DELIVERY_METHOD_XSENDFILE = 'mod_xsendfile'
 
const DELIVERY_METHOD_XACCEL = 'x-accel-redirect'
 
const DELIVERY_METHOD_PHP = 'php'
 
const DELIVERY_METHOD_PHP_CHUNKED = 'php_chunked'
 
const DELIVERY_METHOD_VIRTUAL = 'virtual'
 
const DISP_ATTACHMENT = 'attachment'
 
const DISP_INLINE = 'inline'
 
const VIRTUAL_DATA = 'virtual-data'
 
const SECURED_DATA = 'secured-data'
 
const DATA = 'data'
 

Protected Member Functions

 deliverXSendfile ()
 
 deliverXAccelRedirect ()
 
 deliverPHP ()
 
 clearHeaders ()
 
 determineMimeType ()
 
 determineDownloadFileName ()
 
 detemineDeliveryType ()
 
 deliverPHPChunked ()
 
 sendEtagHeader ()
 
 sendLastModified ()
 
 isNonModified ()
 
 checkExisting ()
 
 sendFileUnbufferedUsingHeaders (\Closure $closure)
 

Protected Attributes

 $delivery_type = self::DELIVERY_METHOD_PHP
 
 $mime_type = ''
 
 $path_to_file = ''
 
 $download_file_name = ''
 
 $disposition = self::DISP_ATTACHMENT
 
 $send_mime_type = true
 
 $exit_after = true
 
 $convert_file_name_to_asci = true
 
 $etag = ''
 
 $show_last_modified = true
 
 $has_context = true
 
 $cache = false
 
 $hash_filename = false
 
 $delete_file = false
 
 $urlencode_filename = false
 

Static Protected Attributes

static $self_streaming_methods
 
static $delivery_type_static = null
 
static $DEBUG = false
 

Detailed Description

Class ilFileDelivery.

Author
Fabian Schmid fs@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch
Version
1.0.0

Definition at line 15 of file class.ilFileDelivery.php.

Constructor & Destructor Documentation

◆ __construct()

ilFileDelivery::__construct (   $path_to_file)
Parameters
$path_to_file

Definition at line 158 of file class.ilFileDelivery.php.

References $path_to_file, detemineDeliveryType(), determineDownloadFileName(), determineMimeType(), ilContext\getType(), setHasContext(), and setPathToFile().

158  {
159  if ($path_to_file == self::DIRECT_PHP_OUTPUT) {
160  $this->setPathToFile(self::DIRECT_PHP_OUTPUT);
161  } else {
162  $path_to_file = explode("?", $path_to_file); // removing everything behind ?
165  $this->detemineDeliveryType();
166  $this->determineMimeType();
167  $this->determineDownloadFileName();
168  }
169  $this->setHasContext(ilContext::getType() !== null);
170  }
setHasContext($has_context)
setPathToFile($path_to_file)
static getType()
Get context type.
+ Here is the call graph for this function:

Member Function Documentation

◆ checkCache()

ilFileDelivery::checkCache ( )

Definition at line 760 of file class.ilFileDelivery.php.

References generateEtag(), hasCache(), isNonModified(), sendEtagHeader(), setCachingHeaders(), and setShowLastModified().

Referenced by deliver(), and ilPHPOutputDelivery\start().

760  {
761  if ($this->hasCache()) {
762  $this->generateEtag();
763  $this->sendEtagHeader();
764  $this->setShowLastModified(true);
765  $this->setCachingHeaders();
766  if ($this->isNonModified()) {
767  //ilHTTP::status(304);
768  //$this->close();
769  }
770  }
771  }
setShowLastModified($show_last_modified)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkExisting()

ilFileDelivery::checkExisting ( )
protected

Definition at line 784 of file class.ilFileDelivery.php.

References $DIC, $download_file_name, close(), getDownloadFileName(), getPathToFile(), isConvertFileNameToAsci(), isUrlencodeFilename(), ilIniFile\readVariable(), setConvertFileNameToAsci(), setDownloadFileName(), setUrlencodeFilename(), and ilHTTP\status().

Referenced by setGeneralHeaders().

784  {
785  if ($this->getPathToFile() != self::DIRECT_PHP_OUTPUT
786  && !file_exists($this->getPathToFile())
787  ) {
788  ilHTTP::status(404);
789  $this->close();
790  }
791  }
static status($status)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clearBuffer()

ilFileDelivery::clearBuffer ( )

Definition at line 774 of file class.ilFileDelivery.php.

References ilWACLog\getInstance().

Referenced by deliver(), and ilPHPOutputDelivery\start().

774  {
775  $ob_get_contents = ob_get_contents();
776  if ($ob_get_contents) {
777  ilWACLog::getInstance()->write(__CLASS__ . ' had output before file delivery: '
778  . $ob_get_contents);
779  }
780  ob_end_clean(); // fixed 0016469, 0016467, 0016468
781  }
static getInstance()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clearHeaders()

ilFileDelivery::clearHeaders ( )
protected

Definition at line 273 of file class.ilFileDelivery.php.

Referenced by deliverVirtual(), and deliverXAccelRedirect().

273  {
274  header_remove();
275  }
+ Here is the caller graph for this function:

◆ close()

ilFileDelivery::close ( )

Definition at line 318 of file class.ilFileDelivery.php.

References exit.

Referenced by checkExisting(), deliver(), deliverPHPChunked(), and ilPHPOutputDelivery\stop().

318  {
319  exit;
320  }
+ Here is the caller graph for this function:

◆ deliver()

ilFileDelivery::deliver ( )

Definition at line 181 of file class.ilFileDelivery.php.

References checkCache(), clearBuffer(), close(), deliverPHP(), deliverPHPChunked(), deliverVirtual(), deliverXAccelRedirect(), deliverXSendfile(), getDeliveryType(), getPathToFile(), isDeleteFile(), isExitAfter(), and setGeneralHeaders().

Referenced by stream().

181  {
182  $this->cleanDownloadFileName();
183  $this->clearBuffer();
184  $this->checkCache();
185  $this->setGeneralHeaders();
186  switch ($this->getDeliveryType()) {
187  default:
188  $this->deliverPHP();
189  break;
190  case self::DELIVERY_METHOD_XSENDFILE:
191  $this->deliverXSendfile();
192  break;
193  case self::DELIVERY_METHOD_XACCEL:
194  $this->deliverXAccelRedirect();
195  break;
196  case self::DELIVERY_METHOD_PHP_CHUNKED:
197  $this->deliverPHPChunked();
198  break;
199  case self::DELIVERY_METHOD_VIRTUAL:
200  $this->deliverVirtual();
201  break;
202  case self::DELIVERY_METHOD_NONE;
203  break;
204  }
205  if ($this->isDeleteFile()) {
206  unlink($this->getPathToFile());
207  }
208  if ($this->isExitAfter()) {
209  $this->close();
210  }
211  }
deliverVirtual()
not supported
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deliverFileAttached()

static ilFileDelivery::deliverFileAttached (   $path_to_file,
  $download_file_name = null,
  $mime_type = null,
  $delete_file = false 
)
static
Parameters
$path_to_file
null$download_file_name
null$mime_type
bool$delete_file

Definition at line 112 of file class.ilFileDelivery.php.

References $delete_file, $download_file_name, $mime_type, and $path_to_file.

Referenced by ilSystemStyleSkinContainer\export(), and ilObjBibliographicGUI\sendFile().

112  {
113  $obj = new self($path_to_file);
114  if ($download_file_name) {
115  $obj->setDownloadFileName($download_file_name);
116  }
117  if ($mime_type) {
118  $obj->setMimeType($mime_type);
119  }
120  $obj->setDisposition(self::DISP_ATTACHMENT);
121  $obj->setDeleteFile($delete_file);
122  $obj->deliver();
123  }
+ Here is the caller graph for this function:

◆ deliverFileInline()

static ilFileDelivery::deliverFileInline (   $path_to_file,
  $download_file_name = null 
)
static
Parameters
$path_to_file
null$download_file_name

Definition at line 144 of file class.ilFileDelivery.php.

References $download_file_name, and $path_to_file.

144  {
145  $obj = new self($path_to_file);
146 
147  if ($download_file_name) {
148  $obj->setDownloadFileName($download_file_name);
149  }
150  $obj->setDisposition(self::DISP_INLINE);
151  $obj->deliver();
152  }

◆ deliverPHP()

ilFileDelivery::deliverPHP ( )
protected

Definition at line 265 of file class.ilFileDelivery.php.

References $file, and getPathToFile().

Referenced by deliver().

265  {
266  set_time_limit(0);
267  $file = fopen(($this->getPathToFile()), "rb");
268 
269  fpassthru($file);
270  }
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deliverPHPChunked()

ilFileDelivery::deliverPHPChunked ( )
protected

Definition at line 610 of file class.ilFileDelivery.php.

References $_SERVER, $file, $size, $start, close(), getPathToFile(), header, and ilHTTP\status().

Referenced by deliver().

610  {
611  $file = $this->getPathToFile();
612  $fp = @fopen($file, 'rb');
613 
614  $size = filesize($file); // File size
615  $length = $size; // Content length
616  $start = 0; // Start byte
617  $end = $size - 1; // End byte
618  // Now that we've gotten so far without errors we send the accept range header
619  /* At the moment we only support single ranges.
620  * Multiple ranges requires some more work to ensure it works correctly
621  * and comply with the spesifications: http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.2
622  *
623  * Multirange support annouces itself with:
624  * header('Accept-Ranges: bytes');
625  *
626  * Multirange content must be sent with multipart/byteranges mediatype,
627  * (mediatype = mimetype)
628  * as well as a boundry header to indicate the various chunks of data.
629  */
630  header("Accept-Ranges: 0-$length");
631  // header('Accept-Ranges: bytes');
632  // multipart/byteranges
633  // http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.2
634  if (isset($_SERVER['HTTP_RANGE'])) {
635  $c_start = $start;
636  $c_end = $end;
637 
638  // Extract the range string
639  list(, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2);
640  // Make sure the client hasn't sent us a multibyte range
641  if (strpos($range, ',') !== false) {
642  // (?) Shoud this be issued here, or should the first
643  // range be used? Or should the header be ignored and
644  // we output the whole content?
645  ilHTTP::status(416);
646  header("Content-Range: bytes $start-$end/$size");
647  // (?) Echo some info to the client?
648  $this->close();
649  } // fim do if
650  // If the range starts with an '-' we start from the beginning
651  // If not, we forward the file pointer
652  // And make sure to get the end byte if spesified
653  if ($range{0} == '-') {
654  // The n-number of the last bytes is requested
655  $c_start = $size - substr($range, 1);
656  } else {
657  $range = explode('-', $range);
658  $c_start = $range[0];
659  $c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] : $size;
660  } // fim do if
661  /* Check the range and make sure it's treated according to the specs.
662  * http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
663  */
664  // End bytes can not be larger than $end.
665  $c_end = ($c_end > $end) ? $end : $c_end;
666  // Validate the requested range and return an error if it's not correct.
667  if ($c_start > $c_end || $c_start > $size - 1 || $c_end >= $size) {
668  ilHTTP::status(416);
669  header("Content-Range: bytes $start-$end/$size");
670  // (?) Echo some info to the client?
671  $this->close();
672  } // fim do if
673 
674  $start = $c_start;
675  $end = $c_end;
676  $length = $end - $start + 1; // Calculate new content length
677  fseek($fp, $start);
678  ilHTTP::status(206);
679  } // fim do if
680 
681  // Notify the client the byte range we'll be outputting
682  header("Content-Range: bytes $start-$end/$size");
683  header("Content-Length: $length");
684 
685  // Start buffered download
686  $buffer = 1024 * 8;
687  while (!feof($fp) && ($p = ftell($fp)) <= $end) {
688  if ($p + $buffer > $end) {
689  // In case we're only outputtin a chunk, make sure we don't
690  // read past the length
691  $buffer = $end - $p + 1;
692  } // fim do if
693 
694  set_time_limit(0); // Reset time limit for big files
695  echo fread($fp, $buffer);
696  flush(); // Free up memory. Otherwise large files will trigger PHP's memory limit.
697  } // fim do while
698 
699  fclose($fp);
700  }
$size
Definition: RandomTest.php:79
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
static status($status)
Add a drawing to the header
Definition: 04printing.php:69
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deliverVirtual()

ilFileDelivery::deliverVirtual ( )

not supported

Definition at line 217 of file class.ilFileDelivery.php.

References $path_to_file, clearHeaders(), getPathToFile(), and header.

Referenced by deliver().

217  {
218  $path_to_file = $this->getPathToFile();
219  $this->clearHeaders();
220  header('Content-type:');
221  if (strpos($path_to_file, './' . self::DATA . '/') === 0
222  && is_dir('./' . self::VIRTUAL_DATA)
223  ) {
224  $path_to_file = str_replace('./' . self::DATA . '/', '/' . self::VIRTUAL_DATA
225  . '/', $path_to_file);
226  }
227  virtual($path_to_file);
228  }
Add a drawing to the header
Definition: 04printing.php:69
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deliverXAccelRedirect()

ilFileDelivery::deliverXAccelRedirect ( )
protected

Definition at line 244 of file class.ilFileDelivery.php.

References $path_to_file, clearHeaders(), getPathToFile(), header, isDeleteFile(), and sendFileUnbufferedUsingHeaders().

Referenced by deliver().

244  {
245  $this->clearHeaders();
246  $path_to_file = $this->getPathToFile();
247 
248  if (strpos($path_to_file, './' . self::DATA . '/') === 0) {
249  $path_to_file = str_replace('./' . self::DATA . '/', '/' . self::SECURED_DATA
250  . '/', $path_to_file);
251  }
252 
253  $closure = function () use ($path_to_file) {
254  header('Content-type:');
255  header('X-Accel-Redirect: ' . ($path_to_file));
256  };
257  if ($this->isDeleteFile()) {
258  $this->sendFileUnbufferedUsingHeaders($closure);
259  } else {
260  $closure();
261  }
262  }
Add a drawing to the header
Definition: 04printing.php:69
sendFileUnbufferedUsingHeaders(\Closure $closure)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deliverXSendfile()

ilFileDelivery::deliverXSendfile ( )
protected

Definition at line 231 of file class.ilFileDelivery.php.

References getPathToFile(), header, isDeleteFile(), and sendFileUnbufferedUsingHeaders().

Referenced by deliver().

231  {
232  $realpath = realpath($this->getPathToFile());
233  $closure = function () use ($realpath) {
234  header('X-Sendfile: ' . $realpath);
235  };
236  if ($this->isDeleteFile()) {
237  $this->sendFileUnbufferedUsingHeaders($closure);
238  } else {
239  $closure();
240  }
241  }
Add a drawing to the header
Definition: 04printing.php:69
sendFileUnbufferedUsingHeaders(\Closure $closure)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ detemineDeliveryType()

ilFileDelivery::detemineDeliveryType ( )
protected
Returns
bool

Definition at line 360 of file class.ilFileDelivery.php.

References getDeliveryType(), ilRuntime\getInstance(), ilWACLog\getInstance(), getPathToFile(), and setDeliveryType().

Referenced by __construct().

360  {
361  if (self::$delivery_type_static) {
362  ilWACLog::getInstance()->write('used cached delivery type');
363  $this->setDeliveryType(self::$delivery_type_static);
364 
365  return true;
366  }
367 
368  if (function_exists('apache_get_modules')
369  && in_array('mod_xsendfile', apache_get_modules())
370  ) {
371  $this->setDeliveryType(self::DELIVERY_METHOD_XSENDFILE);
372  }
373 
374  if (is_file('./Services/FileDelivery/classes/override.php')) {
375  $override_delivery_type = false;
376  require_once('./Services/FileDelivery/classes/override.php');
377  if ($override_delivery_type) {
378  $this->setDeliveryType($override_delivery_type);
379  }
380  }
381 
382  require_once('./Services/Environment/classes/class.ilRuntime.php');
383  $ilRuntime = ilRuntime::getInstance();
384  if ((!$ilRuntime->isFPM() && !$ilRuntime->isHHVM())
385  && $this->getDeliveryType() == self::DELIVERY_METHOD_XACCEL
386  ) {
387  $this->setDeliveryType(self::DELIVERY_METHOD_PHP);
388  }
389 
390  if ($this->getDeliveryType() == self::DELIVERY_METHOD_XACCEL
391  && strpos($this->getPathToFile(), './data') !== 0
392  ) {
393  $this->setDeliveryType(self::DELIVERY_METHOD_PHP);
394  }
395 
396  self::$delivery_type_static = $this->getDeliveryType();
397 
398  return true;
399  }
static getInstance()
static getInstance()
setDeliveryType($delivery_type)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ determineDownloadFileName()

ilFileDelivery::determineDownloadFileName ( )
protected
Returns
bool

Definition at line 349 of file class.ilFileDelivery.php.

References $download_file_name, getDownloadFileName(), getPathToFile(), and setDownloadFileName().

Referenced by __construct().

349  {
350  if (!$this->getDownloadFileName()) {
351  $download_file_name = basename($this->getPathToFile());
353  }
354  }
setDownloadFileName($download_file_name)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ determineMimeType()

ilFileDelivery::determineMimeType ( )
protected
Returns
bool

Definition at line 326 of file class.ilFileDelivery.php.

References $info, ilMimeTypeUtil\APPLICATION__OCTET_STREAM, getPathToFile(), ilMimeTypeUtil\lookupMimeType(), and setMimeType().

Referenced by __construct().

326  {
328  if ($info) {
329  $this->setMimeType($info);
330 
331  return true;
332  }
333  $finfo = finfo_open(FILEINFO_MIME_TYPE);
334  $info = finfo_file($finfo, $this->getPathToFile());
335  finfo_close($finfo);
336  if ($info) {
337  $this->setMimeType($info);
338 
339  return true;
340  }
341 
342  return false;
343  }
static lookupMimeType($path_to_file, $fallback=self::APPLICATION__OCTET_STREAM, $a_external=false)
$info
Definition: example_052.php:80
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generateEtag()

ilFileDelivery::generateEtag ( )

Definition at line 313 of file class.ilFileDelivery.php.

References getPathToFile(), and setEtag().

Referenced by checkCache().

313  {
314  $this->setEtag(md5(filemtime($this->getPathToFile()) . filesize($this->getPathToFile())));
315  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDeliveryType()

ilFileDelivery::getDeliveryType ( )
Returns
string

Definition at line 405 of file class.ilFileDelivery.php.

References $delivery_type.

Referenced by deliver(), detemineDeliveryType(), setGeneralHeaders(), and stream().

405  {
406  return $this->delivery_type;
407  }
+ Here is the caller graph for this function:

◆ getDisposition()

ilFileDelivery::getDisposition ( )
Returns
string

Definition at line 469 of file class.ilFileDelivery.php.

References $disposition.

Referenced by setGeneralHeaders().

469  {
470  return $this->disposition;
471  }
+ Here is the caller graph for this function:

◆ getDownloadFileName()

ilFileDelivery::getDownloadFileName ( )
Returns
string

Definition at line 453 of file class.ilFileDelivery.php.

References $download_file_name.

Referenced by checkExisting(), determineDownloadFileName(), and setGeneralHeaders().

453  {
455  }
+ Here is the caller graph for this function:

◆ getEtag()

ilFileDelivery::getEtag ( )
Returns
string

Definition at line 533 of file class.ilFileDelivery.php.

References $etag.

Referenced by isNonModified(), and sendEtagHeader().

533  {
534  return $this->etag;
535  }
+ Here is the caller graph for this function:

◆ getMimeType()

ilFileDelivery::getMimeType ( )
Returns
string

Definition at line 421 of file class.ilFileDelivery.php.

References $mime_type.

Referenced by setGeneralHeaders().

421  {
422  return $this->mime_type;
423  }
+ Here is the caller graph for this function:

◆ getPathToFile()

◆ getShowLastModified()

ilFileDelivery::getShowLastModified ( )
Returns
boolean

Definition at line 549 of file class.ilFileDelivery.php.

References $show_last_modified.

Referenced by sendLastModified().

549  {
551  }
+ Here is the caller graph for this function:

◆ hasCache()

ilFileDelivery::hasCache ( )
Returns
boolean

Definition at line 581 of file class.ilFileDelivery.php.

References $cache.

Referenced by checkCache().

581  {
582  return $this->cache;
583  }
+ Here is the caller graph for this function:

◆ hasHashFilename()

ilFileDelivery::hasHashFilename ( )
Returns
boolean

Definition at line 597 of file class.ilFileDelivery.php.

References $hash_filename.

Referenced by setGeneralHeaders().

597  {
598  return $this->hash_filename;
599  }
+ Here is the caller graph for this function:

◆ isConvertFileNameToAsci()

ilFileDelivery::isConvertFileNameToAsci ( )
Returns
boolean

Definition at line 517 of file class.ilFileDelivery.php.

References $convert_file_name_to_asci.

Referenced by checkExisting(), and setGeneralHeaders().

517  {
519  }
+ Here is the caller graph for this function:

◆ isDEBUG()

static ilFileDelivery::isDEBUG ( )
static
Returns
boolean

Definition at line 747 of file class.ilFileDelivery.php.

747  {
748  return self::$DEBUG;
749  }

◆ isDeleteFile()

ilFileDelivery::isDeleteFile ( )
Returns
boolean

Definition at line 832 of file class.ilFileDelivery.php.

References $delete_file.

Referenced by deliver(), deliverXAccelRedirect(), and deliverXSendfile().

832  {
833  return $this->delete_file;
834  }
+ Here is the caller graph for this function:

◆ isExitAfter()

ilFileDelivery::isExitAfter ( )
Returns
boolean

Definition at line 501 of file class.ilFileDelivery.php.

References $exit_after.

Referenced by deliver().

501  {
502  return $this->exit_after;
503  }
+ Here is the caller graph for this function:

◆ isHasContext()

ilFileDelivery::isHasContext ( )
Returns
boolean

Definition at line 565 of file class.ilFileDelivery.php.

References $has_context.

565  {
566  return $this->has_context;
567  }

◆ isNonModified()

ilFileDelivery::isNonModified ( )
protected
Returns
bool

Definition at line 721 of file class.ilFileDelivery.php.

References $_SERVER, getEtag(), and getPathToFile().

Referenced by checkCache().

721  {
722  if (self::$DEBUG) {
723  return false;
724  }
725 
726  if (!isset($_SERVER['HTTP_IF_NONE_MATCH']) || !isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
727  return false;
728  }
729 
730  $http_if_none_match = $_SERVER['HTTP_IF_NONE_MATCH'];
731  $http_if_modified_since = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
732 
733  switch (true) {
734  case ($http_if_none_match != $this->getEtag()):
735  return false;
736  case (@strtotime($http_if_modified_since) <= filemtime($this->getPathToFile())):
737  return false;
738  }
739 
740  return true;
741  }
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isSendMimeType()

ilFileDelivery::isSendMimeType ( )
Returns
boolean

Definition at line 485 of file class.ilFileDelivery.php.

References $send_mime_type.

Referenced by setGeneralHeaders().

485  {
486  return $this->send_mime_type;
487  }
+ Here is the caller graph for this function:

◆ isUrlencodeFilename()

ilFileDelivery::isUrlencodeFilename ( )
Returns
bool

Definition at line 848 of file class.ilFileDelivery.php.

References $urlencode_filename.

Referenced by checkExisting().

848  {
850  }
+ Here is the caller graph for this function:

◆ returnASCIIFileName()

static ilFileDelivery::returnASCIIFileName (   $original_name)
static
Parameters
$original_name
Returns
string

Definition at line 823 of file class.ilFileDelivery.php.

References ilUtil\getASCIIFilename().

823  {
824  return ilUtil::getASCIIFilename($original_name);
825  // return iconv("UTF-8", "ASCII//TRANSLIT", $original_name); // proposal
826  }
static getASCIIFilename($a_filename)
convert utf8 to ascii filename
+ Here is the call graph for this function:

◆ sendEtagHeader()

ilFileDelivery::sendEtagHeader ( )
protected

Definition at line 703 of file class.ilFileDelivery.php.

References getEtag(), and header.

Referenced by checkCache(), and setCachingHeaders().

703  {
704  if ($this->getEtag()) {
705  header('ETag: ' . $this->getEtag() . '');
706  }
707  }
Add a drawing to the header
Definition: 04printing.php:69
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendFileUnbufferedUsingHeaders()

ilFileDelivery::sendFileUnbufferedUsingHeaders ( \Closure  $closure)
protected
Parameters
\Closure$closurewhich sets the output-headers, e.g. header('X-Sendfile: ' . realpath($this->getPathToFile()));

Definition at line 865 of file class.ilFileDelivery.php.

Referenced by deliverXAccelRedirect(), and deliverXSendfile().

865  {
866  ignore_user_abort(true);
867  set_time_limit(0);
868  ob_start();
869 
870  $closure();
871 
872  ob_flush();
873  ob_end_flush();
874  flush();
875  }
+ Here is the caller graph for this function:

◆ sendLastModified()

ilFileDelivery::sendLastModified ( )
protected

Definition at line 710 of file class.ilFileDelivery.php.

References date, getPathToFile(), getShowLastModified(), and header.

Referenced by setCachingHeaders().

710  {
711  if ($this->getShowLastModified()) {
712  header('Last-Modified: ' . date("D, j M Y H:i:s", filemtime($this->getPathToFile()))
713  . " GMT");
714  }
715  }
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
Add a drawing to the header
Definition: 04printing.php:69
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCache()

ilFileDelivery::setCache (   $cache)
Parameters
boolean$cache

Definition at line 589 of file class.ilFileDelivery.php.

References $cache.

Referenced by ilWebAccessCheckerDelivery\deliver().

589  {
590  $this->cache = $cache;
591  }
+ Here is the caller graph for this function:

◆ setCachingHeaders()

ilFileDelivery::setCachingHeaders ( )

Definition at line 305 of file class.ilFileDelivery.php.

References header, sendEtagHeader(), and sendLastModified().

Referenced by checkCache(), and ilPHPOutputDelivery\start().

305  {
306  header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
307  header('Pragma: public');
308  $this->sendEtagHeader();
309  $this->sendLastModified();
310  }
Add a drawing to the header
Definition: 04printing.php:69
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setConvertFileNameToAsci()

ilFileDelivery::setConvertFileNameToAsci (   $convert_file_name_to_asci)
Parameters
boolean$convert_file_name_to_asci

Definition at line 525 of file class.ilFileDelivery.php.

References $convert_file_name_to_asci.

Referenced by checkExisting().

525  {
526  $this->convert_file_name_to_asci = $convert_file_name_to_asci;
527  }
+ Here is the caller graph for this function:

◆ setDEBUG()

static ilFileDelivery::setDEBUG (   $DEBUG)
static
Parameters
boolean$DEBUG

Definition at line 755 of file class.ilFileDelivery.php.

References $DEBUG.

755  {
756  self::$DEBUG = $DEBUG;
757  }

◆ setDeleteFile()

ilFileDelivery::setDeleteFile (   $delete_file)
Parameters
boolean$delete_file

Definition at line 840 of file class.ilFileDelivery.php.

References $delete_file.

840  {
841  $this->delete_file = $delete_file;
842  }

◆ setDeliveryType()

ilFileDelivery::setDeliveryType (   $delivery_type)
Parameters
string$delivery_type

Definition at line 413 of file class.ilFileDelivery.php.

References $delivery_type.

Referenced by detemineDeliveryType(), and stream().

413  {
414  $this->delivery_type = $delivery_type;
415  }
+ Here is the caller graph for this function:

◆ setDisposition()

ilFileDelivery::setDisposition (   $disposition)
Parameters
string$disposition

Definition at line 477 of file class.ilFileDelivery.php.

References $disposition.

Referenced by ilWebAccessCheckerDelivery\deliverDummyImage(), ilWebAccessCheckerDelivery\deliverDummyVideo(), and ilPHPOutputDelivery\start().

477  {
478  $this->disposition = $disposition;
479  }
+ Here is the caller graph for this function:

◆ setDownloadFileName()

ilFileDelivery::setDownloadFileName (   $download_file_name)
Parameters
string$download_file_name

Definition at line 461 of file class.ilFileDelivery.php.

References $download_file_name.

Referenced by checkExisting(), determineDownloadFileName(), and ilPHPOutputDelivery\start().

461  {
462  $this->download_file_name = $download_file_name;
463  }
+ Here is the caller graph for this function:

◆ setEtag()

ilFileDelivery::setEtag (   $etag)
Parameters
string$etag

Definition at line 541 of file class.ilFileDelivery.php.

References $etag.

Referenced by generateEtag().

541  {
542  $this->etag = $etag;
543  }
+ Here is the caller graph for this function:

◆ setExitAfter()

ilFileDelivery::setExitAfter (   $exit_after)
Parameters
boolean$exit_after

Definition at line 509 of file class.ilFileDelivery.php.

References $exit_after.

509  {
510  $this->exit_after = $exit_after;
511  }

◆ setGeneralHeaders()

ilFileDelivery::setGeneralHeaders ( )

Definition at line 278 of file class.ilFileDelivery.php.

References $download_file_name, checkExisting(), getDeliveryType(), getDisposition(), getDownloadFileName(), getMimeType(), getPathToFile(), hasHashFilename(), header, isConvertFileNameToAsci(), and isSendMimeType().

Referenced by deliver(), and ilPHPOutputDelivery\start().

278  {
279  header("X-ILIAS-FileDelivery-Method: " . $this->getDeliveryType());
280  $this->checkExisting();
281  if ($this->isSendMimeType()) {
282  header("Content-type: " . $this->getMimeType());
283  }
285  if ($this->isConvertFileNameToAsci()) {
286  $download_file_name = self::returnASCIIFileName($download_file_name);
287  }
288  if ($this->hasHashFilename()) {
290  }
291  header('Content-Disposition: ' . $this->getDisposition() . '; filename="'
292  . $download_file_name . '"');
293  header('Content-Description: ' . $download_file_name);
294  header('Accept-Ranges: bytes');
295  if ($this->getDeliveryType() == self::DELIVERY_METHOD_PHP
296  && $this->getPathToFile() != self::DIRECT_PHP_OUTPUT
297  ) {
298  header("Content-Length: " . (string)filesize($this->getPathToFile()));
299  }
300  header("Connection: close");
301  header("X-ILIAS-FileDelivery: " . $this->getDeliveryType());
302  }
Add a drawing to the header
Definition: 04printing.php:69
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setHasContext()

ilFileDelivery::setHasContext (   $has_context)
Parameters
boolean$has_context

Definition at line 573 of file class.ilFileDelivery.php.

References $has_context.

Referenced by __construct().

573  {
574  $this->has_context = $has_context;
575  }
+ Here is the caller graph for this function:

◆ setHashFilename()

ilFileDelivery::setHashFilename (   $hash_filename)
Parameters
boolean$hash_filename

Definition at line 605 of file class.ilFileDelivery.php.

References $hash_filename.

605  {
606  $this->hash_filename = $hash_filename;
607  }

◆ setMimeType()

ilFileDelivery::setMimeType (   $mime_type)
Parameters
string$mime_type

Definition at line 429 of file class.ilFileDelivery.php.

References $mime_type.

Referenced by determineMimeType(), and ilPHPOutputDelivery\start().

429  {
430  $this->mime_type = $mime_type;
431  }
+ Here is the caller graph for this function:

◆ setPathToFile()

ilFileDelivery::setPathToFile (   $path_to_file)
Parameters
string$path_to_file

Definition at line 445 of file class.ilFileDelivery.php.

References $path_to_file.

Referenced by __construct().

445  {
446  $this->path_to_file = $path_to_file;
447  }
+ Here is the caller graph for this function:

◆ setSendMimeType()

ilFileDelivery::setSendMimeType (   $send_mime_type)
Parameters
boolean$send_mime_type

Definition at line 493 of file class.ilFileDelivery.php.

References $send_mime_type.

493  {
494  $this->send_mime_type = $send_mime_type;
495  }

◆ setShowLastModified()

ilFileDelivery::setShowLastModified (   $show_last_modified)
Parameters
boolean$show_last_modified

Definition at line 557 of file class.ilFileDelivery.php.

References $show_last_modified.

Referenced by checkCache(), and ilPHPOutputDelivery\start().

557  {
558  $this->show_last_modified = $show_last_modified;
559  }
+ Here is the caller graph for this function:

◆ setUrlencodeFilename()

ilFileDelivery::setUrlencodeFilename (   $urlencode_filename)
Parameters
bool$urlencode_filename

Definition at line 856 of file class.ilFileDelivery.php.

References $urlencode_filename.

Referenced by checkExisting().

856  {
857  $this->urlencode_filename = $urlencode_filename;
858  }
+ Here is the caller graph for this function:

◆ stream()

ilFileDelivery::stream ( )

Definition at line 173 of file class.ilFileDelivery.php.

References deliver(), getDeliveryType(), and setDeliveryType().

173  {
174  if (!in_array($this->getDeliveryType(), self::$self_streaming_methods)) {
175  $this->setDeliveryType(self::DELIVERY_METHOD_PHP_CHUNKED);
176  }
177  $this->deliver();
178  }
setDeliveryType($delivery_type)
+ Here is the call graph for this function:

◆ streamVideoInline()

static ilFileDelivery::streamVideoInline (   $path_to_file,
  $download_file_name = null 
)
static
Parameters
$path_to_file
null$download_file_name

Definition at line 130 of file class.ilFileDelivery.php.

References $download_file_name, and $path_to_file.

130  {
131  $obj = new self($path_to_file);
132  if ($download_file_name) {
133  $obj->setDownloadFileName($download_file_name);
134  }
135  $obj->setDisposition(self::DISP_INLINE);
136  $obj->stream();
137  }

Field Documentation

◆ $cache

ilFileDelivery::$cache = false
protected

Definition at line 87 of file class.ilFileDelivery.php.

Referenced by hasCache(), and setCache().

◆ $convert_file_name_to_asci

ilFileDelivery::$convert_file_name_to_asci = true
protected

Definition at line 71 of file class.ilFileDelivery.php.

Referenced by isConvertFileNameToAsci(), and setConvertFileNameToAsci().

◆ $DEBUG

ilFileDelivery::$DEBUG = false
staticprotected

Definition at line 103 of file class.ilFileDelivery.php.

Referenced by setDEBUG().

◆ $delete_file

ilFileDelivery::$delete_file = false
protected

Definition at line 95 of file class.ilFileDelivery.php.

Referenced by deliverFileAttached(), isDeleteFile(), and setDeleteFile().

◆ $delivery_type

ilFileDelivery::$delivery_type = self::DELIVERY_METHOD_PHP
protected

Definition at line 43 of file class.ilFileDelivery.php.

Referenced by getDeliveryType(), and setDeliveryType().

◆ $delivery_type_static

ilFileDelivery::$delivery_type_static = null
staticprotected

Definition at line 39 of file class.ilFileDelivery.php.

◆ $disposition

ilFileDelivery::$disposition = self::DISP_ATTACHMENT
protected

Definition at line 59 of file class.ilFileDelivery.php.

Referenced by getDisposition(), and setDisposition().

◆ $download_file_name

◆ $etag

ilFileDelivery::$etag = ''
protected

Definition at line 75 of file class.ilFileDelivery.php.

Referenced by getEtag(), and setEtag().

◆ $exit_after

ilFileDelivery::$exit_after = true
protected

Definition at line 67 of file class.ilFileDelivery.php.

Referenced by isExitAfter(), and setExitAfter().

◆ $has_context

ilFileDelivery::$has_context = true
protected

Definition at line 83 of file class.ilFileDelivery.php.

Referenced by isHasContext(), and setHasContext().

◆ $hash_filename

ilFileDelivery::$hash_filename = false
protected

Definition at line 91 of file class.ilFileDelivery.php.

Referenced by hasHashFilename(), and setHashFilename().

◆ $mime_type

ilFileDelivery::$mime_type = ''
protected

Definition at line 47 of file class.ilFileDelivery.php.

Referenced by deliverFileAttached(), getMimeType(), and setMimeType().

◆ $path_to_file

◆ $self_streaming_methods

ilFileDelivery::$self_streaming_methods
staticprotected
Initial value:
self::DELIVERY_METHOD_XSENDFILE,
self::DELIVERY_METHOD_XACCEL,
)

Definition at line 32 of file class.ilFileDelivery.php.

◆ $send_mime_type

ilFileDelivery::$send_mime_type = true
protected

Definition at line 63 of file class.ilFileDelivery.php.

Referenced by isSendMimeType(), and setSendMimeType().

◆ $show_last_modified

ilFileDelivery::$show_last_modified = true
protected

Definition at line 79 of file class.ilFileDelivery.php.

Referenced by getShowLastModified(), and setShowLastModified().

◆ $urlencode_filename

ilFileDelivery::$urlencode_filename = false
protected

Definition at line 99 of file class.ilFileDelivery.php.

Referenced by isUrlencodeFilename(), and setUrlencodeFilename().

◆ DATA

const ilFileDelivery::DATA = 'data'

Definition at line 28 of file class.ilFileDelivery.php.

◆ DELIVERY_METHOD_NONE

const ilFileDelivery::DELIVERY_METHOD_NONE = 'cache'

Definition at line 18 of file class.ilFileDelivery.php.

◆ DELIVERY_METHOD_PHP

const ilFileDelivery::DELIVERY_METHOD_PHP = 'php'

Definition at line 21 of file class.ilFileDelivery.php.

◆ DELIVERY_METHOD_PHP_CHUNKED

const ilFileDelivery::DELIVERY_METHOD_PHP_CHUNKED = 'php_chunked'

Definition at line 22 of file class.ilFileDelivery.php.

◆ DELIVERY_METHOD_VIRTUAL

const ilFileDelivery::DELIVERY_METHOD_VIRTUAL = 'virtual'

Definition at line 23 of file class.ilFileDelivery.php.

◆ DELIVERY_METHOD_XACCEL

const ilFileDelivery::DELIVERY_METHOD_XACCEL = 'x-accel-redirect'

Definition at line 20 of file class.ilFileDelivery.php.

◆ DELIVERY_METHOD_XSENDFILE

const ilFileDelivery::DELIVERY_METHOD_XSENDFILE = 'mod_xsendfile'

Definition at line 19 of file class.ilFileDelivery.php.

◆ DIRECT_PHP_OUTPUT

const ilFileDelivery::DIRECT_PHP_OUTPUT = 'php://output'

Definition at line 17 of file class.ilFileDelivery.php.

Referenced by ilExcel\sendToClient(), and ilPHPOutputDelivery\start().

◆ DISP_ATTACHMENT

const ilFileDelivery::DISP_ATTACHMENT = 'attachment'

◆ DISP_INLINE

const ilFileDelivery::DISP_INLINE = 'inline'

Definition at line 25 of file class.ilFileDelivery.php.

Referenced by ilObjFile\determineFileSize().

◆ SECURED_DATA

const ilFileDelivery::SECURED_DATA = 'secured-data'

Definition at line 27 of file class.ilFileDelivery.php.

◆ VIRTUAL_DATA

const ilFileDelivery::VIRTUAL_DATA = 'virtual-data'

Definition at line 26 of file class.ilFileDelivery.php.


The documentation for this class was generated from the following file: