diff --git a/common_config.php b/common_config.php index 18ab453..e305f13 100644 --- a/common_config.php +++ b/common_config.php @@ -27,6 +27,7 @@ const DBUSER_PROSODY = 'prosody'; // Database user const DBPASS_PROSODY = 'YOUR_PASSWORD'; // Database password const DBNAME_PROSODY = 'prosody'; // Database const REGISTRATION_ENABLED = true; // Whether registration is enabled +const DEFAULT_QUOTA = 50 * 1024 * 1024; // Default mailbox quota in bytes const LANGUAGES = [ 'cs' => ['name' => 'čeština', 'locale' => 'cs_CZ', 'flag' => '🇨🇿', 'show_in_menu' => true, 'dir' => 'ltr'], @@ -351,3 +352,13 @@ function alt_links(): void echo ''; } } + +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]; + } +} \ No newline at end of file diff --git a/www/admin.php b/www/admin.php index ecfddbc..8b92edb 100644 --- a/www/admin.php +++ b/www/admin.php @@ -289,12 +289,11 @@ if ( $_SERVER[ 'REQUEST_METHOD' ] === 'POST' ) { $additional = preg_split( "/[\s,]+/", $_POST[ 'alias_to' ] ); $alias_goto .= validate_email_list( $additional, $msg ); } - $quota = 1024 * 1024 * 1024; $alias_goto = rtrim( $alias_goto, ',' ); $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 = $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 .= '
'.htmlspecialchars(_('contact me')).'', CLEARNET_SERVER); ?>
+'.htmlspecialchars(_('contact me')).'', CLEARNET_SERVER); ?>
'.htmlspecialchars(_('download GnuPG')).'', ''.htmlspecialchars(_('add it to your account')).''); ?>
'.htmlspecialchars(_('SquirrelMail')).'', ''.htmlspecialchars(_('SnappyMail')).''); ?>
diff --git a/www/register.php b/www/register.php index 880ae34..e0a070d 100644 --- a/www/register.php +++ b/www/register.php @@ -69,8 +69,8 @@ if ( isset( $_POST[ 'user' ] ) ) { $hash = password_hash( $_POST[ 'pwd' ], PASSWORD_ARGON2ID ); $stmt = $db->prepare( 'INSERT INTO alias (address, goto, domain, created, modified) VALUES (?, ?, ?, NOW(), NOW());' ); $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->execute( [ "$user@$domain", $hash, $user, $domain, '{ARGON2ID}', z_base32_encode( hash( 'sha1', mb_strtolower( $user ), true ) ) ] ); + $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, DEFAULT_QUOTA, $user, $domain, '{ARGON2ID}', z_base32_encode( hash( 'sha1', mb_strtolower( $user ), true ) ) ] ); $msg .= '