From 4c8288f85e5164927a6e9953ce13a6182f30bfa5 Mon Sep 17 00:00:00 2001 From: andryyy Date: Thu, 9 Mar 2017 17:06:58 +0100 Subject: [PATCH] Use tag settings for alias addresses --- data/conf/rspamd/dynmaps/tags.php | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/data/conf/rspamd/dynmaps/tags.php b/data/conf/rspamd/dynmaps/tags.php index 20210ef1..7552575c 100644 --- a/data/conf/rspamd/dynmaps/tags.php +++ b/data/conf/rspamd/dynmaps/tags.php @@ -12,16 +12,23 @@ $opt = [ try { $pdo = new PDO($dsn, $database_user, $database_pass, $opt); $stmt = $pdo->query("SELECT `username` FROM `mailbox` WHERE `wants_tagged_subject` = '1'"); - $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); - while ($row = array_shift($rows)) { + $rows_a = $stmt->fetchAll(PDO::FETCH_ASSOC); + while ($row_a = array_shift($rows_a)) { + $stmt = $pdo->prepare("SELECT `address` FROM `alias` WHERE `goto` REGEXP :username AND goto != `address` AND `address` NOT LIKE '@%'"); + $stmt->execute(array(':username' => '(^|,)'.$row_a['username'].'($|,)')); + $rows_a_a = $stmt->fetchAll(PDO::FETCH_ASSOC); + while ($row_a_a = array_shift($rows_a_a)) { + echo strtolower(trim($row_a_a['address'])) . PHP_EOL; + } $has_object = 1; - echo strtolower(trim($row['username'])) . PHP_EOL; + echo strtolower(trim($row_a['username'])) . PHP_EOL; } - $stmt = $pdo->query("SELECT CONCAT(mailbox.local_part, '@', alias_domain.alias_domain) as `tag_ad` FROM `mailbox` INNER JOIN `alias_domain` ON mailbox.domain = alias_domain.target_domain WHERE mailbox.wants_tagged_subject='1';"); - $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); - while ($row = array_shift($rows)) { + $stmt = $pdo->query("SELECT CONCAT(`mailbox`.`local_part`, '@', `alias_domain`.`alias_domain`) AS `tag_ad` FROM `mailbox` + INNER JOIN `alias_domain` ON `mailbox`.`domain` = `alias_domain`.`target_domain` WHERE `mailbox`.`wants_tagged_subject` = '1';"); + $rows_b = $stmt->fetchAll(PDO::FETCH_ASSOC); + while ($row_b = array_shift($rows_b)) { $has_object = 1; - echo strtolower(trim($row['tag_ad'])) . PHP_EOL; + echo strtolower(trim($row_b['tag_ad'])) . PHP_EOL; } if ($has_object == 0) { echo "dummy@domain.local";