mirror of
https://github.com/DanWin/mail-hosting.git
synced 2024-11-21 23:20:25 +00:00
Add setting for default quota
This commit is contained in:
parent
d9d7323a9a
commit
c35d47c6c6
5 changed files with 17 additions and 8 deletions
|
@ -27,6 +27,7 @@ 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 REGISTRATION_ENABLED = true; // Whether registration is enabled
|
||||||
|
const DEFAULT_QUOTA = 50 * 1024 * 1024; // Default mailbox quota in bytes
|
||||||
|
|
||||||
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'],
|
||||||
|
@ -351,3 +352,13 @@ function alt_links(): void
|
||||||
echo '<meta property="og:locale:alternate" content="'.$data['locale'].'">';
|
echo '<meta property="og:locale:alternate" content="'.$data['locale'].'">';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function bytes_to_human_readable(int $bytes) : string {
|
||||||
|
$suffix = ['B', 'KiB', 'MiB', 'GiB', 'TiB'];
|
||||||
|
$size_class=(int) log($bytes, 1024);
|
||||||
|
if($size_class!==0){
|
||||||
|
return sprintf('%1.1f', $bytes / pow(1024, $size_class)) . $suffix[$size_class];
|
||||||
|
}else{
|
||||||
|
return $bytes . $suffix[0];
|
||||||
|
}
|
||||||
|
}
|
|
@ -289,12 +289,11 @@ if ( $_SERVER[ 'REQUEST_METHOD' ] === 'POST' ) {
|
||||||
$additional = preg_split( "/[\s,]+/", $_POST[ 'alias_to' ] );
|
$additional = preg_split( "/[\s,]+/", $_POST[ 'alias_to' ] );
|
||||||
$alias_goto .= validate_email_list( $additional, $msg );
|
$alias_goto .= validate_email_list( $additional, $msg );
|
||||||
}
|
}
|
||||||
$quota = 1024 * 1024 * 1024;
|
|
||||||
$alias_goto = rtrim( $alias_goto, ',' );
|
$alias_goto = rtrim( $alias_goto, ',' );
|
||||||
$stmt = $db->prepare( 'UPDATE alias SET goto = ?, enforce_tls_in = ?, active = ? WHERE address = ?;' );
|
$stmt = $db->prepare( 'UPDATE alias SET goto = ?, enforce_tls_in = ?, active = ? WHERE address = ?;' );
|
||||||
$stmt->execute( [ $alias_goto, ( isset( $_POST[ 'enforce_tls_in' ] ) ? 1 : 0 ), ( isset( $_POST[ 'active' ] ) ? 1 : 0 ), $_POST[ 'user' ] ] );
|
$stmt->execute( [ $alias_goto, ( isset( $_POST[ 'enforce_tls_in' ] ) ? 1 : 0 ), ( isset( $_POST[ 'active' ] ) ? 1 : 0 ), $_POST[ 'user' ] ] );
|
||||||
$stmt = $db->prepare( 'UPDATE mailbox SET enforce_tls_in = ?, enforce_tls_out = ?, active = ?, quota = ?, modified = NOW() WHERE username = ?;' );
|
$stmt = $db->prepare( 'UPDATE mailbox SET enforce_tls_in = ?, enforce_tls_out = ?, active = ?, quota = ?, modified = NOW() WHERE username = ?;' );
|
||||||
$stmt->execute( [ ( isset( $_POST[ 'enforce_tls_in' ] ) ? 1 : 0 ), ( isset( $_POST[ 'enforce_tls_out' ] ) ? 1 : 0 ), ( isset( $_POST[ 'active' ] ) ? 1 : 0 ), $quota, $_POST[ 'user' ] ] );
|
$stmt->execute( [ ( isset( $_POST[ 'enforce_tls_in' ] ) ? 1 : 0 ), ( isset( $_POST[ 'enforce_tls_out' ] ) ? 1 : 0 ), ( isset( $_POST[ 'active' ] ) ? 1 : 0 ), DEFAULT_QUOTA, $_POST[ 'user' ] ] );
|
||||||
$msg .= '<div class="green" role="alert">'.htmlspecialchars(_('Successfully updated mailbox.')).'</div>';
|
$msg .= '<div class="green" role="alert">'.htmlspecialchars(_('Successfully updated mailbox.')).'</div>';
|
||||||
}
|
}
|
||||||
} elseif ( $_POST[ 'action' ] === 'save_new_mailbox' && ! empty( $_POST[ 'user' ] ) ) {
|
} elseif ( $_POST[ 'action' ] === 'save_new_mailbox' && ! empty( $_POST[ 'user' ] ) ) {
|
||||||
|
@ -316,7 +315,6 @@ if ( $_SERVER[ 'REQUEST_METHOD' ] === 'POST' ) {
|
||||||
$user = $parser->getLocalPart();
|
$user = $parser->getLocalPart();
|
||||||
$domain = $parser->getDomainPart();
|
$domain = $parser->getDomainPart();
|
||||||
$hash = password_hash( $_POST[ 'pwd' ], PASSWORD_ARGON2ID );
|
$hash = password_hash( $_POST[ 'pwd' ], PASSWORD_ARGON2ID );
|
||||||
$quota = 50 * 1024 * 1024;
|
|
||||||
$alias_goto = '';
|
$alias_goto = '';
|
||||||
if ( isset( $_POST[ 'alias_keep_copy' ] ) ) {
|
if ( isset( $_POST[ 'alias_keep_copy' ] ) ) {
|
||||||
$alias_goto .= $email . ',';
|
$alias_goto .= $email . ',';
|
||||||
|
@ -329,7 +327,7 @@ if ( $_SERVER[ 'REQUEST_METHOD' ] === 'POST' ) {
|
||||||
$stmt = $db->prepare( 'INSERT INTO alias (address, goto, domain, created, modified, enforce_tls_in, active) VALUES (?, ?, ?, NOW(), NOW(), ?, ?);' );
|
$stmt = $db->prepare( 'INSERT INTO alias (address, goto, domain, created, modified, enforce_tls_in, active) VALUES (?, ?, ?, NOW(), NOW(), ?, ?);' );
|
||||||
$stmt->execute( [ $email, $alias_goto, $domain, ( isset( $_POST[ 'enforce_tls_in' ] ) ? 1 : 0 ), ( isset( $_POST[ 'active' ] ) ? 1 : 0 ) ] );
|
$stmt->execute( [ $email, $alias_goto, $domain, ( isset( $_POST[ 'enforce_tls_in' ] ) ? 1 : 0 ), ( isset( $_POST[ 'active' ] ) ? 1 : 0 ) ] );
|
||||||
$stmt = $db->prepare( 'INSERT INTO mailbox (username, password, quota, local_part, domain, created, modified, password_hash_type, openpgpkey_wkd, enforce_tls_in, enforce_tls_out, active) VALUES(?, ?, ?, ?, ?, NOW(), NOW(), ?, ?, ?, ?, ?);' );
|
$stmt = $db->prepare( 'INSERT INTO mailbox (username, password, quota, local_part, domain, created, modified, password_hash_type, openpgpkey_wkd, enforce_tls_in, enforce_tls_out, active) VALUES(?, ?, ?, ?, ?, NOW(), NOW(), ?, ?, ?, ?, ?);' );
|
||||||
$stmt->execute( [ $email, $hash, $quota, $user, $domain, '{ARGON2ID}', z_base32_encode( hash( 'sha1', mb_strtolower( $user ), true ) ), ( isset( $_POST[ 'enforce_tls_in' ] ) ? 1 : 0 ), ( isset( $_POST[ 'enforce_tls_out' ] ) ? 1 : 0 ), ( isset( $_POST[ 'active' ] ) ? 1 : 0 ) ] );
|
$stmt->execute( [ $email, $hash, DEFAULT_QUOTA, $user, $domain, '{ARGON2ID}', z_base32_encode( hash( 'sha1', mb_strtolower( $user ), true ) ), ( isset( $_POST[ 'enforce_tls_in' ] ) ? 1 : 0 ), ( isset( $_POST[ 'enforce_tls_out' ] ) ? 1 : 0 ), ( isset( $_POST[ 'active' ] ) ? 1 : 0 ) ] );
|
||||||
$msg .= '<div class="green" role="alert">'.htmlspecialchars(_('Successfully created new mailbox!')).'</div>';
|
$msg .= '<div class="green" role="alert">'.htmlspecialchars(_('Successfully created new mailbox!')).'</div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ global $language, $dir, $locale;
|
||||||
<p><?php echo htmlspecialchars(_('Info')); ?> | <a href="<?php echo ROOT_URL; ?>register.php"><?php echo htmlspecialchars(_('Register')); ?></a> | <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 htmlspecialchars(_('Info')); ?> | <a href="<?php echo ROOT_URL; ?>register.php"><?php echo htmlspecialchars(_('Register')); ?></a> | <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>
|
||||||
<h2><?php echo htmlspecialchars(_('What you will get')); ?></h2>
|
<h2><?php echo htmlspecialchars(_('What you will get')); ?></h2>
|
||||||
<p><?php printf(htmlspecialchars(_('You get a free anonymous E-Mail address and an XMPP/Jabber account using the same details. Your Jabber ID is user@%1$s and can be connected to directly from clearnet or via Tor hidden service (%2$s).')), CLEARNET_SERVER, ONION_SERVER); ?></p>
|
<p><?php printf(htmlspecialchars(_('You get a free anonymous E-Mail address and an XMPP/Jabber account using the same details. Your Jabber ID is user@%1$s and can be connected to directly from clearnet or via Tor hidden service (%2$s).')), CLEARNET_SERVER, ONION_SERVER); ?></p>
|
||||||
<p><?php printf(htmlspecialchars(_('You will have 50MB of disk space available for your mails. If you need more space, %1$s. Your E-Mail address will be %2$s')), '<a href="'.CONTACT_URL.'">'.htmlspecialchars(_('contact me')).'</a>', CLEARNET_SERVER); ?></p>
|
<p><?php printf(htmlspecialchars(_('You will have %1$s of disk space available for your mails. If you need more space, %2$s. Your E-Mail address will be %3$s')), bytes_to_human_readable(DEFAULT_QUOTA), '<a href="'.CONTACT_URL.'">'.htmlspecialchars(_('contact me')).'</a>', CLEARNET_SERVER); ?></p>
|
||||||
<p><?php printf(htmlspecialchars(_('For privacy, please use PGP mail encryption, if you can. This prevents others from reading your mails to protect your privacy. You can %1$s or similar software for it. Once you have generated your PGP key, you can %2$s to make use of WKD automatic discovery for mail clients.')), '<a href="https://gnupg.org/download/index.html" target="_blank" rel="noopener noreferrer">'.htmlspecialchars(_('download GnuPG')).'</a>', '<a href="manage_account.php">'.htmlspecialchars(_('add it to your account')).'</a>'); ?></p>
|
<p><?php printf(htmlspecialchars(_('For privacy, please use PGP mail encryption, if you can. This prevents others from reading your mails to protect your privacy. You can %1$s or similar software for it. Once you have generated your PGP key, you can %2$s to make use of WKD automatic discovery for mail clients.')), '<a href="https://gnupg.org/download/index.html" target="_blank" rel="noopener noreferrer">'.htmlspecialchars(_('download GnuPG')).'</a>', '<a href="manage_account.php">'.htmlspecialchars(_('add it to your account')).'</a>'); ?></p>
|
||||||
<p><?php printf(htmlspecialchars(_('You can choose between two Web-Mail clients installed on the server. %1$s is a very old mail client which works without any JavaScript and is thus the most popular mail client among darknet users. However, it hasn\'t been under development for many years and does not support all features that mail has to offer. You may see strange attachments that should have been inlined in your email, such as PGP/MIME encrypted email messages. A more modern client is %2$s, which also supports PGP encryption within your browser and is more similar to what you may be used to from other mail services. SnappyMail requires JavaScript though, so SquirrelMail is for you if you do not trust executing JavaScript in your browser. Alternatively, you can simply use your favourite desktop mail client and configure it with the settings given below.')), '<a href="squirrelmail/src/login.php">'.htmlspecialchars(_('SquirrelMail')).'</a>', '<a href="snappymail/">'.htmlspecialchars(_('SnappyMail')).'</a>'); ?></p>
|
<p><?php printf(htmlspecialchars(_('You can choose between two Web-Mail clients installed on the server. %1$s is a very old mail client which works without any JavaScript and is thus the most popular mail client among darknet users. However, it hasn\'t been under development for many years and does not support all features that mail has to offer. You may see strange attachments that should have been inlined in your email, such as PGP/MIME encrypted email messages. A more modern client is %2$s, which also supports PGP encryption within your browser and is more similar to what you may be used to from other mail services. SnappyMail requires JavaScript though, so SquirrelMail is for you if you do not trust executing JavaScript in your browser. Alternatively, you can simply use your favourite desktop mail client and configure it with the settings given below.')), '<a href="squirrelmail/src/login.php">'.htmlspecialchars(_('SquirrelMail')).'</a>', '<a href="snappymail/">'.htmlspecialchars(_('SnappyMail')).'</a>'); ?></p>
|
||||||
<h2><?php echo htmlspecialchars(_('E-Mail Setup')); ?></h2>
|
<h2><?php echo htmlspecialchars(_('E-Mail Setup')); ?></h2>
|
||||||
|
|
|
@ -69,8 +69,8 @@ if ( isset( $_POST[ 'user' ] ) ) {
|
||||||
$hash = password_hash( $_POST[ 'pwd' ], PASSWORD_ARGON2ID );
|
$hash = password_hash( $_POST[ 'pwd' ], PASSWORD_ARGON2ID );
|
||||||
$stmt = $db->prepare( 'INSERT INTO alias (address, goto, domain, created, modified) VALUES (?, ?, ?, NOW(), NOW());' );
|
$stmt = $db->prepare( 'INSERT INTO alias (address, goto, domain, created, modified) VALUES (?, ?, ?, NOW(), NOW());' );
|
||||||
$stmt->execute( [ "$user@$domain", "$user@$domain", $domain ] );
|
$stmt->execute( [ "$user@$domain", "$user@$domain", $domain ] );
|
||||||
$stmt = $db->prepare( 'INSERT INTO mailbox (username, password, quota, local_part, domain, created, modified, password_hash_type, openpgpkey_wkd) VALUES(?, ?, 51200000, ?, ?, NOW(), NOW(), ?, ?);' );
|
$stmt = $db->prepare( 'INSERT INTO mailbox (username, password, quota, local_part, domain, created, modified, password_hash_type, openpgpkey_wkd) VALUES(?, ?, ?, ?, ?, NOW(), NOW(), ?, ?);' );
|
||||||
$stmt->execute( [ "$user@$domain", $hash, $user, $domain, '{ARGON2ID}', z_base32_encode( hash( 'sha1', mb_strtolower( $user ), true ) ) ] );
|
$stmt->execute( [ "$user@$domain", $hash, DEFAULT_QUOTA, $user, $domain, '{ARGON2ID}', z_base32_encode( hash( 'sha1', mb_strtolower( $user ), true ) ) ] );
|
||||||
$msg .= '<div class="green" role="alert">'.htmlspecialchars(_('Successfully created new mailbox!')).'</div>';
|
$msg .= '<div class="green" role="alert">'.htmlspecialchars(_('Successfully created new mailbox!')).'</div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ global $language, $dir, $locale;
|
||||||
<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(_('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 has %1$s of disk space by default. If you need more, you can %2$s, and I will increase it for free.')), bytes_to_human_readable(DEFAULT_QUOTA), '<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>
|
||||||
|
|
Loading…
Reference in a new issue