示例#1
0
 /**
 +----------------------------------------------------------
 * 读取静态缓存
 +----------------------------------------------------------
 * @access static
 +----------------------------------------------------------
 * @return void
 +----------------------------------------------------------
 * @throws ThinkExecption
 +----------------------------------------------------------
 */
 static function readHTMLCache()
 {
     if (file_exists(CONFIG_PATH . 'htmls.php')) {
         // 读取静态规则文件
         // 静态规则文件定义格式 actionName=>array(‘静态规则’,’缓存时间’,’附加规则')
         // 'read'=>array('{id},{name}',60,'md5') 必须保证静态规则的唯一性 和 可判断性
         $htmls = (include CONFIG_PATH . 'htmls.php');
         if (!is_array($htmls)) {
             $htmls = $_htmls;
         }
         // 检测操作的静态规则
         if (isset($htmls[MODULE_NAME . ':' . ACTION_NAME])) {
             // 定义了某个模块的操作的静态规则
             $html = $htmls[MODULE_NAME . ':' . ACTION_NAME];
         } elseif (isset($htmls[ACTION_NAME])) {
             // 所有操作的静态规则
             $html = $htmls[ACTION_NAME];
         } elseif (isset($htmls['*'])) {
             // 定义了全局的静态规则
             $html = $htmls['*'];
         }
         if (!empty($html)) {
             self::$requireCache = true;
             // 解读静态规则
             $rule = $html[0];
             // 以$_开头的系统变量
             $rule = preg_replace('/{\\$(_\\w+)\\.(\\w+)\\|(\\w+)}/e', "\\3(\$\\1['\\2'])", $rule);
             $rule = preg_replace('/{\\$(_\\w+)\\.(\\w+)}/e', "\$\\1['\\2']", $rule);
             // {ID|FUN} GET变量的简写
             $rule = preg_replace('/{(\\w+)\\|(\\w+)}/e', "\\2(\$_GET['\\1'])", $rule);
             $rule = preg_replace('/{(\\w+)}/e', "\$_GET['\\1']", $rule);
             // 特殊系统变量
             $rule = str_ireplace(array('{:app}', '{:module}', '{:action}'), array(APP_NAME, MODULE_NAME, ACTION_NAME), $rule);
             // {|FUN} 单独使用函数
             $rule = preg_replace('/{|(\\w+)}/e', "\\1()", $rule);
             if (!empty($html[2])) {
                 // 应用附加函数
                 $rule = $html[2]($rule);
             }
             $time = $html[1] ? $html[1] : C('HTML_CACHE_TIME');
             // 缓存有效期 -1 为永久缓存
             self::$cacheTime = $time;
             $cacheName = $rule . C('HTML_FILE_SUFFIX');
             self::$cacheFile = $cacheName;
             define('HTML_FILE_NAME', HTML_PATH . $cacheName);
             if (self::checkHTMLCache(HTML_FILE_NAME, $time)) {
                 //静态页面有效
                 if (C('HTML_READ_TYPE') == 1) {
                     // 重定向到静态页面
                     redirect(str_replace(array(realpath($_SERVER["DOCUMENT_ROOT"]), "\\"), array('', "/"), realpath(HTML_FILE_NAME)));
                 } else {
                     // 读取静态页面输出
                     readfile(HTML_FILE_NAME);
                     exit;
                 }
             }
         }
     }
     return;
 }
示例#2
0
 private static function requireHtmlCache()
 {
     // 分析当前的静态规则
     $htmls = C('_htmls_');
     // 读取静态规则
     if (!empty($htmls)) {
         // 静态规则文件定义格式 actionName=>array(‘静态规则’,’缓存时间’,’附加规则')
         // 'read'=>array('{id},{name}',60,'md5') 必须保证静态规则的唯一性 和 可判断性
         // 检测静态规则
         if (isset($htmls[strtolower(GROUP_NAME . ':' . MODULE_NAME . ':' . ACTION_NAME)])) {
             $html = $htmls[strtolower(GROUP_NAME . ':' . MODULE_NAME . ':' . ACTION_NAME)];
             // 某个模块的操作的静态规则
         } elseif (isset($htmls[MODULE_NAME . ':' . ACTION_NAME])) {
             $html = $htmls[MODULE_NAME . ':' . ACTION_NAME];
             // 某个模块的操作的静态规则
         } elseif (isset($htmls[MODULE_NAME . ':'])) {
             // 某个模块的静态规则
             $html = $htmls[MODULE_NAME . ':'];
         } elseif (isset($htmls[ACTION_NAME])) {
             $html = $htmls[ACTION_NAME];
             // 所有操作的静态规则
         } elseif (isset($htmls['*'])) {
             $html = $htmls['*'];
             // 全局静态规则
         } elseif (isset($htmls['Empty:index']) && !class_exists(MODULE_NAME . 'Action')) {
             $html = $htmls['Empty:index'];
             // 空模块静态规则
         } elseif (isset($htmls[MODULE_NAME . ':_empty']) && self::isEmptyAction(MODULE_NAME, ACTION_NAME)) {
             $html = $htmls[MODULE_NAME . ':_empty'];
             // 空操作静态规则
         }
         if (!empty($html)) {
             self::$requireCache = true;
             // 需要缓存
             // 解读静态规则
             $rule = $html[0];
             // 以$_开头的系统变量
             $rule = preg_replace('/{\\$(_\\w+)\\.(\\w+)\\|(\\w+)}/e', "\\3(\$\\1['\\2'])", $rule);
             $rule = preg_replace('/{\\$(_\\w+)\\.(\\w+)}/e', "\$\\1['\\2']", $rule);
             // {ID|FUN} GET变量的简写
             $rule = preg_replace('/{(\\w+)\\|(\\w+)}/e', "\\2(\$_GET['\\1'])", $rule);
             $rule = preg_replace('/{(\\w+)}/e', "\$_GET['\\1']", $rule);
             // 特殊系统变量
             $rule = str_ireplace(array('{:app}', '{:module}', '{:action}', '{:group}'), array(APP_NAME, MODULE_NAME, ACTION_NAME, defined('GROUP_NAME') ? GROUP_NAME : ''), $rule);
             // {|FUN} 单独使用函数
             $rule = preg_replace('/{|(\\w+)}/e', "\\1()", $rule);
             if (!empty($html[2])) {
                 $rule = $html[2]($rule);
             }
             // 应用附加函数
             self::$cacheTime = isset($html[1]) ? $html[1] : C('HTML_CACHE_TIME');
             // 缓存有效期
             // 当前缓存文件
             define('HTML_FILE_NAME', HTML_PATH . $rule . C('HTML_FILE_SUFFIX'));
             return true;
         }
     }
     // 无需缓存
     return false;
 }
 /**
 +----------------------------------------------------------
 * 应用程序初始化
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @return void
 +----------------------------------------------------------
 */
 public static function init()
 {
     // 设定错误和异常处理
     set_error_handler(array('App', 'appError'));
     set_exception_handler(array('App', 'appException'));
     //[RUNTIME]
     // 检查项目是否编译过
     // 在部署模式下会自动在第一次执行的时候编译项目
     if (defined('RUNTIME_MODEL')) {
         // 运行模式无需载入项目编译缓存
     } elseif (is_file(RUNTIME_PATH . '~' . APP_CACHE_NAME . '.php') && (!is_file(CONFIG_PATH . 'config.php') || filemtime(RUNTIME_PATH . '~' . APP_CACHE_NAME . '.php') > filemtime(CONFIG_PATH . 'config.php'))) {
         // 直接读取编译后的项目文件
         C(include RUNTIME_PATH . '~' . APP_CACHE_NAME . '.php');
     } else {
         // 预编译项目
         App::build();
     }
     //[/RUNTIME]
     // 设置系统时区 PHP5支持
     if (function_exists('date_default_timezone_set')) {
         date_default_timezone_set(C('DEFAULT_TIMEZONE'));
     }
     // 允许注册AUTOLOAD方法
     if (C('APP_AUTOLOAD_REG') && function_exists('spl_autoload_register')) {
         spl_autoload_register(array('Think', 'autoload'));
     }
     // Session初始化
     if (C('SESSION_AUTO_START')) {
         session_start();
     }
     // URL调度
     Dispatcher::dispatch();
     // 加载模块配置文件
     if (is_file(CONFIG_PATH . strtolower(MODULE_NAME) . '_config.php')) {
         C(include CONFIG_PATH . strtolower(MODULE_NAME) . '_config.php');
     }
     // 系统检查
     App::checkLanguage();
     //语言检查
     App::checkTemplate();
     //模板检查
     // 开启静态缓存
     if (C('HTML_CACHE_ON')) {
         HtmlCache::readHTMLCache();
     }
     // 项目初始化标签
     if (C('APP_PLUGIN_ON')) {
         tag('app_init');
     }
     return;
 }
