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


PHP SendSaveAsFileHeaderIfNeeded函数代码示例

本文整理汇总了PHP中SendSaveAsFileHeaderIfNeeded函数的典型用法代码示例。如果您正苦于以下问题:PHP SendSaveAsFileHeaderIfNeeded函数的具体用法?PHP SendSaveAsFileHeaderIfNeeded怎么用?PHP SendSaveAsFileHeaderIfNeeded使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: RedirectToCachedFile

function RedirectToCachedFile() {
	global $phpThumb, $PHPTHUMB_CONFIG;

	$nice_cachefile = str_replace(DIRECTORY_SEPARATOR, '/', $phpThumb->cache_filename);
	$nice_docroot   = str_replace(DIRECTORY_SEPARATOR, '/', rtrim($PHPTHUMB_CONFIG['document_root'], '/\\'));

	$parsed_url = phpthumb_functions::ParseURLbetter(@$_SERVER['HTTP_REFERER']);

	$nModified  = filemtime($phpThumb->cache_filename);

	if ($phpThumb->config_nooffsitelink_enabled && @$_SERVER['HTTP_REFERER'] && !in_array(@$parsed_url['host'], $phpThumb->config_nooffsitelink_valid_domains)) {

		$phpThumb->DebugMessage('Would have used cached (image/'.$phpThumb->thumbnailFormat.') file "'.$phpThumb->cache_filename.'" (Last-Modified: '.gmdate('D, d M Y H:i:s', $nModified).' GMT), but skipping because $_SERVER[HTTP_REFERER] ('.@$_SERVER['HTTP_REFERER'].') is not in $phpThumb->config_nooffsitelink_valid_domains ('.implode(';', $phpThumb->config_nooffsitelink_valid_domains).')', __FILE__, __LINE__);

	} elseif ($phpThumb->phpThumbDebug) {

		$phpThumb->DebugTimingMessage('skipped using cached image', __FILE__, __LINE__);
		$phpThumb->DebugMessage('Would have used cached file, but skipping due to phpThumbDebug', __FILE__, __LINE__);
		$phpThumb->DebugMessage('* Would have sent headers (1): Last-Modified: '.gmdate('D, d M Y H:i:s', $nModified).' GMT', __FILE__, __LINE__);
		if ($getimagesize = @GetImageSize($phpThumb->cache_filename)) {
			$phpThumb->DebugMessage('* Would have sent headers (2): Content-Type: '.phpthumb_functions::ImageTypeToMIMEtype($getimagesize[2]), __FILE__, __LINE__);
		}
		if (preg_match('#^'.preg_quote($nice_docroot).'(.*)$#', $nice_cachefile, $matches)) {
			$phpThumb->DebugMessage('* Would have sent headers (3): Location: '.dirname($matches[1]).'/'.urlencode(basename($matches[1])), __FILE__, __LINE__);
		} else {
			$phpThumb->DebugMessage('* Would have sent data: readfile('.$phpThumb->cache_filename.')', __FILE__, __LINE__);
		}

	} else {

		if (headers_sent()) {
			$phpThumb->ErrorImage('Headers already sent ('.basename(__FILE__).' line '.__LINE__.')');
			exit;
		}
		SendSaveAsFileHeaderIfNeeded();

		header('Last-Modified: '.gmdate('D, d M Y H:i:s', $nModified).' GMT');
		if (@$_SERVER['HTTP_IF_MODIFIED_SINCE'] && ($nModified == strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])) && @$_SERVER['SERVER_PROTOCOL']) {
			header($_SERVER['SERVER_PROTOCOL'].' 304 Not Modified');
			exit;
		}

		if ($getimagesize = @GetImageSize($phpThumb->cache_filename)) {
			header('Content-Type: '.phpthumb_functions::ImageTypeToMIMEtype($getimagesize[2]));
		} elseif (preg_match('#\\.ico$#i', $phpThumb->cache_filename)) {
			header('Content-Type: image/x-icon');
		}
		if (!@$PHPTHUMB_CONFIG['cache_force_passthru'] && preg_match('#^'.preg_quote($nice_docroot).'(.*)$#', $nice_cachefile, $matches)) {
			header('Location: '.dirname($matches[1]).'/'.urlencode(basename($matches[1])));
		} else {
			@readfile($phpThumb->cache_filename);
		}
		exit;

	}
	return true;
}
开发者ID:hungnv0789,项目名称:vhtm,代码行数:57,代码来源:phpThumb.php

示例2: cached

////////////////////////////////////////////////////////////////
// Debug output, to try and help me diagnose problems
if (@$_GET['phpThumbDebug'] == '5') {
    $phpThumb->phpThumbDebug();
}
////////////////////////////////////////////////////////////////
// check to see if file already exists in cache, and output it with no processing if it does
$phpThumb->SetCacheFilename();
if (is_file($phpThumb->cache_filename)) {
    $parsed_url = @parse_url(@$_SERVER['HTTP_REFERER']);
    if ($phpThumb->config_nooffsitelink_enabled && @$_SERVER['HTTP_REFERER'] && !in_array(@$parsed_url['host'], $phpThumb->config_nooffsitelink_valid_domains)) {
        $phpThumb->DebugMessage('Would have used cached (image/' . $phpThumb->thumbnailFormat . ') file "' . $phpThumb->cache_filename . '" (Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($phpThumb->cache_filename)) . ' GMT), but skipping because $_SERVER[HTTP_REFERER] (' . @$_SERVER['HTTP_REFERER'] . ') is not in $phpThumb->config_nooffsitelink_valid_domains (' . implode(';', $phpThumb->config_nooffsitelink_valid_domains) . ')', __FILE__, __LINE__);
    } elseif (@$_GET['phpThumbDebug']) {
        $phpThumb->DebugMessage('Would have used cached (image/' . $phpThumb->thumbnailFormat . ') file "' . $phpThumb->cache_filename . '" (Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($phpThumb->cache_filename)) . ' GMT), but skipping due to phpThumbDebug', __FILE__, __LINE__);
    } else {
        SendSaveAsFileHeaderIfNeeded();
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($phpThumb->cache_filename)) . ' GMT');
        if ($getimagesize = @GetImageSize($phpThumb->cache_filename)) {
            header('Content-type: ' . phpthumb_functions::ImageTypeToMIMEtype($getimagesize[2]));
        }
        @readfile($phpThumb->cache_filename);
        exit;
    }
} else {
    $phpThumb->DebugMessage('Cached file "' . $phpThumb->cache_filename . '" does not exist, processing as normal', __FILE__, __LINE__);
}
////////////////////////////////////////////////////////////////
// Debug output, to try and help me diagnose problems
if (@$_GET['phpThumbDebug'] == '6') {
    $phpThumb->phpThumbDebug();
}
开发者ID:BackupTheBerlios,项目名称:milaninegw-svn,代码行数:31,代码来源:phpThumb.php


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