parent
3453207301
commit
943b7c6bb2
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/lib/Spyc.php';
|
||||
|
||||
function presets($_action, $_data = null)
|
||||
{
|
||||
if ($_SESSION['mailcow_cc_role'] !== 'admin') {
|
||||
$_SESSION['return'][] = [
|
||||
'type' => 'danger',
|
||||
'log' => [__FUNCTION__, $_action, $_data_log],
|
||||
'msg' => 'access_denied',
|
||||
];
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
global $lang;
|
||||
if ($_action === 'get') {
|
||||
$kind = strtolower(trim($_data));
|
||||
if (!in_array($kind, ['rspamd', 'sieve'], true)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$presets = [];
|
||||
foreach (glob(__DIR__ . '/presets/' . $kind . '/*.yml') as $filename) {
|
||||
$preset = Spyc::YAMLLoad($filename);
|
||||
|
||||
/* get translated headlines */
|
||||
if (isset($preset['headline']) && strpos($preset['headline'], 'lang.') === 0) {
|
||||
$textName = trim(substr($preset['headline'], 5));
|
||||
|
||||
if ($kind === 'rspamd') {
|
||||
$preset['headline'] = $lang['admin'][$textName];
|
||||
} elseif ($kind === 'sieve') {
|
||||
$preset['headline'] = $lang['mailbox'][$textName];
|
||||
}
|
||||
}
|
||||
|
||||
$presets[] = $preset;
|
||||
}
|
||||
|
||||
return $presets;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -223,6 +223,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/functions.rspamd.inc.php';
|
|||
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/functions.tls_policy_maps.inc.php';
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/functions.fail2ban.inc.php';
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/functions.docker.inc.php';
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/functions.presets.inc.php';
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/init_db.inc.php';
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/triggers.inc.php';
|
||||
init_db_schema();
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
headline: lang.rsettings_preset_1
|
||||
content: |
|
||||
priority = 10;
|
||||
authenticated = yes;
|
||||
apply "default" {
|
||||
symbols_enabled = ["DKIM_SIGNED", "RATELIMITED", "RATELIMIT_UPDATE", "RATELIMIT_CHECK", "DYN_RL_CHECK", "HISTORY_SAVE", "MILTER_HEADERS", "ARC_SIGNED"];
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
headline: lang.rsettings_preset_2
|
||||
content: |
|
||||
priority = 10;
|
||||
rcpt = "/postmaster@.*/";
|
||||
want_spam = yes;
|
|
@ -0,0 +1,7 @@
|
|||
headline: lang.sieve_preset_1
|
||||
content: |
|
||||
if header :contains "x-attached"
|
||||
[".exe",".bat",".js",".com",".cmd",".ini",".dll",".bas",".cpl",".drv",".inf",".sys",".pif",".doc",".docx"] {
|
||||
discard;
|
||||
stop;
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
headline: lang.sieve_preset_2
|
||||
content: |
|
||||
require ["envelope", "imap4flags"];
|
||||
if envelope "from" "mark@me-read.com"
|
||||
{
|
||||
setflag "\\seen";
|
||||
}
|
|
@ -8,6 +8,10 @@ var rspamdPresets = [
|
|||
codeValue: 'priority = 10;\nrcpt = "/postmaster@.*/";\nwant_spam = yes;'
|
||||
}
|
||||
];
|
||||
/*
|
||||
TODO: aus API holen:
|
||||
/api/v1/get/rspamd/sieve/
|
||||
*/
|
||||
|
||||
var rspamd_presetsElem = document.getElementById("rspamd_presets");
|
||||
if (rspamd_presetsElem && rspamdPresets) {
|
||||
|
|
|
@ -8,6 +8,10 @@ var sieveMailboxPresets = [
|
|||
codeValue: 'require ["envelope", "imap4flags"];\nif envelope "from" "mark@me-read.com"\n{\n setflag "\\\\seen";\n}'
|
||||
}
|
||||
];
|
||||
/*
|
||||
TODO: aus API holen:
|
||||
/api/v1/get/rspamd/sieve/
|
||||
*/
|
||||
|
||||
var sieve_presetsElem = document.getElementById("sieve_presets");
|
||||
if (sieve_presetsElem && sieveMailboxPresets) {
|
||||
|
|
|
@ -1071,6 +1071,9 @@ if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_u
|
|||
break;
|
||||
}
|
||||
break;
|
||||
case "presets":
|
||||
process_get_return(presets('get', $object));
|
||||
break;
|
||||
// return no route found if no case is matched
|
||||
default:
|
||||
http_response_code(404);
|
||||
|
|
Loading…
Reference in New Issue