diff --git a/admin/css/install.css b/admin/css/install.css index 9de7538c..9d6e1f39 100644 --- a/admin/css/install.css +++ b/admin/css/install.css @@ -9,13 +9,15 @@ details summary { cursor: pointer; } .keep .fresh-word { display: none; } -form > .message { display: none; } +form > .message { display: none; padding: 20px; border-radius: 5px; } + +.message textarea { width: 100%; height: 200px; resize: none; margin: 10px 0; } .message.fade { display: block; animation: fadein .5s linear; } .message *:last-child { margin-bottom: 0; } -.message p { margin-top: 8px; } +.message p { margin-top: 10px; } .message p button { margin-left: 5px; } diff --git a/admin/src/scss/install.scss b/admin/src/scss/install.scss index 8e309c59..4dae66f3 100644 --- a/admin/src/scss/install.scss +++ b/admin/src/scss/install.scss @@ -26,8 +26,18 @@ details { } .message { + form > & { display: none; + padding: 20px; + border-radius: 5px; + } + + textarea { + width: 100%; + height: 200px; + resize: none; + margin: 10px 0; } &.fade { @@ -40,7 +50,7 @@ details { } p { - margin-top: 8px; + margin-top: 10px; button { margin-left: 5px; diff --git a/install.php b/install.php index 1e2e8f6d..5bccb9c6 100644 --- a/install.php +++ b/install.php @@ -62,7 +62,10 @@ function install_get_lang(): string { * @return string */ function install_get_site_url(): string { - $serverSiteUrl = Typecho_Request::getInstance()->getServer('TYPECHO_SITE_URL'); + $serverSiteUrl = Typecho_Request::getInstance()->getServer( + 'TYPECHO_SITE_URL', + install_is_cli() ? 'http://localhost' : null + ); if (!empty($serverSiteUrl)) { return $serverSiteUrl; @@ -87,69 +90,75 @@ function install_is_cli(): bool { * @return array */ function install_get_default_options(): array { - return [ - 'theme' => 'default', - 'theme:default' => 'a:2:{s:7:"logoUrl";N;s:12:"sidebarBlock";a:5:{i:0;s:15:"ShowRecentPosts";i:1;s:18:"ShowRecentComments";i:2;s:12:"ShowCategory";i:3;s:11:"ShowArchive";i:4;s:9:"ShowOther";}}', - 'timezone' => '28800', - 'lang' => install_get_lang(), - 'charset' => _('UTF-8'), - 'contentType' => 'text/html', - 'gzip' => 0, - 'generator' => 'Typecho ' . Typecho_Common::VERSION, - 'title' => 'Hello World', - 'description' => 'Your description here.', - 'keywords' => 'typecho,php,blog', - 'rewrite' => 0, - 'frontPage' => 'recent', - 'frontArchive' => 0, - 'commentsRequireMail' => 1, - 'commentsWhitelist' => 0, - 'commentsRequireURL' => 0, - 'commentsRequireModeration' => 0, - 'plugins' => 'a:0:{}', - 'commentDateFormat' => 'F jS, Y \a\t h:i a', - 'siteUrl' => install_is_cli() ? 'http://localhost' : install_get_site_url(), - 'defaultCategory' => 1, - 'allowRegister' => 0, - 'defaultAllowComment' => 1, - 'defaultAllowPing' => 1, - 'defaultAllowFeed' => 1, - 'pageSize' => 5, - 'postsListSize' => 10, - 'commentsListSize' => 10, - 'commentsHTMLTagAllowed' => null, - 'postDateFormat' => 'Y-m-d', - 'feedFullText' => 1, - 'editorSize' => 350, - 'autoSave' => 0, - 'markdown' => 1, - 'xmlrpcMarkdown' => 0, - 'commentsMaxNestingLevels' => 5, - 'commentsPostTimeout' => 24 * 3600 * 30, - 'commentsUrlNofollow' => 1, - 'commentsShowUrl' => 1, - 'commentsMarkdown' => 0, - 'commentsPageBreak' => 0, - 'commentsThreaded' => 1, - 'commentsPageSize' => 20, - 'commentsPageDisplay' => 'last', - 'commentsOrder' => 'ASC', - 'commentsCheckReferer' => 1, - 'commentsAutoClose' => 0, - 'commentsPostIntervalEnable' => 1, - 'commentsPostInterval' => 60, - 'commentsShowCommentOnly' => 0, - 'commentsAvatar' => 1, - 'commentsAvatarRating' => 'G', - 'commentsAntiSpam' => 1, - 'routingTable' => 'a:25:{s:5:"index";a:3:{s:3:"url";s:1:"/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:7:"archive";a:3:{s:3:"url";s:6:"/blog/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:2:"do";a:3:{s:3:"url";s:22:"/action/[action:alpha]";s:6:"widget";s:9:"Widget_Do";s:6:"action";s:6:"action";}s:4:"post";a:3:{s:3:"url";s:24:"/archives/[cid:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:10:"attachment";a:3:{s:3:"url";s:26:"/attachment/[cid:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:8:"category";a:3:{s:3:"url";s:17:"/category/[slug]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:3:"tag";a:3:{s:3:"url";s:12:"/tag/[slug]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:6:"author";a:3:{s:3:"url";s:22:"/author/[uid:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:6:"search";a:3:{s:3:"url";s:19:"/search/[keywords]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:10:"index_page";a:3:{s:3:"url";s:21:"/page/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:12:"archive_page";a:3:{s:3:"url";s:26:"/blog/page/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:13:"category_page";a:3:{s:3:"url";s:32:"/category/[slug]/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:8:"tag_page";a:3:{s:3:"url";s:27:"/tag/[slug]/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:11:"author_page";a:3:{s:3:"url";s:37:"/author/[uid:digital]/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:11:"search_page";a:3:{s:3:"url";s:34:"/search/[keywords]/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:12:"archive_year";a:3:{s:3:"url";s:18:"/[year:digital:4]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:13:"archive_month";a:3:{s:3:"url";s:36:"/[year:digital:4]/[month:digital:2]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:11:"archive_day";a:3:{s:3:"url";s:52:"/[year:digital:4]/[month:digital:2]/[day:digital:2]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:17:"archive_year_page";a:3:{s:3:"url";s:38:"/[year:digital:4]/page/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:18:"archive_month_page";a:3:{s:3:"url";s:56:"/[year:digital:4]/[month:digital:2]/page/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:16:"archive_day_page";a:3:{s:3:"url";s:72:"/[year:digital:4]/[month:digital:2]/[day:digital:2]/page/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:12:"comment_page";a:3:{s:3:"url";s:53:"[permalink:string]/comment-page-[commentPage:digital]";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:4:"feed";a:3:{s:3:"url";s:20:"/feed[feed:string:0]";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:4:"feed";}s:8:"feedback";a:3:{s:3:"url";s:31:"[permalink:string]/[type:alpha]";s:6:"widget";s:15:"Widget_Feedback";s:6:"action";s:6:"action";}s:4:"page";a:3:{s:3:"url";s:12:"/[slug].html";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}}', - 'actionTable' => 'a:0:{}', - 'panelTable' => 'a:0:{}', - 'attachmentTypes' => '@image@', - 'secret' => Typecho_Common::randString(32, true), - 'installed' => 0, - 'allowXmlRpc' => 2 - ]; + static $options; + + if (empty($options)) { + $options = [ + 'theme' => 'default', + 'theme:default' => 'a:2:{s:7:"logoUrl";N;s:12:"sidebarBlock";a:5:{i:0;s:15:"ShowRecentPosts";i:1;s:18:"ShowRecentComments";i:2;s:12:"ShowCategory";i:3;s:11:"ShowArchive";i:4;s:9:"ShowOther";}}', + 'timezone' => '28800', + 'lang' => install_get_lang(), + 'charset' => _('UTF-8'), + 'contentType' => 'text/html', + 'gzip' => 0, + 'generator' => 'Typecho ' . Typecho_Common::VERSION, + 'title' => 'Hello World', + 'description' => 'Your description here.', + 'keywords' => 'typecho,php,blog', + 'rewrite' => 0, + 'frontPage' => 'recent', + 'frontArchive' => 0, + 'commentsRequireMail' => 1, + 'commentsWhitelist' => 0, + 'commentsRequireURL' => 0, + 'commentsRequireModeration' => 0, + 'plugins' => 'a:0:{}', + 'commentDateFormat' => 'F jS, Y \a\t h:i a', + 'siteUrl' => install_get_site_url(), + 'defaultCategory' => 1, + 'allowRegister' => 0, + 'defaultAllowComment' => 1, + 'defaultAllowPing' => 1, + 'defaultAllowFeed' => 1, + 'pageSize' => 5, + 'postsListSize' => 10, + 'commentsListSize' => 10, + 'commentsHTMLTagAllowed' => null, + 'postDateFormat' => 'Y-m-d', + 'feedFullText' => 1, + 'editorSize' => 350, + 'autoSave' => 0, + 'markdown' => 1, + 'xmlrpcMarkdown' => 0, + 'commentsMaxNestingLevels' => 5, + 'commentsPostTimeout' => 24 * 3600 * 30, + 'commentsUrlNofollow' => 1, + 'commentsShowUrl' => 1, + 'commentsMarkdown' => 0, + 'commentsPageBreak' => 0, + 'commentsThreaded' => 1, + 'commentsPageSize' => 20, + 'commentsPageDisplay' => 'last', + 'commentsOrder' => 'ASC', + 'commentsCheckReferer' => 1, + 'commentsAutoClose' => 0, + 'commentsPostIntervalEnable' => 1, + 'commentsPostInterval' => 60, + 'commentsShowCommentOnly' => 0, + 'commentsAvatar' => 1, + 'commentsAvatarRating' => 'G', + 'commentsAntiSpam' => 1, + 'routingTable' => 'a:25:{s:5:"index";a:3:{s:3:"url";s:1:"/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:7:"archive";a:3:{s:3:"url";s:6:"/blog/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:2:"do";a:3:{s:3:"url";s:22:"/action/[action:alpha]";s:6:"widget";s:9:"Widget_Do";s:6:"action";s:6:"action";}s:4:"post";a:3:{s:3:"url";s:24:"/archives/[cid:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:10:"attachment";a:3:{s:3:"url";s:26:"/attachment/[cid:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:8:"category";a:3:{s:3:"url";s:17:"/category/[slug]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:3:"tag";a:3:{s:3:"url";s:12:"/tag/[slug]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:6:"author";a:3:{s:3:"url";s:22:"/author/[uid:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:6:"search";a:3:{s:3:"url";s:19:"/search/[keywords]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:10:"index_page";a:3:{s:3:"url";s:21:"/page/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:12:"archive_page";a:3:{s:3:"url";s:26:"/blog/page/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:13:"category_page";a:3:{s:3:"url";s:32:"/category/[slug]/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:8:"tag_page";a:3:{s:3:"url";s:27:"/tag/[slug]/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:11:"author_page";a:3:{s:3:"url";s:37:"/author/[uid:digital]/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:11:"search_page";a:3:{s:3:"url";s:34:"/search/[keywords]/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:12:"archive_year";a:3:{s:3:"url";s:18:"/[year:digital:4]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:13:"archive_month";a:3:{s:3:"url";s:36:"/[year:digital:4]/[month:digital:2]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:11:"archive_day";a:3:{s:3:"url";s:52:"/[year:digital:4]/[month:digital:2]/[day:digital:2]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:17:"archive_year_page";a:3:{s:3:"url";s:38:"/[year:digital:4]/page/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:18:"archive_month_page";a:3:{s:3:"url";s:56:"/[year:digital:4]/[month:digital:2]/page/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:16:"archive_day_page";a:3:{s:3:"url";s:72:"/[year:digital:4]/[month:digital:2]/[day:digital:2]/page/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:12:"comment_page";a:3:{s:3:"url";s:53:"[permalink:string]/comment-page-[commentPage:digital]";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:4:"feed";a:3:{s:3:"url";s:20:"/feed[feed:string:0]";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:4:"feed";}s:8:"feedback";a:3:{s:3:"url";s:31:"[permalink:string]/[type:alpha]";s:6:"widget";s:15:"Widget_Feedback";s:6:"action";s:6:"action";}s:4:"page";a:3:{s:3:"url";s:12:"/[slug].html";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}}', + 'actionTable' => 'a:0:{}', + 'panelTable' => 'a:0:{}', + 'attachmentTypes' => '@image@', + 'secret' => Typecho_Common::randString(32, true), + 'installed' => 0, + 'allowXmlRpc' => 2 + ]; + } + + return $options; } /** @@ -226,9 +235,10 @@ function install_get_current_db_driver(): string { * @param string $adapter * @param string $dbPrefix * @param array $dbConfig + * @param bool $return * @return string */ -function install_config_file(string $adapter, string $dbPrefix, array $dbConfig): string { +function install_config_file(string $adapter, string $dbPrefix, array $dbConfig, bool $return = false): string { global $configWritten; $lines = array_slice(file(__FILE__), 1, 26); @@ -240,7 +250,12 @@ Typecho_Db::set(\$db); "; $code = implode('', $lines); - $configWritten = @file_put_contents(__TYPECHO_ROOT_DIR__ . '/config.inc.php', $code) !== false; + $configWritten = false; + + if (!$return) { + $configWritten = @file_put_contents(__TYPECHO_ROOT_DIR__ . '/config.inc.php', $code) !== false; + } + return $code; } @@ -346,11 +361,11 @@ function install_success($step, ?array $config = null) { } /** - * add ajax support + * add common js support * * @throws Typecho_Exception */ -function install_ajax_support() { +function install_js_support() { $options = Typecho_Widget::widget('Widget_Options'); ?> @@ -368,34 +383,35 @@ function install_ajax_support() { :
- -
GPL 协议发布, 我们允许用户在 GPL 协议许可的范围内使用, 拷贝, 修改和分发此程序.'); ?> -
-- -
-- - - 1): ?> - - -
-