From 45a45641d9bbc2ea0fc73357a99cbbb5f0f3d489 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Wed, 20 Aug 2025 10:04:03 +0500 Subject: feat: config.php --- lib/config.php | 24 ++++++++++++++++++++++++ register.php | 12 ++++++------ 2 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 lib/config.php diff --git a/lib/config.php b/lib/config.php new file mode 100644 index 0000000..2f150bb --- /dev/null +++ b/lib/config.php @@ -0,0 +1,24 @@ + 20) { - exit(create_alert('/register.php', 400, 'Your username must be between 4 and 20 characters long', null)); + if ($username_len < USERNAME_LENGTH[0] || $username_len > USERNAME_LENGTH[1]) { + exit(create_alert('/register.php', 400, sprintf('Your username must be between %d and %d characters long', USERNAME_LENGTH[0], USERNAME_LENGTH[1]), null)); } - if (strlen($password) < 8) { - exit(create_alert('/register.php', 400, 'Your password must be at least 8 characters long', null)); + if (strlen($password) < PASSWORD_LENGTH) { + exit(create_alert('/register.php', 400, sprintf('Your password must be at least %d characters long', PASSWORD_LENGTH), null)); } $db = new PDO(DB_URL, DB_USER, DB_PASS); @@ -39,7 +39,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { $userid = 0; do { - $userid = random_int(90_000_000_000_000_000, 99_000_000_000_000_000); + $userid = random_int(USERNAME_ID_RANGE[0], USERNAME_ID_RANGE[1]); $stmt = $db->prepare('SELECT username FROM users WHERE id = ?'); $stmt->execute([$userid]); } while ($stmt->rowCount() > 0); -- cgit v1.2.3