From 59a2ea095972112f6b9317fedeacf5d551592b76 Mon Sep 17 00:00:00 2001 From: andryyy Date: Mon, 13 Apr 2020 20:34:39 +0200 Subject: [PATCH] [Web, Dovecot] Show last IMAP and POP3 logins, toggle via vars.inc.php SHOW_LAST_LOGIN --- data/conf/dovecot/dovecot.conf | 2 +- data/web/css/site/mailbox.css | 4 ++++ data/web/inc/functions.mailbox.inc.php | 13 +++++++++---- data/web/inc/vars.inc.php | 2 ++ data/web/js/site/mailbox.js | 25 +++++++++++++++---------- 5 files changed, 31 insertions(+), 15 deletions(-) diff --git a/data/conf/dovecot/dovecot.conf b/data/conf/dovecot/dovecot.conf index 8f8d9f2e..5285d9c1 100644 --- a/data/conf/dovecot/dovecot.conf +++ b/data/conf/dovecot/dovecot.conf @@ -359,7 +359,7 @@ plugin { acl_shared_dict = file:/var/vmail/shared-mailboxes.db acl = vfile last_login_dict=Get('last-login/' . $_data); - if ($last_mail_login === false) { - $last_mail_login = ''; + $last_imap_login = $redis->Get('last-login/imap/' . $_data); + $last_pop3_login = $redis->Get('last-login/pop3/' . $_data); + if ($last_imap_login === false || $GLOBALS['SHOW_LAST_LOGIN'] === false) { + $last_imap_login = '0'; + } + if ($last_pop3_login === false || $GLOBALS['SHOW_LAST_LOGIN'] === false) { + $last_pop3_login = '0'; } if (preg_match('/y|yes/i', getenv('MASTER'))) { $stmt = $pdo->prepare("SELECT @@ -3397,7 +3401,8 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) { } $mailboxdata['is_relayed'] = $row['backupmx']; $mailboxdata['name'] = $row['name']; - $mailboxdata['last_mail_login'] = $last_mail_login; + $mailboxdata['last_imap_login'] = $last_imap_login; + $mailboxdata['last_pop3_login'] = $last_pop3_login; $mailboxdata['active'] = $row['active']; $mailboxdata['active_int'] = $row['active_int']; $mailboxdata['domain'] = $row['domain']; diff --git a/data/web/inc/vars.inc.php b/data/web/inc/vars.inc.php index 45675d11..95adcfff 100644 --- a/data/web/inc/vars.inc.php +++ b/data/web/inc/vars.inc.php @@ -157,6 +157,8 @@ $MAILBOX_DEFAULT_ATTRIBUTES['quarantine_notification'] = 'hourly'; // Check dovecot.conf for further changes (e.g. shared namespace) $MAILBOX_DEFAULT_ATTRIBUTES['mailbox_format'] = 'maildir:'; +// Show last IMAP and POP3 logins +$SHOW_LAST_LOGIN = true; // Set visible Rspamd maps in mailcow UI, do not change unless you know what you are doing diff --git a/data/web/js/site/mailbox.js b/data/web/js/site/mailbox.js index 11976567..36c1b30d 100644 --- a/data/web/js/site/mailbox.js +++ b/data/web/js/site/mailbox.js @@ -204,6 +204,7 @@ jQuery(function($){ function escapeHtml(n){return String(n).replace(/[&<>"'`=\/]/g,function(n){return entityMap[n]})} // http://stackoverflow.com/questions/46155/validate-email-address-in-javascript function humanFileSize(i){if(Math.abs(i)<1024)return i+" B";var B=["KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],e=-1;do{i/=1024,++e}while(Math.abs(i)>=1024&&e