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; }
static private function sessionArray() { if( MMUserLogin::$isLogin ) { eZSession::start(); return $_SESSION; } if ( is_null(self::$_localSession) ) { eZSession::start(); self::$_localSession = $_SESSION; if ( !isset($_COOKIE['eZSESSID']) ) { setcookie( 'eZSESSID', session_id(), null, '/', CookieTool::getCookieDomain() ); $_COOKIE['eZSESSID'] = session_id(); } eZSession::stop(); } return self::$_localSession; }
/** * Prepares a file for Download and terminates the execution. * This method will: * - empty the output buffer * - stop buffering * - stop the active session (in order to allow concurrent browsing while downloading) * * @param string $file Path to the local file * @param bool $isAttachedDownload Determines weather to download the file as an attachment ( download popup box ) or not. * @param string $overrideFilename * @param int $startOffset Offset to start transfer from, in bytes * @param int $length Data size to transfer * * @return bool false if error */ static function download($file, $isAttachedDownload = true, $overrideFilename = false, $startOffset = 0, $length = false) { if (!file_exists($file)) { return false; } ob_end_clean(); eZSession::stop(); self::downloadHeaders($file, $isAttachedDownload, $overrideFilename, $startOffset, $length); self::downloadContent($file, $startOffset, $length); eZExecution::cleanExit(); }
} break; default: // give a warning $actionname = '[ERROR: unknown action] "' . $action . '"'; } // Before calling execute, echo out brief description of action taken + date and time ??? // this gives good user feedback for long-running methods... /// @todo use a template for html layout if ($action != 'inspect' || $debug) { echo '<h2>' . htmlspecialchars($actionname) . ' on server ' . htmlspecialchars($server) . " ...</h2>\n"; flush(); } // avoid locking in case we are using a session for executing the action which // is the sane session as used by the debugger and plain php session storage eZSession::stop(); // execute method(s) $response = null; $responses = array(); $time = microtime(true); foreach ($msg as $message) { $response = $client->send($message); $responses[] = $response; if (!is_object($response) || $response->isFault()) { break; } } $time = microtime(true) - $time; if ($debug) { /// @todo should echo the request+response of all requests, when sending more than 1 echo '<div class="dbginfo"><h2>Debug info:</h2>';