'\Typecho\Plugin\PluginInterface', 'Typecho_Widget_Helper_Empty' => '\Typecho\Widget\Helper\EmptyClass', 'Widget_Abstract' => '\Widget\Base', 'Widget_Abstract_Contents' => '\Widget\Base\Contents', 'Widget_Abstract_Comments' => '\Widget\Base\Comments', 'Widget_Abstract_Metas' => '\Widget\Base\Metas', 'Widget_Abstract_Options' => '\Widget\Base\Options', 'Widget_Abstract_Users' => '\Widget\Base\Users', 'Widget_Metas_Category_List' => '\Widget\Metas\Category\Rows', 'Widget_Contents_Page_List' => '\Widget\Contents\Page\Rows', 'Widget_Plugins_List' => '\Widget\Plugins\Rows', 'Widget_Themes_List' => '\Widget\Themes\Rows', 'Widget_Interface_Do' => '\Widget\ActionInterface', 'Widget_Do' => '\Widget\Action', ]); /** 对变量赋值 */ $options = Options::alloc(); /** 检查安装状态 */ if (!defined('__TYPECHO_INSTALL__') && !$options->installed) { $options->update(['value' => 1], Db::get()->sql()->where('name = ?', 'installed')); } /** 语言包初始化 */ if ($options->lang && $options->lang != 'zh_CN') { $dir = defined('__TYPECHO_LANG_DIR__') ? __TYPECHO_LANG_DIR__ : __TYPECHO_ROOT_DIR__ . '/usr/langs'; I18n::setLang($dir . '/' . $options->lang . '.mo'); } /** 备份文件目录初始化 */ if (!defined('__TYPECHO_BACKUP_DIR__')) { define('__TYPECHO_BACKUP_DIR__', __TYPECHO_ROOT_DIR__ . '/usr/backups'); } /** cookie初始化 */ Cookie::setPrefix($options->rootUrl); /** 初始化exception */ if (!defined('__TYPECHO_DEBUG__') || !__TYPECHO_DEBUG__) { set_exception_handler(function (\Throwable $exception) { Response::getInstance()->clean(); ob_end_clean(); ob_start(function ($content) { Response::getInstance()->sendHeaders(); return $content; }); if (404 == $exception->getCode()) { new ExceptionHandle($exception); } else { Common::error($exception); } exit; }); } /** 初始化路由器 */ Router::setRoutes($options->routingTable); /** 初始化插件 */ Plugin::init($options->plugins); /** 初始化回执 */ $this->response->setCharset($options->charset); $this->response->setContentType($options->contentType); /** 初始化时区 */ Date::setTimezoneOffset($options->timezone); /** 开始会话, 减小负载只针对后台打开session支持 */ if (!defined('__TYPECHO_INSTALL__') && User::alloc()->hasLogin()) { @session_start(); } } }