示例#4
0
 /**
 +----------------------------------------------------------
 * 应用程序初始化
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @return void
 +----------------------------------------------------------
 */
 public static function init()
 {
     // 设定错误和异常处理
     set_error_handler(array('App', 'appError'));
     set_exception_handler(array('App', 'appException'));
     //[RUNTIME]
     App::build();
     // 预编译项目
     //[/RUNTIME]
     // 注册AUTOLOAD方法
     if (function_exists('spl_autoload_register')) {
         spl_autoload_register(array('Think', 'autoload'));
     }
     // 设置系统时区 PHP5支持
     if (function_exists('date_default_timezone_set')) {
         date_default_timezone_set(C('DEFAULT_TIMEZONE'));
     }
     // 加载动态项目公共文件
     if (is_file(COMMON_PATH . 'extend.php')) {
         include COMMON_PATH . 'extend.php';
     }
     // URL调度
     Dispatcher::dispatch();
     // 加载模块配置文件
     if (is_file(CONFIG_PATH . strtolower(MODULE_NAME) . '_config.php')) {
         C(include CONFIG_PATH . strtolower(MODULE_NAME) . '_config.php');
     }
     // 系统检查
     App::checkLanguage();
     //语言检查
     App::checkTemplate();
     //模板检查
     // 开启静态缓存
     if (C('HTML_CACHE_ON')) {
         HtmlCache::readHTMLCache();
     }
     return;
 }
示例#5
0
 /**
 +----------------------------------------------------------
 * 应用程序初始化
 +----------------------------------------------------------
 * @access public 
 +----------------------------------------------------------
 * @return void
 +----------------------------------------------------------
 */
 public function init()
 {
     // 设定错误和异常处理
     set_error_handler(array(&$this, "appError"));
     set_exception_handler(array(&$this, "appException"));
     // 检查项目是否编译过
     // 在部署模式下会自动在第一次执行的时候编译项目
     if (file_exists(RUNTIME_PATH . '~app.php')) {
         // 直接读取编译后的项目文件
         C(array_change_key_case(include RUNTIME_PATH . '~app.php'));
     } else {
         // 预编译项目
         $this->build();
     }
     // 设置系统时区 PHP5支持
     if (function_exists('date_default_timezone_set')) {
         date_default_timezone_set(C('TIME_ZONE'));
     }
     if ('FILE' != strtoupper(C('SESSION_TYPE'))) {
         // 其它方式Session支持 目前支持Db 通过过滤器方式扩展
         import("Think.Util.Filter");
         Filter::load(ucwords(C('SESSION_TYPE')) . 'Session');
     }
     // Session初始化
     session_start();
     // 加载插件 必须在Session开启之后加载插件
     if (C('THINK_PLUGIN_ON')) {
         $this->loadPlugIn();
     }
     // 应用调度过滤器
     // 如果没有加载任何URL调度器
     // 默认只支持 QUERY_STRING 方式
     // 例如 ?m=user&a=add
     if (C('DISPATCH_ON')) {
         if ('Think' == C('DISPATCH_NAME')) {
             // 使用内置的ThinkDispatcher调度器
             import('Think.Core.Dispatcher');
             Dispatcher::dispatch();
         } else {
             // 加载第三方调度器
             apply_filter('app_dispatch');
         }
     }
     if (!defined('PHP_FILE')) {
         // PHP_FILE 由内置的Dispacher定义
         // 如果不使用该插件,需要重新定义
         define('PHP_FILE', _PHP_FILE_);
     }
     // 取得模块和操作名称 如果有伪装 则返回真实的名称
     // 可以在Dispatcher中定义获取规则
     if (!defined('MODULE_NAME')) {
         define('MODULE_NAME', $this->getModule());
     }
     // Module名称
     if (!defined('ACTION_NAME')) {
         define('ACTION_NAME', $this->getAction());
     }
     // Action操作
     // 加载模块配置文件 并自动生成配置缓存文件
     if (file_exists(CONFIG_PATH . 'm_' . MODULE_NAME . 'Config.php')) {
         C(array_change_key_case(include CONFIG_PATH . 'm_' . MODULE_NAME . 'Config.php'));
     }
     //	启用页面防刷新机制
     if (C('LIMIT_RESFLESH_ON')) {
         //	启用页面防刷新机制
         $guid = md5($_SERVER['PHP_SELF']);
         // 检查页面刷新间隔
         if (Cookie::is_set('_last_visit_time_' . $guid) && Cookie::get('_last_visit_time_' . $guid) > time() - C('LIMIT_REFLESH_TIMES')) {
             // 页面刷新读取浏览器缓存
             header('HTTP/1.1 304 Not Modified');
             exit;
         } else {
             // 缓存当前地址访问时间
             Cookie::set('_last_visit_time_' . $guid, $_SERVER['REQUEST_TIME'], $_SERVER['REQUEST_TIME'] + 3600);
             header('Last-Modified:' . date('D,d M Y H:i:s', $_SERVER['REQUEST_TIME'] - C('LIMIT_REFLESH_TIMES')) . ' GMT');
         }
     }
     // 系统检查
     $this->checkLanguage();
     //语言检查
     $this->checkTemplate();
     //模板检查
     if (C('USER_AUTH_ON')) {
         // 启用权限认证 调用RBAC组件
         import('ORG.RBAC.RBAC');
         RBAC::AccessDecision();
     }
     if (C('HTML_CACHE_ON')) {
         import('Think.Util.HtmlCache');
         HtmlCache::readHTMLCache();
     }
     // 应用初始化过滤插件
     apply_filter('app_init');
     // 记录应用初始化时间
     $GLOBALS['_initTime'] = microtime(TRUE);
     return;
 }
