Skip to content

Commit d907c0c

Browse files
author
Till Brehm
committed
1 parent 8fa8ed5 commit d907c0c

File tree

2 files changed

+59
-31
lines changed

2 files changed

+59
-31
lines changed

interface/lib/plugins/mail_user_filter_plugin.inc.php

Lines changed: 57 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -137,41 +137,69 @@ private function mail_user_filter_get_rule($page_form) {
137137
$content .= '### BEGIN FILTER_ID:'.$page_form->id."\n";
138138

139139
//$content .= 'require ["fileinto", "regex", "vacation"];'."\n";
140-
141-
$content .= 'if header :regex ["'.strtolower($page_form->dataRecord["source"]).'"] ["';
142-
143-
$searchterm = preg_quote($page_form->dataRecord["searchterm"]);
144-
$searchterm = str_replace(
145-
array(
146-
'"',
147-
'\\[',
148-
'\\]'
149-
),
150-
array(
151-
'\\"',
152-
'\\\\[',
153-
'\\\\]'
154-
), $searchterm);
155-
156-
if($page_form->dataRecord["op"] == 'contains') {
157-
$content .= ".*".$searchterm;
158-
} elseif ($page_form->dataRecord["op"] == 'is') {
159-
$content .= "^".$searchterm."$";
160-
} elseif ($page_form->dataRecord["op"] == 'begins') {
161-
$content .= " ".$searchterm."";
162-
} elseif ($page_form->dataRecord["op"] == 'ends') {
163-
$content .= ".*".$searchterm."$";
140+
141+
if($page_form->dataRecord["op"] == 'domain') {
142+
$content .= 'if address :domain :is "'.strtolower($page_form->dataRecord["source"]).'" "'.$page_form->dataRecord["searchterm"].'" {'."\n";
143+
} elseif ($page_form->dataRecord["op"] == 'localpart') {
144+
$content .= 'if address :localpart :is "'.strtolower($page_form->dataRecord["source"]).'" "'.$page_form->dataRecord["searchterm"].'" {'."\n";
145+
} elseif ($page_form->dataRecord["source"] == 'Size') {
146+
if(substr(trim($page_form->dataRecord["searchterm"]),-1) == 'k' || substr(trim($page_form->dataRecord["searchterm"]),-1) == 'K') {
147+
$unit = 'k';
148+
} else {
149+
$unit = 'm';
150+
}
151+
$content .= 'if size :over '.intval($page_form->dataRecord["searchterm"]).$unit.' {'."\n";
152+
} else {
153+
154+
if($page_form->dataRecord["source"] == 'Header') {
155+
$parts = explode(':',trim($page_form->dataRecord["searchterm"]));
156+
$page_form->dataRecord["source"] = trim($parts[0]);
157+
unset($parts[0]);
158+
$page_form->dataRecord["searchterm"] = trim(implode(':',$parts));
159+
unset($parts);
160+
}
161+
162+
$content .= 'if header :regex ["'.strtolower($page_form->dataRecord["source"]).'"] ["';
163+
164+
$searchterm = preg_quote($page_form->dataRecord["searchterm"]);
165+
$searchterm = str_replace(
166+
array(
167+
'"',
168+
'\\[',
169+
'\\]'
170+
),
171+
array(
172+
'\\"',
173+
'\\\\[',
174+
'\\\\]'
175+
), $searchterm);
176+
177+
if($page_form->dataRecord["op"] == 'contains') {
178+
$content .= ".*".$searchterm;
179+
} elseif ($page_form->dataRecord["op"] == 'is') {
180+
$content .= "^".$searchterm."$";
181+
} elseif ($page_form->dataRecord["op"] == 'begins') {
182+
$content .= " ".$searchterm."";
183+
} elseif ($page_form->dataRecord["op"] == 'ends') {
184+
$content .= ".*".$searchterm."$";
185+
}
186+
187+
$content .= '"] {'."\n";
164188
}
165189

166-
$content .= '"] {'."\n";
167-
168190
if($page_form->dataRecord["action"] == 'move') {
169-
$content .= ' fileinto "'.$page_form->dataRecord["target"].'";' . "\n";
191+
$content .= ' fileinto "'.$page_form->dataRecord["target"].'";' . "\n stop;\n";
192+
} elseif ($page_form->dataRecord["action"] == 'keep') {
193+
$content .= " keep;\n";
194+
} elseif ($page_form->dataRecord["action"] == 'stop') {
195+
$content .= " stop;\n";
196+
} elseif ($page_form->dataRecord["action"] == 'reject') {
197+
$content .= ' reject "'.$page_form->dataRecord["target"].'"; stop;\n\n';
170198
} else {
171-
$content .= " discard;\n";
199+
$content .= " discard;\n stop;\n";
172200
}
173201

174-
$content .= " stop;\n}\n";
202+
$content .= "}\n";
175203

176204
$content .= '### END FILTER_ID:'.$page_form->id."\n";
177205

server/plugins-available/bind_plugin.inc.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ function soa_update($event_name, $data) {
117117

118118
//TODO : change this when distribution information has been integrated into server record
119119
if (file_exists('/etc/gentoo-release')) {
120-
$filename = escapeshellcmd($dns_config['bind_zonefiles_dir'].'/pri.'.str_replace("/", "_", substr($zone['origin'], 0, -1)));
120+
$filename = escapeshellcmd($dns_config['bind_zonefiles_dir'].'/pri/'.str_replace("/", "_", substr($zone['origin'], 0, -1)));
121121
}
122122
else {
123123
$filename = escapeshellcmd($dns_config['bind_zonefiles_dir'].'/pri.'.str_replace("/", "_", substr($zone['origin'], 0, -1)));
@@ -151,7 +151,7 @@ function soa_update($event_name, $data) {
151151
if($data['old']['origin'] != $data['new']['origin']) {
152152
//TODO : change this when distribution information has been integrated into server record
153153
if (file_exists('/etc/gentoo-release')) {
154-
$filename = $dns_config['bind_zonefiles_dir'].'/pri.'.str_replace("/", "_", substr($data['old']['origin'], 0, -1));
154+
$filename = $dns_config['bind_zonefiles_dir'].'/pri/'.str_replace("/", "_", substr($data['old']['origin'], 0, -1));
155155
}
156156
else {
157157
$filename = $dns_config['bind_zonefiles_dir'].'/pri.'.str_replace("/", "_", substr($data['old']['origin'], 0, -1));

0 commit comments

Comments
 (0)