本文整理汇总了PHP中ob_gzhandler函数的典型用法代码示例。如果您正苦于以下问题:PHP ob_gzhandler函数的具体用法?PHP ob_gzhandler怎么用?PHP ob_gzhandler使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ob_gzhandler函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: printContent
/**
* print either html or xml content given oModule object
* @remark addon execution and the trigger execution are included within this method, which might create inflexibility for the fine grained caching
* @param ModuleObject $oModule the module object
* @return void
*/
function printContent(&$oModule)
{
// Check if the gzip encoding supported
if (defined('__OB_GZHANDLER_ENABLE__') && __OB_GZHANDLER_ENABLE__ == 1 && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE && function_exists('ob_gzhandler') && extension_loaded('zlib') && $oModule->gzhandler_enable) {
$this->gz_enabled = TRUE;
}
// Extract contents to display by the request method
if (Context::get('xeVirtualRequestMethod') == 'xml') {
require_once _XE_PATH_ . "classes/display/VirtualXMLDisplayHandler.php";
$handler = new VirtualXMLDisplayHandler();
} else {
if (Context::getRequestMethod() == 'XMLRPC') {
require_once _XE_PATH_ . "classes/display/XMLDisplayHandler.php";
$handler = new XMLDisplayHandler();
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) {
$this->gz_enabled = FALSE;
}
} else {
if (Context::getRequestMethod() == 'JSON') {
require_once _XE_PATH_ . "classes/display/JSONDisplayHandler.php";
$handler = new JSONDisplayHandler();
} else {
if (Context::getRequestMethod() == 'JS_CALLBACK') {
require_once _XE_PATH_ . "classes/display/JSCallbackDisplayHandler.php";
$handler = new JSCallbackDisplayHandler();
} else {
require_once _XE_PATH_ . "classes/display/HTMLDisplayHandler.php";
$handler = new HTMLDisplayHandler();
}
}
}
}
$output = $handler->toDoc($oModule);
// call a trigger before display
ModuleHandler::triggerCall('display', 'before', $output);
// execute add-on
$called_position = 'before_display_content';
$oAddonController = getController('addon');
$addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone() ? "mobile" : "pc");
if (file_exists($addon_file)) {
include $addon_file;
}
if (method_exists($handler, "prepareToPrint")) {
$handler->prepareToPrint($output);
}
// header output
if ($this->gz_enabled) {
header("Content-Encoding: gzip");
}
$httpStatusCode = $oModule->getHttpStatusCode();
if ($httpStatusCode && $httpStatusCode != 200) {
$this->_printHttpStatusCode($httpStatusCode);
} else {
if (Context::getResponseMethod() == 'JSON' || Context::getResponseMethod() == 'JS_CALLBACK') {
$this->_printJSONHeader();
} else {
if (Context::getResponseMethod() != 'HTML') {
$this->_printXMLHeader();
} else {
$this->_printHTMLHeader();
}
}
}
// debugOutput output
$this->content_size = strlen($output);
$output .= $this->_debugOutput();
// results directly output
if ($this->gz_enabled) {
print ob_gzhandler($output, 5);
} else {
print $output;
}
// call a trigger after display
ModuleHandler::triggerCall('display', 'after', $output);
}
示例2: epb
function epb($buffer, $mode)
{
//@ob_gzhandler($buffer, $mode);
@ob_gzhandler($buffer);
//return $buffer; // uncomment if you're messing with output buffering so errors show. ~pb
return expProcessBuffer($buffer);
}
示例3: gzip_ops
function gzip_ops( &$buffer, $mode = 5 )
{
if ( GZIP === true && function_exists('ob_gzhandler') && substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') )
{
$buffer = ob_gzhandler($buffer, $mode);
}
return $buffer;
}
示例4: compress_handler
function compress_handler($p_buffer, $p_mode)
{
if (compress_is_enabled()) {
return ob_gzhandler($p_buffer, $p_mode);
} else {
return $p_buffer;
}
}
示例5: do_end
static function do_end($buffer, $mode)
{
// write contents to file
chdir(dirname($_SERVER['SCRIPT_FILENAME']));
file_put_contents(Cache::cache_file(), $buffer);
// use gz_handler to output if possible
if (headers_sent() || true) {
return false;
} else {
return ob_gzhandler($buffer, $mode);
}
}
示例6: compressionOutputHandler
/**
* Corrects HTTP "Content-length" header if it was sent by TYPO3 and compression
* is enabled.
*
* @param string $outputBuffer Output buffer to compress
* @param int $mode One of PHP_OUTPUT_HANDLER_xxx contants
* @return string Compressed string
* @see ob_start()
* @see ob_gzhandler()
*/
function compressionOutputHandler($outputBuffer, $mode)
{
// Compress the content
$outputBuffer = ob_gzhandler($outputBuffer, $mode);
if ($outputBuffer !== false) {
// Save compressed size
$this->contentLength += strlen($outputBuffer);
// Check if this was the last content chunk
if (0 != ($mode & PHP_OUTPUT_HANDLER_END)) {
// Check if we have content-length header
foreach (headers_list() as $header) {
if (0 == strncasecmp('Content-length:', $header, 15)) {
header('Content-length: ' . $this->contentLength);
break;
}
}
}
}
return $outputBuffer;
}
示例7: printContent
/**
* @brief 모듈객체를 받아서 content 출력
**/
function printContent(&$oModule)
{
// gzip encoding 지원 여부 체크
if (defined('__OB_GZHANDLER_ENABLE__') && __OB_GZHANDLER_ENABLE__ == 1 && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false && function_exists('ob_gzhandler') && extension_loaded('zlib')) {
$this->gz_enabled = true;
}
// request method에 따른 컨텐츠 결과물 추출
if (Context::get('xeVirtualRequestMethod') == 'xml') {
$output = $this->_toVirtualXmlDoc($oModule);
} else {
if (Context::getRequestMethod() == 'XMLRPC') {
$output = $this->_toXmlDoc($oModule);
} else {
if (Context::getRequestMethod() == 'JSON') {
$output = $this->_toJSON($oModule);
} else {
$output = $this->_toHTMLDoc($oModule);
}
}
}
// HTML 출력 요청일 경우 레이아웃 컴파일과 더블어 완성된 코드를 제공
if (Context::getResponseMethod() == "HTML") {
// 관리자 모드일 경우 #xeAdmin id를 가지는 div 추가
if (Context::get('module') != 'admin' && strpos(Context::get('act'), 'Admin') > 0) {
$output = '<div id="xeAdmin">' . $output . '</div>';
}
// 내용을 content라는 변수로 설정 (layout에서 {$output}에서 대체됨)
Context::set('content', $output);
// 레이아웃을 컴파일
$oTemplate =& TemplateHandler::getInstance();
// layout이라는 변수가 none으로 설정되면 기본 레이아웃으로 변경
if (Context::get('layout') != 'none') {
if (__DEBUG__ == 3) {
$start = getMicroTime();
}
$layout_path = $oModule->getLayoutPath();
$layout_file = $oModule->getLayoutFile();
$edited_layout_file = $oModule->getEditedLayoutFile();
// 현재 요청된 레이아웃 정보를 구함
$oLayoutModel =& getModel('layout');
$current_module_info = Context::get('current_module_info');
$layout_srl = $current_module_info->layout_srl;
// 레이아웃과 연결되어 있으면 레이아웃 컴파일
if ($layout_srl > 0) {
$layout_info = Context::get('layout_info');
// faceoff 레이아웃일 경우 별도 처리
if ($layout_info && $layout_info->type == 'faceoff') {
$oLayoutModel->doActivateFaceOff($layout_info);
Context::set('layout_info', $layout_info);
}
// 관리자 레이아웃 수정화면에서 변경된 CSS가 있는지 조사
$edited_layout_css = $oLayoutModel->getUserLayoutCss($layout_srl);
if (file_exists($edited_layout_css)) {
Context::addCSSFile($edited_layout_css, true, 'all', '', 100);
}
}
if (!$layout_path) {
$layout_path = "./common/tpl";
}
if (!$layout_file) {
$layout_file = "default_layout";
}
$output = $oTemplate->compile($layout_path, $layout_file, $edited_layout_file);
if (__DEBUG__ == 3) {
$GLOBALS['__layout_compile_elapsed__'] = getMicroTime() - $start;
}
}
}
// 출력하기 전에 trigger 호출 (before)
ModuleHandler::triggerCall('display', 'before', $output);
// 애드온 실행
$called_position = 'before_display_content';
$oAddonController =& getController('addon');
$addon_file = $oAddonController->getCacheFilePath();
if (file_exists($addon_file)) {
@(include $addon_file);
}
// HTML 출력일 경우 최종적으로 common layout을 씌워서 출력
if (Context::getResponseMethod() == "HTML") {
if (__DEBUG__ == 3) {
$start = getMicroTime();
}
// body 내의 <style ..></style>를 header로 이동
$output = preg_replace_callback('!<style(.*?)<\\/style>!is', array($this, 'moveStyleToHeader'), $output);
// 메타 파일 변경 (캐싱기능등으로 인해 위젯등에서 <!--Meta:경로--> 태그를 content에 넣는 경우가 있음
$output = preg_replace_callback('/<!--Meta:([a-z0-9\\_\\/\\.\\@]+)-->/is', array($this, 'transMeta'), $output);
// rewrite module 사용시 생기는 상대경로에 대한 처리를 함
if (Context::isAllowRewrite()) {
$url = parse_url(Context::getRequestUri());
$real_path = $url['path'];
$pattern = '/src=("|\'){1}(\\.\\/)?(files\\/attach|files\\/cache|files\\/faceOff|files\\/member_extra_info|modules|common|widgets|widgetstyle|layouts|addons)\\/([^"\']+)\\.(jpg|jpeg|png|gif)("|\'){1}/s';
$output = preg_replace($pattern, 'src=$1' . $real_path . '$3/$4.$5$6', $output);
if (Context::get('vid')) {
$pattern = '/\\/' . Context::get('vid') . '\\?([^=]+)=/is';
$output = preg_replace($pattern, '/?$1=', $output);
}
}
//.........这里部分代码省略.........
示例8: SendImageFromCache
function SendImageFromCache($src, $cached = true)
{
// set header
header('Content-type: image/jpg');
header('Cache-Control: public');
// set cache signal
header('Sd-signature: ' . ($cached ? 'Cached Image' : 'Created Image'));
// gzhandler
die(ob_gzhandler(file_get_contents($src), 9));
}
示例9: _httpConditionalCallBack
function _httpConditionalCallBack($buffer, $mode = 5)
{
//Private function automatically called at the end of the script when compression is enabled
//rfc2616-sec14.html#sec14.11
//You can adjust the level of compression with zlib.output_compression_level in php.ini
if (extension_loaded('zlib') && !ini_get('zlib.output_compression')) {
$buffer2 = ob_gzhandler($buffer, $mode);
//Will check HTTP_ACCEPT_ENCODING and put correct headers
if (strlen($buffer2) > 1) {
//When ob_gzhandler succeeded
$buffer = $buffer2;
}
}
header('Content-Length: ' . strlen($buffer));
//Allows persistant connections //rfc2616-sec14.html#sec14.13
return $buffer;
}
示例10: render
/**
* Returns the Asset Types content.
* It will try and use Gzip to compress the content and save bandwidth
*
* @return string
*/
public function render()
{
$content = $this->assetType->getContent();
/**
* Do not use ob_gzhandler() if zlib.output_compression ini option is set
* This will gzip the output twice and the text will be garbled
*/
if (@ini_get('zlib.output_compression')) {
$ret = $content;
} else {
if (!($ret = ob_gzhandler($content, PHP_OUTPUT_HANDLER_START | PHP_OUTPUT_HANDLER_END))) {
$ret = $content;
}
}
return $ret;
}
示例11: gzHandler
public function gzHandler($buffer = '', $mode = 0)
{
if (!is_string($buffer)) {
return Error::set(lang('Error', 'stringParameter', 'buffer'));
}
if (!is_numeric($mode)) {
return Error::set(lang('Error', 'numericParameter', 'mode'));
}
return ob_gzhandler($buffer, $mode);
}
示例12: dolphin_handler
function dolphin_handler($str)
{
$str = ob_gzhandler($str, 5);
header("Content-length: " . strlen($str));
return $str;
}
示例13: atm_compress_handler
/**
* Launch output compression if enabled
*/
function atm_compress_handler($p_buffer, $p_mode)
{
if (ENABLE_HTML_COMPRESSION && APPLICATION_EXEC_TYPE == 'http' && !headers_sent() && 'ob_gzhandler' != ini_get('output_handler') && extension_loaded('zlib') && strpos(strtolower(@$_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip') !== false && !ini_get('zlib.output_compression')) {
//no output compression should already defined at PHP level
if (!defined('HTML_COMPRESSION_STARTED')) {
define('HTML_COMPRESSION_STARTED', true);
}
return ob_gzhandler($p_buffer, $p_mode);
} else {
return $p_buffer;
}
}
示例14: output
/**
* Output callback method which will be called when the output buffer
* is flushed at the end of the request.
*
* @param string $uValue the generated content
* @param int $uStatus the status of the output buffer
*
* @return string final content
*/
public static function output($uValue, $uStatus)
{
$tParms = array('exitStatus' => &self::$exitStatus, 'responseFormat' => &self::$responseFormat, 'content' => &$uValue);
Events::invoke('output', $tParms);
if (ini_get('output_handler') === "") {
$tParms['content'] = mb_output_handler($tParms['content'], $uStatus);
// PHP_OUTPUT_HANDLER_START | PHP_OUTPUT_HANDLER_END
if (!ini_get('zlib.output_compression') && PHP_SAPI !== 'cli' && Config::get('options/gzip', true) === true) {
$tParms['content'] = ob_gzhandler($tParms['content'], $uStatus);
// PHP_OUTPUT_HANDLER_START | PHP_OUTPUT_HANDLER_END
}
}
return $tParms['content'];
}
示例15: handler
function handler($buffer, $mode)
{
$buffer = ob_gzhandler($buffer, $mode);
return $buffer;
}