[Web, Dovecot] Show last IMAP and POP3 logins, toggle via vars.inc.php SHOW_LAST_LOGIN

master
andryyy 2020-04-13 20:34:39 +02:00
parent 7753a8324f
commit 59a2ea0959
No known key found for this signature in database
GPG Key ID: 8EC34FF2794E25EF
5 changed files with 31 additions and 15 deletions

View File

@ -359,7 +359,7 @@ plugin {
acl_shared_dict = file:/var/vmail/shared-mailboxes.db
acl = vfile
last_login_dict=</etc/dovecot/last_login
last_login_key = last-login/%u
last_login_key = last-login/%s/%u
fts = solr
fts_autoindex = yes
fts_solr = url=http://solr:8983/solr/dovecot-fts/

View File

@ -57,3 +57,7 @@ table tbody tr {
table tbody tr td input[type="checkbox"] {
cursor: pointer;
}
.label-last {
color: #c7254e !important;
background-color: #f9f2f4 !important;
}

View File

@ -3330,9 +3330,13 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
}
$mailboxdata = array();
$rl = ratelimit('get', 'mailbox', $_data);
$last_mail_login = $redis->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'];

View File

@ -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

View File

@ -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<B.length-1);return i.toFixed(1)+" "+B[e]}
function unix_time_format(i){return""==i?lang.no:new Date(i?1e3*i:0).toLocaleDateString(void 0,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}
$(".refresh_table").on('click', function(e) {
e.preventDefault();
var table_name = $(this).data('table');
@ -245,17 +246,11 @@ jQuery(function($){
"sortValue": function(value){
res = value.split("/");
return Number(res[0]);
},
},
{"name":"stats","style":{"whiteSpace":"nowrap"},"title":lang.stats,"formatter": function(value){
}},
{"name":"stats","sortable": false,"style":{"whiteSpace":"nowrap"},"title":lang.stats,"formatter": function(value){
res = value.split("/");
return '<span class="glyphicon glyphicon-file" aria-hidden="true"></span> ' + res[0] + ' / ' + humanFileSize(res[1]);
},
"sortValue": function(value){
res = value.split("/");
return Number(res[0]);
},
},
}},
{"name":"def_quota_for_mbox","title":lang.mailbox_defquota,"breakpoints":"xs sm md","style":{"width":"125px"}},
{"name":"max_quota_for_mbox","title":lang.mailbox_quota,"breakpoints":"xs sm","style":{"width":"125px"}},
{"name":"rl","title":"RL","breakpoints":"xs sm md lg","style":{"maxWidth":"100px","width":"100px"}},
@ -361,7 +356,16 @@ jQuery(function($){
{"name":"spam_aliases","filterable": false,"title":lang.spam_aliases,"breakpoints":"all"},
{"name":"tls_enforce_in","filterable": false,"title":lang.tls_enforce_in,"breakpoints":"all"},
{"name":"tls_enforce_out","filterable": false,"title":lang.tls_enforce_out,"breakpoints":"all"},
{"name":"last_mail_login","breakpoints":"xs sm","formatter":function unix_time_format(tm) { if (tm == '') { return lang.no; } else { var date = new Date(tm ? tm * 1000 : 0); return date.toLocaleDateString(undefined, {year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit"}); }},"title":lang.last_mail_login,"style":{"width":"170px"}},
{"name":"last_mail_login","breakpoints":"xs sm","title":lang.last_mail_login,"style":{"width":"170px"},
"sortValue": function(value){
res = value.split("/");
return Math.max(res[0], res[1]);
},
"formatter": function(value){
res = value.split("/");
return '<div class="label label-last">IMAP @ ' + unix_time_format(Number(res[0])) + '</div> ' +
'<div class="label label-last">POP3 @ ' + unix_time_format(Number(res[1])) + '</div>';
}},
{"name":"quarantine_notification","filterable": false,"title":lang.quarantine_notification,"breakpoints":"all"},
{"name":"in_use","filterable": false,"type":"html","title":lang.in_use,"sortValue": function(value){
return Number($(value).find(".progress-bar-mailbox").attr('aria-valuenow'));
@ -384,6 +388,7 @@ jQuery(function($){
$.each(data, function (i, item) {
item.quota = item.quota_used + "/" + item.quota;
item.max_quota_for_mbox = humanFileSize(item.max_quota_for_mbox);
item.last_mail_login = item.last_imap_login + '/' + item.last_pop3_login;
if (!item.rl) {
item.rl = '∞';
} else {