diff --git a/admin/common.php b/admin/common.php index 597209c4..b18173bb 100644 --- a/admin/common.php +++ b/admin/common.php @@ -34,7 +34,6 @@ if (!empty($currentMenu)) { $adminFile = basename($params['path']); if (!$user->logged && !\Typecho\Cookie::get('__typecho_first_run')) { - if ('welcome.php' != $adminFile) { $response->redirect(\Typecho\Common::url('welcome.php', $options->adminUrl)); } else { diff --git a/admin/manage-comments.php b/admin/manage-comments.php index 65015084..a8c70250 100644 --- a/admin/manage-comments.php +++ b/admin/manage-comments.php @@ -112,7 +112,7 @@ $isAllComments = ('on' == $request->get('__typecho_all_comments') || 'on' == \Ty 'text' => $comments->text ); - echo htmlspecialchars(Json::encode($comment)); + echo htmlspecialchars(json_encode($comment)); ?>"> diff --git a/admin/write-js.php b/admin/write-js.php index adee5dc8..e072e3bb 100644 --- a/admin/write-js.php +++ b/admin/write-js.php @@ -67,7 +67,7 @@ $(document).ready(function() { 'tags' => $tags->name ); } - echo Json::encode($data); + echo json_encode($data); ?>, { propertyToSearch: 'tags', tokenValue : 'tags', diff --git a/install.php b/install.php index 6a50bfd4..c46bcd73 100644 --- a/install.php +++ b/install.php @@ -74,7 +74,7 @@ function install_get_site_url(): string */ function install_is_cli(): bool { - return php_sapi_name() == 'cli'; + return \Typecho\Request::getInstance()->isCli(); } /** @@ -92,7 +92,7 @@ function install_get_default_options(): array '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' => _t('UTF-8'), + 'charset' => 'UTF-8', 'contentType' => 'text/html', 'gzip' => 0, 'generator' => 'Typecho ' . \Typecho\Common::VERSION, @@ -341,7 +341,7 @@ function install_raise_error($error, $config = null) exit(1); } else { - \Typecho\Response::getInstance()->throwJson([ + install_throw_json([ 'success' => 0, 'message' => is_string($error) ? nl2br($error) : $error, 'config' => $config @@ -370,7 +370,7 @@ function install_success($step, ?array $config = null) exit(0); } else { - \Typecho\Response::getInstance()->throwJson([ + install_throw_json([ 'success' => 1, 'message' => $step, 'config' => $config @@ -378,6 +378,28 @@ function install_success($step, ?array $config = null) } } +/** + * @param $data + */ +function install_throw_json($data) +{ + \Typecho\Response::getInstance()->setContentType('application/json') + ->addResponder(function () use ($data) { + echo json_encode($data); + }) + ->respond(); +} + +/** + * @param string $url + */ +function install_redirect(string $url) +{ + \Typecho\Response::getInstance()->setStatus(302) + ->setHeader('Location', $url) + ->respond(); +} + /** * add common js support * @@ -493,6 +515,22 @@ function install_js_support()
-
+

@@ -520,7 +558,7 @@ function install_step_1()

- + 1) : ?>