function handleFileDownload($contentObject, $contentObjectAttribute, $type, $fileInfo) { $fileName = $fileInfo['filepath']; $file = eZClusterFileHandler::instance($fileName); if ($fileName != "" and $file->exists()) { $fileSize = $file->size(); if (isset($_SERVER['HTTP_RANGE']) && preg_match("/^bytes=(\\d+)-(\\d+)?\$/", trim($_SERVER['HTTP_RANGE']), $matches)) { $fileOffset = $matches[1]; $contentLength = isset($matches[2]) ? $matches[2] - $matches[1] + 1 : $fileSize - $matches[1]; } else { $fileOffset = 0; $contentLength = $fileSize; } // Figure out the time of last modification of the file right way to get the file mtime ... the $fileModificationTime = $file->mtime(); // stop output buffering, and stop the session so that browsing can be continued while downloading eZSession::stop(); ob_end_clean(); eZFile::downloadHeaders($fileName, self::dispositionType($fileInfo['mime_type']) === 'attachment', false, $fileOffset, $contentLength, $fileSize); try { $file->passthrough($fileOffset, $contentLength); } catch (eZClusterFileHandlerNotFoundException $e) { eZDebug::writeError($e->getMessage, __METHOD__); header($_SERVER["SERVER_PROTOCOL"] . ' 500 Internal Server Error'); } catch (eZClusterFileHandlerGeneralException $e) { eZDebug::writeError($e->getMessage, __METHOD__); header($_SERVER["SERVER_PROTOCOL"] . ' 404 Not Found'); } eZExecution::cleanExit(); } return eZBinaryFileHandler::RESULT_UNAVAILABLE; }