ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilFileDelivery Class Reference

Class ilFileDelivery. More...

+ Collaboration diagram for ilFileDelivery:

Public Member Functions

 __construct ($path_to_file)
 
 stream ()
 
 deliver ()
 
 deliverVirtual ()
 @description not supported More...
 
 setGeneralHeaders ()
 
 setCachingHeaders ()
 
 generateEtag ()
 
 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)
 
 isDeleteFile ()
 
 setDeleteFile ($delete_file)
 
 isUrlencodeFilename ()
 
 setUrlencodeFilename ($urlencode_filename)
 

Static Public Member Functions

static deliverFileAttached ($path_to_file, $download_file_name=null, $mime_type=null)
 
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 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 ()
 
 close ()
 
 determineMimeType ()
 
 determineDownloadFileName ()
 
 detemineDeliveryType ()
 
 deliverPHPChunked ()
 
 sendEtagHeader ()
 
 sendLastModified ()
 
 isNonModified ()
 
 checkCache ()
 
 clearBuffer ()
 
 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 14 of file class.ilFileDelivery.php.

Constructor & Destructor Documentation

◆ __construct()

ilFileDelivery::__construct (   $path_to_file)
Parameters
$path_to_file

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

153 {
154 $parts = parse_url($path_to_file);
155 $this->setPathToFile(($parts['path']));
156 $this->detemineDeliveryType();
157 $this->determineMimeType();
159 $this->setHasContext(ilContext::getType() !== null);
160 }
static getType()
Get context type.
setPathToFile($path_to_file)
setHasContext($has_context)

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

+ Here is the call graph for this function:

Member Function Documentation

◆ checkCache()

ilFileDelivery::checkCache ( )
protected

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

733 {
734 if ($this->hasCache()) {
735 $this->generateEtag();
736 $this->sendEtagHeader();
737 $this->setShowLastModified(true);
738 $this->setCachingHeaders();
739 if ($this->isNonModified()) {
740 //ilHTTP::status(304);
741 //$this->close();
742 }
743 }
744 }
setShowLastModified($show_last_modified)

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

Referenced by deliver().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkExisting()

ilFileDelivery::checkExisting ( )
protected

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

756 {
757 if (!file_exists($this->getPathToFile())) {
758 ilHTTP::status(404);
759 $this->close();
760 }
761 }
static status($status)

References close(), getPathToFile(), and ilHTTP\status().

Referenced by setGeneralHeaders().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clearBuffer()

ilFileDelivery::clearBuffer ( )
protected

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

747 {
748 $ob_get_contents = ob_get_contents();
749 if ($ob_get_contents) {
750 ilWACLog::getInstance()->write(__CLASS__ . ' had output before file delivery: ' . $ob_get_contents);
751 }
752 ob_end_clean(); // fixed 0016469, 0016467, 0016468
753 }
static getInstance()

References ilWACLog\getInstance().

Referenced by deliver().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clearHeaders()

ilFileDelivery::clearHeaders ( )
protected

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

256 {
257 header_remove();
258 }

Referenced by deliverVirtual(), and deliverXAccelRedirect().

+ Here is the caller graph for this function:

◆ close()

ilFileDelivery::close ( )
protected

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

298 {
299 exit;
300 }
exit
Definition: login.php:54

References exit.

Referenced by checkExisting(), deliver(), and deliverPHPChunked().

+ Here is the caller graph for this function:

◆ deliver()

ilFileDelivery::deliver ( )

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

171 {
172 $this->cleanDownloadFileName();
173 $this->clearBuffer();
174 $this->checkCache();
175 $this->setGeneralHeaders();
176 switch ($this->getDeliveryType()) {
177 default:
178 $this->deliverPHP();
179 break;
181 $this->deliverXSendfile();
182 break;
184 $this->deliverXAccelRedirect();
185 break;
187 $this->deliverPHPChunked();
188 break;
190 $this->deliverVirtual();
191 break;
193 break;
194 }
195 if ($this->isExitAfter()) {
196 $this->close();
197 }
198 }
deliverVirtual()
@description not supported

