Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezfilepassthroughhandler.php
Go to the documentation of this file.
1 <?php
17 class eZFilePassthroughHandler extends eZBinaryFileHandler
18 {
19 const HANDLER_ID = 'ezfilepassthrough';
20
21 public function __construct()
22 {
23 parent::__construct( self::HANDLER_ID, "PHP passthrough", eZBinaryFileHandler::HANDLE_DOWNLOAD );
24 }
25
26 function handleFileDownload( $contentObject, $contentObjectAttribute, $type,
27 $fileInfo )
28 {
29 $fileName = $fileInfo['filepath'];
30
31 $file = eZClusterFileHandler::instance( $fileName );
32
33 if ( $fileName != "" and $file->exists() )
34 {
35 $fileSize = $file->size();
36 if ( isset( $_SERVER['HTTP_RANGE'] ) && preg_match( "/^bytes=(\d+)-(\d+)?$/", trim( $_SERVER['HTTP_RANGE'] ), $matches ) )
37 {
38 $fileOffset = $matches[1];
39 $contentLength = isset( $matches[2] ) ? $matches[2] - $matches[1] + 1 : $fileSize - $matches[1];
40 }
41 else
42 {
43 $fileOffset = 0;
44 $contentLength = $fileSize;
45 }
46 // Figure out the time of last modification of the file right way to get the file mtime ... the
47 $fileModificationTime = $file->mtime();
48
49 // stop output buffering, and stop the session so that browsing can be continued while downloading
50 eZSession::stop();
51 ob_end_clean();
52
53 eZFile::downloadHeaders(
54 $fileName,
55 self::dispositionType( $fileInfo['mime_type'] ) === 'attachment',
56 false,
57 $fileOffset,
58 $contentLength,
59 $fileSize
60 );
61
62 try
63 {
64 $file->passthrough( $fileOffset, $contentLength );
65 }
66 catch ( eZClusterFileHandlerNotFoundException $e )
67 {
68 eZDebug::writeError( $e->getMessage, __METHOD__ );
69 header( $_SERVER["SERVER_PROTOCOL"] . ' 500 Internal Server Error' );
70 }
71 catch ( eZClusterFileHandlerGeneralException $e )
72 {
73 eZDebug::writeError( $e->getMessage, __METHOD__ );
74 header( $_SERVER["SERVER_PROTOCOL"] . ' 404 Not Found' );
75 }
76
77 eZExecution::cleanExit();
78 }
79 return eZBinaryFileHandler::RESULT_UNAVAILABLE;
80 }
81
91 protected static function dispositionType( $mimeType )
92 {
93 $ini = eZINI::instance( 'file.ini' );
94
95 $mimeTypes = $ini->variable( 'PassThroughSettings', 'ContentDisposition', array() );
96 if ( isset( $mimeTypes[$mimeType] ) )
97 {
98 return $mimeTypes[$mimeType];
99 }
100
101 return $ini->variable( 'PassThroughSettings', 'DefaultContentDisposition' );
102 }
103 }
104
105 ?>
eZBinaryFileHandler
Interface for all binary file handlers.
Definition: ezbinaryfilehandler.php:23
eZBinaryFileHandler\HANDLE_DOWNLOAD
const HANDLE_DOWNLOAD
Definition: ezbinaryfilehandler.php:25
eZBinaryFileHandler\RESULT_UNAVAILABLE
const RESULT_UNAVAILABLE
Definition: ezbinaryfilehandler.php:33
eZClusterFileHandler\instance
static instance( $filename=false)
Definition: ezclusterfilehandler.php:21
eZDebug\writeError
static writeError( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:545
eZExecution\cleanExit
static cleanExit()
Definition: ezexecution.php:100
eZFilePassthroughHandler
Handles file downloading by passing the file through PHP.
Definition: ezfilepassthroughhandler.php:18
eZFilePassthroughHandler\handleFileDownload
handleFileDownload( $contentObject, $contentObjectAttribute, $type, $fileInfo)
Definition: ezfilepassthroughhandler.php:26
eZFilePassthroughHandler\HANDLER_ID
const HANDLER_ID
Definition: ezfilepassthroughhandler.php:19
eZFilePassthroughHandler\__construct
__construct()
Definition: ezfilepassthroughhandler.php:21
eZFilePassthroughHandler\dispositionType
static dispositionType( $mimeType)
Definition: ezfilepassthroughhandler.php:91
eZFile\downloadHeaders
static downloadHeaders( $file, $isAttachedDownload=true, $overrideFilename=false, $startOffset=0, $length=false, $fileSize=false)
Definition: ezfile.php:220
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.