From 22be48c30933e36d75cc9dadec7d8169bea2a094 Mon Sep 17 00:00:00 2001 From: printempw Date: Wed, 10 Aug 2016 22:22:28 +0800 Subject: [PATCH] enhance performance at installation --- app/Services/Boot.php | 4 ++-- setup/index.php | 13 +++++++++---- setup/migrations/index.php | 2 ++ setup/options.php | 5 ++--- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/app/Services/Boot.php b/app/Services/Boot.php index b3da8e8c..bd62628d 100644 --- a/app/Services/Boot.php +++ b/app/Services/Boot.php @@ -50,10 +50,10 @@ class Boot Config::checkCache(); } - public static function checkInstallation() + public static function checkInstallation($redirect_to = '../setup/index.php') { if (!Config::checkTableExist()) { - Http::redirect('../setup/index.php'); + Http::redirect($redirect_to); } if (!is_dir(BASE_DIR.'/textures/')) { diff --git a/setup/index.php b/setup/index.php index b91ef202..6f68f6e3 100644 --- a/setup/index.php +++ b/setup/index.php @@ -56,7 +56,7 @@ switch ($step) { $sitename = isset($_POST['sitename']) ? $_POST['sitename'] : "Blessing Skin Server"; if (Validate::email($email)) { - if (!Validate::password($password)) { + if (!Validate::password($password, true)) { Http::redirect('index.php?step=2', '无效的密码。密码长度应该大于 8 并小于 16。'); } else if (Utils::convertString($password) != $password) { @@ -75,9 +75,10 @@ switch ($step) { // import options $options = require "options.php"; - $options['site_name'] = $_POST['sitename']; - $options['site_url'] = Http::getBaseUrl(); - $options['version'] = App::getVersion(); + $options['site_name'] = $_POST['sitename']; + $options['site_url'] = Http::getBaseUrl(); + $options['version'] = App::getVersion(); + $options['announcement'] = str_replace('{version}', $options['version'], $options['announcement']); foreach ($options as $key => $value) { Option::add($key, $value); @@ -96,4 +97,8 @@ switch ($step) { echo View::make('setup.steps.3')->with('email', $_POST['email'])->with('password', $_POST['password']); break; + + default: + throw new App\Exceptions\E('非法参数', 1, true); + break; } diff --git a/setup/migrations/index.php b/setup/migrations/index.php index 0000c553..0ee7ee60 100644 --- a/setup/migrations/index.php +++ b/setup/migrations/index.php @@ -23,6 +23,8 @@ if (Config::checkDbConfig($db_config)) { Boot::bootEloquent($db_config); } +Boot::checkInstallation('../../setup/index.php'); + if (isset($_COOKIE['email']) && isset($_COOKIE['token'])) { $_SESSION['email'] = $_COOKIE['email']; $_SESSION['token'] = $_COOKIE['token']; diff --git a/setup/options.php b/setup/options.php index 74256cf1..c8fd9ef9 100644 --- a/setup/options.php +++ b/setup/options.php @@ -3,7 +3,7 @@ * @Author: printempw * @Date: 2016-07-29 11:53:11 * @Last Modified by: printempw - * @Last Modified time: 2016-08-08 22:41:23 + * @Last Modified time: 2016-08-10 22:11:03 */ return [ @@ -13,10 +13,9 @@ return [ 'user_can_register' => '1', 'regs_per_ip' => '3', 'api_type' => '0', - 'announcement' => '欢迎使用 Blessing Skin Server 3.0!', + 'announcement' => '欢迎使用 Blessing Skin Server {version}!', 'color_scheme' => 'skin-blue', 'home_pic_url' => './assets/images/bg.jpg', - 'current_version' => '3.0-beta', 'custom_css' => '', 'custom_js' => '', 'update_url' => 'https://work.prinzeugen.net/update.json',