From 2d086424fa1e86cc43a1a97dab4b592f747cde33 Mon Sep 17 00:00:00 2001 From: andryyy Date: Sat, 4 Mar 2017 14:05:06 +0100 Subject: [PATCH] Fix settings for aliases, alias domains --- data/conf/rspamd/dynmaps/settings.php | 84 +++++++++++++++++++++++++-- 1 file changed, 78 insertions(+), 6 deletions(-) diff --git a/data/conf/rspamd/dynmaps/settings.php b/data/conf/rspamd/dynmaps/settings.php index 3407444b..9be1f696 100644 --- a/data/conf/rspamd/dynmaps/settings.php +++ b/data/conf/rspamd/dynmaps/settings.php @@ -4,6 +4,11 @@ The match section performs AND operation on different matches: for example, if y then the rule matches only when from AND rcpt match. For similar matches, the OR rule applies: if you have multiple rcpt matches, then any of these will trigger the rule. If a rule is triggered then no more rules are matched. */ +function parse_email($email) { + if(!filter_var($email, FILTER_VALIDATE_EMAIL)) return false; + $a = strrpos($email, '@'); + return array('local' => substr($email, 0, $a), 'domain' => substr($email, $a)); +} header('Content-Type: text/plain'); require_once "vars.inc.php"; @@ -56,13 +61,27 @@ while ($row = array_shift($rows)) { + rcpt = "/\+.*/"; + rcpt = ""; prepare("SELECT `address` FROM `alias` WHERE `goto` = :object_goto AND `address` NOT LIKE '@%' AND `address` != :object_address"); - $stmt->execute(array(':object_goto' => $row['object'], ':object_address' => $row['object'])); + $stmt = $pdo->prepare("SELECT `address` FROM `alias` WHERE `goto` LIKE :object_goto AND `address` NOT LIKE '@%' AND `address` != :object_address"); + $stmt->execute(array(':object_goto' => '%' . $row['object'] . '%', ':object_address' => $row['object'])); $rows_aliases_1 = $stmt->fetchAll(PDO::FETCH_ASSOC); while ($row_aliases_1 = array_shift($rows_aliases_1)) { + $local = parse_email($row_aliases_1['address'])['local']; + $domain = parse_email($row_aliases_1['address'])['domain']; + if (!empty($local) && !empty($local)) { +?> + rcpt = "/\+.*/"; + rcpt = ""; + rcpt = "/\+.*/"; + rcpt = ""; priority = high; + + rcpt = "/\+.*/"; + rcpt = ""; prepare("SELECT `address` FROM `alias` WHERE `goto` = :object_goto AND `address` NOT LIKE '@%' AND `address` != :object_address"); - $stmt->execute(array(':object_goto' => $row['object'], ':object_address' => $row['object'])); + $stmt = $pdo->prepare("SELECT `address` FROM `alias` WHERE `goto` LIKE :object_goto AND `address` NOT LIKE '@%' AND `address` != :object_address"); + $stmt->execute(array(':object_goto' => '%' . $row['object'] . '%', ':object_address' => $row['object'])); $rows_aliases_wl_1 = $stmt->fetchAll(PDO::FETCH_ASSOC); array_filter($rows_aliases_wl_1); while ($row_aliases_wl_1 = array_shift($rows_aliases_wl_1)) { + $local = parse_email($row_aliases_wl_1['address'])['local']; + $domain = parse_email($row_aliases_wl_1['address'])['domain']; + if (!empty($local) && !empty($local)) { +?> + rcpt = "/\+.*/"; + rcpt = ""; + rcpt = "/\+.*/"; + rcpt = ""; priority = high; + + rcpt = "/\+.*/"; + rcpt = ""; prepare("SELECT `address` FROM `alias` WHERE `goto` = :object_goto AND `address` NOT LIKE '@%' AND `address` != :object_address"); - $stmt->execute(array(':object_goto' => $row['object'], ':object_address' => $row['object'])); + $stmt = $pdo->prepare("SELECT `address` FROM `alias` WHERE `goto` LIKE :object_goto AND `address` NOT LIKE '@%' AND `address` != :object_address"); + $stmt->execute(array(':object_goto' => '%' . $row['object'] . '%', ':object_address' => $row['object'])); $rows_aliases_bl_1 = $stmt->fetchAll(PDO::FETCH_ASSOC); array_filter($rows_aliases_bl_1); while ($row_aliases_bl_1 = array_shift($rows_aliases_bl_1)) { + $local = parse_email($row_aliases_bl_1['address'])['local']; + $domain = parse_email($row_aliases_bl_1['address'])['domain']; + if (!empty($local) && !empty($local)) { +?> + rcpt = "/\+.*/"; + rcpt = ""; + rcpt = "/\+.*/"; + rcpt = "";