/** * 发送数据到客户端 * @access public * @return mixed * @throws \InvalidArgumentException */ public function send() { // 处理输出数据 $data = $this->getContent(); // Trace调试注入 if (Env::get('app_trace', Config::get('app_trace'))) { Debug::inject($this, $data); } if (!headers_sent() && !empty($this->header)) { // 发送状态码 http_response_code($this->code); // 发送头部信息 foreach ($this->header as $name => $val) { header($name . ':' . $val); } } echo $data; if (function_exists('fastcgi_finish_request')) { // 提高页面响应 fastcgi_finish_request(); } }
/** * 发送数据到客户端 * @access public * @return mixed * @throws \InvalidArgumentException */ public function send() { // 处理输出数据 $data = $this->getContent(); // Trace调试注入 if (Env::get('app_trace', Config::get('app_trace'))) { Debug::inject($this, $data); } if (!headers_sent() && !empty($this->header)) { // 发送状态码 http_response_code($this->code); // 发送头部信息 foreach ($this->header as $name => $val) { header($name . ':' . $val); } } if (200 == $this->code) { $cache = Request::instance()->getCache(); if ($cache) { header('Cache-Control: max-age=' . $cache[1] . ',must-revalidate'); header('Last-Modified:' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Expires:' . gmdate('D, d M Y H:i:s', $_SERVER['REQUEST_TIME'] + $cache[1]) . ' GMT'); $header['Content-Type'] = $this->header['Content-Type']; Cache::set($cache[0], [$data, $header], $cache[1]); } } echo $data; if (function_exists('fastcgi_finish_request')) { // 提高页面响应 fastcgi_finish_request(); } // 监听response_end Hook::listen('response_end', $this); }
/** * 发送数据到客户端 * @access public * @return mixed * @throws \InvalidArgumentException */ public function send() { // 处理输出数据 $data = $this->getContent(); // Trace调试注入 if (Env::get('app_trace', Config::get('app_trace'))) { Debug::inject($this, $data); } if (!headers_sent() && !empty($this->header)) { // 发送状态码 http_response_code($this->code); // 发送头部信息 foreach ($this->header as $name => $val) { header($name . ':' . $val); } } echo $data; if (200 == $this->code) { $cache = Request::instance()->getCache(); if ($cache) { Cache::set($cache[0], $data, $cache[1]); Cache::set($cache[0] . '_header', $this->header['Content-Type']); } } if (function_exists('fastcgi_finish_request')) { // 提高页面响应 fastcgi_finish_request(); } // 监听response_end Hook::listen('response_end', $this); }
/** * 初始化应用 */ public static function initCommon() { if (empty(self::$init)) { // 初始化应用 $config = self::init(); self::$suffix = $config['class_suffix']; // 应用调试模式 self::$debug = Env::get('app_debug', Config::get('app_debug')); if (!self::$debug) { ini_set('display_errors', 'Off'); } elseif (!IS_CLI) { //重新申请一块比较大的buffer if (ob_get_level() > 0) { $output = ob_get_clean(); } ob_start(); if (!empty($output)) { echo $output; } } // 注册应用命名空间 self::$namespace = $config['app_namespace']; Loader::addNamespace($config['app_namespace'], APP_PATH); if (!empty($config['root_namespace'])) { Loader::addNamespace($config['root_namespace']); } // 加载额外文件 if (!empty($config['extra_file_list'])) { foreach ($config['extra_file_list'] as $file) { $file = strpos($file, '.') ? $file : APP_PATH . $file . EXT; if (is_file($file) && !isset(self::$file[$file])) { include $file; self::$file[$file] = true; } } } // 设置系统时区 date_default_timezone_set($config['default_timezone']); // 监听app_init Hook::listen('app_init'); self::$init = $config; } return self::$init; }
<?php // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- // | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st <*****@*****.**> // +---------------------------------------------------------------------- use think\Env; return ['template' => ['type' => 'Think', 'view_path' => '', 'strip_space' => false, 'view_suffix' => 'html', 'view_depr' => DS, 'tpl_begin' => '{', 'tpl_end' => '}', 'taglib_begin' => '{', 'taglib_end' => '}'], 'view_replace_str' => ['__JS__' => '/static/acp/js', '__CSS__' => '/static/acp/css', '__IMG__' => '/static/acp/images', '__PLG__' => '/static/plugins', '__ACE__' => '/static/ace', '__VERSION__' => 'version=' . Env::get('static_version')], 'dispatch_success_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl', 'dispatch_error_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl', 'exception_tmpl' => THINK_PATH . 'tpl' . DS . 'think_exception.tpl', 'error_message' => '页面错误!请稍后再试~', 'show_error_msg' => false, 'trace' => ['type' => 'Html'], 'session' => ['id' => '', 'var_session_id' => '', 'prefix' => 'think', 'type' => '', 'auto_start' => true], 'cookie' => ['prefix' => '', 'expire' => 0, 'path' => '/', 'domain' => '', 'secure' => false, 'httponly' => '', 'setcookie' => true], 'paginate' => ['type' => 'bootstrap', 'var_page' => 'page', 'list_rows' => 15]];