本文整理汇总了PHP中AJXP_Utils::getImageMimeType方法的典型用法代码示例。如果您正苦于以下问题:PHP AJXP_Utils::getImageMimeType方法的具体用法?PHP AJXP_Utils::getImageMimeType怎么用?PHP AJXP_Utils::getImageMimeType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AJXP_Utils
的用法示例。
在下文中一共展示了AJXP_Utils::getImageMimeType方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: switchAction
public function switchAction($action, $httpVars, $filesVars)
{
if (!isset($this->actions[$action])) {
return false;
}
$repository = ConfService::getRepository();
if (!$repository->detectStreamWrapper(true)) {
return false;
}
if (!isset($this->pluginConf)) {
$this->pluginConf = array("GENERATE_THUMBNAIL" => false);
}
$streamData = $repository->streamData;
$this->streamData = $streamData;
$destStreamURL = $streamData["protocol"] . "://" . $repository->getId();
if ($action == "preview_data_proxy") {
$file = AJXP_Utils::decodeSecureMagic($httpVars["file"]);
if (!file_exists($destStreamURL . $file)) {
header("Content-Type: " . AJXP_Utils::getImageMimeType(basename($file)) . "; name=\"" . basename($file) . "\"");
header("Content-Length: 0");
return;
}
if (isset($httpVars["get_thumb"]) && $this->getFilteredOption("GENERATE_THUMBNAIL", $repository->getId())) {
$dimension = 200;
if (isset($httpVars["dimension"]) && is_numeric($httpVars["dimension"])) {
$dimension = $httpVars["dimension"];
}
$this->currentDimension = $dimension;
$cacheItem = AJXP_Cache::getItem("diaporama_" . $dimension, $destStreamURL . $file, array($this, "generateThumbnail"));
$data = $cacheItem->getData();
$cId = $cacheItem->getId();
header("Content-Type: " . AJXP_Utils::getImageMimeType(basename($cId)) . "; name=\"" . basename($cId) . "\"");
header("Content-Length: " . strlen($data));
header('Cache-Control: public');
header("Pragma:");
header("Last-Modified: " . gmdate("D, d M Y H:i:s", time() - 10000) . " GMT");
header("Expires: " . gmdate("D, d M Y H:i:s", time() + 5 * 24 * 3600) . " GMT");
print $data;
} else {
//$filesize = filesize($destStreamURL.$file);
$node = new AJXP_Node($destStreamURL . $file);
$fp = fopen($destStreamURL . $file, "r");
$stat = fstat($fp);
$filesize = $stat["size"];
header("Content-Type: " . AJXP_Utils::getImageMimeType(basename($file)) . "; name=\"" . basename($file) . "\"");
header("Content-Length: " . $filesize);
header('Cache-Control: public');
header("Pragma:");
header("Last-Modified: " . gmdate("D, d M Y H:i:s", time() - 10000) . " GMT");
header("Expires: " . gmdate("D, d M Y H:i:s", time() + 5 * 24 * 3600) . " GMT");
$class = $streamData["classname"];
$stream = fopen("php://output", "a");
call_user_func(array($streamData["classname"], "copyFileInStream"), $destStreamURL . $file, $stream);
fflush($stream);
fclose($stream);
AJXP_Controller::applyHook("node.read", array($node));
}
}
}
示例2: switchAction
public function switchAction($action, $httpVars, $filesVars)
{
if (!isset($this->actions[$action])) {
return false;
}
$repository = ConfService::getRepository();
if (!$repository->detectStreamWrapper(true)) {
return false;
}
if (!isset($this->pluginConf)) {
$this->pluginConf = array("GENERATE_THUMBNAIL" => false);
}
$streamData = $repository->streamData;
$destStreamURL = $streamData["protocol"] . "://" . $repository->getId();
if ($action == "preview_data_proxy") {
$file = AJXP_Utils::decodeSecureMagic($httpVars["file"]);
if (isset($httpVars["get_thumb"]) && $this->pluginConf["GENERATE_THUMBNAIL"]) {
require_once INSTALL_PATH . "/plugins/editor.diaporama/PThumb.lib.php";
$pThumb = new PThumb($this->pluginConf["THUMBNAIL_QUALITY"]);
if (!$pThumb->isError()) {
$pThumb->remote_wrapper = $streamData["classname"];
$pThumb->use_cache = $this->pluginConf["USE_THUMBNAIL_CACHE"];
$pThumb->cache_dir = $this->pluginConf["THUMBNAIL_CACHE_DIR"];
$pThumb->fit_thumbnail($destStreamURL . $file, 200);
if ($pThumb->isError()) {
print_r($pThumb->error_array);
AJXP_Logger::logAction("error", $pThumb->error_array);
}
//exit(0);
} else {
print_r($pThumb->error_array);
AJXP_Logger::logAction("error", $pThumb->error_array);
}
} else {
$filesize = filesize($destStreamURL . $file);
$fp = fopen($destStreamURL . $file, "r");
header("Content-Type: " . AJXP_Utils::getImageMimeType(basename($file)) . "; name=\"" . basename($file) . "\"");
header("Content-Length: " . $filesize);
header('Cache-Control: public');
$class = $streamData["classname"];
$stream = fopen("php://output", "a");
call_user_func(array($streamData["classname"], "copyFileInStream"), $destStreamURL . $file, $stream);
fflush($stream);
fclose($stream);
//exit(1);
}
}
}
示例3: loadBinary
/**
* @param array $context
* @param String $ID
* @param Resource $outputStream
* @return boolean
*/
public function loadBinary($context, $ID, $outputStream = null)
{
$fileName = $this->getBinaryPathStorage($context) . "/" . $ID;
if (is_file($fileName)) {
if ($outputStream == null) {
header("Content-Type: " . AJXP_Utils::getImageMimeType($ID));
// PROBLEM AT STARTUP
header('Pragma:');
header('Cache-Control: public');
header("Last-Modified: " . gmdate("D, d M Y H:i:s", filemtime($fileName)) . " GMT");
header("Expires: " . gmdate("D, d M Y H:i:s", filemtime($fileName) + 5 * 24 * 3600) . " GMT");
readfile($fileName);
} else {
if (is_resource($outputStream)) {
fwrite($outputStream, file_get_contents($this->getBinaryPathStorage($context) . "/" . $ID));
}
}
}
}
示例4: switchAction
//.........这里部分代码省略.........
$user = $userObject->getId();
$secret = defined("AJXP_SAFE_SECRET_KEY") ? AJXP_SAFE_SECRET_KEY : "CDAFx¨op#";
$password = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($user . $secret), $password, MCRYPT_MODE_ECB));
}
$davData["PASS"] = $password;
}
$userObject->setPref("AJXP_WEBDAV_DATA", $davData);
$userObject->save("user");
}
if (!empty($davData)) {
$webdavActive = isset($davData["ACTIVE"]) && $davData["ACTIVE"] === true;
$passSet = isset($davData["PASS"]);
}
$repoList = ConfService::getRepositoriesList();
$davRepos = array();
$loggedUser = AuthService::getLoggedUser();
foreach ($repoList as $repoIndex => $repoObject) {
$accessType = $repoObject->getAccessType();
$driver = AJXP_PluginsService::getInstance()->getPluginByTypeName("access", $accessType);
if (is_a($driver, "AjxpWrapperProvider") && !$repoObject->getOption("AJXP_WEBDAV_DISABLED") && ($loggedUser->canRead($repoIndex) || $loggedUser->canWrite($repoIndex))) {
$davRepos[$repoIndex] = $webdavBaseUrl . "" . ($repoObject->getSlug() == null ? $repoObject->getId() : $repoObject->getSlug());
}
}
$prefs = array("webdav_active" => $webdavActive, "password_set" => $passSet, "digest_set" => $digestSet, "webdav_force_basic" => ConfService::getCoreConf("WEBDAV_FORCE_BASIC") === true, "webdav_base_url" => $webdavBaseUrl, "webdav_repositories" => $davRepos);
HTMLWriter::charsetHeader("application/json");
print json_encode($prefs);
break;
case "get_user_template_logo":
$tplId = $httpVars["template_id"];
$iconFormat = $httpVars["icon_format"];
$repo = ConfService::getRepositoryById($tplId);
$logo = $repo->getOption("TPL_ICON_" . strtoupper($iconFormat));
if (isset($logo) && is_file(AJXP_DATA_PATH . "/plugins/core.conf/tpl_logos/" . $logo)) {
header("Content-Type: " . AJXP_Utils::getImageMimeType($logo) . "; name=\"" . $logo . "\"");
header("Content-Length: " . filesize(AJXP_DATA_PATH . "/plugins/core.conf/tpl_logos/" . $logo));
header('Pragma:');
header('Cache-Control: public');
header("Last-Modified: " . gmdate("D, d M Y H:i:s", time() - 10000) . " GMT");
header("Expires: " . gmdate("D, d M Y H:i:s", time() + 5 * 24 * 3600) . " GMT");
readfile(AJXP_DATA_PATH . "/plugins/core.conf/tpl_logos/" . $logo);
} else {
$logo = "default_template_logo-" . ($iconFormat == "small" ? 16 : 22) . ".png";
header("Content-Type: " . AJXP_Utils::getImageMimeType($logo) . "; name=\"" . $logo . "\"");
header("Content-Length: " . filesize(AJXP_INSTALL_PATH . "/" . AJXP_PLUGINS_FOLDER . "/core.conf/" . $logo));
header('Pragma:');
header('Cache-Control: public');
header("Last-Modified: " . gmdate("D, d M Y H:i:s", time() - 10000) . " GMT");
header("Expires: " . gmdate("D, d M Y H:i:s", time() + 5 * 24 * 3600) . " GMT");
readfile(AJXP_INSTALL_PATH . "/" . AJXP_PLUGINS_FOLDER . "/core.conf/" . $logo);
}
break;
case "get_user_templates_definition":
AJXP_XMLWriter::header("repository_templates");
$count = 0;
$repositories = ConfService::listRepositoriesWithCriteria(array("isTemplate" => 1), $count);
$pServ = AJXP_PluginsService::getInstance();
foreach ($repositories as $repo) {
if (!$repo->isTemplate) {
continue;
}
if (!$repo->getOption("TPL_USER_CAN_CREATE")) {
continue;
}
$repoId = $repo->getId();
$repoLabel = $repo->getDisplay();
$repoType = $repo->getAccessType();
示例5: loadBinary
/**
* @param array $context
* @param String $ID
* @param Resource $outputStream
* @return boolean
*/
public function loadBinary($context, $ID, $outputStream = null)
{
$store = $this->binaryContextToStoreID($context);
$data = "";
$this->simpleStoreGet($store, $ID, "binary", $data);
if ($outputStream != null) {
fwrite($outputStream, $data, strlen($data));
} else {
header("Content-Type: " . AJXP_Utils::getImageMimeType($ID));
echo $data;
}
}
示例6: downFile
function downFile($fileArray, $headerType = "plain", $fileName)
{
if ($headerType == "plain") {
header("Content-type:text/plain");
} else {
if ($headerType == "image") {
header("Content-Type: " . AJXP_Utils::getImageMimeType(basename($fileName)) . "; name=\"" . basename($fileName) . "\"");
header('Cache-Control: public');
} else {
if ($headerType == "mp3") {
header("Content-Type: audio/mp3; name=\"" . basename($fileName) . "\"");
} else {
header("Content-Type: application/force-download; name=\"" . $fileName . "\"");
header("Content-Transfer-Encoding: binary");
if ($gzip) {
header("Content-Encoding: gzip");
}
header("Content-Disposition: attachment; filename=\"" . $fileName . "\"");
header("Expires: 0");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
// For SSL websites there is a bug with IE see article KB 323308
// therefore we must reset the Cache-Control and Pragma Header
if (ConfService::getConf("USE_HTTPS") == 1 && preg_match('/ MSIE /', $_SERVER['HTTP_USER_AGENT'])) {
header("Cache-Control:");
header("Pragma:");
}
}
}
}
$this->SSHOperation->downloadRemoteFile($fileArray);
}
示例7: readFile
public function readFile($filePathOrData, $headerType = "plain", $localName = "", $data = false, $gzip = null, $realfileSystem = false, $byteOffset = -1, $byteLength = -1)
{
if ($gzip === null) {
$gzip = ConfService::getCoreConf("GZIP_COMPRESSION");
}
if (!$realfileSystem && $this->wrapperClassName == "fsAccessWrapper") {
$originalFilePath = $filePathOrData;
$filePathOrData = fsAccessWrapper::patchPathForBaseDir($filePathOrData);
}
session_write_close();
restore_error_handler();
restore_exception_handler();
set_exception_handler('download_exception_handler');
set_error_handler('download_exception_handler');
// required for IE, otherwise Content-disposition is ignored
if (ini_get('zlib.output_compression')) {
AJXP_Utils::safeIniSet('zlib.output_compression', 'Off');
}
$isFile = !$data && !$gzip;
if ($byteLength == -1) {
if ($data) {
$size = strlen($filePathOrData);
} else {
if ($realfileSystem) {
$size = sprintf("%u", filesize($filePathOrData));
} else {
$size = $this->filesystemFileSize($filePathOrData);
}
}
} else {
$size = $byteLength;
}
if ($gzip && ($size > ConfService::getCoreConf("GZIP_LIMIT") || !function_exists("gzencode") || @strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') === FALSE)) {
$gzip = false;
// disable gzip
}
$localName = $localName == "" ? basename(isset($originalFilePath) ? $originalFilePath : $filePathOrData) : $localName;
if ($headerType == "plain") {
header("Content-type:text/plain");
} else {
if ($headerType == "image") {
header("Content-Type: " . AJXP_Utils::getImageMimeType(basename($filePathOrData)) . "; name=\"" . $localName . "\"");
header("Content-Length: " . $size);
header('Cache-Control: public');
} else {
/*
if (preg_match('/ MSIE /',$_SERVER['HTTP_USER_AGENT']) || preg_match('/ WebKit /',$_SERVER['HTTP_USER_AGENT'])) {
$localName = str_replace("+", " ", urlencode(SystemTextEncoding::toUTF8($localName)));
}
*/
if ($isFile) {
header("Accept-Ranges: 0-{$size}");
$this->logDebug("Sending accept range 0-{$size}");
}
// Check if we have a range header (we are resuming a transfer)
if (isset($_SERVER['HTTP_RANGE']) && $isFile && $size != 0) {
if ($headerType == "stream_content") {
if (extension_loaded('fileinfo') && $this->wrapperClassName == "fsAccessWrapper") {
$fInfo = new fInfo(FILEINFO_MIME);
$realfile = call_user_func(array($this->wrapperClassName, "getRealFSReference"), $filePathOrData);
$mimeType = $fInfo->file($realfile);
$splitChar = explode(";", $mimeType);
$mimeType = trim($splitChar[0]);
$this->logDebug("Detected mime {$mimeType} for {$realfile}");
} else {
$mimeType = AJXP_Utils::getStreamingMimeType(basename($filePathOrData));
}
header('Content-type: ' . $mimeType);
}
// multiple ranges, which can become pretty complex, so ignore it for now
$ranges = explode('=', $_SERVER['HTTP_RANGE']);
$offsets = explode('-', $ranges[1]);
$offset = floatval($offsets[0]);
$length = floatval($offsets[1]) - $offset;
if (!$length) {
$length = $size - $offset;
}
if ($length + $offset > $size || $length < 0) {
$length = $size - $offset;
}
$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) {
//.........这里部分代码省略.........
示例8: readFile
function readFile($filePathOrData, $headerType = "plain", $localName = "", $data = false, $gzip = GZIP_DOWNLOAD, $realfileSystem = false)
{
session_write_close();
set_exception_handler(download_exception_handler);
set_error_handler(download_exception_handler);
// required for IE, otherwise Content-disposition is ignored
if (ini_get('zlib.output_compression')) {
ini_set('zlib.output_compression', 'Off');
}
$isFile = !$data && !$gzip;
$size = $data ? strlen($filePathOrData) : filesize($filePathOrData);
if ($gzip && ($size > GZIP_LIMIT || !function_exists("gzencode") || @strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') === FALSE)) {
$gzip = false;
// disable gzip
}
$localName = $localName == "" ? basename($filePathOrData) : $localName;
if ($headerType == "plain") {
header("Content-type:text/plain");
} else {
if ($headerType == "image") {
header("Content-Type: " . AJXP_Utils::getImageMimeType(basename($filePathOrData)) . "; name=\"" . $localName . "\"");
header("Content-Length: " . $size);
header('Cache-Control: public');
} else {
if (preg_match('/ MSIE /', $_SERVER['HTTP_USER_AGENT']) || preg_match('/ WebKit /', $_SERVER['HTTP_USER_AGENT'])) {
$localName = str_replace("+", " ", urlencode(SystemTextEncoding::toUTF8($localName)));
}
if ($isFile) {
header("Accept-Ranges: bytes");
}
// Check if we have a range header (we are resuming a transfer)
if (isset($_SERVER['HTTP_RANGE']) && $isFile && $size != 0) {
// multiple ranges, which can become pretty complex, so ignore it for now
$ranges = explode('=', $_SERVER['HTTP_RANGE']);
$offsets = explode('-', $ranges[1]);
$offset = floatval($offsets[0]);
$length = floatval($offsets[1]) - $offset;
if (!$length) {
$length = $size - $offset;
}
if ($length + $offset > $size || $length < 0) {
$length = $size - $offset;
}
header('HTTP/1.1 206 Partial Content');
header('Content-Range: bytes ' . $offset . '-' . ($offset + $length - 1) . '/' . $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;
while (!feof($file) && $readSize < $length && connection_status() == 0) {
echo fread($file, 2048);
$readSize += 2048.0;
flush();
}
fclose($file);
return;
} else {
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
if (ConfService::getConf("USE_HTTPS") == 1 && preg_match('/ MSIE /', $_SERVER['HTTP_USER_AGENT'])) {
header("Cache-Control:");
//.........这里部分代码省略.........
示例9: switchAction
//.........这里部分代码省略.........
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND);
$password = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($user . $secret), $password, MCRYPT_MODE_ECB, $iv));
}
$davData["PASS"] = $password;
}
$userObject->setPref("AJXP_WEBDAV_DATA", $davData);
$userObject->save("user");
}
$davData = $userObject->getPref("AJXP_WEBDAV_DATA");
if (!empty($davData)) {
$webdavActive = isset($davData["ACTIVE"]) && $davData["ACTIVE"] === true;
$passSet = isset($davData["PASS"]);
}
$repoList = ConfService::getRepositoriesList();
$davRepos = array();
$loggedUser = AuthService::getLoggedUser();
foreach ($repoList as $repoIndex => $repoObject) {
$accessType = $repoObject->getAccessType();
$driver = AJXP_PluginsService::getInstance()->getPluginByTypeName("access", $accessType);
if (is_a($driver, "AjxpWebdavProvider") && ($loggedUser->canRead($repoIndex) || $loggedUser->canWrite($repoIndex))) {
$davRepos[$repoIndex] = $webdavBaseUrl . "" . ($repoObject->getSlug() == null ? $repoObject->getId() : $repoObject->getSlug());
}
}
$prefs = array("webdav_active" => $webdavActive, "password_set" => $passSet, "webdav_base_url" => $webdavBaseUrl, "webdav_repositories" => $davRepos);
HTMLWriter::charsetHeader("application/json");
print json_encode($prefs);
break;
case "get_user_template_logo":
$tplId = $httpVars["template_id"];
$iconFormat = $httpVars["icon_format"];
$repo = ConfService::getRepositoryById($tplId);
$logo = $repo->getOption("TPL_ICON_" . strtoupper($iconFormat));
if (isset($logo) && is_file(AJXP_DATA_PATH . "/plugins/core.conf/tpl_logos/" . $logo)) {
header("Content-Type: " . AJXP_Utils::getImageMimeType($logo) . "; name=\"" . $logo . "\"");
header("Content-Length: " . filesize(AJXP_DATA_PATH . "/plugins/core.conf/tpl_logos/" . $logo));
header('Pragma:');
header('Cache-Control: public');
header("Last-Modified: " . gmdate("D, d M Y H:i:s", time() - 10000) . " GMT");
header("Expires: " . gmdate("D, d M Y H:i:s", time() + 5 * 24 * 3600) . " GMT");
readfile(AJXP_DATA_PATH . "/plugins/core.conf/tpl_logos/" . $logo);
} else {
$logo = "default_template_logo-" . ($iconFormat == "small" ? 16 : 22) . ".png";
header("Content-Type: " . AJXP_Utils::getImageMimeType($logo) . "; name=\"" . $logo . "\"");
header("Content-Length: " . filesize(AJXP_INSTALL_PATH . "/" . AJXP_PLUGINS_FOLDER . "/core.conf/" . $logo));
header('Pragma:');
header('Cache-Control: public');
header("Last-Modified: " . gmdate("D, d M Y H:i:s", time() - 10000) . " GMT");
header("Expires: " . gmdate("D, d M Y H:i:s", time() + 5 * 24 * 3600) . " GMT");
readfile(AJXP_INSTALL_PATH . "/" . AJXP_PLUGINS_FOLDER . "/core.conf/" . $logo);
}
break;
case "get_user_templates_definition":
AJXP_XMLWriter::header("repository_templates");
$repositories = ConfService::getRepositoriesList();
$pServ = AJXP_PluginsService::getInstance();
foreach ($repositories as $repo) {
if (!$repo->isTemplate) {
continue;
}
if (!$repo->getOption("TPL_USER_CAN_CREATE")) {
continue;
}
$repoId = $repo->getUniqueId();
$repoLabel = $repo->getDisplay();
$repoType = $repo->getAccessType();
print "<template repository_id=\"{$repoId}\" repository_label=\"{$repoLabel}\" repository_type=\"{$repoType}\">";
示例10: readFile
function readFile($filePathOrData, $headerType = "plain", $localName = "", $data = false, $gzip = null, $realfileSystem = false, $byteOffset = -1, $byteLength = -1)
{
if ($gzip === null) {
$gzip = ConfService::getCoreConf("GZIP_COMPRESSION");
}
if (!$realfileSystem && $this->wrapperClassName == "fsAccessWrapper") {
$originalFilePath = $filePathOrData;
$filePathOrData = fsAccessWrapper::patchPathForBaseDir($filePathOrData);
}
session_write_close();
restore_error_handler();
restore_exception_handler();
set_exception_handler('download_exception_handler');
set_error_handler('download_exception_handler');
// required for IE, otherwise Content-disposition is ignored
if (ini_get('zlib.output_compression')) {
AJXP_Utils::safeIniSet('zlib.output_compression', 'Off');
}
$isFile = !$data && !$gzip;
if ($byteLength == -1) {
if ($data) {
$size = strlen($filePathOrData);
} else {
if ($realfileSystem) {
$size = sprintf("%u", filesize($filePathOrData));
} else {
$size = $this->filesystemFileSize($filePathOrData);
}
}
} else {
$size = $byteLength;
}
if ($gzip && ($size > ConfService::getCoreConf("GZIP_LIMIT") || !function_exists("gzencode") || @strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') === FALSE)) {
$gzip = false;
// disable gzip
}
$localName = $localName == "" ? basename(isset($originalFilePath) ? $originalFilePath : $filePathOrData) : $localName;
if ($headerType == "plain") {
header("Content-type:text/plain");
} else {
if ($headerType == "image") {
header("Content-Type: " . AJXP_Utils::getImageMimeType(basename($filePathOrData)) . "; name=\"" . $localName . "\"");
header("Content-Length: " . $size);
header('Cache-Control: public');
} else {
/*
if(preg_match('/ MSIE /',$_SERVER['HTTP_USER_AGENT']) || preg_match('/ WebKit /',$_SERVER['HTTP_USER_AGENT'])){
$localName = str_replace("+", " ", urlencode(SystemTextEncoding::toUTF8($localName)));
}
*/
if ($isFile) {
header("Accept-Ranges: 0-{$size}");
AJXP_Logger::debug("Sending accept range 0-{$size}");
}
// Check if we have a range header (we are resuming a transfer)
if (isset($_SERVER['HTTP_RANGE']) && $isFile && $size != 0) {
if ($headerType == "stream_content") {
if (extension_loaded('fileinfo') && $this->wrapperClassName == "fsAccessWrapper") {
$fInfo = new fInfo(FILEINFO_MIME);
$realfile = call_user_func(array($this->wrapperClassName, "getRealFSReference"), $filePathOrData);
$mimeType = $fInfo->file($realfile);
$splitChar = explode(";", $mimeType);
$mimeType = trim($splitChar[0]);
AJXP_Logger::debug("Detected mime {$mimeType} for {$realfile}");
} else {
$mimeType = AJXP_Utils::getStreamingMimeType(basename($filePathOrData));
}
header('Content-type: ' . $mimeType);
}
// multiple ranges, which can become pretty complex, so ignore it for now
$ranges = explode('=', $_SERVER['HTTP_RANGE']);
$offsets = explode('-', $ranges[1]);
$offset = floatval($offsets[0]);
$length = floatval($offsets[1]) - $offset;
if (!$length) {
$length = $size - $offset;
}
if ($length + $offset > $size || $length < 0) {
$length = $size - $offset;
}
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) {
//.........这里部分代码省略.........