[Web] Autodiscover returns given password decoded and trimed; Add sieve pre and post filters to UI; Move ajax called files; Rework log system: 100 entries per default, add more per click; Syncjobs: Do not read log to data attribute

This commit is contained in:
André
2017-11-03 20:37:24 +01:00
parent 1ef10f1358
commit 85d1ee2f49
65 changed files with 3460 additions and 709 deletions

View File

@@ -878,15 +878,24 @@ function get_u2f_registrations($username) {
$sel->execute(array($username));
return $sel->fetchAll(PDO::FETCH_OBJ);
}
function get_logs($container, $lines = 100) {
function get_logs($container, $lines = false) {
if ($lines === false) {
$lines = $GLOBALS['LOG_LINES'] - 1;
}
global $lang;
global $redis;
if ($_SESSION['mailcow_cc_role'] != "admin") {
return false;
}
$lines = intval($lines);
if ($container == "dovecot-mailcow") {
if ($data = $redis->lRange('DOVECOT_MAILLOG', 0, $lines)) {
if (!is_numeric($lines)) {
list ($from, $to) = explode('-', $lines);
$data = $redis->lRange('DOVECOT_MAILLOG', intval($from), intval($to));
}
else {
$data = $redis->lRange('DOVECOT_MAILLOG', 0, intval($lines));
}
if ($data) {
foreach ($data as $json_line) {
$data_array[] = json_decode($json_line, true);
}
@@ -894,7 +903,14 @@ function get_logs($container, $lines = 100) {
}
}
if ($container == "postfix-mailcow") {
if ($data = $redis->lRange('POSTFIX_MAILLOG', 0, $lines)) {
if (!is_numeric($lines)) {
list ($from, $to) = explode('-', $lines);
$data = $redis->lRange('POSTFIX_MAILLOG', intval($from), intval($to));
}
else {
$data = $redis->lRange('POSTFIX_MAILLOG', 0, intval($lines));
}
if ($data) {
foreach ($data as $json_line) {
$data_array[] = json_decode($json_line, true);
}
@@ -902,7 +918,14 @@ function get_logs($container, $lines = 100) {
}
}
if ($container == "sogo-mailcow") {
if ($data = $redis->lRange('SOGO_LOG', 0, $lines)) {
if (!is_numeric($lines)) {
list ($from, $to) = explode('-', $lines);
$data = $redis->lRange('SOGO_LOG', intval($from), intval($to));
}
else {
$data = $redis->lRange('SOGO_LOG', 0, intval($lines));
}
if ($data) {
foreach ($data as $json_line) {
$data_array[] = json_decode($json_line, true);
}
@@ -910,7 +933,14 @@ function get_logs($container, $lines = 100) {
}
}
if ($container == "fail2ban-mailcow") {
if ($data = $redis->lRange('F2B_LOG', 0, $lines)) {
if (!is_numeric($lines)) {
list ($from, $to) = explode('-', $lines);
$data = $redis->lRange('F2B_LOG', intval($from), intval($to));
}
else {
$data = $redis->lRange('F2B_LOG', 0, intval($lines));
}
if ($data) {
foreach ($data as $json_line) {
$data_array[] = json_decode($json_line, true);
}
@@ -918,7 +948,14 @@ function get_logs($container, $lines = 100) {
}
}
if ($container == "autodiscover-mailcow") {
if ($data = $redis->lRange('AUTODISCOVER_LOG', 0, $lines)) {
if (!is_numeric($lines)) {
list ($from, $to) = explode('-', $lines);
$data = $redis->lRange('AUTODISCOVER_LOG', intval($from), intval($to));
}
else {
$data = $redis->lRange('AUTODISCOVER_LOG', 0, intval($lines));
}
if ($data) {
foreach ($data as $json_line) {
$data_array[] = json_decode($json_line, true);
}
@@ -927,10 +964,16 @@ function get_logs($container, $lines = 100) {
}
if ($container == "rspamd-history") {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL,"http://rspamd-mailcow:11334/history");
if (!is_numeric($lines)) {
list ($from, $to) = explode('-', $lines);
curl_setopt($curl, CURLOPT_URL,"http://rspamd-mailcow:11334/history?from=" . intval($from) . "&to=" . intval($to));
}
else {
curl_setopt($curl, CURLOPT_URL,"http://rspamd-mailcow:11334/history?to=" . intval($lines));
}
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$history = curl_exec($curl);
if (!curl_errno($ch)) {
if (!curl_errno($curl)) {
$data_array = json_decode($history, true);
curl_close($curl);
return $data_array['rows'];
@@ -940,4 +983,4 @@ function get_logs($container, $lines = 100) {
}
return false;
}
?>
?>