References checkCache(), clearBuffer(), close(), deliverPHP(), deliverPHPChunked(), deliverVirtual(), deliverXAccelRedirect(), deliverXSendfile(), DELIVERY_METHOD_NONE, DELIVERY_METHOD_PHP_CHUNKED, DELIVERY_METHOD_VIRTUAL, DELIVERY_METHOD_XACCEL, DELIVERY_METHOD_XSENDFILE, getDeliveryType(), isExitAfter(), and setGeneralHeaders().

Referenced by stream().

+ 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 
)
static
Parameters
$path_to_file
null$download_file_name

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

108 {
109 $obj = new self($path_to_file);
111 $obj->setDownloadFileName($download_file_name);
112 }
113 if ($mime_type) {
114 $obj->setMimeType($mime_type);
115 }
116 $obj->setDisposition(self::DISP_ATTACHMENT);
117 $obj->deliver();
118 }

References $download_file_name, $mime_type, and $path_to_file.

Referenced by ilObjBibliographicGUI\sendFile().

+ 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 139 of file class.ilFileDelivery.php.

139 {
140 $obj = new self($path_to_file);
141
143 $obj->setDownloadFileName($download_file_name);
144 }
145 $obj->setDisposition(self::DISP_INLINE);
146 $obj->deliver();
147 }

References $download_file_name, and $path_to_file.

◆ deliverPHP()

ilFileDelivery::deliverPHP ( )
protected

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

248 {
249 set_time_limit(0);
250 $file = fopen(($this->getPathToFile()), "rb");
251
252 fpassthru($file);
253 }
print $file

References $file, and getPathToFile().

Referenced by deliver().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deliverPHPChunked()

ilFileDelivery::deliverPHPChunked ( )
protected

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

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

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

Referenced by deliver().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deliverVirtual()

ilFileDelivery::deliverVirtual ( )

@description not supported

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

204 {
205 $path_to_file = $this->getPathToFile();
206 $this->clearHeaders();
207 header('Content-type:');
208 if (strpos($path_to_file, './' . self::DATA . '/') === 0 && is_dir('./' . self::VIRTUAL_DATA)) {
209 $path_to_file = str_replace('./' . self::DATA . '/', '/' . self::VIRTUAL_DATA . '/', $path_to_file);
210 }
211 virtual($path_to_file);
212 }

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

Referenced by deliver().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deliverXAccelRedirect()

ilFileDelivery::deliverXAccelRedirect ( )
protected

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

228 {
229 $this->clearHeaders();
230 $path_to_file = $this->getPathToFile();
231
232 if (strpos($path_to_file, './' . self::DATA . '/') === 0) {
233 $path_to_file = str_replace('./' . self::DATA . '/', '/' . self::SECURED_DATA . '/', $path_to_file);
234 }
235
236 $closure = function () use ($path_to_file) {
237 header('Content-type:');
238 header('X-Accel-Redirect: ' . ($path_to_file));
239 };
240 if ($this->isDeleteFile()) {
241 $this->sendFileUnbufferedUsingHeaders($closure);
242 } else {
243 $closure();
244 }
245 }
sendFileUnbufferedUsingHeaders(\Closure $closure)

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

Referenced by deliver().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deliverXSendfile()

ilFileDelivery::deliverXSendfile ( )
protected

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

215 {
216 $realpath = realpath($this->getPathToFile());
217 $closure = function () use ($realpath) {
218 header('X-Sendfile: ' . $realpath);
219 };
220 if ($this->isDeleteFile()) {
221 $this->sendFileUnbufferedUsingHeaders($closure);
222 } else {
223 $closure();
224 }
225 }

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

Referenced by deliver().

+ 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 340 of file class.ilFileDelivery.php.

