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; +}