From 33b20423951c269d85137a4753fb29e8ece055c9 Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Thu, 23 Nov 2023 09:15:06 +0700 Subject: [PATCH] Invites config re-formatting (#1162) * Invites config re-formatting * Update config.php * Update CHANGELOG.md --- CHANGELOG.md | 1 + library/config.php | 21 ++++++++++---------- library/includes/ucp/register.php | 9 ++++----- styles/templates/default/usercp_register.tpl | 10 +++++----- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c1248d00..c45cc0f60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ **Merged pull requests:** +- Invites config re-formatting [\#1162](https://github.com/torrentpier/torrentpier/pull/1162) ([belomaxorka](https://github.com/belomaxorka)) - Use external cookie library to prevent incorrect cookie setting [\#1160](https://github.com/torrentpier/torrentpier/pull/1160), [\#1161](https://github.com/torrentpier/torrentpier/pull/1161) ([belomaxorka](https://github.com/belomaxorka)) - Some improvements in default template [\#1159](https://github.com/torrentpier/torrentpier/pull/1159) ([belomaxorka](https://github.com/belomaxorka)) - Use sent port instead of source [\#1158](https://github.com/torrentpier/torrentpier/pull/1158) ([kovalensky](https://github.com/kovalensky)) diff --git a/library/config.php b/library/config.php index 67da0909b..bc83e62f2 100644 --- a/library/config.php +++ b/library/config.php @@ -378,16 +378,17 @@ $bb_cfg['unique_ip'] = false; // Disallow registration from multiple IP addresse $bb_cfg['new_user_reg_restricted'] = false; // Disallow registration in below hours $bb_cfg['new_user_reg_interval'] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]; // Available hours $bb_cfg['reg_email_activation'] = true; // Demand to activate profile by email confirmation -// Invites -$bb_cfg['invite_only'] = false; -// Invite codes -// Syntax: 'invite_code' => 'validity_period' -// The 'validity_period' value is based on strtotime() function: https://www.php.net/manual/en/function.strtotime.php -// Invite link example: site_url/profile.php?mode=register&invite=new_year -$bb_cfg['invite_codes'] = [ - 'new_year' => '2022-12-31 00:00:01', - 'ein_volk' => '29 July 1936', - 'catch_up_overtake' => '1917-10-09' + +$bb_cfg['invites_system'] = [ + 'enabled' => false, + 'codes' => [ + // Syntax: 'invite_code' => 'validity_period' + // The 'validity_period' value is based on strtotime() function: https://www.php.net/manual/en/function.strtotime.php + // Invite link example: site_url/profile.php?mode=register&invite=new_year + 'new_year' => '2022-12-31 00:00:01', + 'ein_volk' => '29 July 1936', + 'catch_up_overtake' => '1917-10-09' + ] ]; $bb_cfg['password_symbols'] = [ diff --git a/library/includes/ucp/register.php b/library/includes/ucp/register.php index 4817e60aa..5aaf376f6 100644 --- a/library/includes/ucp/register.php +++ b/library/includes/ucp/register.php @@ -203,15 +203,14 @@ foreach ($profile_fields as $field => $can_edit) { * Invite code (reg) */ case 'invite_code': - if ($bb_cfg['invite_only']) { + if ($bb_cfg['invites_system']['enabled']) { $invite_code = $_POST['invite_code'] ?? ''; if ($submit) { - if (isset($bb_cfg['invite_codes'][$invite_code])) { - if (TIMENOW > strtotime($bb_cfg['invite_codes'][$invite_code])) { + if (isset($bb_cfg['invites_system']['codes'][$invite_code])) { + if (TIMENOW > strtotime($bb_cfg['invites_system']['codes'][$invite_code])) { $errors[] = $lang['INVITE_EXPIRED']; } - } - else { + } else { $errors[] = $lang['INCORRECT_INVITE']; } } diff --git a/styles/templates/default/usercp_register.tpl b/styles/templates/default/usercp_register.tpl index 24269aa9a..eca2cc80c 100644 --- a/styles/templates/default/usercp_register.tpl +++ b/styles/templates/default/usercp_register.tpl @@ -95,11 +95,11 @@   - - - {L_INVITE_CODE}: * - - + + + {L_INVITE_CODE}: * + +