From 3c5d927182079a078162d2ff4bcdd70575fcd7b7 Mon Sep 17 00:00:00 2001 From: Chihiro Adachi <8196725+chihiro-adachi@users.noreply.github.com> Date: Mon, 12 Apr 2021 17:13:29 +0900 Subject: [PATCH 1/5] =?UTF-8?q?=E3=83=97=E3=83=A9=E3=82=B0=E3=82=A4?= =?UTF-8?q?=E3=83=B3=E3=81=8B=E3=82=89=E3=81=AE=E3=83=9E=E3=82=A4=E3=82=B0?= =?UTF-8?q?=E3=83=AC=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Version20210412073123.php | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 app/DoctrineMigrations/Version20210412073123.php diff --git a/app/DoctrineMigrations/Version20210412073123.php b/app/DoctrineMigrations/Version20210412073123.php new file mode 100644 index 00000000000..0fe07c6cb3a --- /dev/null +++ b/app/DoctrineMigrations/Version20210412073123.php @@ -0,0 +1,75 @@ +hasTable('plg_admin_record_config')) { + $denyHosts = array_merge( + env('ECCUBE_ADMIN_DENY_HOSTS', []), + $this->connection->fetchArray('select admin_deny_hosts FROM plg_admin_record_config') ?: [] + ); + + $denyHosts = \json_encode($denyHosts); + + $envFile = __DIR__.'/../../.env'; + $env = file_get_contents($envFile); + + $env = StringUtil::replaceOrAddEnv($env, [ + 'ECCUBE_ADMIN_DENY_HOSTS' => "'{$denyHosts}'", + ]); + + file_put_contents($envFile, $env); + } + + if ($schema->hasTable('plg_admin_record')) { + $stmt = $this->connection->createQueryBuilder() + ->select('*') + ->from('plg_admin_record') + ->orderBy('id', 'ASC') + ->execute(); + + while ($row = $stmt->fetch()) { + $this->addSql( + "INSERT INTO dtb_login_history (user_name, client_ip, create_date, update_date, login_history_status_id, member_id, discriminator_type) VALUES (?, ?, ?, ?, ?, ?, 'loginhistory')", + [ + $row['user_name'], + $row['client_ip'], + $row['create_date'], + $row['update_date'], + $row['success_flg'] ? LoginHistoryStatus::SUCCESS : LoginHistoryStatus::FAILURE, + $row['member_id'], + ] + ); + } + } + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + } +} From d2f7f495ed30ce711babddf7386eff6283c1b223 Mon Sep 17 00:00:00 2001 From: Chihiro Adachi <8196725+chihiro-adachi@users.noreply.github.com> Date: Thu, 15 Apr 2021 10:47:02 +0900 Subject: [PATCH 2/5] =?UTF-8?q?json=E3=81=AE{}=E3=81=A8=E8=A6=8B=E9=96=93?= =?UTF-8?q?=E9=81=95=E3=81=86=E3=81=AE=E3=81=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/DoctrineMigrations/Version20210412073123.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/DoctrineMigrations/Version20210412073123.php b/app/DoctrineMigrations/Version20210412073123.php index 0fe07c6cb3a..4a53fcf8797 100644 --- a/app/DoctrineMigrations/Version20210412073123.php +++ b/app/DoctrineMigrations/Version20210412073123.php @@ -39,7 +39,7 @@ public function up(Schema $schema): void $env = file_get_contents($envFile); $env = StringUtil::replaceOrAddEnv($env, [ - 'ECCUBE_ADMIN_DENY_HOSTS' => "'{$denyHosts}'", + 'ECCUBE_ADMIN_DENY_HOSTS' => "'${denyHosts}'", ]); file_put_contents($envFile, $env); From ac5b9b200868f6e48233e7c56e5a5dba2365daac Mon Sep 17 00:00:00 2001 From: Chihiro Adachi <8196725+chihiro-adachi@users.noreply.github.com> Date: Thu, 15 Apr 2021 10:47:17 +0900 Subject: [PATCH 3/5] =?UTF-8?q?down=E3=82=92=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/DoctrineMigrations/Version20210412073123.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/DoctrineMigrations/Version20210412073123.php b/app/DoctrineMigrations/Version20210412073123.php index 4a53fcf8797..6215d964cf3 100644 --- a/app/DoctrineMigrations/Version20210412073123.php +++ b/app/DoctrineMigrations/Version20210412073123.php @@ -70,6 +70,8 @@ public function up(Schema $schema): void public function down(Schema $schema): void { - // this down() migration is auto-generated, please modify it to your needs + if ($schema->hasTable('dtb_login_history')) { + $this->addSql('DROP TABLE dtb_login_history'); + } } } From 000f63768749687252578913ad4fae4204f384e6 Mon Sep 17 00:00:00 2001 From: Chihiro Adachi <8196725+chihiro-adachi@users.noreply.github.com> Date: Thu, 22 Apr 2021 10:59:39 +0900 Subject: [PATCH 4/5] =?UTF-8?q?=E8=A4=87=E6=95=B0=E7=99=BB=E9=8C=B2?= =?UTF-8?q?=E6=99=82=E3=81=AB=E6=AD=A3=E3=81=97=E3=81=8F=E5=87=BA=E5=8A=9B?= =?UTF-8?q?=E3=81=A7=E3=81=8D=E3=81=AA=E3=81=84=E4=B8=8D=E5=85=B7=E5=90=88?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/DoctrineMigrations/Version20210412073123.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/DoctrineMigrations/Version20210412073123.php b/app/DoctrineMigrations/Version20210412073123.php index 6215d964cf3..bf52b516bd6 100644 --- a/app/DoctrineMigrations/Version20210412073123.php +++ b/app/DoctrineMigrations/Version20210412073123.php @@ -28,10 +28,13 @@ final class Version20210412073123 extends AbstractMigration public function up(Schema $schema): void { if ($schema->hasTable('plg_admin_record_config')) { - $denyHosts = array_merge( - env('ECCUBE_ADMIN_DENY_HOSTS', []), - $this->connection->fetchArray('select admin_deny_hosts FROM plg_admin_record_config') ?: [] - ); + $denyHostsPlugin = $this->connection->fetchColumn('select admin_deny_hosts FROM plg_admin_record_config') ?: ''; + $denyHostsPlugin = array_filter(\explode("\n", StringUtil::convertLineFeed($denyHostsPlugin)), function ($str) { + return StringUtil::isNotBlank($str); + }); + + $denyHosts = array_merge(env('ECCUBE_ADMIN_DENY_HOSTS', []), $denyHostsPlugin); + $denyHosts = array_values(array_unique($denyHosts)); $denyHosts = \json_encode($denyHosts); From b057295c1ac3d93c114638272406bb32991bcf7b Mon Sep 17 00:00:00 2001 From: Chihiro Adachi <8196725+chihiro-adachi@users.noreply.github.com> Date: Mon, 30 Aug 2021 15:10:06 +0900 Subject: [PATCH 5/5] =?UTF-8?q?drop=E3=81=99=E3=82=8B=E3=81=A8=E3=82=A8?= =?UTF-8?q?=E3=83=A9=E3=83=BC=E3=81=AB=E3=81=AA=E3=82=8B=E3=81=9F=E3=82=81?= =?UTF-8?q?=E3=80=81delete=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/DoctrineMigrations/Version20210412073123.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/DoctrineMigrations/Version20210412073123.php b/app/DoctrineMigrations/Version20210412073123.php index bf52b516bd6..68691054850 100644 --- a/app/DoctrineMigrations/Version20210412073123.php +++ b/app/DoctrineMigrations/Version20210412073123.php @@ -74,7 +74,7 @@ public function up(Schema $schema): void public function down(Schema $schema): void { if ($schema->hasTable('dtb_login_history')) { - $this->addSql('DROP TABLE dtb_login_history'); + $this->addSql('DELETE FROM dtb_login_history'); } } }