340 {
341 if (self::$delivery_type_static) {
342 ilWACLog::getInstance()->write('used cached delivery type');
343 $this->setDeliveryType(self::$delivery_type_static);
344
345 return true;
346 }
347
348 if (function_exists('apache_get_modules') && in_array('mod_xsendfile', apache_get_modules())) {
349 $this->setDeliveryType(self::DELIVERY_METHOD_XSENDFILE);
350 }
351
352 if (is_file('./Services/FileDelivery/classes/override.php')) {
353 $override_delivery_type = false;
354 require_once('./Services/FileDelivery/classes/override.php');
355 if ($override_delivery_type) {
356 $this->setDeliveryType($override_delivery_type);
357 }
358 }
359
360 require_once('./Services/Environment/classes/class.ilRuntime.php');
361 $ilRuntime = ilRuntime::getInstance();
362 if ((!$ilRuntime->isFPM() && !$ilRuntime->isHHVM()) && $this->getDeliveryType() == self::DELIVERY_METHOD_XACCEL) {
363 $this->setDeliveryType(self::DELIVERY_METHOD_PHP);
364 }
365
366 if ($this->getDeliveryType() == self::DELIVERY_METHOD_XACCEL && strpos($this->getPathToFile(), './data') !== 0) {
367 $this->setDeliveryType(self::DELIVERY_METHOD_PHP);
368 }
369
370 self::$delivery_type_static = $this->getDeliveryType();
371
372 return true;
373 }
setDeliveryType($delivery_type)
static getInstance()

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

Referenced by __construct().

+ 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 329 of file class.ilFileDelivery.php.

329 {
330 if (!$this->getDownloadFileName()) {
331 $download_file_name = basename($this->getPathToFile());
333 }
334 }
setDownloadFileName($download_file_name)

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

Referenced by __construct().

+ 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 306 of file class.ilFileDelivery.php.

306 {
308 if ($info) {
309 $this->setMimeType($info);
310
311 return true;
312 }
313 $finfo = finfo_open(FILEINFO_MIME_TYPE);
314 $info = finfo_file($finfo, $this->getPathToFile());
315 finfo_close($finfo);
316 if ($info) {
317 $this->setMimeType($info);
318
319 return true;
320 }
321
322 return false;
323 }
static lookupMimeType($path_to_file, $fallback=self::APPLICATION__OCTET_STREAM, $a_external=false)
$info
Definition: example_052.php:80

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

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generateEtag()

ilFileDelivery::generateEtag ( )

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

293 {
294 $this->setEtag(md5(filemtime($this->getPathToFile()) . filesize($this->getPathToFile())));
295 }

References getPathToFile(), and setEtag().

Referenced by checkCache().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDeliveryType()

ilFileDelivery::getDeliveryType ( )
Returns
string

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

379 {
381 }

References $delivery_type.

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

+ Here is the caller graph for this function:

◆ getDisposition()

ilFileDelivery::getDisposition ( )
Returns
string

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

443 {
444 return $this->disposition;
445 }

References $disposition.

Referenced by setGeneralHeaders().

+ Here is the caller graph for this function:

◆ getDownloadFileName()

ilFileDelivery::getDownloadFileName ( )
Returns
string

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

427 {
429 }

References $download_file_name.

Referenced by determineDownloadFileName(), and setGeneralHeaders().

+ Here is the caller graph for this function:

◆ getEtag()

ilFileDelivery::getEtag ( )
Returns
string

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

507 {
508 return $this->etag;
509 }

References $etag.

Referenced by isNonModified(), and sendEtagHeader().

+ Here is the caller graph for this function:

◆ getMimeType()

ilFileDelivery::getMimeType ( )
Returns
string

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

395 {
396 return $this->mime_type;
397 }

References $mime_type.

Referenced by setGeneralHeaders().

+ Here is the caller graph for this function:

◆ getPathToFile()

ilFileDelivery::getPathToFile ( )

◆ getShowLastModified()

ilFileDelivery::getShowLastModified ( )
Returns
boolean

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

523 {
525 }

References $show_last_modified.

Referenced by sendLastModified().

+ Here is the caller graph for this function:

◆ hasCache()

ilFileDelivery::hasCache ( )
Returns
boolean

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

