|
本帖最后由 mickeyort 于 2020-10-27 14:54 编辑
- /**
- * 系统输出
- * @return 返回内容
- */
- function output() {
- global $_G;
- if(defined('DISCUZ_OUTPUTED')) {
- return;
- } else {
- define('DISCUZ_OUTPUTED', 1);
- }
- if(!empty($_G['blockupdate'])) {
- block_updatecache($_G['blockupdate']['bid']);
- }
- if(defined('IN_MOBILE')) {
- mobileoutput();
- }
- $havedomain = implode('', $_G['setting']['domain']['app']);
- if($_G['setting']['rewritestatus'] || !empty($havedomain)) {
- $content = ob_get_contents();
- $content = output_replace($content);
- ob_end_clean();
- $_G['gzipcompress'] ? ob_start('ob_gzhandler') : ob_start();
- echo $content;
- }
- if(isset($_G['makehtml'])) {
- helper_makehtml::make_html();
- }
- if($_G['setting']['ftp']['connid']) {
- @ftp_close($_G['setting']['ftp']['connid']);
- }
- $_G['setting']['ftp'] = array();
- if(defined('CACHE_FILE') && CACHE_FILE && !defined('CACHE_FORBIDDEN') && !defined('IN_MOBILE') && !checkmobile()) {
- if(diskfreespace(DISCUZ_ROOT.'./'.$_G['setting']['cachethreaddir']) > 1000000) {
- if($fp = @fopen(CACHE_FILE, 'w')) {
- flock($fp, LOCK_EX);
- $content = empty($content) ? ob_get_contents() : $content;
- $temp_formhash = substr(md5(substr($_G['timestamp'], 0, -3).substr($_G['config']['security']['authkey'], 3, -3)), 8, 8);
- $content = preg_replace('/(name=[\'|"]formhash[\'|"] value=[\'"]|formhash=)('.constant("FORMHASH").')/ismU', '${1}'.$temp_formhash, $content);
- fwrite($fp, empty($content) ? ob_get_contents() : $content);
- }
- @fclose($fp);
- chmod(CACHE_FILE, 0777);
- }
- }
- if(defined('DISCUZ_DEBUG') && DISCUZ_DEBUG && @include(libfile('function/debug'))) {
- function_exists('debugmessage') && debugmessage();
- }
- }
复制代码
- //补充一个处理函数
- function output_replace($content) {
- global $_G;
- if(defined('IN_MODCP') || defined('IN_ADMINCP')) return $content;
- if(!empty($_G['setting']['output']['str']['search'])) {
- if(empty($_G['setting']['domain']['app']['default'])) {
- $_G['setting']['output']['str']['replace'] = str_replace('{CURHOST}', $_G['siteurl'], $_G['setting']['output']['str']['replace']);
- }
- $content = str_replace($_G['setting']['output']['str']['search'], $_G['setting']['output']['str']['replace'], $content);
- }
- if(!empty($_G['setting']['output']['preg']['search'])) {
- if(empty($_G['setting']['domain']['app']['default'])) {
- $_G['setting']['output']['preg']['search'] = str_replace('\{CURHOST\}', preg_quote($_G['siteurl'], '/'), $_G['setting']['output']['preg']['search']);
- $_G['setting']['output']['preg']['replace'] = str_replace('{CURHOST}', $_G['siteurl'], $_G['setting']['output']['preg']['replace']);
- }
-
- $content = preg_replace($_G['setting']['output']['preg']['search'], $_G['setting']['output']['preg']['replace'], $content);
- }
-
- return $content;
- }
复制代码 |
|