From eaf2305b9d5d043bf625dc1b6cd60e75853c5d36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Dzieko=C5=84ski?= Date: Sun, 3 Jul 2022 22:22:29 +0200 Subject: [PATCH] GH-230 Move user updates to an util --- modules/overview/_includes.php | 1 + .../effects/updateUserOnFirstLogin.effect.php | 48 +++++++++++++++++++ overview.php | 14 ++---- 3 files changed, 53 insertions(+), 10 deletions(-) create mode 100644 modules/overview/screens/FirstLogin/utils/effects/updateUserOnFirstLogin.effect.php diff --git a/modules/overview/_includes.php b/modules/overview/_includes.php index 49b00741..f5f38e4d 100644 --- a/modules/overview/_includes.php +++ b/modules/overview/_includes.php @@ -11,6 +11,7 @@ include($includePath . './screens/FirstLogin/utils/effects/handleProxyDetection.effect.php'); include($includePath . './screens/FirstLogin/utils/effects/handleReferralMultiAccountDetection.effect.php'); include($includePath . './screens/FirstLogin/utils/effects/triggerUserReferralTask.effect.php'); + include($includePath . './screens/FirstLogin/utils/effects/updateUserOnFirstLogin.effect.php'); include($includePath . './screens/FirstLogin/utils/helpers/getReferrerTasksData.helper.php'); }); diff --git a/modules/overview/screens/FirstLogin/utils/effects/updateUserOnFirstLogin.effect.php b/modules/overview/screens/FirstLogin/utils/effects/updateUserOnFirstLogin.effect.php new file mode 100644 index 00000000..91476f97 --- /dev/null +++ b/modules/overview/screens/FirstLogin/utils/effects/updateUserOnFirstLogin.effect.php @@ -0,0 +1,48 @@ + diff --git a/overview.php b/overview.php index dbbf4c5b..a4069912 100644 --- a/overview.php +++ b/overview.php @@ -49,16 +49,10 @@ $_Lang['LoginPage_Text'] = str_replace($Search, $Replace, $_Lang['LoginPage_Text']); - doquery("INSERT IGNORE INTO {{table}} VALUES (0, {$_User['id']}, {$Now});", 'chat_online'); - doquery("UPDATE {{table}} SET `last_update` = {$Now} WHERE `id_owner` = {$_User['id']} LIMIT 1;", 'planets'); - - $NewUserProtectionTime = $Now + $_GameConfig['Protection_NewPlayerTime']; - $Query_UpdateUser = ''; - $Query_UpdateUser .= "UPDATE {{table}} SET "; - $Query_UpdateUser .= "`first_login` = {$Now}, "; - $Query_UpdateUser .= "`NoobProtection_EndTime` = {$NewUserProtectionTime} "; - $Query_UpdateUser .= "WHERE `id` = {$_User['id']} LIMIT 1;"; - doquery($Query_UpdateUser, 'users'); + Overview\Screens\FirstLogin\Utils\Effects\updateUserOnFirstLogin([ + 'userId' => $_User['id'], + 'currentTimestamp' => $Now, + ]); if ($_User['referred'] > 0) { $referringUserWithTasksData = Overview\Screens\FirstLogin\Utils\Helpers\getReferrerTasksData([