From ccf6bd9a98fa1fad33ee9d1d6c66fcd2f96f1f60 Mon Sep 17 00:00:00 2001 From: gtlee Date: Fri, 14 Jun 2024 22:38:07 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=A4=B4=E5=83=8FURL?= =?UTF-8?q?=E5=9C=A8=E5=91=BD=E4=BB=A4=E8=A1=8C=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E5=AE=89=E8=A3=85=E6=97=B6=E6=97=A0=E6=B3=95=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=9F=9F=E5=90=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/command/Install.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/admin/command/Install.php b/application/admin/command/Install.php index 24e29d20..df026c77 100644 --- a/application/admin/command/Install.php +++ b/application/admin/command/Install.php @@ -244,7 +244,7 @@ class Install extends Command throw new Exception(__('The current permissions are insufficient to write the file %s', 'application/config.php')); } - $avatar = request()->domain() . '/assets/img/avatar.png'; + $avatar = '/assets/img/avatar.png'; // 变更默认管理员密码 $adminPassword = $adminPassword ? $adminPassword : Random::alnum(8); $adminEmail = $adminEmail ? $adminEmail : "admin@admin.com"; From 0fb49c1a9aa4d7f8306bb326675f3323a1a77117 Mon Sep 17 00:00:00 2001 From: ox5a0b54 Date: Thu, 1 Aug 2024 15:38:42 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E9=87=8D=E6=9E=84=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E5=AE=89=E8=A3=85=E7=9A=84=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/command/Install.php | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/application/admin/command/Install.php b/application/admin/command/Install.php index 8b37c903..f87f4b94 100644 --- a/application/admin/command/Install.php +++ b/application/admin/command/Install.php @@ -214,22 +214,28 @@ class Install extends Command $adminFile = ROOT_PATH . 'public' . DS . 'admin.php'; // 数据库配置文件 - $dbConfigFile = APP_PATH . 'database.php'; - $dbConfigText = @file_get_contents($dbConfigFile); + // 数据库配置文件 + $envSampleFile = ROOT_PATH . '.env.sample'; + $envFile = ROOT_PATH . '.env'; + if (!file_exists($envFile)) { + if (!copy($envSampleFile, $envFile)) { + throw new Exception(__('Failed to copy %s to %s', '.env.sample', '.env')); + } + } + + $envText = @file_get_contents($envFile); + $callback = function ($matches) use ($mysqlHostname, $mysqlHostport, $mysqlUsername, $mysqlPassword, $mysqlDatabase, $mysqlPrefix) { $field = "mysql" . ucfirst($matches[1]); $replace = $$field; - if ($matches[1] == 'hostport' && $mysqlHostport == 3306) { - $replace = ''; - } - return "'{$matches[1]}'{$matches[2]}=>{$matches[3]}Env::get('database.{$matches[1]}', '{$replace}'),"; + return "{$matches[1]} = {$replace}"; }; - $dbConfigText = preg_replace_callback("/'(hostname|database|username|password|hostport|prefix)'(\s+)=>(\s+)Env::get\((.*)\)\,/", $callback, $dbConfigText); + $envText = preg_replace_callback("/(hostname|database|username|password|hostport|prefix)\s*=\s*(.*)/", $callback, $envText); // 检测能否成功写入数据库配置 - $result = @file_put_contents($dbConfigFile, $dbConfigText); + $result = @file_put_contents($envFile, $envText); if (!$result) { - throw new Exception(__('The current permissions are insufficient to write the file %s', 'application/database.php')); + throw new Exception(__('The current permissions are insufficient to write the file %s', '.env')); } // 设置新的Token随机密钥key From c12e304aec1e0481f1b23d2badf32fa32c4f8281 Mon Sep 17 00:00:00 2001 From: ox5a0b54 Date: Thu, 1 Aug 2024 15:50:55 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E9=87=8D=E6=9E=84=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E5=AE=89=E8=A3=85=E7=9A=84=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/command/Install.php | 1 - 1 file changed, 1 deletion(-) diff --git a/application/admin/command/Install.php b/application/admin/command/Install.php index f87f4b94..c4330599 100644 --- a/application/admin/command/Install.php +++ b/application/admin/command/Install.php @@ -213,7 +213,6 @@ class Install extends Command // 后台入口文件 $adminFile = ROOT_PATH . 'public' . DS . 'admin.php'; - // 数据库配置文件 // 数据库配置文件 $envSampleFile = ROOT_PATH . '.env.sample'; $envFile = ROOT_PATH . '.env';