[Web] Allow spam/ham "traps"

[Web] Changes to docker functions
[Web] List all containers of compose project name
master
André 2018-07-29 00:38:22 +02:00
parent 15b80760b2
commit 8934a3a68b
13 changed files with 162 additions and 245 deletions

View File

@ -32,7 +32,7 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
<?php
$exec_fields = array('cmd' => 'df', 'dir' => '/var/vmail');
$vmail_df = explode(',', json_decode(docker('dovecot-mailcow', 'post', 'exec', $exec_fields), true));
$vmail_df = explode(',', json_decode(docker('post', 'dovecot-mailcow', 'exec', $exec_fields), true));
?>
<div role="tabpanel" class="tab-pane active" id="tab-containers">
<div class="panel panel-default">
@ -60,52 +60,35 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
<div class="panel-body">
<ul class="list-group">
<?php
$container_array = array(
'nginx-mailcow',
'rspamd-mailcow',
'postfix-mailcow',
'dovecot-mailcow',
'sogo-mailcow',
'acme-mailcow',
'memcached-mailcow',
'watchdog-mailcow',
'unbound-mailcow',
'redis-mailcow',
'php-fpm-mailcow',
'mysql-mailcow',
'netfilter-mailcow',
'clamd-mailcow'
);
$container_states = (docker($container, 'states'));
foreach ($container_array as $container) {
$container_state = $container_states[$container];
?>
<li class="list-group-item">
<?=$container;?>
<?php
date_default_timezone_set('UTC');
$StartedAt = date_parse($container_state['StartedAt']);
if ($StartedAt['hour'] !== false) {
$date = new \DateTime();
$date->setTimestamp(mktime(
$StartedAt['hour'],
$StartedAt['minute'],
$StartedAt['second'],
$StartedAt['month'],
$StartedAt['day'],
$StartedAt['year']));
$user_tz = new DateTimeZone(getenv('TZ'));
$date->setTimezone($user_tz);
$started = $date->format('r');
}
else {
$started = '?';
}
?>
<small>(Started on <?=$started;?>),
<a href data-toggle="modal" data-container="<?=$container;?>" data-target="#RestartContainer">Restart</a></small>
<span class="pull-right label label-<?=($container_state !== false && !empty($container_state)) ? (($container_state['Running'] == 1) ? 'success' : 'danger') : 'default'; ?>">&nbsp;&nbsp;&nbsp;</span>
</li>
$containers = (docker('info'));
foreach ($containers as $container => $container_info) {
?>
<li class="list-group-item">
<?=$container . ' (' . $container_info['Config']['Image'] . ')';?>
<?php
date_default_timezone_set('UTC');
$StartedAt = date_parse($container_info['State']['StartedAt']);
if ($StartedAt['hour'] !== false) {
$date = new \DateTime();
$date->setTimestamp(mktime(
$StartedAt['hour'],
$StartedAt['minute'],
$StartedAt['second'],
$StartedAt['month'],
$StartedAt['day'],
$StartedAt['year']));
$user_tz = new DateTimeZone(getenv('TZ'));
$date->setTimezone($user_tz);
$started = $date->format('r');
}
else {
$started = '?';
}
?>
<small>(Started on <?=$started;?>),
<a href data-toggle="modal" data-container="<?=$container;?>" data-target="#RestartContainer">Restart</a></small>
<span class="pull-right label label-<?=($container_info['State'] !== false && !empty($container_info['State'])) ? (($container_info['State']['Running'] == 1) ? 'success' : 'danger') : 'default'; ?>">&nbsp;&nbsp;&nbsp;</span>
</li>
<?php
}
?>

View File

@ -31,9 +31,15 @@ if (isset($_SESSION['mailcow_cc_role'])) {
<div class="form-group">
<label class="control-label col-sm-2" for="goto"><?=$lang['edit']['target_address'];?></label>
<div class="col-sm-10">
<textarea id="textarea_alias_goto" class="form-control" autocapitalize="none" autocorrect="off" rows="10" id="goto" name="goto" required><?= ($result['goto'] != "null@localhost") ? htmlspecialchars($result['goto']) : null; ?></textarea>
<textarea id="textarea_alias_goto" class="form-control" autocapitalize="none" autocorrect="off" rows="10" id="goto" name="goto" required><?= (!preg_match('/^(null|ham|spam)@localhost$/i', $result['goto'])) ? htmlspecialchars($result['goto']) : null; ?></textarea>
<div class="checkbox">
<label><input id="goto_null" type="checkbox" value="1" name="goto_null" <?= ($result['goto'] == "null@localhost") ? "checked" : null; ?>> <?=$lang['add']['goto_null'];?></label>
<label><input class="goto_checkbox"id="goto_null" type="checkbox" value="1" name="goto_null" <?= ($result['goto'] == "null@localhost") ? "checked" : null; ?>> <?=$lang['add']['goto_null'];?></label>
</div>
<div class="checkbox">
<label><input class="goto_checkbox" id="goto_spam" type="checkbox" value="1" name="goto_spam" <?= ($result['goto'] == "spam@localhost") ? "checked" : null; ?>> <?=$lang['add']['goto_spam'];?></label>
</div>
<div class="checkbox">
<label><input class="goto_checkbox" id="goto_ham" type="checkbox" value="1" name="goto_ham" <?= ($result['goto'] == "ham@localhost") ? "checked" : null; ?>> <?=$lang['add']['goto_ham'];?></label>
</div>
</div>
</div>

View File

@ -9,8 +9,8 @@ if (preg_match('/^[a-z\-]{0,}-mailcow/', $_GET['service'])) {
if ($_GET['action'] == "start") {
header('Content-Type: text/html; charset=utf-8');
$retry = 0;
while (docker($_GET['service'], 'info')['State']['Running'] != 1 && $retry <= 3) {
$response = docker($_GET['service'], 'post', 'start');
while (docker('info', $_GET['service'])['State']['Running'] != 1 && $retry <= 3) {
$response = docker('post', $_GET['service'], 'start');
$response = json_decode($response, true);
$last_response = ($response['type'] == "success") ? '<b><span class="pull-right text-success">OK</span></b>' : '<b><span class="pull-right text-danger">Error: ' . $response['msg'] . '</span></b>';
if ($response['type'] == "success") {
@ -24,8 +24,8 @@ if (preg_match('/^[a-z\-]{0,}-mailcow/', $_GET['service'])) {
if ($_GET['action'] == "stop") {
header('Content-Type: text/html; charset=utf-8');
$retry = 0;
while (docker($_GET['service'], 'info')['State']['Running'] == 1 && $retry <= 3) {
$response = docker($_GET['service'], 'post', 'stop');
while (docker('info', $_GET['service'])['State']['Running'] == 1 && $retry <= 3) {
$response = docker('post', $_GET['service'], 'stop');
$response = json_decode($response, true);
$last_response = ($response['type'] == "success") ? '<b><span class="pull-right text-success">OK</span></b>' : '<b><span class="pull-right text-danger">Error: ' . $response['msg'] . '</span></b>';
if ($response['type'] == "success") {
@ -38,7 +38,7 @@ if (preg_match('/^[a-z\-]{0,}-mailcow/', $_GET['service'])) {
}
if ($_GET['action'] == "restart") {
header('Content-Type: text/html; charset=utf-8');
$response = docker($_GET['service'], 'post', 'restart');
$response = docker('post', $_GET['service'], 'restart');
$response = json_decode($response, true);
$last_response = ($response['type'] == "success") ? '<b><span class="pull-right text-success">OK</span></b>' : '<b><span class="pull-right text-danger">Error: ' . $response['msg'] . '</span></b>';
echo (!isset($last_response)) ? '<b><span class="pull-right text-warning">Cannot restart container</span></b>' : $last_response;
@ -46,7 +46,7 @@ if (preg_match('/^[a-z\-]{0,}-mailcow/', $_GET['service'])) {
if ($_GET['action'] == "logs") {
$lines = (empty($_GET['lines']) || !is_numeric($_GET['lines'])) ? 1000 : $_GET['lines'];
header('Content-Type: text/plain; charset=utf-8');
print_r(preg_split('/\n/', docker($_GET['service'], 'logs', $lines)));
print_r(preg_split('/\n/', docker('logs', $_GET['service'], $lines)));
}
}

View File

@ -1,5 +1,5 @@
<?php
function docker($service_name, $action, $attr1 = null, $attr2 = null, $extra_headers = null) {
function docker($action, $service_name = null, $attr1 = null, $attr2 = null, $extra_headers = null) {
global $DOCKER_TIMEOUT;
$curl = curl_init();
curl_setopt($curl, CURLOPT_HTTPHEADER,array( 'Content-Type: application/json' ));
@ -20,14 +20,15 @@ function docker($service_name, $action, $attr1 = null, $attr2 = null, $extra_hea
$containers = json_decode($response, true);
if (!empty($containers)) {
foreach ($containers as $container) {
if ($container['Config']['Labels']['com.docker.compose.service'] == $service_name) {
if ($container['Config']['Labels']['com.docker.compose.service'] == $service_name
&& $container['Config']['Labels']['com.docker.compose.project'] == getenv('COMPOSE_PROJECT_NAME')) {
return trim($container['Id']);
}
}
}
}
return false;
case 'states':
case 'containers':
curl_setopt($curl, CURLOPT_URL, 'http://dockerapi:8080/containers/json');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 0);
@ -43,7 +44,10 @@ function docker($service_name, $action, $attr1 = null, $attr2 = null, $extra_hea
$containers = json_decode($response, true);
if (!empty($containers)) {
foreach ($containers as $container) {
$out[$container['Config']['Labels']['com.docker.compose.service']] = $container['State'];
if ($container['Config']['Labels']['com.docker.compose.project'] == getenv('COMPOSE_PROJECT_NAME')) {
$out[$container['Config']['Labels']['com.docker.compose.service']]['State'] = $container['State'];
$out[$container['Config']['Labels']['com.docker.compose.service']]['Config'] = $container['Config'];
}
}
}
return (!empty($out)) ? $out : false;
@ -51,35 +55,62 @@ function docker($service_name, $action, $attr1 = null, $attr2 = null, $extra_hea
return false;
break;
case 'info':
$container_id = docker($service_name, 'get_id');
if (ctype_xdigit($container_id)) {
curl_setopt($curl, CURLOPT_URL, 'http://dockerapi:8080/containers/' . $container_id . '/json');
if (empty($service_name)) {
curl_setopt($curl, CURLOPT_URL, 'http://dockerapi:8080/containers/json');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 0);
curl_setopt($curl, CURLOPT_TIMEOUT, $DOCKER_TIMEOUT);
$response = curl_exec($curl);
if ($response === false) {
$err = curl_error($curl);
curl_close($curl);
return $err;
}
else {
curl_close($curl);
if (empty($response)) {
return true;
}
else {
return json_decode($response, true);
}
}
}
else {
return false;
$container_id = docker('get_id', $service_name);
if (ctype_xdigit($container_id)) {
curl_setopt($curl, CURLOPT_URL, 'http://dockerapi:8080/containers/' . $container_id . '/json');
}
else {
return false;
}
}
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 0);
curl_setopt($curl, CURLOPT_TIMEOUT, $DOCKER_TIMEOUT);
$response = curl_exec($curl);
if ($response === false) {
$err = curl_error($curl);
curl_close($curl);
return $err;
}
else {
curl_close($curl);
$decoded_response = json_decode($response, true);
if (!empty($decoded_response)) {
if (empty($service_name)) {
foreach ($decoded_response as $container) {
if ($container['Config']['Labels']['com.docker.compose.project'] == getenv('COMPOSE_PROJECT_NAME')) {
unset($container['Config']['Env']);
$out[$container['Config']['Labels']['com.docker.compose.service']]['State'] = $container['State'];
$out[$container['Config']['Labels']['com.docker.compose.service']]['Config'] = $container['Config'];
}
}
}
else {
if ($decoded_response['Config']['Labels']['com.docker.compose.project'] == getenv('COMPOSE_PROJECT_NAME')) {
unset($container['Config']['Env']);
$out[$decoded_response['Config']['Labels']['com.docker.compose.service']]['State'] = $decoded_response['State'];
$out[$decoded_response['Config']['Labels']['com.docker.compose.service']]['Config'] = $decoded_response['Config'];
}
}
}
if (empty($response)) {
return true;
}
else {
return (!empty($out)) ? $out : false;
}
}
break;
case 'post':
if (!empty($attr1)) {
$container_id = docker($service_name, 'get_id');
$container_id = docker('get_id', $service_name);
if (ctype_xdigit($container_id) && ctype_alnum($attr1)) {
curl_setopt($curl, CURLOPT_URL, 'http://dockerapi:8080/containers/' . $container_id . '/' . $attr1);
curl_setopt($curl, CURLOPT_POST, 1);

View File

@ -1010,7 +1010,7 @@ function rspamd_ui($action, $data = null) {
);
return false;
}
$docker_return = docker('rspamd-mailcow', 'post', 'exec', array('cmd' => 'worker_password', 'raw' => $rspamd_ui_pass), array('Content-Type: application/json'));
$docker_return = docker('post', 'rspamd-mailcow', 'exec', array('cmd' => 'worker_password', 'raw' => $rspamd_ui_pass), array('Content-Type: application/json'));
if ($docker_return_array = json_decode($docker_return, true)) {
if ($docker_return_array['type'] == 'success') {
$_SESSION['return'] = array(

View File

@ -414,10 +414,10 @@ function mailbox($_action, $_type, $_data = null, $attr = null) {
);
return false;
}
if ($domain == $MAILCOW_HOSTNAME) {
if ($domain == getenv('MAILCOW_HOSTNAME')) {
$_SESSION['return'] = array(
'type' => 'danger',
'msg' => sprintf($lang['danger']['domain_matches_hostname'], htmlspecialchars($domain))
'msg' => 'Domain cannot match hostname'
);
return false;
}
@ -446,7 +446,7 @@ function mailbox($_action, $_type, $_data = null, $attr = null) {
return false;
}
if (!empty($restart_sogo)) {
$restart_reponse = json_decode(docker('sogo-mailcow', 'post', 'restart'), true);
$restart_reponse = json_decode(docker('post', 'sogo-mailcow', 'restart'), true);
if ($restart_reponse['type'] == "success") {
$_SESSION['return'] = array(
'type' => 'success',
@ -475,6 +475,8 @@ function mailbox($_action, $_type, $_data = null, $attr = null) {
$gotos = array_map('trim', preg_split( "/( |,|;|\n)/", $_data['goto']));
$active = intval($_data['active']);
$goto_null = intval($_data['goto_null']);
$goto_spam = intval($_data['goto_spam']);
$goto_ham = intval($_data['goto_ham']);
if (empty($addresses[0])) {
$_SESSION['return'] = array(
'type' => 'danger',
@ -492,6 +494,12 @@ function mailbox($_action, $_type, $_data = null, $attr = null) {
if ($goto_null == "1") {
$goto = "null@localhost";
}
elseif ($goto_spam == "1") {
$goto = "spam@localhost";
}
elseif ($goto_ham == "1") {
$goto = "ham@localhost";
}
else {
foreach ($gotos as &$goto) {
if (empty($goto)) {
@ -1714,6 +1722,8 @@ function mailbox($_action, $_type, $_data = null, $attr = null) {
if (!empty($is_now)) {
$active = (isset($_data['active'])) ? intval($_data['active']) : $is_now['active_int'];
$goto_null = (isset($_data['goto_null'])) ? intval($_data['goto_null']) : $is_now['goto_null'];
$goto_spam = (isset($_data['goto_spam'])) ? intval($_data['goto_spam']) : $is_now['goto_spam'];
$goto_ham = (isset($_data['goto_ham'])) ? intval($_data['goto_ham']) : $is_now['goto_ham'];
$goto = (!empty($_data['goto'])) ? $_data['goto'] : $is_now['goto'];
}
else {
@ -1726,6 +1736,12 @@ function mailbox($_action, $_type, $_data = null, $attr = null) {
if ($goto_null == "1") {
$goto = "null@localhost";
}
elseif ($goto_spam == "1") {
$goto = "spam@localhost";
}
elseif ($goto_ham == "1") {
$goto = "ham@localhost";
}
else {
$gotos = array_map('trim', preg_split( "/( |,|;|\n)/", $_data['goto']));
foreach ($gotos as &$goto) {
@ -2529,7 +2545,7 @@ function mailbox($_action, $_type, $_data = null, $attr = null) {
'cmd' => 'sieve_list',
'username' => $_data
);
$filters = json_decode(docker('dovecot-mailcow', 'post', 'exec', $exec_fields), true);
$filters = json_decode(docker('post', 'dovecot-mailcow', 'exec', $exec_fields), true);
$filters = array_filter(explode(PHP_EOL, $filters));
foreach ($filters as $filter) {
if (preg_match('/.+ ACTIVE/i', $filter)) {
@ -2538,7 +2554,7 @@ function mailbox($_action, $_type, $_data = null, $attr = null) {
'script_name' => substr($filter, 0, -7),
'username' => $_data
);
$filters = json_decode(docker('dovecot-mailcow', 'post', 'exec', $exec_fields), true);
$filters = json_decode(docker('post', 'dovecot-mailcow', 'exec', $exec_fields), true);
return preg_replace('/^.+\n/', '', $filters);
}
}

View File

@ -118,4 +118,5 @@ $OTP_LABEL = "mailcow UI";
$RELAY_TO = "null@hosted.mailcow.de";
// How long to wait (in s) for cURL Docker requests
$DOCKER_TIMEOUT = 60;
$DOCKER_TIMEOUT = 60;

View File

@ -1,15 +1,16 @@
$(document).ready(function() {
if ($("#goto_null").is(":checked")) {
$('#textarea_alias_goto').prop('disabled', true);
}
$("#goto_null").click(function( event ) {
if ($("#goto_null").is(":checked")) {
$(".goto_checkbox").click(function( event ) {
$("form[data-id='editalias'] .goto_checkbox").not(this).prop('checked', false);
if ($("form[data-id='editalias'] .goto_checkbox:checked").length > 0) {
$('#textarea_alias_goto').prop('disabled', true);
}
else {
$("#textarea_alias_goto").removeAttr('disabled');
}
});
if ($("form[data-id='editalias'] .goto_checkbox:checked").length > 0) {
$('#textarea_alias_goto').prop('disabled', true);
}
$("#script_data").numberedtextarea({allowTabChar: true});
});
if ($("#multiple_bookings_select").val() == "custom") {

View File

@ -89,8 +89,17 @@ $(document).ready(function() {
$('#password2').val(random_passwd);
});
$("#goto_null").click(function( event ) {
if ($("#goto_null").is(":checked")) {
$(".goto_checkbox").click(function( event ) {
$("form[data-id='add_alias'] .goto_checkbox").not(this).prop('checked', false);
if ($("form[data-id='add_alias'] .goto_checkbox:checked").length > 0) {
$('#textarea_alias_goto').prop('disabled', true);
}
else {
$("#textarea_alias_goto").removeAttr('disabled');
}
});
$('#addAliasModal').on('show.bs.modal', function(e) {
if ($("form[data-id='add_alias'] .goto_checkbox:checked").length > 0) {
$('#textarea_alias_goto').prop('disabled', true);
}
else {
@ -616,6 +625,12 @@ jQuery(function($){
if (item.goto == "null@localhost") {
item.goto = '⤷ <span style="font-size:12px" class="glyphicon glyphicon-trash" aria-hidden="true"></span>';
}
else if (item.goto == "spam@localhost") {
item.goto = '<span class="label label-danger">Learn as spam</span>';
}
else if (item.goto == "ham@localhost") {
item.goto = '<span class="label label-success">Learn as ham</span>';
}
if (item.in_primary_domain !== "") {
item.domain = "↳ " + item.domain + " (" + item.in_primary_domain + ")";
}

View File

@ -167,7 +167,9 @@ if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_u
if ($data) {
$return = array();
$stats_array = json_decode($data, true)['actions'];
$stats_array['soft reject'] = $stats_array['soft reject'] + $stats_array['greylist'];
if (!empty($stats_array['soft reject']) || !empty($stats_array['greylist'])) {
$stats_array['soft reject'] = $stats_array['soft reject'] + $stats_array['greylist'];
}
unset($stats_array['greylist']);
foreach ($stats_array as $action => $count) {
$return[] = array($action, $count);
@ -178,154 +180,6 @@ if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_u
echo '{}';
}
break;
case "stat":
$data = file_get_contents('http://rspamd-mailcow:11334/stat');
process_get_return($data);
break;
case "graph":
switch ($extra) {
case "hourly":
$data = file_get_contents('http://rspamd-mailcow:11334/graph?type=hourly');
if (!empty($data)) {
$data_array = json_decode($data, true);
$rejected['label'] = "reject";
foreach ($data_array[0] as $dataset) {
$rejected['data'][] = $dataset;
}
$temp_reject['label'] = "temp_reject";
foreach ($data_array[1] as $dataset) {
$temp_reject['data'][] = $dataset;
}
$add_header['label'] = "add_header";
foreach ($data_array[2] as $dataset) {
$add_header['data'][] = $dataset;
}
$prob_spam['label'] = "prob_spam";
foreach ($data_array[3] as $dataset) {
$prob_spam['data'][] = $dataset;
}
$greylist['label'] = "greylist";
foreach ($data_array[4] as $dataset) {
$greylist['data'][] = $dataset;
}
$clean['label'] = "clean";
$clean['pointStyle'] = "cross";
foreach ($data_array[5] as $dataset) {
$clean['data'][] = $dataset;
}
echo json_encode(array($rejected, $temp_reject, $add_header, $prob_spam, $greylist, $clean), JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
}
elseif (!isset($data) || empty($data)) {
echo '{}';
}
break;
case "daily":
$data = file_get_contents('http://rspamd-mailcow:11334/graph?type=daily');
if (!empty($data)) {
$data_array = json_decode($data, true);
$rejected['label'] = "reject";
foreach ($data_array[0] as $dataset) {
$rejected['data'][] = $dataset;
}
$temp_reject['label'] = "temp_reject";
foreach ($data_array[1] as $dataset) {
$temp_reject['data'][] = $dataset;
}
$add_header['label'] = "add_header";
foreach ($data_array[2] as $dataset) {
$add_header['data'][] = $dataset;
}
$prob_spam['label'] = "prob_spam";
foreach ($data_array[3] as $dataset) {
$prob_spam['data'][] = $dataset;
}
$greylist['label'] = "greylist";
foreach ($data_array[4] as $dataset) {
$greylist['data'][] = $dataset;
}
$clean['label'] = "clean";
$clean['pointStyle'] = "cross";
foreach ($data_array[5] as $dataset) {
$clean['data'][] = $dataset;
}
echo json_encode(array($rejected, $temp_reject, $add_header, $prob_spam, $greylist, $clean), JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
}
elseif (!isset($data) || empty($data)) {
echo '{}';
}
break;
case "weekly":
$data = file_get_contents('http://rspamd-mailcow:11334/graph?type=weekly');
if (!empty($data)) {
$data_array = json_decode($data, true);
$rejected['label'] = "reject";
foreach ($data_array[0] as $dataset) {
$rejected['data'][] = $dataset;
}
$temp_reject['label'] = "temp_reject";
foreach ($data_array[1] as $dataset) {
$temp_reject['data'][] = $dataset;
}
$add_header['label'] = "add_header";
foreach ($data_array[2] as $dataset) {
$add_header['data'][] = $dataset;
}
$prob_spam['label'] = "prob_spam";
foreach ($data_array[3] as $dataset) {
$prob_spam['data'][] = $dataset;
}
$greylist['label'] = "greylist";
foreach ($data_array[4] as $dataset) {
$greylist['data'][] = $dataset;
}
$clean['label'] = "clean";
$clean['pointStyle'] = "cross";
foreach ($data_array[5] as $dataset) {
$clean['data'][] = $dataset;
}
echo json_encode(array($rejected, $temp_reject, $add_header, $prob_spam, $greylist, $clean), JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
}
elseif (!isset($data) || empty($data)) {
echo '{}';
}
break;
case "monthly":
$data = file_get_contents('http://rspamd-mailcow:11334/graph?type=monthly');
if (!empty($data)) {
$data_array = json_decode($data, true);
$rejected['label'] = "reject";
foreach ($data_array[0] as $dataset) {
$rejected['data'][] = $dataset;
}
$temp_reject['label'] = "temp_reject";
foreach ($data_array[1] as $dataset) {
$temp_reject['data'][] = $dataset;
}
$add_header['label'] = "add_header";
foreach ($data_array[2] as $dataset) {
$add_header['data'][] = $dataset;
}
$prob_spam['label'] = "prob_spam";
foreach ($data_array[3] as $dataset) {
$prob_spam['data'][] = $dataset;
}
$greylist['label'] = "greylist";
foreach ($data_array[4] as $dataset) {
$greylist['data'][] = $dataset;
}
$clean['label'] = "clean";
$clean['pointStyle'] = "cross";
foreach ($data_array[5] as $dataset) {
$clean['data'][] = $dataset;
}
echo json_encode(array($rejected, $temp_reject, $add_header, $prob_spam, $greylist, $clean), JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
}
elseif (!isset($data) || empty($data)) {
echo '{}';
}
break;
}
break;
}
break;
case "domain":

View File

@ -339,6 +339,8 @@ $lang['add']['password'] = 'Passwort';
$lang['add']['password_repeat'] = 'Passwort (Wiederholung)';
$lang['add']['restart_sogo_hint'] = 'Der SOGo Container muss nach dem Hinzufügen einer neuen Domain neugestartet werden!';
$lang['add']['goto_null'] = 'Nachrichten sofort verwerfen';
$lang['add']['goto_ham'] = 'Nachrichten als <span class="text-success"><b>Ham</b></span> lernen';
$lang['add']['goto_spam'] = 'Nachrichten als <span class="text-danger"><b>Spam</b></span> lernen';
$lang['add']['validation_success'] = 'Erfolgreich validiert';
$lang['add']['activate_filter_warn'] = 'Alle anderen Filter diesen Typs werden deaktiviert, falls dieses Script aktiv markiert wird.';
$lang['add']['validate'] = 'Validieren';

View File

@ -344,6 +344,8 @@ $lang['add']['password'] = 'Password';
$lang['add']['password_repeat'] = 'Confirmation password (repeat)';
$lang['add']['restart_sogo_hint'] = 'You will need to restart the SOGo service container after adding a new domain!';
$lang['add']['goto_null'] = 'Silently discard mail';
$lang['add']['goto_ham'] = 'Learn as <span class="text-success"><b>ham</b></span>';
$lang['add']['goto_spam'] = 'Learn as <span class="text-danger"><b>spam</b></span>';
$lang['add']['validation_success'] = 'Validated successfully';
$lang['add']['activate_filter_warn'] = 'All other filters will be deactivated, when active is checked.';
$lang['add']['validate'] = 'Validate';

View File

@ -245,10 +245,16 @@ if (!isset($_SESSION['mailcow_cc_role'])) {
<label class="control-label col-sm-2" for="goto"><?=$lang['add']['target_address'];?></label>
<div class="col-sm-10">
<textarea id="textarea_alias_goto" autocorrect="off" autocapitalize="none" class="form-control" rows="5" id="goto" name="goto" required></textarea>
<div class="checkbox">
<label><input id="goto_null" type="checkbox" value="1" name="goto_null"> <?=$lang['add']['goto_null'];?></label>
</div>
<p><?=$lang['add']['target_address_info'];?></p>
<div class="checkbox">
<label><input class="goto_checkbox" id="goto_null" type="checkbox" value="1" name="goto_null"> <?=$lang['add']['goto_null'];?></label>
</div>
<div class="checkbox">
<label><input class="goto_checkbox" id="goto_spam" type="checkbox" value="1" name="goto_spam"> <?=$lang['add']['goto_spam'];?></label>
</div>
<div class="checkbox">
<label><input class="goto_checkbox" id="goto_ham" type="checkbox" value="1" name="goto_ham"> <?=$lang['add']['goto_ham'];?></label>
</div>
</div>
</div>
<div class="form-group">