您当前的位置:首页 > 网站建设笔记 >

discuz_application类的_init_output()方法

0
<?php
private function _init_output() {
  //CC攻击防御, 设置文件/config/config_global.php里的$_config['security']['attackevasive']
  if ($this->config['security']['attackevasive'] && (!defined('CURSCRIPT') || !in_array($this->var['mod'], array('seccode','secqaa','swfupload')) && !defined('DISABLEDEFENSE'))) {
    require_once libfile('misc/security', 'include');
  }
  //HTTP_ACCEPT_ENCODING 当前请求头中Accept-Encoding: 项的内容, 如果存在的话。
  //$_SERVER['HTTP_ACCEPT_ENCODING']等于gzip, deflate
  if (!empty($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') === false) {
    $this->config['output']['gzip'] = false;
  }
  $allowgzip = $this->config['output']['gzip'] && empty($this->var['inajax']) && $this->var['mod'] != 'attachment' && EXT_OBGZIP;
  //更新$_G[gzipcompress]的值
  setglobal('gzipcompress', $allowgzip);
  //bool ob_start ([callback $output_callback [,int $chunk_size [,bool $erase]]])
  //此函数将打开输出缓冲。当输出缓冲激活后, 脚本将不会输出内容(除http标头外), 相反需要输出的内容被存储在内部缓冲区中。
  //内部缓冲区的内容可以用ob_get_contents()函数复制到一个字符串变量中。想要输出存储在内部缓冲区中的内容, 可以使用ob_end_flush()函数。
  //另外, 使用ob_end_clean()函数会静默丢弃掉缓冲区的内容。
  if (!ob_start($allowgzip ? 'ob_gzhandler' : null)) {
    ob_start();
  }
  //更新$_G[charset]的值
  setglobal('charset', $this->config['output']['charset']);
  define('CHARSET', $this->config['output']['charset']);
  //强制输出页面字符集, 用于避免某些环境乱码
  if ($this->config['output']['forceheader']) {
    @header('Content-Type: text/html; charset='.CHARSET);
  }
}
?>

建站咨询

在线咨询真诚为您提供专业解答服务

咨询热线

137 1731 25507×24小时服务热线

微信交流

二维码终于等到你,还好我没放弃
返回顶部