From f03869efb022cd6dc2682ef22751c81a0f60bf62 Mon Sep 17 00:00:00 2001 From: 1day2die Date: Tue, 7 Jun 2022 17:30:38 +0200 Subject: [PATCH] Initial Admin user should receive a ref-code aswell --- public/install/forms.php | 4 ++-- public/install/functions.php | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/public/install/forms.php b/public/install/forms.php index b737b031..70562a0a 100644 --- a/public/install/forms.php +++ b/public/install/forms.php @@ -269,8 +269,8 @@ if (isset($_POST['createUser'])) { } - - $query1 = "INSERT INTO `" . getEnvironmentValue("DB_DATABASE") . "`.`users` (`name`, `role`, `credits`, `server_limit`, `pterodactyl_id`, `email`, `password`, `created_at`) VALUES ('$name', 'admin', '250', '1', '$pteroID', '$mail', '$pass', CURRENT_TIMESTAMP)"; + $random = generateRandomString(); + $query1 = "INSERT INTO `" . getEnvironmentValue("DB_DATABASE") . "`.`users` (`name`, `role`, `credits`, `server_limit`, `pterodactyl_id`, `email`, `password`, `created_at`, `referral_code`) VALUES ('$name', 'admin', '250', '1', '$pteroID', '$mail', '$pass', CURRENT_TIMESTAMP, '$random')"; diff --git a/public/install/functions.php b/public/install/functions.php index 82df4017..10baf2e7 100644 --- a/public/install/functions.php +++ b/public/install/functions.php @@ -139,3 +139,14 @@ function wh_log($log_msg) // if you don't add `FILE_APPEND`, the file will be erased each time you add a log file_put_contents($log_file_data, "[" . date('h:i:s') . "] " . $log_msg . "\n", FILE_APPEND); } + + +function generateRandomString($length = 8) { + $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + $charactersLength = strlen($characters); + $randomString = ''; + for ($i = 0; $i < $length; $i++) { + $randomString .= $characters[rand(0, $charactersLength - 1)]; + } + return $randomString; +}