/** * 入口函数,初始化路由器 * * @access public * @return void */ public function execute() { /** 对变量赋值 */ $options = $this->widget('Widget_Options'); /** 语言包初始化 */ if ($options->lang && $options->lang != 'zh_CN') { $dir = defined('__TYPECHO_LANG_DIR__') ? __TYPECHO_LANG_DIR__ : __TYPECHO_ROOT_DIR__ . '/usr/langs'; Typecho_I18n::setLang($dir . '/' . $options->lang . '.mo'); } /** cookie初始化 */ Typecho_Cookie::setPrefix($options->rootUrl); /** 初始化charset */ Typecho_Common::$charset = $options->charset; /** 初始化exception */ Typecho_Common::$exceptionHandle = 'Widget_ExceptionHandle'; /** 设置路径 */ if (defined('__TYPECHO_PATHINFO_ENCODING__')) { $pathInfo = $this->request->getPathInfo(__TYPECHO_PATHINFO_ENCODING__, $options->charset); } else { $pathInfo = $this->request->getPathInfo(); } Typecho_Router::setPathInfo($pathInfo); /** 初始化路由器 */ Typecho_Router::setRoutes($options->routingTable); /** 初始化插件 */ Typecho_Plugin::init($options->plugins); /** 初始化回执 */ $this->response->setCharset($options->charset); $this->response->setContentType($options->contentType); /** 默认时区 */ if (function_exists("ini_get") && !ini_get("date.timezone") && function_exists("date_default_timezone_set")) { @date_default_timezone_set('UTC'); } /** 初始化时区 */ Typecho_Date::setTimezoneOffset($options->timezone); /** 开始会话, 减小负载只针对后台打开session支持 */ // modified_by_jiangmuzi 2015.09.23 // 开始会话 @session_start(); // end modified /** 监听缓冲区 */ ob_start(); }
/** 获取语言 */ $lang = _r('lang', Typecho_Cookie::get('__typecho_lang')); $langs = Widget_Options_General::getLangs(); if (empty($lang) && count($langs) > 1) { foreach ($langs as $lang) { if ('zh_CN' != $lang) { break; } } } if (empty($lang)) { $lang = 'zh_CN'; } if ('zh_CN' != $lang) { $dir = defined('__TYPECHO_LANG_DIR__') ? __TYPECHO_LANG_DIR__ : __TYPECHO_ROOT_DIR__ . '/usr/langs'; Typecho_I18n::setLang($dir . '/' . $lang . '.mo'); } Typecho_Cookie::set('__typecho_lang', $lang); ?> <!DOCTYPE HTML> <html xmlns="http://www.w3.org/1999/xhtml"> <head lang="zh-CN"> <meta charset="<?php _e('UTF-8'); ?> " /> <title><?php _e('Typecho 安装程序'); ?> </title> <link rel="stylesheet" type="text/css" href="admin/css/normalize.css" />