555 {
556 return $this->cache;
557 }

References $cache.

Referenced by checkCache().

+ Here is the caller graph for this function:

◆ hasHashFilename()

ilFileDelivery::hasHashFilename ( )
Returns
boolean

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

571 {
573 }

References $hash_filename.

Referenced by setGeneralHeaders().

+ Here is the caller graph for this function:

◆ isConvertFileNameToAsci()

ilFileDelivery::isConvertFileNameToAsci ( )
Returns
boolean

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

References $convert_file_name_to_asci.

Referenced by setGeneralHeaders().

+ Here is the caller graph for this function:

◆ isDEBUG()

static ilFileDelivery::isDEBUG ( )
static
Returns
boolean

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

720 {
721 return self::$DEBUG;
722 }

References $DEBUG.

◆ isDeleteFile()

ilFileDelivery::isDeleteFile ( )
Returns
boolean

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

799 {
800 return $this->delete_file;
801 }

References $delete_file.

Referenced by deliverXAccelRedirect(), and deliverXSendfile().

+ Here is the caller graph for this function:

◆ isExitAfter()

ilFileDelivery::isExitAfter ( )
Returns
boolean

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

475 {
476 return $this->exit_after;
477 }

References $exit_after.

Referenced by deliver().

+ Here is the caller graph for this function:

◆ isHasContext()

ilFileDelivery::isHasContext ( )
Returns
boolean

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

539 {
540 return $this->has_context;
541 }

References $has_context.

◆ isNonModified()

ilFileDelivery::isNonModified ( )
protected
Returns
bool

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

694 {
695 if (self::$DEBUG) {
696 return false;
697 }
698
699 if (!isset($_SERVER['HTTP_IF_NONE_MATCH']) || !isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
700 return false;
701 }
702
703 $http_if_none_match = $_SERVER['HTTP_IF_NONE_MATCH'];
704 $http_if_modified_since = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
705
706 switch (true) {
707 case ($http_if_none_match != $this->getEtag()):
708 return false;
709 case (@strtotime($http_if_modified_since) <= filemtime($this->getPathToFile())):
710 return false;
711 }
712
713 return true;
714 }

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

Referenced by checkCache().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isSendMimeType()

ilFileDelivery::isSendMimeType ( )
Returns
boolean

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

459 {
461 }

References $send_mime_type.

Referenced by setGeneralHeaders().

+ Here is the caller graph for this function:

◆ isUrlencodeFilename()

ilFileDelivery::isUrlencodeFilename ( )
Returns
bool

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

815 {
817 }

References $urlencode_filename.

◆ returnASCIIFileName()

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

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

790 {
791 return ilUtil::getASCIIFilename($original_name);
792 // return iconv("UTF-8", "ASCII//TRANSLIT", $original_name); // proposal
793 }
static getASCIIFilename($a_filename)
convert utf8 to ascii filename

References ilUtil\getASCIIFilename().

Referenced by setGeneralHeaders().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendEtagHeader()

ilFileDelivery::sendEtagHeader ( )
protected

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

677 {
678 if ($this->getEtag()) {
679 header('ETag: ' . $this->getEtag() . '');
680 }
681 }

References getEtag().

Referenced by checkCache(), and setCachingHeaders().

+ 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 832 of file class.ilFileDelivery.php.

832 {
833 ignore_user_abort(true);
834 set_time_limit(0);
835 ob_start();
836
837 $closure();
838
839 ob_flush();
840 ob_end_flush();
841 flush();
842 }

Referenced by deliverXAccelRedirect(), and deliverXSendfile().

+ Here is the caller graph for this function:

◆ sendLastModified()

ilFileDelivery::sendLastModified ( )
protected

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

684 {
685 if ($this->getShowLastModified()) {
686 header('Last-Modified: ' . date("D, j M Y H:i:s", filemtime($this->getPathToFile())) . " GMT");
687 }
688 }

References getPathToFile(), and getShowLastModified().

Referenced by setCachingHeaders().

