Add option to disable registration

This commit is contained in:
2023-10-21 11:57:25 +02:00
parent a6ab6c52e3
commit 0bb8ac6590
4 changed files with 100 additions and 67 deletions

View File

@ -26,6 +26,7 @@ const DBHOST_PROSODY = 'localhost'; // Database host
const DBUSER_PROSODY = 'prosody'; // Database user const DBUSER_PROSODY = 'prosody'; // Database user
const DBPASS_PROSODY = 'YOUR_PASSWORD'; // Database password const DBPASS_PROSODY = 'YOUR_PASSWORD'; // Database password
const DBNAME_PROSODY = 'prosody'; // Database const DBNAME_PROSODY = 'prosody'; // Database
const REGISTRATION_ENABLED = true; // Whether registration is enabled
const LANGUAGES = [ const LANGUAGES = [
'cs' => ['name' => 'čeština', 'locale' => 'cs_CZ', 'flag' => '🇨🇿', 'show_in_menu' => true, 'dir' => 'ltr'], 'cs' => ['name' => 'čeština', 'locale' => 'cs_CZ', 'flag' => '🇨🇿', 'show_in_menu' => true, 'dir' => 'ltr'],

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-10-08 21:46+0200\n" "POT-Creation-Date: 2023-10-21 11:56+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -34,26 +34,26 @@ msgstr ""
msgid "File found in mail directory location: \"%s\". Consider deleting it." msgid "File found in mail directory location: \"%s\". Consider deleting it."
msgstr "" msgstr ""
#: common_config.php:91 setup.php:20 setup.php:23 cron.php:11 #: common_config.php:93 setup.php:20 setup.php:23 cron.php:11
msgid "No Connection to MySQL database!" msgid "No Connection to MySQL database!"
msgstr "" msgstr ""
#: common_config.php:140 #: common_config.php:142
msgid "Copy:" msgid "Copy:"
msgstr "" msgstr ""
#: common_config.php:259 #: common_config.php:261
#, php-format #, php-format
msgid "" msgid ""
"Oops, the email \"%s\" doesn' look like a valid email address and thus " "Oops, the email \"%s\" doesn' look like a valid email address and thus "
"wasn't added to the forwarding list." "wasn't added to the forwarding list."
msgstr "" msgstr ""
#: common_config.php:285 #: common_config.php:287
msgid "You are not allowed to manage this domain." msgid "You are not allowed to manage this domain."
msgstr "" msgstr ""
#: common_config.php:296 #: common_config.php:298
msgid "Invalid email address." msgid "Invalid email address."
msgstr "" msgstr ""
@ -90,32 +90,32 @@ msgstr ""
msgid "Terms of Service for E-Mail and XMPP accounts" msgid "Terms of Service for E-Mail and XMPP accounts"
msgstr "" msgstr ""
#: www/terms.php:22 www/register.php:95 www/index.php:22 #: www/terms.php:22 www/register.php:99 www/index.php:22
#: www/manage_account.php:237 #: www/manage_account.php:237
msgid "Info" msgid "Info"
msgstr "" msgstr ""
#: www/terms.php:22 www/register.php:95 www/register.php:122 www/index.php:22 #: www/terms.php:22 www/register.php:99 www/register.php:130 www/index.php:22
#: www/manage_account.php:241 #: www/manage_account.php:241
msgid "Register" msgid "Register"
msgstr "" msgstr ""
#: www/terms.php:22 www/register.php:95 www/index.php:22 #: www/terms.php:22 www/register.php:99 www/index.php:22
#: www/manage_account.php:247 #: www/manage_account.php:247
msgid "Manage account" msgid "Manage account"
msgstr "" msgstr ""
#: www/terms.php:22 www/register.php:95 www/index.php:22 www/index.php:27 #: www/terms.php:22 www/register.php:99 www/index.php:22 www/index.php:27
#: www/manage_account.php:248 #: www/manage_account.php:248
msgid "SquirrelMail" msgid "SquirrelMail"
msgstr "" msgstr ""
#: www/terms.php:22 www/register.php:95 www/index.php:22 www/index.php:27 #: www/terms.php:22 www/register.php:99 www/index.php:22 www/index.php:27
#: www/manage_account.php:248 #: www/manage_account.php:248
msgid "SnappyMail" msgid "SnappyMail"
msgstr "" msgstr ""
#: www/terms.php:22 www/register.php:95 www/index.php:22 #: www/terms.php:22 www/register.php:99 www/index.php:22
#: www/manage_account.php:248 #: www/manage_account.php:248
msgid "Web-XMPP" msgid "Web-XMPP"
msgstr "" msgstr ""
@ -140,118 +140,138 @@ msgid ""
msgstr "" msgstr ""
#: www/terms.php:28 #: www/terms.php:28
msgid "Mass mailing is not allowed, and you will be blocked if you do."
msgstr ""
#: www/terms.php:29
msgid ""
"Please refrain from sending threats of violence or any harmful content. "
"Dealing with law enforcement requests related to such incidents consumes a "
"significant amount of time."
msgstr ""
#: www/terms.php:30
msgid "" msgid ""
"If you lose your password, I will not reset it unless you can prove " "If you lose your password, I will not reset it unless you can prove "
"ownership of the account. You could do so by signing an email with the same " "ownership of the account. You could do so by signing an email with the same "
"PGP key that you use in your account." "PGP key that you use in your account."
msgstr "" msgstr ""
#: www/terms.php:29 #: www/terms.php:31
msgid "You are responsible for the security of your account and password." msgid "You are responsible for the security of your account and password."
msgstr "" msgstr ""
#: www/terms.php:30 #: www/terms.php:32
#, php-format #, php-format
msgid "" msgid ""
"Your email account only has 50MB of disk space by default. If you need more, " "Your email account only has 50MB of disk space by default. If you need more, "
"you can %s, and I will increase it for free." "you can %s, and I will increase it for free."
msgstr "" msgstr ""
#: www/terms.php:30 www/index.php:25 #: www/terms.php:32 www/index.php:25
msgid "contact me" msgid "contact me"
msgstr "" msgstr ""
#: www/terms.php:31 #: www/terms.php:33
msgid "" msgid ""
"The XMPP service provides message archiving and HTTP upload, which can keep " "The XMPP service provides message archiving and HTTP upload, which can keep "
"your messages and files for up to 1 week. Up to 100MB of file storage is " "your messages and files for up to 1 week. Up to 100MB of file storage is "
"available per user." "available per user."
msgstr "" msgstr ""
#: www/terms.php:32 #: www/terms.php:34
msgid "" msgid ""
"I reserve the right to block or delete your account without prior notice." "I reserve the right to block or delete your account without prior notice."
msgstr "" msgstr ""
#: www/terms.php:33 #: www/terms.php:35
msgid "I reserve the right to change these terms without prior notice." msgid "I reserve the right to change these terms without prior notice."
msgstr "" msgstr ""
#: www/register.php:18 #: www/terms.php:36
msgid "Continued violations may necessitate the closure of registration."
msgstr ""
#: www/register.php:18 www/register.php:103
#, php-format
msgid "Registration is disabled due to too many violations of the %s"
msgstr ""
#: www/register.php:18 www/register.php:103 www/register.php:124
msgid "Terms of Service"
msgstr ""
#: www/register.php:22
msgid "Invalid CSRF token" msgid "Invalid CSRF token"
msgstr "" msgstr ""
#: www/register.php:22 www/manage_account.php:43 #: www/register.php:26 www/manage_account.php:43
msgid "Invalid captcha" msgid "Invalid captcha"
msgstr "" msgstr ""
#: www/register.php:27 #: www/register.php:31
msgid "Invalid username. It may not contain a +, ', \" or /." msgid "Invalid username. It may not contain a +, ', \" or /."
msgstr "" msgstr ""
#: www/register.php:33 www/manage_account.php:100 www/admin.php:175 #: www/register.php:37 www/manage_account.php:100 www/admin.php:175
#: www/admin.php:343 #: www/admin.php:343
msgid "Passwords empty or don't match" msgid "Passwords empty or don't match"
msgstr "" msgstr ""
#: www/register.php:44 #: www/register.php:48
msgid "The domain you specified is not allowed" msgid "The domain you specified is not allowed"
msgstr "" msgstr ""
#: www/register.php:49 #: www/register.php:53
msgid "The email address you specified is not valid" msgid "The email address you specified is not valid"
msgstr "" msgstr ""
#: www/register.php:52 #: www/register.php:56
msgid "The username you specified is reserved" msgid "The username you specified is reserved"
msgstr "" msgstr ""
#: www/register.php:62 www/admin.php:311 #: www/register.php:66 www/admin.php:311
msgid "Sorry, this user already exists" msgid "Sorry, this user already exists"
msgstr "" msgstr ""
#: www/register.php:70 www/admin.php:333 #: www/register.php:74 www/admin.php:333
msgid "Successfully created new mailbox!" msgid "Successfully created new mailbox!"
msgstr "" msgstr ""
#: www/register.php:78 www/register.php:87 www/register.php:91 #: www/register.php:82 www/register.php:91 www/register.php:95
msgid "E-Mail and XMPP - Register" msgid "E-Mail and XMPP - Register"
msgstr "" msgstr ""
#: www/register.php:82 www/register.php:88 www/register.php:91 #: www/register.php:86 www/register.php:92 www/register.php:95
msgid "" msgid ""
"Register for a free and anonymous E-Mail address and an XMPP/Jabber account" "Register for a free and anonymous E-Mail address and an XMPP/Jabber account"
msgstr "" msgstr ""
#: www/register.php:100 www/manage_account.php:255 www/admin.php:407 #: www/register.php:108 www/manage_account.php:255 www/admin.php:407
#: www/admin.php:580 www/admin.php:907 www/admin.php:936 #: www/admin.php:580 www/admin.php:907 www/admin.php:936
msgid "Username" msgid "Username"
msgstr "" msgstr ""
#: www/register.php:104 www/manage_account.php:260 www/manage_account.php:323 #: www/register.php:112 www/manage_account.php:260 www/manage_account.php:323
#: www/admin.php:411 www/admin.php:501 www/admin.php:584 www/admin.php:940 #: www/admin.php:411 www/admin.php:501 www/admin.php:584 www/admin.php:940
#: www/admin.php:1025 #: www/admin.php:1025
msgid "Password" msgid "Password"
msgstr "" msgstr ""
#: www/register.php:108 www/manage_account.php:328 www/admin.php:506 #: www/register.php:116 www/manage_account.php:328 www/admin.php:506
#: www/admin.php:589 www/admin.php:944 www/admin.php:1030 #: www/admin.php:589 www/admin.php:944 www/admin.php:1030
msgid "Password again" msgid "Password again"
msgstr "" msgstr ""
#: www/register.php:112 www/register.php:116 #: www/register.php:120 www/register.php:124
#, php-format #, php-format
msgid "I have read and agreed to the %s" msgid "I have read and agreed to the %s"
msgstr "" msgstr ""
#: www/register.php:112 #: www/register.php:120
msgid "Privacy Policy" msgid "Privacy Policy"
msgstr "" msgstr ""
#: www/register.php:116
msgid "Terms of Service"
msgstr ""
#: www/index.php:6 www/index.php:15 www/index.php:19 #: www/index.php:6 www/index.php:15 www/index.php:19
msgid "E-Mail and XMPP" msgid "E-Mail and XMPP"
msgstr "" msgstr ""

View File

@ -13,6 +13,10 @@ if ( empty( $_SESSION[ 'csrf_token' ] ) || $_SESSION[ 'UA' ] !== $_SERVER[ 'HTTP
$msg = ''; $msg = '';
if ( isset( $_POST[ 'user' ] ) ) { if ( isset( $_POST[ 'user' ] ) ) {
$ok = true; $ok = true;
if( ! REGISTRATION_ENABLED ) {
$ok = false;
$msg .= '<div class="red" role="alert">'.sprintf(htmlspecialchars(_('Registration is disabled due to too many violations of the %s')), '<a href="'.ROOT_URL.'terms.php" target="_blank">'.htmlspecialchars(_('Terms of Service')).'</a>').'</div>';
}
if ( $_SESSION[ 'csrf_token' ] !== $_POST[ 'csrf_token' ] ?? '' ) { if ( $_SESSION[ 'csrf_token' ] !== $_POST[ 'csrf_token' ] ?? '' ) {
$ok = false; $ok = false;
$msg .= '<div class="red" role="alert">'.htmlspecialchars(_('Invalid CSRF token')).'</div>'; $msg .= '<div class="red" role="alert">'.htmlspecialchars(_('Invalid CSRF token')).'</div>';
@ -94,35 +98,40 @@ if ( isset( $_POST[ 'user' ] ) ) {
<main> <main>
<p><a href="<?php echo ROOT_URL; ?>"><?php echo htmlspecialchars(_('Info')); ?></a> | <?php echo htmlspecialchars(_('Register')); ?> | <a href="<?php echo ROOT_URL; ?>manage_account.php"><?php echo htmlspecialchars(_('Manage account')); ?></a> | <a href="<?php echo ROOT_URL; ?>squirrelmail/src/login.php" target="_blank"><?php echo htmlspecialchars(_('SquirrelMail')); ?></a> | <a href="<?php echo ROOT_URL; ?>snappymail/" target="_blank"><?php echo htmlspecialchars(_('SnappyMail')); ?></a> | <a href="<?php echo WEB_XMPP_URL; ?>" target="_blank" rel="noopener"><?php echo htmlspecialchars(_('Web-XMPP')); ?></a> <p><a href="<?php echo ROOT_URL; ?>"><?php echo htmlspecialchars(_('Info')); ?></a> | <?php echo htmlspecialchars(_('Register')); ?> | <a href="<?php echo ROOT_URL; ?>manage_account.php"><?php echo htmlspecialchars(_('Manage account')); ?></a> | <a href="<?php echo ROOT_URL; ?>squirrelmail/src/login.php" target="_blank"><?php echo htmlspecialchars(_('SquirrelMail')); ?></a> | <a href="<?php echo ROOT_URL; ?>snappymail/" target="_blank"><?php echo htmlspecialchars(_('SnappyMail')); ?></a> | <a href="<?php echo WEB_XMPP_URL; ?>" target="_blank" rel="noopener"><?php echo htmlspecialchars(_('Web-XMPP')); ?></a>
</p> </p>
<?php echo "<p>$msg</p>"; ?> <?php echo "<p>$msg</p>";
<form class="form_limit" action="register.php" method="post"><input type="hidden" name="csrf_token" value="<?php echo $_SESSION[ 'csrf_token' ] ?>"> if( ! REGISTRATION_ENABLED ) {
<div class="row"> echo '<p>'.sprintf(htmlspecialchars(_('Registration is disabled due to too many violations of the %s')), '<a href="'.ROOT_URL.'terms.php" target="_blank">'.htmlspecialchars(_('Terms of Service')).'</a>').'</p>';
<div class="col"><label for="user"><?php echo htmlspecialchars(_('Username')); ?></label></div> } else {
<div class="col"><input type="text" name="user" id="user" autocomplete="username" required value="<?php echo htmlspecialchars( $_POST[ 'user' ] ?? '' ); ?>"></div> ?>
</div> <form class="form_limit" action="register.php" method="post"><input type="hidden" name="csrf_token" value="<?php echo $_SESSION[ 'csrf_token' ] ?>">
<div class="row"> <div class="row">
<div class="col"><label for="pwd"><?php echo htmlspecialchars(_('Password')); ?></label></div> <div class="col"><label for="user"><?php echo htmlspecialchars(_('Username')); ?></label></div>
<div class="col"><input type="password" name="pwd" id="pwd" autocomplete="new-password" required></div> <div class="col"><input type="text" name="user" id="user" autocomplete="username" required value="<?php echo htmlspecialchars( $_POST[ 'user' ] ?? '' ); ?>"></div>
</div> </div>
<div class="row"> <div class="row">
<div class="col"><label for="pwd2"><?php echo htmlspecialchars(_('Password again')); ?></label></div> <div class="col"><label for="pwd"><?php echo htmlspecialchars(_('Password')); ?></label></div>
<div class="col"><input type="password" name="pwd2" id="pwd2" autocomplete="new-password" required></div> <div class="col"><input type="password" name="pwd" id="pwd" autocomplete="new-password" required></div>
</div> </div>
<div class="row"> <div class="row">
<div class="col"><label for="accept_privacy"><?php printf(htmlspecialchars(_('I have read and agreed to the %s')), '<a href="'.PRIVACY_POLICY_URL.'" target="_blank">'.htmlspecialchars(_('Privacy Policy')).'</a>'); ?></label></div> <div class="col"><label for="pwd2"><?php echo htmlspecialchars(_('Password again')); ?></label></div>
<div class="col"><input type="checkbox" id="accept_privacy" name="accept_privacy" required></div> <div class="col"><input type="password" name="pwd2" id="pwd2" autocomplete="new-password" required></div>
</div> </div>
<div class="row"> <div class="row">
<div class="col"><label for="accept_terms"><?php printf(htmlspecialchars(_('I have read and agreed to the %s')), '<a href="'.ROOT_URL.'terms.php" target="_blank">'.htmlspecialchars(_('Terms of Service')).'</a>'); ?></label></div> <div class="col"><label for="accept_privacy"><?php printf(htmlspecialchars(_('I have read and agreed to the %s')), '<a href="'.PRIVACY_POLICY_URL.'" target="_blank">'.htmlspecialchars(_('Privacy Policy')).'</a>'); ?></label></div>
<div class="col"><input type="checkbox" id="accept_terms" name="accept_terms" required></div> <div class="col"><input type="checkbox" id="accept_privacy" name="accept_privacy" required></div>
</div> </div>
<?php send_captcha(); ?> <div class="row">
<div class="row"> <div class="col"><label for="accept_terms"><?php printf(htmlspecialchars(_('I have read and agreed to the %s')), '<a href="'.ROOT_URL.'terms.php" target="_blank">'.htmlspecialchars(_('Terms of Service')).'</a>'); ?></label></div>
<div class="col"> <div class="col"><input type="checkbox" id="accept_terms" name="accept_terms" required></div>
<button type="submit"><?php echo htmlspecialchars(_('Register')); ?></button> </div>
</div> <?php send_captcha(); ?>
</div> <div class="row">
</form> <div class="col">
<button type="submit"><?php echo htmlspecialchars(_('Register')); ?></button>
</div>
</div>
</form>
<?php } ?>
</main> </main>
</body> </body>
</html> </html>

View File

@ -25,12 +25,15 @@ global $language, $dir, $locale;
<li><?php echo htmlspecialchars(_('Inactive accounts get automatically deleted after one year of inactivity.')); ?></li> <li><?php echo htmlspecialchars(_('Inactive accounts get automatically deleted after one year of inactivity.')); ?></li>
<li><?php echo htmlspecialchars(_('Spamming is not allowed, and you will be blocked if you do.')); ?></li> <li><?php echo htmlspecialchars(_('Spamming is not allowed, and you will be blocked if you do.')); ?></li>
<li><?php echo htmlspecialchars(_('Using your account for illegal purposes is not allowed, and you will be blocked if you do.')); ?></li> <li><?php echo htmlspecialchars(_('Using your account for illegal purposes is not allowed, and you will be blocked if you do.')); ?></li>
<li><?php echo htmlspecialchars(_('Mass mailing is not allowed, and you will be blocked if you do.')); ?></li>
<li><?php echo htmlspecialchars(_('Please refrain from sending threats of violence or any harmful content. Dealing with law enforcement requests related to such incidents consumes a significant amount of time.')); ?></li>
<li><?php echo htmlspecialchars(_('If you lose your password, I will not reset it unless you can prove ownership of the account. You could do so by signing an email with the same PGP key that you use in your account.')); ?></li> <li><?php echo htmlspecialchars(_('If you lose your password, I will not reset it unless you can prove ownership of the account. You could do so by signing an email with the same PGP key that you use in your account.')); ?></li>
<li><?php echo htmlspecialchars(_('You are responsible for the security of your account and password.')); ?></li> <li><?php echo htmlspecialchars(_('You are responsible for the security of your account and password.')); ?></li>
<li><?php printf(htmlspecialchars(_('Your email account only has 50MB of disk space by default. If you need more, you can %s, and I will increase it for free.')), '<a href="'.CONTACT_URL.'">'.htmlspecialchars(_('contact me')).'</a>'); ?></li> <li><?php printf(htmlspecialchars(_('Your email account only has 50MB of disk space by default. If you need more, you can %s, and I will increase it for free.')), '<a href="'.CONTACT_URL.'">'.htmlspecialchars(_('contact me')).'</a>'); ?></li>
<li><?php echo htmlspecialchars(_('The XMPP service provides message archiving and HTTP upload, which can keep your messages and files for up to 1 week. Up to 100MB of file storage is available per user.')); ?></li> <li><?php echo htmlspecialchars(_('The XMPP service provides message archiving and HTTP upload, which can keep your messages and files for up to 1 week. Up to 100MB of file storage is available per user.')); ?></li>
<li><?php echo htmlspecialchars(_('I reserve the right to block or delete your account without prior notice.')); ?></li> <li><?php echo htmlspecialchars(_('I reserve the right to block or delete your account without prior notice.')); ?></li>
<li><?php echo htmlspecialchars(_('I reserve the right to change these terms without prior notice.')); ?></li> <li><?php echo htmlspecialchars(_('I reserve the right to change these terms without prior notice.')); ?></li>
<li><?php echo htmlspecialchars(_('Continued violations may necessitate the closure of registration.')); ?></li>
</ol> </ol>
</main> </main>
</body></html> </body></html>