当前位置: 首页>>代码示例>>PHP>>正文


PHP HTMLWriter::generateAttachmentsHeader方法代码示例

本文整理汇总了PHP中HTMLWriter::generateAttachmentsHeader方法的典型用法代码示例。如果您正苦于以下问题:PHP HTMLWriter::generateAttachmentsHeader方法的具体用法?PHP HTMLWriter::generateAttachmentsHeader怎么用?PHP HTMLWriter::generateAttachmentsHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HTMLWriter的用法示例。


在下文中一共展示了HTMLWriter::generateAttachmentsHeader方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: readFile


//.........这里部分代码省略.........
                 }
                 $this->logDebug('Content-Range: bytes ' . $offset . '-' . $length . '/' . $size);
                 header('HTTP/1.1 206 Partial Content');
                 header('Content-Range: bytes ' . $offset . '-' . ($offset + $length) . '/' . $size);
                 header("Content-Length: " . $length);
                 $file = fopen($filePathOrData, 'rb');
                 fseek($file, 0);
                 $relOffset = $offset;
                 while ($relOffset > 2000000000.0) {
                     // seek to the requested offset, this is 0 if it's not a partial content request
                     fseek($file, 2000000000, SEEK_CUR);
                     $relOffset -= 2000000000;
                     // This works because we never overcome the PHP 32 bit limit
                 }
                 fseek($file, $relOffset, SEEK_CUR);
                 while (ob_get_level()) {
                     ob_end_flush();
                 }
                 $readSize = 0.0;
                 $bufferSize = 1024 * 8;
                 while (!feof($file) && $readSize < $length && connection_status() == 0) {
                     $this->logDebug("dl reading {$readSize} to {$length}", $_SERVER["HTTP_RANGE"]);
                     echo fread($file, $bufferSize);
                     $readSize += $bufferSize;
                     flush();
                 }
                 fclose($file);
                 return;
             } else {
                 if ($gzip) {
                     $gzippedData = $data ? gzencode($filePathOrData, 9) : gzencode(file_get_contents($filePathOrData), 9);
                     $size = strlen($gzippedData);
                 }
                 HTMLWriter::generateAttachmentsHeader($localName, $size, $isFile, $gzip);
                 if ($gzip) {
                     print $gzippedData;
                     return;
                 }
             }
         }
     }
     if ($data) {
         print $filePathOrData;
     } else {
         if ($this->getFilteredOption("USE_XSENDFILE", $this->repository->getId()) && $this->wrapperClassName == "fsAccessWrapper") {
             if (!$realfileSystem) {
                 $filePathOrData = fsAccessWrapper::getRealFSReference($filePathOrData);
             }
             $filePathOrData = str_replace("\\", "/", $filePathOrData);
             $server_name = $_SERVER["SERVER_SOFTWARE"];
             $regex = '/^(lighttpd\\/1.4).([0-9]{2}$|[0-9]{3}$|[0-9]{4}$)+/';
             if (preg_match($regex, $server_name)) {
                 $header_sendfile = "X-LIGHTTPD-send-file";
             } else {
                 $header_sendfile = "X-Sendfile";
             }
             header($header_sendfile . ": " . SystemTextEncoding::toUTF8($filePathOrData));
             header("Content-type: application/octet-stream");
             header('Content-Disposition: attachment; filename="' . basename($filePathOrData) . '"');
             return;
         }
         if ($this->getFilteredOption("USE_XACCELREDIRECT", $this->repository->getId()) && $this->wrapperClassName == "fsAccessWrapper" && array_key_exists("X-Accel-Mapping", $_SERVER)) {
             if (!$realfileSystem) {
                 $filePathOrData = fsAccessWrapper::getRealFSReference($filePathOrData);
             }
             $filePathOrData = str_replace("\\", "/", $filePathOrData);
开发者ID:biggtfish,项目名称:cms,代码行数:67,代码来源:class.fsAccessDriver.php

示例2: applyActions

 public function applyActions($actionName, $httpVars, $fileVars)
 {
     $git = new VersionControl_Git($this->repoBase);
     switch ($actionName) {
         case "git_history":
             $file = AJXP_Utils::decodeSecureMagic($httpVars["file"]);
             $file = ltrim($file, "/");
             $res = $this->gitHistory($git, $file);
             AJXP_XMLWriter::header();
             $ic = AJXP_Utils::mimetype($file, "image", false);
             $index = count($res);
             $mess = ConfService::getMessages();
             foreach ($res as &$commit) {
                 unset($commit["DETAILS"]);
                 $commit["icon"] = $ic;
                 $commit["index"] = $index;
                 $commit["EVENT"] = $mess["meta.git." . $commit["EVENT"]];
                 $index--;
                 AJXP_XMLWriter::renderNode("/" . $commit["ID"], basename($commit["FILE"]), true, $commit);
             }
             AJXP_XMLWriter::close();
             break;
             break;
         case "git_revertfile":
             $originalFile = AJXP_Utils::decodeSecureMagic($httpVars["original_file"]);
             $file = AJXP_Utils::decodeSecureMagic($httpVars["file"]);
             $commitId = $httpVars["commit_id"];
             $command = $git->getCommand("cat-file");
             $command->setOption("s", true);
             $command->addArgument($commitId . ":" . $file);
             $size = $command->execute();
             $command = $git->getCommand("show");
             $command->addArgument($commitId . ":" . $file);
             $commandLine = $command->createCommandString();
             $outputStream = fopen($this->repoBase . $originalFile, "w");
             $this->executeCommandInStreams($git, $commandLine, $outputStream);
             fclose($outputStream);
             $this->commitChanges();
             AJXP_XMLWriter::header();
             AJXP_XMLWriter::reloadDataNode();
             AJXP_XMLWriter::close();
             break;
         case "git_getfile":
             $file = AJXP_Utils::decodeSecureMagic($httpVars["file"]);
             $commitId = $httpVars["commit_id"];
             $attach = $httpVars["attach"];
             $command = $git->getCommand("cat-file");
             $command->setOption("s", true);
             $command->addArgument($commitId . ":" . $file);
             $size = $command->execute();
             $command = $git->getCommand("show");
             $command->addArgument($commitId . ":" . $file);
             $commandLine = $command->createCommandString();
             if ($attach == "inline") {
                 $fileExt = substr(strrchr(basename($file), '.'), 1);
                 if (empty($fileExt)) {
                     $fileMime = "application/octet-stream";
                 } else {
                     $regex = "/^([\\w\\+\\-\\.\\/]+)\\s+(\\w+\\s)*({$fileExt}\\s)/i";
                     $lines = file(AJXP_INSTALL_PATH . "/" . AJXP_PLUGINS_FOLDER . "/editor.browser/resources/other/mime.types");
                     foreach ($lines as $line) {
                         if (substr($line, 0, 1) == '#') {
                             continue;
                         }
                         // skip comments
                         $line = rtrim($line) . " ";
                         if (!preg_match($regex, $line, $matches)) {
                             continue;
                         }
                         // no match to the extension
                         $fileMime = $matches[1];
                     }
                 }
                 if (empty($fileMime)) {
                     $fileMime = "application/octet-stream";
                 }
                 HTMLWriter::generateInlineHeaders(basename($file), $size, $fileMime);
             } else {
                 HTMLWriter::generateAttachmentsHeader(basename($file), $size, false, false);
             }
             $outputStream = fopen("php://output", "a");
             $this->executeCommandInStreams($git, $commandLine, $outputStream);
             fclose($outputStream);
             break;
             break;
         default:
             break;
     }
 }
开发者ID:thermalpaste,项目名称:pydio-core,代码行数:89,代码来源:class.GitManager.php

示例3: readFile


//.........这里部分代码省略.........
                 }
                 AJXP_Logger::debug('Content-Range: bytes ' . $offset . '-' . $length . '/' . $size);
                 header('HTTP/1.1 206 Partial Content');
                 header('Content-Range: bytes ' . $offset . '-' . ($offset + $length) . '/' . $size);
                 header("Content-Length: " . $length);
                 $file = fopen($filePathOrData, 'rb');
                 fseek($file, 0);
                 $relOffset = $offset;
                 while ($relOffset > 2000000000.0) {
                     // seek to the requested offset, this is 0 if it's not a partial content request
                     fseek($file, 2000000000, SEEK_CUR);
                     $relOffset -= 2000000000;
                     // This works because we never overcome the PHP 32 bit limit
                 }
                 fseek($file, $relOffset, SEEK_CUR);
                 while (ob_get_level()) {
                     ob_end_flush();
                 }
                 $readSize = 0.0;
                 $bufferSize = 1024 * 8;
                 while (!feof($file) && $readSize < $length && connection_status() == 0) {
                     AJXP_Logger::debug("dl reading {$readSize} to {$length}", $_SERVER["HTTP_RANGE"]);
                     echo fread($file, $bufferSize);
                     $readSize += $bufferSize;
                     flush();
                 }
                 fclose($file);
                 return;
             } else {
                 if ($gzip) {
                     $gzippedData = $data ? gzencode($filePathOrData, 9) : gzencode(file_get_contents($filePathOrData), 9);
                     $size = strlen($gzippedData);
                 }
                 HTMLWriter::generateAttachmentsHeader($localName, $size, $isFile, $gzip);
                 /*
                 				header("Content-Type: application/force-download; name=\"".$localName."\"");
                 				header("Content-Transfer-Encoding: binary");
                 				if($gzip){
                 					header("Content-Encoding: gzip");
                 					// If gzip, recompute data size!
                 					$gzippedData = ($data?gzencode($filePathOrData,9):gzencode(file_get_contents($filePathOrData), 9));
                 					$size = strlen($gzippedData);
                 				}
                 				header("Content-Length: ".$size);
                 				if ($isFile && ($size != 0)) header("Content-Range: bytes 0-" . ($size - 1) . "/" . $size . ";");
                 				header("Content-Disposition: attachment; filename=\"".$localName."\"");
                 				header("Expires: 0");
                 				header("Cache-Control: no-cache, must-revalidate");
                 				header("Pragma: no-cache");
                 				if (preg_match('/ MSIE /',$_SERVER['HTTP_USER_AGENT'])){
                 					header("Cache-Control: max_age=0");
                 					header("Pragma: public");
                 				}
                 
                 // IE8 is dumb
                 				if (preg_match('/ MSIE /',$_SERVER['HTTP_USER_AGENT']))
                 {
                     header("Pragma: public");
                     header("Expires: 0");
                     header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                     header("Cache-Control: private",false);
                 //                    header("Content-Type: application/octet-stream");
                 }
                 
                 				// For SSL websites there is a bug with IE see article KB 323308
                 				// therefore we must reset the Cache-Control and Pragma Header
开发者ID:crodriguezn,项目名称:administrator-files,代码行数:67,代码来源:class.fsAccessDriver.php


注:本文中的HTMLWriter::generateAttachmentsHeader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。