+ 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 563 of file class.ilFileDelivery.php.

563 {
564 $this->cache = $cache;
565 }

References $cache.

◆ setCachingHeaders()

ilFileDelivery::setCachingHeaders ( )

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

285 {
286 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
287 header('Pragma: public');
288 $this->sendEtagHeader();
289 $this->sendLastModified();
290 }

References sendEtagHeader(), and sendLastModified().

Referenced by checkCache().

+ 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 499 of file class.ilFileDelivery.php.

499 {
500 $this->convert_file_name_to_asci = $convert_file_name_to_asci;
501 }

References $convert_file_name_to_asci.

◆ setDEBUG()

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

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

728 {
729 self::$DEBUG = $DEBUG;
730 }

References $DEBUG.

◆ setDeleteFile()

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

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

807 {
808 $this->delete_file = $delete_file;
809 }

References $delete_file.

◆ setDeliveryType()

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

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

387 {
388 $this->delivery_type = $delivery_type;
389 }

References $delivery_type.

Referenced by detemineDeliveryType(), and stream().

+ Here is the caller graph for this function:

◆ setDisposition()

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

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

451 {
452 $this->disposition = $disposition;
453 }

References $disposition.

◆ setDownloadFileName()

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

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

435 {
436 $this->download_file_name = $download_file_name;
437 }

References $download_file_name.

Referenced by determineDownloadFileName().

+ Here is the caller graph for this function:

◆ setEtag()

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

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

515 {
516 $this->etag = $etag;
517 }

References $etag.

Referenced by generateEtag().

+ Here is the caller graph for this function:

◆ setExitAfter()

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

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

483 {
484 $this->exit_after = $exit_after;
485 }

References $exit_after.

◆ setGeneralHeaders()

ilFileDelivery::setGeneralHeaders ( )

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

261 {
262 header("X-ILIAS-FileDelivery-Method: " . $this->getDeliveryType());
263 $this->checkExisting();
264 if ($this->isSendMimeType()) {
265 header("Content-type: " . $this->getMimeType());
266 }
268 if ($this->isConvertFileNameToAsci()) {
270 }
271 if ($this->hasHashFilename()) {
273 }
274 header('Content-Disposition: ' . $this->getDisposition() . '; filename="' . $download_file_name . '"');
275 header('Content-Description: ' . $download_file_name);
276 header('Accept-Ranges: bytes');
277 if ($this->getDeliveryType() == self::DELIVERY_METHOD_PHP) {
278 header("Content-Length: " . (string)filesize($this->getPathToFile()));
279 }
280 header("Connection: close");
281 header("X-ILIAS-FileDelivery: " . $this->getDeliveryType());
282 }
static returnASCIIFileName($original_name)

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

Referenced by deliver().

+ 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 547 of file class.ilFileDelivery.php.

547 {
548 $this->has_context = $has_context;
549 }

References $has_context.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setHashFilename()

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

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

579 {
580 $this->hash_filename = $hash_filename;
581 }

References $hash_filename.

◆ setMimeType()

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

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

403 {
404 $this->mime_type = $mime_type;
405 }

References $mime_type.

Referenced by determineMimeType().

+ Here is the caller graph for this function:

◆ setPathToFile()

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

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

419 {
420 $this->path_to_file = $path_to_file;
421 }

References $path_to_file.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setSendMimeType()

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

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

467 {
468 $this->send_mime_type = $send_mime_type;
469 }

References $send_mime_type.

◆ setShowLastModified()

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

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

531 {
532 $this->show_last_modified = $show_last_modified;
533 }

References $show_last_modified.

Referenced by checkCache().

+ Here is the caller graph for this function:

◆ setUrlencodeFilename()

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

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

823 {
824 $this->urlencode_filename = $urlencode_filename;
825 }

References $urlencode_filename.

◆ stream()

ilFileDelivery::stream ( )

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

163 {
164 if (!in_array($this->getDeliveryType(), self::$self_streaming_methods)) {
165 $this->setDeliveryType(self::DELIVERY_METHOD_PHP_CHUNKED);
166 }
167 $this->deliver();
168 }

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