示例#6
0
 /**
 +----------------------------------------------------------
 * 加载模板和页面输出
 +----------------------------------------------------------
 * @access public 
 +----------------------------------------------------------
 * @param string $templateFile 模板文件名 留空为自动获取
 * @param string $charset 模板输出字符集
 * @param string $contentType 输出类型
 * @param string $varPrefix 模板变量前缀      
 * @param integer $mode 0 返回 1 输出 2 下载 
 +----------------------------------------------------------
 * @throws ThinkExecption
 +----------------------------------------------------------
 */
 public function fetch($templateFile = '', $charset = '', $contentType = 'text/html', $varPrefix = '', $display = false)
 {
     $startTime = array_sum(explode(' ', microtime()));
     if (null === $templateFile) {
         // 使用null参数作为模版名直接返回不做任何输出
         return;
     }
     if ('layout::' == substr($templateFile, 0, 8)) {
         $this->layout(substr($templateFile, 8));
         return;
     }
     if (empty($charset)) {
         $charset = C('OUTPUT_CHARSET');
     }
     // 网页字符编码
     header("Content-Type:" . $contentType . "; charset=" . $charset);
     header("Cache-control: private");
     //支持页面回跳
     // 设置输出缓存
     ini_set('output_buffering', 4096);
     $zlibCompress = ini_get('zlib.output_compression');
     if (empty($zlibCompress) && function_exists('ini_set')) {
         ini_set('zlib.output_compression', 1);
     }
     // 缓存初始化过滤
     apply_filter('ob_init');
     //页面缓存
     ob_start();
     ob_implicit_flush(0);
     // 缓存开启后执行的过滤
     apply_filter('ob_start');
     // 模版文件名过滤
     $templateFile = apply_filter('template_file', $templateFile);
     if ('' == $templateFile) {
         // 如果模板文件名为空 按照默认规则定位
         $templateFile = C('TMPL_FILE_NAME');
     } elseif (strpos($templateFile, '@')) {
         // 引入其它主题的操作模板 必须带上模块名称 例如 blue@User:add
         $templateFile = TMPL_PATH . '/' . str_replace(array('@', ':'), '/', $templateFile) . C('TEMPLATE_SUFFIX');
     } elseif (strpos($templateFile, ':')) {
         // 引入其它模块的操作模板
         $templateFile = TEMPLATE_PATH . '/' . str_replace(':', '/', $templateFile) . C('TEMPLATE_SUFFIX');
     } elseif (!file_exists($templateFile)) {
         // 引入当前模块的其它操作模板
         $templateFile = dirname(C('TMPL_FILE_NAME')) . '/' . $templateFile . C('TEMPLATE_SUFFIX');
     }
     if (!file_exists($templateFile)) {
         throw_exception(L('_TEMPLATE_NOT_EXIST_'));
     }
     // 模版变量过滤
     $this->tVar = apply_filter('template_var', $this->tVar);
     //根据不同模版引擎进行处理
     if ('PHP' == $this->type || empty($this->type)) {
         // 默认使用PHP模版
         include $templateFile;
     } elseif ('THINK' == $this->type) {
         // 使用内置的ThinkTemplate模板引擎
         if (!$this->checkCache($templateFile)) {
             // 缓存无效 重新编译
             $compiler = true;
             import('Think.Template.ThinkTemplate');
             $tpl = new ThinkTemplate();
             // 编译并加载模板文件
             $tpl->load($templateFile, $charset, $this->tVar, $varPrefix);
         } else {
             // 缓存有效 直接载入模板缓存
             // 模板阵列变量分解成为独立变量
             extract($this->tVar, empty($varPrefix) ? EXTR_OVERWRITE : EXTR_PREFIX_ALL, $varPrefix);
             //载入模版缓存文件
             include CACHE_PATH . md5($templateFile) . C('CACHFILE_SUFFIX');
         }
     } else {
         // 通过插件的方式扩展第三方模板引擎
         use_compiler(C('TMPL_ENGINE_TYPE'), $templateFile, $this->tVar, $charset, $varPrefix);
     }
     // 获取并清空缓存
     $content = ob_get_clean();
     // 输出编码转换
     $content = auto_charset($content, C('TEMPLATE_CHARSET'), $charset);
     // 输出过滤
     $content = apply_filter('ob_content', $content);
     if (C('HTML_CACHE_ON')) {
         // 写入静态文件
         HtmlCache::writeHTMLCache($content);
     }
     if ($display) {
         $showTime = $this->showTime($startTime);
         echo $content;
         if (C('SHOW_RUN_TIME')) {
             echo '<div  class="think_run_time">' . $showTime . '</div>';
         }
         if (C('SHOW_PAGE_TRACE')) {
             // 显示页面Trace信息 读取Trace定义文件
             // 定义格式 return array('当前页面'=>$_SERVER['PHP_SELF'],'通信协议'=>$_SERVER['SERVER_PROTOCOL'],...);
             $traceFile = CONFIG_PATH . '_trace.php';
             if (file_exists($traceFile)) {
                 $_trace = (include $traceFile);
             } else {
                 $_trace = array();
             }
             // 系统默认显示信息
             $this->trace('当前页面', $_SERVER['PHP_SELF']);
             $this->trace('请求方法', $_SERVER['REQUEST_METHOD']);
             $this->trace('通信协议', $_SERVER['SERVER_PROTOCOL']);
             $this->trace('请求时间', Date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']));
             $this->trace('用户代理', $_SERVER['HTTP_USER_AGENT']);
             $this->trace('会话ID', session_id());
             $this->trace('运行数据', $showTime);
             $this->trace('输出编码', $charset);
             $this->trace('加载类库', $GLOBALS['include_file']);
             $this->trace('模板编译', !empty($compiler) ? '重新编译' : '读取缓存');
             if (isset(Log::$log[SQL_LOG_DEBUG])) {
                 $log = Log::$log[SQL_LOG_DEBUG];
                 $this->trace('SQL记录', is_array($log) ? count($log) . '条SQL<br/>' . implode('<br/>', $log) : '无SQL记录');
             } else {
                 $this->trace('SQL记录', '无SQL记录');
             }
             $this->trace('错误记录', count(App::$debug) . '条注意<br/>' . implode('<br/>', App::$debug));
             $_trace = array_merge($_trace, $this->trace);
             $_trace = auto_charset($_trace, 'utf-8');
             $_title = auto_charset('页面Trace信息', 'utf-8');
             // 调用Trace页面模板
             include THINK_PATH . '/Tpl/PageTrace.tpl.php';
         }
         return null;
     } else {
         return $content;
     }
 }
 /**
 +----------------------------------------------------------
 * 输出模板
 +----------------------------------------------------------
 * @access protected
 +----------------------------------------------------------
 * @param string $content 模板内容
 * @param boolean $display 是否直接显示
 +----------------------------------------------------------
 * @return mixed
 +----------------------------------------------------------
 */
 protected function output($content, $display)
 {
     if (C('HTML_CACHE_ON')) {
         HtmlCache::writeHTMLCache($content);
     }
     if ($display) {
         if (C('SHOW_RUN_TIME')) {
             if (false !== strpos($content, '{__NORUNTIME__}')) {
                 $content = str_replace('{__NORUNTIME__}', '', $content);
             } else {
                 $runtime = $this->showTime();
                 if (strpos($content, '{__RUNTIME__}')) {
                     $content = str_replace('{__RUNTIME__}', $runtime, $content);
                 } else {
                     $content .= $runtime;
                 }
             }
         } else {
             $content = str_replace(array('{__NORUNTIME__}', '{__RUNTIME__}'), '', $content);
         }
         echo $content;
         if (C('SHOW_PAGE_TRACE')) {
             $this->showTrace();
         }
         return null;
     } else {
         return $content;
     }
 }
示例#8
0
 /**
 +----------------------------------------------------------
 * 应用程序初始化
 +----------------------------------------------------------
 * @access public 
 +----------------------------------------------------------
 * @return void
 +----------------------------------------------------------
 */
 public function init()
 {
     // 设定错误和异常处理
     set_error_handler(array(&$this, "appError"));
     set_exception_handler(array(&$this, "appException"));
     // 加载惯例配置文件
     C(array_change_key_case(include THINK_PATH . '/Common/convention.php'));
     // 加载项目配置文件
     // 支持App.* 作为配置文件
     // 自动生成_appConfig.php 配置缓存
     $this->loadConfig('App', CONFIG_PATH, '_config.php');
     // 如果是调试模式加载调试模式配置文件
     if (C('DEBUG_MODE')) {
         // 加载系统默认的开发模式配置文件
         C(array_change_key_case(include THINK_PATH . '/Common/debug.php'));
         if (file_exists(CONFIG_PATH . '_debug.php')) {
             // 允许项目增加开发模式配置定义
             C(array_change_key_case(include CONFIG_PATH . '_debug.php'));
         }
     }
     // 设置系统时区 PHP5支持
     if (function_exists('date_default_timezone_set')) {
         date_default_timezone_set(C('TIME_ZONE'));
     }
     if ('FILE' != strtoupper(C('SESSION_TYPE'))) {
         // 其它方式Session支持 目前支持Db 通过过滤器方式扩展
         import("Think.Util.Filter");
         Filter::load(ucwords(C('SESSION_TYPE')) . 'Session');
     }
     // Session初始化
     Session::start();
     // 加载插件 必须在Session开启之后加载插件
     if (C('THINK_PLUGIN_ON')) {
         $this->loadPlugIn();
     }
     // 应用调度过滤器
     // 如果没有加载任何URL调度器
     // 默认只支持 QUERY_STRING 方式
     // 例如 ?m=user&a=add
     if (C('DISPATCH_ON')) {
         if ('Think' == C('DISPATCH_NAME')) {
             // 使用内置的ThinkDispatcher调度器
             import('Think.Core.Dispatcher');
             Dispatcher::dispatch();
         } else {
             // 加载第三方调度器
             apply_filter('app_dispatch');
         }
     }
     if (!defined('PHP_FILE')) {
         // PHP_FILE 由内置的Dispacher定义
         // 如果不使用该插件,需要重新定义
         define('PHP_FILE', _PHP_FILE_);
     }
     // 取得模块和操作名称 如果有伪装 则返回真实的名称
     // 可以在Dispatcher中定义获取规则
     if (!defined('MODULE_NAME')) {
         define('MODULE_NAME', $this->getModule());
     }
     // Module名称
     if (!defined('ACTION_NAME')) {
         define('ACTION_NAME', $this->getAction());
     }
     // Action操作
     // 加载模块配置文件 并自动生成配置缓存文件
     $this->loadConfig('m_' . MODULE_NAME, CONFIG_PATH, 'm_' . MODULE_NAME . 'Config.php', false);
     //	启用页面防刷新机制
     if (C('LIMIT_RESFLESH_ON')) {
         $guid = md5($_SERVER['PHP_SELF']);
         // 检查页面刷新间隔
         if (Session::is_set('_last_visit_time_' . $guid) && Session::get('_last_visit_time_' . $guid) > time() - C('LIMIT_REFLESH_TIMES')) {
             // 页面刷新读取浏览器缓存
             header('HTTP/1.1 304 Not Modified');
             exit;
         } else {
             // 缓存当前地址访问时间
             Session::set('_last_visit_time_' . $guid, time());
             header('Last-Modified:' . date('D,d M Y H:i:s', time() - C('LIMIT_REFLESH_TIMES')) . ' GMT');
         }
     }
     // 加载项目公共文件
     if (file_exists(APP_PATH . '/Common/common.php')) {
         include APP_PATH . '/Common/common.php';
     }
     // 系统检查
     $this->checkLanguage();
     //语言检查
     $this->checkTemplate();
     //模板检查
     if (C('USER_AUTH_ON')) {
         // 启用权限认证 调用RBAC组件
         import('ORG.RBAC.RBAC');
         RBAC::AccessDecision();
     }
     if (C('HTML_CACHE_ON')) {
         import('Think.Util.HtmlCache');
         HtmlCache::readHTMLCache();
     }
     // 应用初始化过滤插件
     apply_filter('app_init');
     // 记录应用初始化时间
     $GLOBALS['_initTime'] = array_sum(explode(' ', microtime()));
     return;
 }
示例#9
0
 public function init()
 {
     set_error_handler(array(&$this, "appError"));
     set_exception_handler(array(&$this, "appException"));
     if (is_file(RUNTIME_PATH . '~app.php') && (!is_file(CONFIG_PATH . 'config.php') || filemtime(RUNTIME_PATH . '~app.php') > filemtime(CONFIG_PATH . 'config.php'))) {
         C(include RUNTIME_PATH . '~app.php');
     } else {
         $this->build();
     }
     if (IS_CLI) {
         define('MODULE_NAME', $this->getModule());
         define('ACTION_NAME', $this->getAction());
         L(include CORE_PATH . 'Lang/' . C('DEFAULT_LANGUAGE') . '.php');
     } else {
         if (function_exists('date_default_timezone_set')) {
             date_default_timezone_set(C('TIME_ZONE'));
         }
         if ('FILE' != strtoupper(C('SESSION_TYPE'))) {
             import("Think.Util.Filter");
             Filter::load(ucwords(strtolower(C('SESSION_TYPE'))) . 'Session');
         }
         session_start();
         if ($plugInOn = C('THINK_PLUGIN_ON')) {
             $this->loadPlugIn();
         }
         if (C('DISPATCH_ON')) {
             if ('Think' == C('DISPATCH_NAME')) {
                 import('Think.Util.Dispatcher');
                 Dispatcher::dispatch();
             } elseif ($plugInOn) {
                 apply_filter('app_dispatch');
             }
         }
         if (!defined('PHP_FILE')) {
             define('PHP_FILE', _PHP_FILE_);
         }
         if (!defined('MODULE_NAME')) {
             define('MODULE_NAME', $this->getModule());
         }
         if (!defined('ACTION_NAME')) {
             define('ACTION_NAME', $this->getAction());
         }
         if (is_file(CONFIG_PATH . MODULE_NAME . '_config.php')) {
             C(include CONFIG_PATH . MODULE_NAME . '_config.php');
         }
         if (C('LIMIT_RESFLESH_ON') && (!isset($_REQUEST[C('VAR_RESFLESH')]) || $_REQUEST[C('VAR_RESFLESH')] != "1")) {
             $guid = md5($_SERVER['PHP_SELF']);
             if (Cookie::is_set('last_visit_time_' . $guid) && Cookie::get('last_visit_time_' . $guid) > time() - C('LIMIT_REFLESH_TIMES')) {
                 header('HTTP/1.1 304 Not Modified');
                 exit;
             } else {
                 Cookie::set('last_visit_time_' . $guid, $_SERVER['REQUEST_TIME'], C('COOKIE_EXPIRE'));
                 header('Last-Modified:' . date('D,d M Y H:i:s', $_SERVER['REQUEST_TIME'] - C('LIMIT_REFLESH_TIMES')) . ' GMT');
             }
         }
         $this->checkLanguage();
         $this->checkTemplate();
         if (C('HTML_CACHE_ON')) {
             import('Think.Util.HtmlCache');
             HtmlCache::readHTMLCache();
         }
         if ($plugInOn) {
             apply_filter('app_init');
         }
     }
     if (C('SHOW_RUN_TIME')) {
         $GLOBALS['_initTime'] = microtime(TRUE);
     }
     return;
 }
示例#10
0
 /**
 +----------------------------------------------------------
 * 应用程序初始化
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @return void
 +----------------------------------------------------------
 */
 public function init()
 {
     // 设定错误和异常处理
     set_error_handler(array(&$this, "appError"));
     set_exception_handler(array(&$this, "appException"));
     // 检查项目是否编译过
     // 在部署模式下会自动在第一次执行的时候编译项目
     if (is_file(RUNTIME_PATH . '~app.php') && (!is_file(CONFIG_PATH . 'config.php') || filemtime(RUNTIME_PATH . '~app.php') > filemtime(CONFIG_PATH . 'config.php'))) {
         // 直接读取编译后的项目文件
         C(include RUNTIME_PATH . '~app.php');
     } else {
         // 预编译项目
         $this->build();
     }
     // 项目开始标签
     if (C('TAG_PLUGIN_ON')) {
         tag('app_begin');
     }
     // 设置系统时区 PHP5支持
     if (function_exists('date_default_timezone_set')) {
         date_default_timezone_set(C('TIME_ZONE'));
     }
     if (C('SESSION_AUTO_START')) {
         // Session初始化
         session_start();
     }
     // 应用调度过滤器
     // 如果没有加载任何URL调度器
     // 默认只支持 QUERY_STRING 方式
     // 例如 ?m=user&a=add
     if (C('DISPATCH_ON')) {
         import('Dispatcher');
         Dispatcher::dispatch();
     }
     if (!defined('PHP_FILE')) {
         // PHP_FILE 由内置的Dispacher定义
         // 如果不使用该插件,需要重新定义
         define('PHP_FILE', _PHP_FILE_);
     }
     // 取得模块和操作名称
     // 可以在Dispatcher中定义获取规则
     if (!defined('MODULE_NAME')) {
         define('MODULE_NAME', $this->getModule());
     }
     // Module名称
     if (!defined('ACTION_NAME')) {
         define('ACTION_NAME', $this->getAction());
     }
     // Action操作
     // 加载模块配置文件
     if (is_file(CONFIG_PATH . strtolower(MODULE_NAME) . '_config.php')) {
         C(include CONFIG_PATH . strtolower(MODULE_NAME) . '_config.php');
     }
     // 系统检查
     $this->checkLanguage();
     //语言检查
     $this->checkTemplate();
     //模板检查
     if (C('HTML_CACHE_ON')) {
         // 开启静态缓存
         import('HtmlCache');
         HtmlCache::readHTMLCache();
     }
     // 项目初始化标签
     if (C('TAG_PLUGIN_ON')) {
         tag('app_init');
     }
     return;
 }
示例#11
0
 /**
 +----------------------------------------------------------
 * 输出模板
 +----------------------------------------------------------
 * @access protected
 +----------------------------------------------------------
 * @param string $content 模板内容
 * @param boolean $display 是否直接显示
 +----------------------------------------------------------
 * @return mixed
 +----------------------------------------------------------
 */
 protected function output($content, $display)
 {
     if (C('HTML_CACHE_ON')) {
         // 写入静态文件
         HtmlCache::writeHTMLCache($content);
     }
     // 视图输出标签
     if (C('TAG_PLUGIN_ON')) {
         tag('view_output', array($content));
     }
     if ($display) {
         $showTime = $this->showTime();
         echo $content;
         if (C('SHOW_RUN_TIME')) {
             echo '<div  id="think_run_time" class="think_run_time">' . $showTime . '</div>';
         }
         $this->showTrace($showTime);
         return null;
     } else {
         return $content;
     }
 }
示例#12
0
 /**
 +----------------------------------------------------------
 * 应用程序初始化
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @return void
 +----------------------------------------------------------
 */
 public static function init()
 {
     // 设定错误和异常处理
     set_error_handler(array('App', 'appError'));
     set_exception_handler(array('App', 'appException'));
     //[RUNTIME]
     // 检查项目是否编译过
     // 在部署模式下会自动在第一次执行的时候编译项目
     if (defined('RUNTIME_MODEL')) {
         // 运行模式无需载入项目编译缓存
     } else {
         if (is_file(RUNTIME_PATH . '/~app.php') && (!is_file(CONFIG_PATH . 'config.php') || filemtime(RUNTIME_PATH . '/~app.php') > filemtime(CONFIG_PATH . 'config.php'))) {
             // 直接读取编译后的项目文件
             C(include RUNTIME_PATH . '/~app.php');
         } else {
             // 预编译项目
             App::build();
         }
     }
     //[/RUNTIME]
     //加载所有插件
     Addons::loadAllValidAddons();
     if (!defined('MODULE_NAME')) {
         define('MODULE_NAME', App::getModule());
     }
     // Module名称
     if (!defined('ACTION_NAME')) {
         define('ACTION_NAME', App::getAction());
     }
     // Action操作
     // If already slashed, strip.
     if (get_magic_quotes_gpc()) {
         $_GET = stripslashes_deep($_GET);
         $_POST = stripslashes_deep($_POST);
         $_COOKIE = stripslashes_deep($_COOKIE);
     }
     // 初始化运行时缓存
     object_cache_init();
     // 修正IIS下的$_SERVER['REQUEST_URI']
     if ($_SERVER['REQUEST_URI']) {
         $_SERVER['REQUEST_URI'] = $_SERVER['PHP_SELF'] . ($_SERVER['QUERY_STRING'] ? '?' . $_SERVER['QUERY_STRING'] : '');
     }
     // 站点设置
     App::checkSiteOption();
     // 项目开始标签
     if (C('APP_PLUGIN_ON')) {
         tag('app_begin');
     }
     // 设置系统时区 PHP5支持
     if (function_exists('date_default_timezone_set')) {
         date_default_timezone_set(C('DEFAULT_TIMEZONE'));
     }
     // 允许注册AUTOLOAD方法
     if (C('APP_AUTOLOAD_REG') && function_exists('spl_autoload_register')) {
         spl_autoload_register(array('Think', 'autoload'));
     }
     // 重塑Session (必须位于session_start()之前)
     if (isset($_POST['PHPSESSID'])) {
         Session::destroy();
         session_id($_POST['PHPSESSID']);
     }
     // 初始化Session
     if (C('SESSION_AUTO_START')) {
         Session::start();
     }
     /*
      * 应用调度过滤器
      * 如果没有加载任何URL调度器, 默认只支持 QUERY_STRING 方式
      */
     if (C('URL_DISPATCH_ON')) {
         Dispatcher::dispatch();
     }
     /*
      * PHP_FILE 由内置的Dispacher定义
      * 如果不使用该插件,需要重新定义
      */
     if (!defined('PHP_FILE')) {
         define('PHP_FILE', _PHP_FILE_);
     }
     // 取得模块和操作名称
     // 可以在Dispatcher中定义获取规则
     // 使用手持设备时, 对home的访问默认跳转至移动版, 除非用户指定访问普通版。
     if (APP_NAME == 'home' && $_SESSION['wap_to_normal'] != '1' && cookie('wap_to_normal') != '1' && $_REQUEST['wap_to_normal'] != '1') {
         if (MODULE_NAME == 'Public' && ACTION_NAME == 'tryOtherLogin') {
         } else {
             if (MODULE_NAME == 'Widget' && ACTION_NAME == 'addonsRequest') {
             } else {
                 if (isiOS() || isAndroid()) {
                     // iOS和Android跳转至3G版
                     U('w3g/Index/index', '', true);
                 } else {
                     if (isMobile()) {
                         // 其他手机跳转至WAP版
                         U('wap/Index/index', '', true);
                     }
                 }
             }
         }
     }
     // 检查应用是否安装 (Admin和默认应用不需要安装)
     if (MODULE_NAME != 'Admin' && !in_array(APP_NAME, C('DEFAULT_APPS')) && !model('App')->isAppNameActive(APP_NAME)) {
         throw_exception(L('_APP_INACTIVE_') . APP_NAME);
     }
     $GLOBALS['ts']['_app'] = APP_NAME;
     $GLOBALS['ts']['_mod'] = MODULE_NAME;
     $GLOBALS['ts']['_act'] = ACTION_NAME;
     // 加载模块配置文件
     if (is_file(CONFIG_PATH . strtolower(MODULE_NAME) . '_config.php')) {
         C(include CONFIG_PATH . strtolower(MODULE_NAME) . '_config.php');
     }
     //Ucenter初始化
     App::initUcenter();
     // 用户认证
     App::checkUser();
     // 语言检查
     App::checkLanguage();
     // 模板检查
     App::checkTemplate();
     // 开启静态缓存
     if (C('HTML_CACHE_ON')) {
         HtmlCache::readHTMLCache();
     }
     // 项目初始化标签
     if (C('APP_PLUGIN_ON')) {
         tag('app_init');
     }
     return;
 }
示例#13
0
 /**
 +----------------------------------------------------------
 * 应用程序初始化
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @return void
 +----------------------------------------------------------
 */
 public static function init()
 {
     // 设定错误和异常处理
     set_error_handler(array('App', 'appError'));
     set_exception_handler(array('App', 'appException'));
     //[RUNTIME]
     // 检查项目是否编译过
     // 在部署模式下会自动在第一次执行的时候编译项目
     if (defined('RUNTIME_MODEL')) {
         // 运行模式无需载入项目编译缓存
     } elseif (is_file(RUNTIME_PATH . '/~app.php') && (!is_file(CONFIG_PATH . 'config.php') || filemtime(RUNTIME_PATH . '/~app.php') > filemtime(CONFIG_PATH . 'config.php'))) {
         // 直接读取编译后的项目文件
         C(include RUNTIME_PATH . '/~app.php');
     } else {
         // 预编译项目
         App::build();
     }
     //[/RUNTIME]
     if (!defined('MODULE_NAME')) {
         define('MODULE_NAME', App::getModule());
     }
     // Module名称
     if (!defined('ACTION_NAME')) {
         define('ACTION_NAME', App::getAction());
     }
     // Action操作
     // If already slashed, strip.
     if (get_magic_quotes_gpc()) {
         $_GET = stripslashes_deep($_GET);
         $_POST = stripslashes_deep($_POST);
         $_COOKIE = stripslashes_deep($_COOKIE);
     }
     // 站点设置
     App::checkSiteOption();
     // 项目开始标签
     if (C('APP_PLUGIN_ON')) {
         tag('app_begin');
     }
     // 设置系统时区 PHP5支持
     if (function_exists('date_default_timezone_set')) {
         date_default_timezone_set(C('DEFAULT_TIMEZONE'));
     }
     // 允许注册AUTOLOAD方法
     if (C('APP_AUTOLOAD_REG') && function_exists('spl_autoload_register')) {
         spl_autoload_register(array('Think', 'autoload'));
     }
     if (C('SESSION_AUTO_START')) {
         session_start();
     }
     // Session初始化
     // 应用调度过滤器
     // 如果没有加载任何URL调度器
     // 默认只支持 QUERY_STRING 方式
     if (C('URL_DISPATCH_ON')) {
         Dispatcher::dispatch();
     }
     if (!defined('PHP_FILE')) {
         // PHP_FILE 由内置的Dispacher定义
         // 如果不使用该插件,需要重新定义
         define('PHP_FILE', _PHP_FILE_);
     }
     // 取得模块和操作名称
     // 可以在Dispatcher中定义获取规则
     // 404
     C('ERROR_PAGE', U('home/Public/error404'));
     // 检查应用是否安装
     if (!in_array(APP_NAME, C('DEFAULT_APPS')) && !model('App')->isAppNameActive(APP_NAME)) {
         throw_exception(L('_APP_INACTIVE_') . APP_NAME);
     }
     global $ts;
     $ts['_app'] = APP_NAME;
     $ts['_mod'] = MODULE_NAME;
     $ts['_act'] = ACTION_NAME;
     // 加载模块配置文件
     if (is_file(CONFIG_PATH . strtolower(MODULE_NAME) . '_config.php')) {
         C(include CONFIG_PATH . strtolower(MODULE_NAME) . '_config.php');
     }
     // 用户认证
     App::checkUser();
     // 系统检查
     App::checkLanguage();
     //语言检查
     App::checkTemplate();
     //模板检查
     if (C('HTML_CACHE_ON')) {
         // 开启静态缓存
         HtmlCache::readHTMLCache();
     }
     // 项目初始化标签
     if (C('APP_PLUGIN_ON')) {
         tag('app_init');
     }
     return;
 }
示例#14
0
 protected function output($content, $display, $charset, $htmlCache = true)
 {
     if (C('HTML_CACHE_ON') && $htmlCache) {
         HtmlCache::writeHTMLCache($content);
     }
     if ($display) {
         $showTime = $this->showTime();
         echo $content;
         if (C('SHOW_RUN_TIME')) {
             echo '<div  id="think_run_time" class="think_run_time">' . $showTime . '</div>';
         }
         $this->showTrace($showTime, $charset);
         return null;
     } else {
         return $content;
     }
 }
示例#15
0
 /**
 +----------------------------------------------------------
 * 应用程序初始化
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @return void
 +----------------------------------------------------------
 */
 public static function init()
 {
     // 设定错误和异常处理
     set_error_handler(array('App', 'appError'));
     set_exception_handler(array('App', 'appException'));
     //[RUNTIME]
     // 检查项目是否编译过
     // 在部署模式下会自动在第一次执行的时候编译项目
     if (defined('RUNTIME_MODEL')) {
         // 运行模式无需载入项目编译缓存
     } elseif (is_file(RUNTIME_PATH . '~app.php') && (!is_file(CONFIG_PATH . 'config.php') || filemtime(RUNTIME_PATH . '~app.php') > filemtime(CONFIG_PATH . 'config.php'))) {
         // 直接读取编译后的项目文件
         C(include RUNTIME_PATH . '~app.php');
     } else {
         // 预编译项目
         App::build();
     }
     //[/RUNTIME]
     // 项目开始标签
     if (C('APP_PLUGIN_ON')) {
         tag('app_begin');
     }
     // 设置系统时区 PHP5支持
     if (function_exists('date_default_timezone_set')) {
         date_default_timezone_set(C('DEFAULT_TIMEZONE'));
     }
     // 允许注册AUTOLOAD方法
     if (C('APP_AUTOLOAD_REG') && function_exists('spl_autoload_register')) {
         spl_autoload_register(array('Think', 'autoload'));
     }
     if (C('SESSION_AUTO_START')) {
         session_start();
     }
     // Session初始化
     // 应用调度过滤器
     // 如果没有加载任何URL调度器
     // 默认只支持 QUERY_STRING 方式
     if (C('URL_DISPATCH_ON')) {
         Dispatcher::dispatch();
     }
     if (!defined('PHP_FILE')) {
         // PHP_FILE 由内置的Dispacher定义
         // 如果不使用该插件,需要重新定义
         define('PHP_FILE', _PHP_FILE_);
     }
     // 取得模块和操作名称
     // 可以在Dispatcher中定义获取规则
     // 加载项目分组公共文件
     if (C('APP_GROUP_LIST')) {
         if (!defined('GROUP_NAME')) {
             define('GROUP_NAME', App::getGroup());
         }
         // Group名称
         // 分组配置文件
         if (is_file(CONFIG_PATH . GROUP_NAME . '/config.php')) {
             C(include CONFIG_PATH . GROUP_NAME . '/config.php');
         }
         // 分组函数文件
         if (is_file(COMMON_PATH . GROUP_NAME . '/function.php')) {
             include COMMON_PATH . GROUP_NAME . '/function.php';
         }
     }
     if (!defined('MODULE_NAME')) {
         define('MODULE_NAME', App::getModule());
     }
     // Module名称
     if (!defined('ACTION_NAME')) {
         define('ACTION_NAME', App::getAction());
     }
     // Action操作
     // 加载模块配置文件
     if (is_file(CONFIG_PATH . strtolower(MODULE_NAME) . '_config.php')) {
         C(include CONFIG_PATH . strtolower(MODULE_NAME) . '_config.php');
     }
     // 系统检查
     App::checkLanguage();
     //语言检查
     App::checkTemplate();
     //模板检查
     if (C('HTML_CACHE_ON')) {
         // 开启静态缓存
         HtmlCache::readHTMLCache();
     }
     // 项目初始化标签
     if (C('APP_PLUGIN_ON')) {
         tag('app_init');
     }
     return;
 }
示例#16
0
 /**
 +----------------------------------------------------------
 * 输出模板
 +----------------------------------------------------------
 * @access protected
 +----------------------------------------------------------
 * @param string $content 模板内容
 * @param boolean $display 是否直接显示
 +----------------------------------------------------------
 * @return mixed
 +----------------------------------------------------------
 */
 protected function output($content, $display)
 {
     if (C('HTML_CACHE_ON')) {
         HtmlCache::writeHTMLCache($content);
     }
     if ($display) {
         if (false !== strpos($content, '{__RUNTIME__}')) {
             $runtime = C('SHOW_RUN_TIME') ? '<div  id="think_run_time" class="think_run_time">' . $this->showTime() . '</div>' : '';
             $content = str_replace('{__RUNTIME__}', $runtime, $content);
         }
         echo $content;
         if (C('SHOW_PAGE_TRACE')) {
             $this->showTrace();
         }
         return null;
     } else {
         return $content;
     }
 }
示例#17
0
 /**
 +----------------------------------------------------------
 * 加载模板和页面输出
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @param string $templateFile 模板文件名 留空为自动获取
 * @param string $charset 模板输出字符集
 * @param string $contentType 输出类型
 * @param string $varPrefix 模板变量前缀
 * @param integer $mode 0 返回 1 输出 2 下载
 +----------------------------------------------------------
 * @throws ThinkExecption
 +----------------------------------------------------------
 */
 public function fetch($templateFile = '', $charset = '', $contentType = 'text/html', $varPrefix = '', $display = false)
 {
     $startTime = microtime(TRUE);
     if (null === $templateFile) {
         // 使用null参数作为模版名直接返回不做任何输出
         return;
     }
     if ('layout::' == substr($templateFile, 0, 8)) {
         $this->layout(substr($templateFile, 8));
         return;
     }
     if (empty($charset)) {
         $charset = C('OUTPUT_CHARSET');
     }
     // 网页字符编码
     header("Content-Type:" . $contentType . "; charset=" . $charset);
     header("Cache-control: private");
     //支持页面回跳
     // 设置输出缓存
     ini_set('output_buffering', 4096);
     $zlibCompress = ini_get('zlib.output_compression');
     if (empty($zlibCompress) && function_exists('ini_set')) {
         ini_set('zlib.output_compression', 1);
     }
     $pluginOn = C('THINK_PLUGIN_ON');
     if ($pluginOn) {
         // 缓存初始化过滤
         apply_filter('ob_init');
     }
     //页面缓存
     ob_start();
     ob_implicit_flush(0);
     if ($pluginOn) {
         // 缓存开启后执行的过滤
         apply_filter('ob_start');
         // 模版文件名过滤
         $templateFile = apply_filter('template_file', $templateFile);
     }
     if ('' == $templateFile) {
         // 如果模板文件名为空 按照默认规则定位
         $templateFile = C('TMPL_FILE_NAME');
     } elseif (strpos($templateFile, '@')) {
         // 引入其它主题的操作模板 必须带上模块名称 例如 blue@User:add
         $templateFile = TMPL_PATH . str_replace(array('@', ':'), '/', $templateFile) . C('TEMPLATE_SUFFIX');
     } elseif (strpos($templateFile, ':')) {
         // 引入其它模块的操作模板
         $templateFile = TEMPLATE_PATH . '/' . str_replace(':', '/', $templateFile) . C('TEMPLATE_SUFFIX');
     } elseif (!file_exists($templateFile)) {
         // 引入当前模块的其它操作模板
         $templateFile = dirname(C('TMPL_FILE_NAME')) . '/' . $templateFile . C('TEMPLATE_SUFFIX');
     }
     if (!file_exists_case($templateFile)) {
         throw_exception(L('_TEMPLATE_NOT_EXIST_') . '[' . $templateFile . ']');
     }
     if ($pluginOn) {
         // 模版变量过滤
         $this->tVar = apply_filter('template_var', $this->tVar);
     }
     $compiler = false;
     //根据不同模版引擎进行处理
     if ('PHP' == $this->type || empty($this->type)) {
         // 模板阵列变量分解成为独立变量
         extract($this->tVar, empty($varPrefix) ? EXTR_OVERWRITE : EXTR_PREFIX_ALL, $varPrefix);
         // 默认使用PHP模版
         include $templateFile;
     } elseif ('THINK' == $this->type) {
         // 使用内置的ThinkTemplate模板引擎
         if (!$this->checkCache($templateFile)) {
             // 缓存无效 重新编译
             $compiler = true;
             import('Think.Template.ThinkTemplate');
             $tpl = ThinkTemplate::getInstance();
             // 编译并加载模板文件
             $tpl->load($templateFile, $charset, $this->tVar, $varPrefix);
         } else {
             // 缓存有效 直接载入模板缓存
             // 模板阵列变量分解成为独立变量
             extract($this->tVar, empty($varPrefix) ? EXTR_OVERWRITE : EXTR_PREFIX_ALL, $varPrefix);
             //载入模版缓存文件
             include CACHE_PATH . md5($templateFile) . C('CACHFILE_SUFFIX');
         }
     } elseif ($pluginOn) {
         // 通过插件的方式扩展第三方模板引擎
         use_compiler(C('TMPL_ENGINE_TYPE'), $templateFile, $this->tVar, $charset, $varPrefix);
     }
     // 获取并清空缓存
     $content = ob_get_clean();
     // 输出编码转换
     $content = auto_charset($content, C('TEMPLATE_CHARSET'), $charset);
     if ($pluginOn) {
         // 输出过滤
         $content = apply_filter('ob_content', $content);
     }
     if (C('HTML_CACHE_ON')) {
         // 写入静态文件
         HtmlCache::writeHTMLCache($content);
     }
     if ($display) {
         $showTime = $this->showTime($startTime);
         echo $content;
         if (C('SHOW_RUN_TIME')) {
             echo '<div  id="think_run_time" class="think_run_time">' . $showTime . '</div>';
         }
         $this->showTrace($showTime, $charset, $compiler);
         return null;
     } else {
         return $content;
     }
 }