Implement Google FBL
This commit is contained in:
8 files changed
+113
-9
No files matched your search
+4
-3
@@ -398,8 +398,8 @@ if ( $_SERVER[ 'REQUEST_METHOD' ] === 'POST' ) {
|
||||
$alias_goto = rtrim( $alias_goto, ',' );
|
||||
$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 = $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, 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 ) ] );
|
||||
$stmt = $db->prepare( 'INSERT INTO mailbox (username, password, quota, local_part, domain, created, modified, password_hash_type, openpgpkey_wkd, feedback_id, enforce_tls_in, enforce_tls_out, active) VALUES(?, ?, ?, ?, ?, NOW(), NOW(), ?, ?, ?, ?, ?, ?);' );
|
||||
$stmt->execute( [ $email, $hash, DEFAULT_QUOTA, $user, $domain, '{ARGON2ID}', z_base32_encode( hash( 'sha1', mb_strtolower( $user ), true ) ), generate_feedback_id( $db ), ( 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>';
|
||||
}
|
||||
}
|
||||
@@ -1171,13 +1171,14 @@ function send_new_mailbox(): void
|
||||
function send_edit_mailbox(): void
|
||||
{
|
||||
$db = get_db_instance();
|
||||
$stmt = $db->prepare( 'SELECT a.goto, m.active, m.enforce_tls_in, m.enforce_tls_out, m.inactivity_period, m.spam_reject_score, m.blocked_senders, m.whitelisted_senders FROM alias AS a INNER JOIN mailbox AS m ON (m.username=a.address) WHERE m.username = ?;' );
|
||||
$stmt = $db->prepare( 'SELECT a.goto, m.active, m.enforce_tls_in, m.enforce_tls_out, m.inactivity_period, m.spam_reject_score, m.blocked_senders, m.whitelisted_senders, m.feedback_id FROM alias AS a INNER JOIN mailbox AS m ON (m.username=a.address) WHERE m.username = ?;' );
|
||||
$stmt->execute( [ $_REQUEST[ 'user' ] ] );
|
||||
if ( $email = $stmt->fetch( PDO::FETCH_ASSOC ) ) {
|
||||
$aliases = explode( ',', $email[ 'goto' ] );
|
||||
$aliases_to = implode( "\n", array_diff( $aliases, [ $_REQUEST[ 'user' ] ] ) );
|
||||
?>
|
||||
<h2><?php printf(htmlspecialchars(_('Edit mailbox %s')), htmlspecialchars( $_REQUEST[ 'user' ] ) ); ?></h2>
|
||||
<p><?php echo htmlspecialchars(_('Google Feedback Loop ID')); ?>: <code>:::<?php echo htmlspecialchars( $email[ 'feedback_id' ] ); ?></code></p>
|
||||
<form class="form_limit" action="admin.php" method="post">
|
||||
<input type="hidden" name="csrf_token" value="<?php echo $_SESSION[ 'csrf_token' ]; ?>">
|
||||
<input type="hidden" name="user" value="<?php echo htmlspecialchars( $_REQUEST[ 'user' ] ); ?>">
|
||||
|
||||
+2
-3
@@ -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(?, ?, ?, ?, ?, NOW(), NOW(), ?, ?);' );
|
||||
$stmt->execute( [ "$user@$domain", $hash, DEFAULT_QUOTA, $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, feedback_id) VALUES(?, ?, ?, ?, ?, NOW(), NOW(), ?, ?, ?);' );
|
||||
$stmt->execute( [ "$user@$domain", $hash, DEFAULT_QUOTA, $user, $domain, '{ARGON2ID}', z_base32_encode( hash( 'sha1', mb_strtolower( $user ), true ) ), generate_feedback_id( $db ) ] );
|
||||
$msg .= '<div class="green" role="alert">'.htmlspecialchars(_('Successfully created new mailbox!')).'</div>';
|
||||
}
|
||||
}
|
||||
@@ -135,4 +135,3 @@ if( ! REGISTRATION_ENABLED ) {
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
require_once( '../common_config.php' );
|
||||
|
||||
header( 'Content-Type: text/plain; charset=utf-8' );
|
||||
header( 'Cache-Control: no-store' );
|
||||
header( 'Expires: 600' );
|
||||
|
||||
$token = $_GET[ 'token' ] ?? '';
|
||||
if ( ! in_array( $_SERVER[ 'REQUEST_METHOD' ], [ 'GET', 'HEAD' ], true ) || ! hash_equals( RSPAMD_SETTINGS_MAP_TOKEN, $token ) ) {
|
||||
http_response_code( 403 );
|
||||
exit;
|
||||
}
|
||||
|
||||
$db = get_db_instance();
|
||||
$stmt = $db->query( 'SELECT username, feedback_id FROM mailbox WHERE active = 1;' );
|
||||
while ( $mailbox = $stmt->fetch( PDO::FETCH_ASSOC ) ) {
|
||||
if ( ! preg_match( '/^[a-f0-9]{5,15}$/', $mailbox[ 'feedback_id' ] ) ) {
|
||||
http_response_code( 500 );
|
||||
error_log( 'Invalid Google Feedback Loop ID for mailbox ' . $mailbox[ 'username' ] );
|
||||
exit;
|
||||
}
|
||||
echo mb_strtolower( $mailbox[ 'username' ] ) . "\t" . $mailbox[ 'feedback_id' ] . "\n";
|
||||
}
|
||||
Reference in new issue
Block a user