+ 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 125 of file class.ilFileDelivery.php.

125 {
126 $obj = new self($path_to_file);
128 $obj->setDownloadFileName($download_file_name);
129 }
130 $obj->setDisposition(self::DISP_INLINE);
131 $obj->stream();
132 }

References $download_file_name, and $path_to_file.

Field Documentation

◆ $cache

ilFileDelivery::$cache = false
protected

Definition at line 85 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 69 of file class.ilFileDelivery.php.

Referenced by isConvertFileNameToAsci(), and setConvertFileNameToAsci().

◆ $DEBUG

ilFileDelivery::$DEBUG = false
staticprotected

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

Referenced by isDEBUG(), and setDEBUG().

◆ $delete_file

ilFileDelivery::$delete_file = false
protected

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

Referenced by isDeleteFile(), and setDeleteFile().

◆ $delivery_type

ilFileDelivery::$delivery_type = self::DELIVERY_METHOD_PHP
protected

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

Referenced by getDeliveryType(), and setDeliveryType().

◆ $delivery_type_static

ilFileDelivery::$delivery_type_static = null
staticprotected

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

◆ $disposition

ilFileDelivery::$disposition = self::DISP_ATTACHMENT
protected

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

Referenced by getDisposition(), and setDisposition().

◆ $download_file_name

◆ $etag

ilFileDelivery::$etag = ''
protected

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

Referenced by getEtag(), and setEtag().

◆ $exit_after

ilFileDelivery::$exit_after = true
protected

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

Referenced by isExitAfter(), and setExitAfter().

◆ $has_context

ilFileDelivery::$has_context = true
protected

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

Referenced by isHasContext(), and setHasContext().

◆ $hash_filename

ilFileDelivery::$hash_filename = false
protected

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

Referenced by hasHashFilename(), and setHashFilename().

◆ $mime_type

ilFileDelivery::$mime_type = ''
protected

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

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

◆ $path_to_file

◆ $self_streaming_methods

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

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

◆ $send_mime_type

ilFileDelivery::$send_mime_type = true
protected

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

Referenced by isSendMimeType(), and setSendMimeType().

◆ $show_last_modified

ilFileDelivery::$show_last_modified = true
protected

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

Referenced by getShowLastModified(), and setShowLastModified().

◆ $urlencode_filename

ilFileDelivery::$urlencode_filename = false
protected

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

Referenced by isUrlencodeFilename(), and setUrlencodeFilename().

◆ DATA

const ilFileDelivery::DATA = 'data'

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

◆ DELIVERY_METHOD_NONE

const ilFileDelivery::DELIVERY_METHOD_NONE = 'cache'

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

Referenced by deliver().

◆ DELIVERY_METHOD_PHP

const ilFileDelivery::DELIVERY_METHOD_PHP = 'php'

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

◆ DELIVERY_METHOD_PHP_CHUNKED

const ilFileDelivery::DELIVERY_METHOD_PHP_CHUNKED = 'php_chunked'

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

Referenced by deliver().

◆ DELIVERY_METHOD_VIRTUAL

const ilFileDelivery::DELIVERY_METHOD_VIRTUAL = 'virtual'

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

Referenced by deliver().

◆ DELIVERY_METHOD_XACCEL

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

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

Referenced by deliver().

◆ DELIVERY_METHOD_XSENDFILE

const ilFileDelivery::DELIVERY_METHOD_XSENDFILE = 'mod_xsendfile'

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

Referenced by deliver().

◆ DISP_ATTACHMENT

const ilFileDelivery::DISP_ATTACHMENT = 'attachment'

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

◆ DISP_INLINE

const ilFileDelivery::DISP_INLINE = 'inline'

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

◆ SECURED_DATA

const ilFileDelivery::SECURED_DATA = 'secured-data'

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

◆ VIRTUAL_DATA

const ilFileDelivery::VIRTUAL_DATA = 'virtual-data'

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


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