[Web] Allow spam/ham "traps"
[Web] Changes to docker functions [Web] List all containers of compose project namemaster
parent
15b80760b2
commit
8934a3a68b
|
@ -32,7 +32,7 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
$exec_fields = array('cmd' => 'df', 'dir' => '/var/vmail');
|
$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 role="tabpanel" class="tab-pane active" id="tab-containers">
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
|
@ -60,31 +60,14 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<ul class="list-group">
|
<ul class="list-group">
|
||||||
<?php
|
<?php
|
||||||
$container_array = array(
|
$containers = (docker('info'));
|
||||||
'nginx-mailcow',
|
foreach ($containers as $container => $container_info) {
|
||||||
'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">
|
<li class="list-group-item">
|
||||||
<?=$container;?>
|
<?=$container . ' (' . $container_info['Config']['Image'] . ')';?>
|
||||||
<?php
|
<?php
|
||||||
date_default_timezone_set('UTC');
|
date_default_timezone_set('UTC');
|
||||||
$StartedAt = date_parse($container_state['StartedAt']);
|
$StartedAt = date_parse($container_info['State']['StartedAt']);
|
||||||
if ($StartedAt['hour'] !== false) {
|
if ($StartedAt['hour'] !== false) {
|
||||||
$date = new \DateTime();
|
$date = new \DateTime();
|
||||||
$date->setTimestamp(mktime(
|
$date->setTimestamp(mktime(
|
||||||
|
@ -104,7 +87,7 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
|
||||||
?>
|
?>
|
||||||
<small>(Started on <?=$started;?>),
|
<small>(Started on <?=$started;?>),
|
||||||
<a href data-toggle="modal" data-container="<?=$container;?>" data-target="#RestartContainer">Restart</a></small>
|
<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'; ?>"> </span>
|
<span class="pull-right label label-<?=($container_info['State'] !== false && !empty($container_info['State'])) ? (($container_info['State']['Running'] == 1) ? 'success' : 'danger') : 'default'; ?>"> </span>
|
||||||
</li>
|
</li>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,9 +31,15 @@ if (isset($_SESSION['mailcow_cc_role'])) {
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-sm-2" for="goto"><?=$lang['edit']['target_address'];?></label>
|
<label class="control-label col-sm-2" for="goto"><?=$lang['edit']['target_address'];?></label>
|
||||||
<div class="col-sm-10">
|
<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">
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -9,8 +9,8 @@ if (preg_match('/^[a-z\-]{0,}-mailcow/', $_GET['service'])) {
|
||||||
if ($_GET['action'] == "start") {
|
if ($_GET['action'] == "start") {
|
||||||
header('Content-Type: text/html; charset=utf-8');
|
header('Content-Type: text/html; charset=utf-8');
|
||||||
$retry = 0;
|
$retry = 0;
|
||||||
while (docker($_GET['service'], 'info')['State']['Running'] != 1 && $retry <= 3) {
|
while (docker('info', $_GET['service'])['State']['Running'] != 1 && $retry <= 3) {
|
||||||
$response = docker($_GET['service'], 'post', 'start');
|
$response = docker('post', $_GET['service'], 'start');
|
||||||
$response = json_decode($response, true);
|
$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>';
|
$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") {
|
if ($response['type'] == "success") {
|
||||||
|
@ -24,8 +24,8 @@ if (preg_match('/^[a-z\-]{0,}-mailcow/', $_GET['service'])) {
|
||||||
if ($_GET['action'] == "stop") {
|
if ($_GET['action'] == "stop") {
|
||||||
header('Content-Type: text/html; charset=utf-8');
|
header('Content-Type: text/html; charset=utf-8');
|
||||||
$retry = 0;
|
$retry = 0;
|
||||||
while (docker($_GET['service'], 'info')['State']['Running'] == 1 && $retry <= 3) {
|
while (docker('info', $_GET['service'])['State']['Running'] == 1 && $retry <= 3) {
|
||||||
$response = docker($_GET['service'], 'post', 'stop');
|
$response = docker('post', $_GET['service'], 'stop');
|
||||||
$response = json_decode($response, true);
|
$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>';
|
$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") {
|
if ($response['type'] == "success") {
|
||||||
|
@ -38,7 +38,7 @@ if (preg_match('/^[a-z\-]{0,}-mailcow/', $_GET['service'])) {
|
||||||
}
|
}
|
||||||
if ($_GET['action'] == "restart") {
|
if ($_GET['action'] == "restart") {
|
||||||
header('Content-Type: text/html; charset=utf-8');
|
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);
|
$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>';
|
$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;
|
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") {
|
if ($_GET['action'] == "logs") {
|
||||||
$lines = (empty($_GET['lines']) || !is_numeric($_GET['lines'])) ? 1000 : $_GET['lines'];
|
$lines = (empty($_GET['lines']) || !is_numeric($_GET['lines'])) ? 1000 : $_GET['lines'];
|
||||||
header('Content-Type: text/plain; charset=utf-8');
|
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)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?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;
|
global $DOCKER_TIMEOUT;
|
||||||
$curl = curl_init();
|
$curl = curl_init();
|
||||||
curl_setopt($curl, CURLOPT_HTTPHEADER,array( 'Content-Type: application/json' ));
|
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);
|
$containers = json_decode($response, true);
|
||||||
if (!empty($containers)) {
|
if (!empty($containers)) {
|
||||||
foreach ($containers as $container) {
|
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 trim($container['Id']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
case 'states':
|
case 'containers':
|
||||||
curl_setopt($curl, CURLOPT_URL, 'http://dockerapi:8080/containers/json');
|
curl_setopt($curl, CURLOPT_URL, 'http://dockerapi:8080/containers/json');
|
||||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
||||||
curl_setopt($curl, CURLOPT_POST, 0);
|
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);
|
$containers = json_decode($response, true);
|
||||||
if (!empty($containers)) {
|
if (!empty($containers)) {
|
||||||
foreach ($containers as $container) {
|
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;
|
return (!empty($out)) ? $out : false;
|
||||||
|
@ -51,9 +55,21 @@ function docker($service_name, $action, $attr1 = null, $attr2 = null, $extra_hea
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
case 'info':
|
case 'info':
|
||||||
$container_id = docker($service_name, 'get_id');
|
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);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$container_id = docker('get_id', $service_name);
|
||||||
if (ctype_xdigit($container_id)) {
|
if (ctype_xdigit($container_id)) {
|
||||||
curl_setopt($curl, CURLOPT_URL, 'http://dockerapi:8080/containers/' . $container_id . '/json');
|
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_RETURNTRANSFER, 1);
|
||||||
curl_setopt($curl, CURLOPT_POST, 0);
|
curl_setopt($curl, CURLOPT_POST, 0);
|
||||||
curl_setopt($curl, CURLOPT_TIMEOUT, $DOCKER_TIMEOUT);
|
curl_setopt($curl, CURLOPT_TIMEOUT, $DOCKER_TIMEOUT);
|
||||||
|
@ -65,21 +81,36 @@ function docker($service_name, $action, $attr1 = null, $attr2 = null, $extra_hea
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
curl_close($curl);
|
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)) {
|
if (empty($response)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return json_decode($response, true);
|
return (!empty($out)) ? $out : false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 'post':
|
case 'post':
|
||||||
if (!empty($attr1)) {
|
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)) {
|
if (ctype_xdigit($container_id) && ctype_alnum($attr1)) {
|
||||||
curl_setopt($curl, CURLOPT_URL, 'http://dockerapi:8080/containers/' . $container_id . '/' . $attr1);
|
curl_setopt($curl, CURLOPT_URL, 'http://dockerapi:8080/containers/' . $container_id . '/' . $attr1);
|
||||||
curl_setopt($curl, CURLOPT_POST, 1);
|
curl_setopt($curl, CURLOPT_POST, 1);
|
||||||
|
|
|
@ -1010,7 +1010,7 @@ function rspamd_ui($action, $data = null) {
|
||||||
);
|
);
|
||||||
return false;
|
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 = json_decode($docker_return, true)) {
|
||||||
if ($docker_return_array['type'] == 'success') {
|
if ($docker_return_array['type'] == 'success') {
|
||||||
$_SESSION['return'] = array(
|
$_SESSION['return'] = array(
|
||||||
|
|
|
@ -414,10 +414,10 @@ function mailbox($_action, $_type, $_data = null, $attr = null) {
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ($domain == $MAILCOW_HOSTNAME) {
|
if ($domain == getenv('MAILCOW_HOSTNAME')) {
|
||||||
$_SESSION['return'] = array(
|
$_SESSION['return'] = array(
|
||||||
'type' => 'danger',
|
'type' => 'danger',
|
||||||
'msg' => sprintf($lang['danger']['domain_matches_hostname'], htmlspecialchars($domain))
|
'msg' => 'Domain cannot match hostname'
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -446,7 +446,7 @@ function mailbox($_action, $_type, $_data = null, $attr = null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!empty($restart_sogo)) {
|
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") {
|
if ($restart_reponse['type'] == "success") {
|
||||||
$_SESSION['return'] = array(
|
$_SESSION['return'] = array(
|
||||||
'type' => 'success',
|
'type' => 'success',
|
||||||
|
@ -475,6 +475,8 @@ function mailbox($_action, $_type, $_data = null, $attr = null) {
|
||||||
$gotos = array_map('trim', preg_split( "/( |,|;|\n)/", $_data['goto']));
|
$gotos = array_map('trim', preg_split( "/( |,|;|\n)/", $_data['goto']));
|
||||||
$active = intval($_data['active']);
|
$active = intval($_data['active']);
|
||||||
$goto_null = intval($_data['goto_null']);
|
$goto_null = intval($_data['goto_null']);
|
||||||
|
$goto_spam = intval($_data['goto_spam']);
|
||||||
|
$goto_ham = intval($_data['goto_ham']);
|
||||||
if (empty($addresses[0])) {
|
if (empty($addresses[0])) {
|
||||||
$_SESSION['return'] = array(
|
$_SESSION['return'] = array(
|
||||||
'type' => 'danger',
|
'type' => 'danger',
|
||||||
|
@ -492,6 +494,12 @@ function mailbox($_action, $_type, $_data = null, $attr = null) {
|
||||||
if ($goto_null == "1") {
|
if ($goto_null == "1") {
|
||||||
$goto = "null@localhost";
|
$goto = "null@localhost";
|
||||||
}
|
}
|
||||||
|
elseif ($goto_spam == "1") {
|
||||||
|
$goto = "spam@localhost";
|
||||||
|
}
|
||||||
|
elseif ($goto_ham == "1") {
|
||||||
|
$goto = "ham@localhost";
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
foreach ($gotos as &$goto) {
|
foreach ($gotos as &$goto) {
|
||||||
if (empty($goto)) {
|
if (empty($goto)) {
|
||||||
|
@ -1714,6 +1722,8 @@ function mailbox($_action, $_type, $_data = null, $attr = null) {
|
||||||
if (!empty($is_now)) {
|
if (!empty($is_now)) {
|
||||||
$active = (isset($_data['active'])) ? intval($_data['active']) : $is_now['active_int'];
|
$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_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'];
|
$goto = (!empty($_data['goto'])) ? $_data['goto'] : $is_now['goto'];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1726,6 +1736,12 @@ function mailbox($_action, $_type, $_data = null, $attr = null) {
|
||||||
if ($goto_null == "1") {
|
if ($goto_null == "1") {
|
||||||
$goto = "null@localhost";
|
$goto = "null@localhost";
|
||||||
}
|
}
|
||||||
|
elseif ($goto_spam == "1") {
|
||||||
|
$goto = "spam@localhost";
|
||||||
|
}
|
||||||
|
elseif ($goto_ham == "1") {
|
||||||
|
$goto = "ham@localhost";
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
$gotos = array_map('trim', preg_split( "/( |,|;|\n)/", $_data['goto']));
|
$gotos = array_map('trim', preg_split( "/( |,|;|\n)/", $_data['goto']));
|
||||||
foreach ($gotos as &$goto) {
|
foreach ($gotos as &$goto) {
|
||||||
|
@ -2529,7 +2545,7 @@ function mailbox($_action, $_type, $_data = null, $attr = null) {
|
||||||
'cmd' => 'sieve_list',
|
'cmd' => 'sieve_list',
|
||||||
'username' => $_data
|
'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));
|
$filters = array_filter(explode(PHP_EOL, $filters));
|
||||||
foreach ($filters as $filter) {
|
foreach ($filters as $filter) {
|
||||||
if (preg_match('/.+ ACTIVE/i', $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),
|
'script_name' => substr($filter, 0, -7),
|
||||||
'username' => $_data
|
'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);
|
return preg_replace('/^.+\n/', '', $filters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,3 +119,4 @@ $RELAY_TO = "null@hosted.mailcow.de";
|
||||||
|
|
||||||
// How long to wait (in s) for cURL Docker requests
|
// How long to wait (in s) for cURL Docker requests
|
||||||
$DOCKER_TIMEOUT = 60;
|
$DOCKER_TIMEOUT = 60;
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
if ($("#goto_null").is(":checked")) {
|
$(".goto_checkbox").click(function( event ) {
|
||||||
$('#textarea_alias_goto').prop('disabled', true);
|
$("form[data-id='editalias'] .goto_checkbox").not(this).prop('checked', false);
|
||||||
}
|
if ($("form[data-id='editalias'] .goto_checkbox:checked").length > 0) {
|
||||||
$("#goto_null").click(function( event ) {
|
|
||||||
if ($("#goto_null").is(":checked")) {
|
|
||||||
$('#textarea_alias_goto').prop('disabled', true);
|
$('#textarea_alias_goto').prop('disabled', true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$("#textarea_alias_goto").removeAttr('disabled');
|
$("#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});
|
$("#script_data").numberedtextarea({allowTabChar: true});
|
||||||
});
|
});
|
||||||
if ($("#multiple_bookings_select").val() == "custom") {
|
if ($("#multiple_bookings_select").val() == "custom") {
|
||||||
|
|
|
@ -89,8 +89,17 @@ $(document).ready(function() {
|
||||||
$('#password2').val(random_passwd);
|
$('#password2').val(random_passwd);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#goto_null").click(function( event ) {
|
$(".goto_checkbox").click(function( event ) {
|
||||||
if ($("#goto_null").is(":checked")) {
|
$("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);
|
$('#textarea_alias_goto').prop('disabled', true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -616,6 +625,12 @@ jQuery(function($){
|
||||||
if (item.goto == "null@localhost") {
|
if (item.goto == "null@localhost") {
|
||||||
item.goto = '⤷ <span style="font-size:12px" class="glyphicon glyphicon-trash" aria-hidden="true"></span>';
|
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 !== "") {
|
if (item.in_primary_domain !== "") {
|
||||||
item.domain = "↳ " + item.domain + " (" + item.in_primary_domain + ")";
|
item.domain = "↳ " + item.domain + " (" + item.in_primary_domain + ")";
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,7 +167,9 @@ if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_u
|
||||||
if ($data) {
|
if ($data) {
|
||||||
$return = array();
|
$return = array();
|
||||||
$stats_array = json_decode($data, true)['actions'];
|
$stats_array = json_decode($data, true)['actions'];
|
||||||
|
if (!empty($stats_array['soft reject']) || !empty($stats_array['greylist'])) {
|
||||||
$stats_array['soft reject'] = $stats_array['soft reject'] + $stats_array['greylist'];
|
$stats_array['soft reject'] = $stats_array['soft reject'] + $stats_array['greylist'];
|
||||||
|
}
|
||||||
unset($stats_array['greylist']);
|
unset($stats_array['greylist']);
|
||||||
foreach ($stats_array as $action => $count) {
|
foreach ($stats_array as $action => $count) {
|
||||||
$return[] = array($action, $count);
|
$return[] = array($action, $count);
|
||||||
|
@ -178,154 +180,6 @@ if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_u
|
||||||
echo '{}';
|
echo '{}';
|
||||||
}
|
}
|
||||||
break;
|
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;
|
break;
|
||||||
case "domain":
|
case "domain":
|
||||||
|
|
|
@ -339,6 +339,8 @@ $lang['add']['password'] = 'Passwort';
|
||||||
$lang['add']['password_repeat'] = 'Passwort (Wiederholung)';
|
$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']['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_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']['validation_success'] = 'Erfolgreich validiert';
|
||||||
$lang['add']['activate_filter_warn'] = 'Alle anderen Filter diesen Typs werden deaktiviert, falls dieses Script aktiv markiert wird.';
|
$lang['add']['activate_filter_warn'] = 'Alle anderen Filter diesen Typs werden deaktiviert, falls dieses Script aktiv markiert wird.';
|
||||||
$lang['add']['validate'] = 'Validieren';
|
$lang['add']['validate'] = 'Validieren';
|
||||||
|
|
|
@ -344,6 +344,8 @@ $lang['add']['password'] = 'Password';
|
||||||
$lang['add']['password_repeat'] = 'Confirmation password (repeat)';
|
$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']['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_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']['validation_success'] = 'Validated successfully';
|
||||||
$lang['add']['activate_filter_warn'] = 'All other filters will be deactivated, when active is checked.';
|
$lang['add']['activate_filter_warn'] = 'All other filters will be deactivated, when active is checked.';
|
||||||
$lang['add']['validate'] = 'Validate';
|
$lang['add']['validate'] = 'Validate';
|
||||||
|
|
|
@ -245,10 +245,16 @@ if (!isset($_SESSION['mailcow_cc_role'])) {
|
||||||
<label class="control-label col-sm-2" for="goto"><?=$lang['add']['target_address'];?></label>
|
<label class="control-label col-sm-2" for="goto"><?=$lang['add']['target_address'];?></label>
|
||||||
<div class="col-sm-10">
|
<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>
|
<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>
|
<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>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
Loading…
Reference in New Issue