commit | author | age
|
b5a23a
|
1 |
<?php |
T |
2 |
|
|
3 |
/* |
|
4 |
Copyright (c) 2007, Till Brehm, projektfarm Gmbh |
|
5 |
All rights reserved. |
|
6 |
|
|
7 |
Redistribution and use in source and binary forms, with or without modification, |
|
8 |
are permitted provided that the following conditions are met: |
|
9 |
|
|
10 |
* Redistributions of source code must retain the above copyright notice, |
|
11 |
this list of conditions and the following disclaimer. |
|
12 |
* Redistributions in binary form must reproduce the above copyright notice, |
|
13 |
this list of conditions and the following disclaimer in the documentation |
|
14 |
and/or other materials provided with the distribution. |
|
15 |
* Neither the name of ISPConfig nor the names of its contributors |
|
16 |
may be used to endorse or promote products derived from this software without |
|
17 |
specific prior written permission. |
|
18 |
|
|
19 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
|
20 |
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
21 |
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
|
22 |
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
|
23 |
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
24 |
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
25 |
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
|
26 |
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
27 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
|
28 |
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
29 |
*/ |
|
30 |
|
|
31 |
class mail_plugin { |
|
32 |
|
|
33 |
var $plugin_name = 'mail_plugin'; |
|
34 |
var $class_name = 'mail_plugin'; |
|
35 |
|
392450
|
36 |
//* This function is called during ispconfig installation to determine |
T |
37 |
// if a symlink shall be created for this plugin. |
|
38 |
function onInstall() { |
|
39 |
global $conf; |
|
40 |
|
|
41 |
if($conf['services']['mail'] == true) { |
|
42 |
return true; |
|
43 |
} else { |
|
44 |
return false; |
|
45 |
} |
|
46 |
|
|
47 |
} |
|
48 |
|
b5a23a
|
49 |
|
T |
50 |
/* |
|
51 |
This function is called when the plugin is loaded |
|
52 |
*/ |
|
53 |
|
|
54 |
function onLoad() { |
|
55 |
global $app; |
|
56 |
|
|
57 |
/* |
|
58 |
Register for the events |
|
59 |
*/ |
|
60 |
|
4585cf
|
61 |
//* Mailboxes |
b5a23a
|
62 |
$app->plugins->registerEvent('mail_user_insert',$this->plugin_name,'user_insert'); |
T |
63 |
$app->plugins->registerEvent('mail_user_update',$this->plugin_name,'user_update'); |
|
64 |
$app->plugins->registerEvent('mail_user_delete',$this->plugin_name,'user_delete'); |
958705
|
65 |
|
4585cf
|
66 |
//* Mail Domains |
T |
67 |
//$app->plugins->registerEvent('mail_domain_insert',$this->plugin_name,'domain_insert'); |
|
68 |
//$app->plugins->registerEvent('mail_domain_update',$this->plugin_name,'domain_update'); |
0c4be7
|
69 |
$app->plugins->registerEvent('mail_domain_delete',$this->plugin_name,'domain_delete'); |
b5a23a
|
70 |
|
9234cc
|
71 |
//* Mail transports |
T |
72 |
$app->plugins->registerEvent('mail_transport_insert',$this->plugin_name,'transport_update'); |
|
73 |
$app->plugins->registerEvent('mail_transport_update',$this->plugin_name,'transport_update'); |
|
74 |
$app->plugins->registerEvent('mail_transport_delete',$this->plugin_name,'transport_update'); |
|
75 |
|
b5a23a
|
76 |
} |
T |
77 |
|
|
78 |
|
|
79 |
function user_insert($event_name,$data) { |
|
80 |
global $app, $conf; |
|
81 |
|
f12a6c
|
82 |
//* get the config |
663caf
|
83 |
$app->uses('getconf,system'); |
J |
84 |
$mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail'); |
06303b
|
85 |
|
T |
86 |
// convert to lower case - it could cause problems if some directory above has upper case name |
|
87 |
// $data['new']['maildir'] = strtolower($data['new']['maildir']); |
3845f1
|
88 |
|
f12a6c
|
89 |
$maildomain_path = $data['new']['maildir']; |
T |
90 |
$tmp_basepath = $data['new']['maildir']; |
|
91 |
$tmp_basepath_parts = explode('/',$tmp_basepath); |
|
92 |
unset($tmp_basepath_parts[count($tmp_basepath_parts)-1]); |
|
93 |
$base_path = implode('/',$tmp_basepath_parts); |
|
94 |
|
|
95 |
//* Create the mail domain directory, if it does not exist |
|
96 |
if(!empty($base_path) && !is_dir($base_path)) { |
b38c88
|
97 |
//exec("su -c 'mkdir -p ".escapeshellcmd($base_path)."' ".$mail_config['mailuser_name']); |
T |
98 |
$app->system->mkdirpath($base_path, 0700, $mail_config['mailuser_name'], $mail_config['mailuser_group']); |
f12a6c
|
99 |
$app->log('Created Directory: '.$base_path,LOGLEVEL_DEBUG); |
6cc49f
|
100 |
} |
T |
101 |
|
|
102 |
// Dovecot uses a different mail layout with a separate 'Maildir' subdirectory. |
|
103 |
if($mail_config['pop3_imap_daemon'] == 'dovecot') { |
b38c88
|
104 |
//exec("su -c 'mkdir -p ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); |
T |
105 |
$app->system->mkdirpath($maildomain_path, 0700, $mail_config['mailuser_name'], $mail_config['mailuser_group']); |
fdb514
|
106 |
$app->log('Created Directory: '.$maildomain_path,LOGLEVEL_DEBUG); |
6cc49f
|
107 |
$maildomain_path .= '/Maildir'; |
b5a23a
|
108 |
} |
06303b
|
109 |
|
b6b793
|
110 |
//* When the mail user dir exists but it is not a valid maildir, remove it |
T |
111 |
if(!empty($maildomain_path) && is_dir($maildomain_path) && !is_dir($maildomain_path.'/new') && !is_dir($maildomain_path.'/cur')) { |
|
112 |
exec("su -c 'rm -rf ".escapeshellcmd($data['new']['maildir'])."' vmail"); |
663caf
|
113 |
$app->log('Removed invalid maildir and rebuild it: '.escapeshellcmd($data['new']['maildir']),LOGLEVEL_WARN); |
b6b793
|
114 |
} |
f12a6c
|
115 |
|
T |
116 |
//* Create the maildir, if it doesn not exist, set permissions, set quota. |
|
117 |
if(!empty($maildomain_path) && !is_dir($maildomain_path)) { |
06303b
|
118 |
|
fdb514
|
119 |
//exec("su -c 'maildirmake ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); |
T |
120 |
$app->system->maildirmake($maildomain_path,$mail_config['mailuser_name']); |
06303b
|
121 |
|
f12a6c
|
122 |
exec('chown -R '.$mail_config['mailuser_name'].':'.$mail_config['mailuser_group'].' '.escapeshellcmd($data['new']['maildir'])); |
663caf
|
123 |
$app->log('Set ownership on '.escapeshellcmd($data['new']['maildir']),LOGLEVEL_DEBUG); |
06303b
|
124 |
|
f12a6c
|
125 |
//* This is to fix the maildrop quota not being rebuilt after the quota is changed. |
2b7e04
|
126 |
if($mail_config['pop3_imap_daemon'] != 'dovecot') { |
T |
127 |
exec("su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); // Avoid maildirmake quota bug, see debian bug #214911 |
|
128 |
$app->log('Created Maildir: '."su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); |
|
129 |
} |
0ca0b8
|
130 |
} |
T |
131 |
|
|
132 |
if(!is_dir($data['new']['maildir'].'/.Sent')) { |
|
133 |
//exec("su -c 'maildirmake -f Sent ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); |
|
134 |
//$app->log('Created submaildir Sent: '."su -c 'maildirmake -f Sent ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); |
|
135 |
$app->system->maildirmake($maildomain_path,$mail_config['mailuser_name'],'Sent'); |
|
136 |
} |
|
137 |
if(!is_dir($data['new']['maildir'].'/.Drafts')) { |
|
138 |
//exec("su -c 'maildirmake -f Drafts ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); |
|
139 |
//$app->log('Created submaildir Drafts: '."su -c 'maildirmake -f Drafts ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); |
|
140 |
$app->system->maildirmake($maildomain_path,$mail_config['mailuser_name'],'Drafts'); |
|
141 |
} |
|
142 |
if(!is_dir($data['new']['maildir'].'/.Trash')) { |
|
143 |
//exec("su -c 'maildirmake -f Trash ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); |
|
144 |
//$app->log('Created submaildir Trash: '."su -c 'maildirmake -f Trash ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); |
|
145 |
$app->system->maildirmake($maildomain_path,$mail_config['mailuser_name'],'Trash'); |
|
146 |
} |
|
147 |
if(!is_dir($data['new']['maildir'].'/.Junk')) { |
|
148 |
//exec("su -c 'maildirmake -f Junk ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); |
|
149 |
//$app->log('Created submaildir Junk: '."su -c 'maildirmake -f Junk ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); |
|
150 |
$app->system->maildirmake($maildomain_path,$mail_config['mailuser_name'],'Junk'); |
a3e2d2
|
151 |
} |
T |
152 |
|
|
153 |
//* Set the maildir quota |
2b7e04
|
154 |
if(is_dir($data['new']['maildir'].'/new') && $mail_config['pop3_imap_daemon'] != 'dovecot') { |
1ca823
|
155 |
if($data['new']['quota'] > 0) { |
T |
156 |
exec("su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($data['new']['maildir'])."' ".$mail_config['mailuser_name']); |
|
157 |
$app->log('Set Maildir quota: '."su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($data['new']['maildir'])."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); |
|
158 |
} |
f42df0
|
159 |
} |
92e509
|
160 |
|
T |
161 |
//* Send the welcome email message |
|
162 |
if(file_exists($conf['rootpath'].'/conf-custom/mail/welcome_email_'.$conf['language'].'.txt')) { |
175eab
|
163 |
$lines = file($conf['rootpath'].'/conf-custom/mail/welcome_email_'.$conf['language'].'.txt'); |
92e509
|
164 |
} elseif(file_exists($conf['rootpath'].'/conf-custom/mail/welcome_email_en.txt')) { |
175eab
|
165 |
$lines = file($conf['rootpath'].'/conf-custom/mail/welcome_email_en.txt'); |
92e509
|
166 |
} elseif(file_exists($conf['rootpath'].'/conf/mail/welcome_email_'.$conf['language'].'.txt')) { |
175eab
|
167 |
$lines = file($conf['rootpath'].'/conf/mail/welcome_email_'.$conf['language'].'.txt'); |
92e509
|
168 |
} else { |
175eab
|
169 |
$lines = file($conf['rootpath'].'/conf/mail/welcome_email_en.txt'); |
92e509
|
170 |
} |
T |
171 |
|
175eab
|
172 |
//* Get from address |
T |
173 |
$parts = explode(':',trim($lines[0])); |
|
174 |
unset($parts[0]); |
|
175 |
$welcome_mail_from = implode(':',$parts); |
|
176 |
unset($lines[0]); |
92e509
|
177 |
|
175eab
|
178 |
//* Get subject |
T |
179 |
$parts = explode(':',trim($lines[1])); |
|
180 |
unset($parts[0]); |
|
181 |
$welcome_mail_subject = implode(':',$parts); |
|
182 |
unset($lines[1]); |
|
183 |
|
|
184 |
//* Get message |
|
185 |
$welcome_mail_message = trim(implode($lines)); |
|
186 |
unset($tmp); |
92e509
|
187 |
|
T |
188 |
$mailHeaders = "MIME-Version: 1.0" . "\n"; |
|
189 |
$mailHeaders .= "Content-type: text/plain; charset=utf-8" . "\n"; |
|
190 |
$mailHeaders .= "Content-Transfer-Encoding: 8bit" . "\n"; |
6d49fc
|
191 |
$mailHeaders .= "From: $welcome_mail_from" . "\n"; |
T |
192 |
$mailHeaders .= "Reply-To: $welcome_mail_from" . "\n"; |
92e509
|
193 |
$mailTarget = $data["new"]["email"]; |
f682c3
|
194 |
$mailSubject = "=?utf-8?B?".base64_encode($welcome_mail_subject)."?="; |
92e509
|
195 |
|
T |
196 |
mail($mailTarget, $mailSubject, $welcome_mail_message, $mailHeaders); |
|
197 |
|
b5a23a
|
198 |
} |
T |
199 |
|
|
200 |
function user_update($event_name,$data) { |
|
201 |
global $app, $conf; |
|
202 |
|
|
203 |
// get the config |
663caf
|
204 |
$app->uses('getconf,system'); |
J |
205 |
$mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail'); |
06303b
|
206 |
|
T |
207 |
// convert to lower case - it could cause problems if some directory above has upper case name |
|
208 |
// $data['new']['maildir'] = strtolower($data['new']['maildir']); |
b5a23a
|
209 |
|
T |
210 |
// Create the maildir, if it does not exist |
f42df0
|
211 |
/* |
be40ba
|
212 |
if(!is_dir($data['new']['maildir'])) { |
663caf
|
213 |
mkdir(escapeshellcmd($data['new']['maildir']), 0, true); |
J |
214 |
chown(escapeshellcmd($data['new']['maildir']), $mail_config['mailuser_name']); |
|
215 |
chgrp(escapeshellcmd($data['new']['maildir']), $mail_config['mailuser_group']); |
b5a23a
|
216 |
$app->log('Created Maildir: '.$data['new']['maildir'],LOGLEVEL_DEBUG); |
f42df0
|
217 |
} |
T |
218 |
*/ |
|
219 |
|
|
220 |
$maildomain_path = $data['new']['maildir']; |
|
221 |
$tmp_basepath = $data['new']['maildir']; |
|
222 |
$tmp_basepath_parts = explode('/',$tmp_basepath); |
|
223 |
unset($tmp_basepath_parts[count($tmp_basepath_parts)-1]); |
|
224 |
$base_path = implode('/',$tmp_basepath_parts); |
|
225 |
|
|
226 |
//* Create the mail domain directory, if it does not exist |
|
227 |
if(!empty($base_path) && !is_dir($base_path)) { |
b38c88
|
228 |
//exec("su -c 'mkdir -p ".escapeshellcmd($base_path)."' ".$mail_config['mailuser_name']); |
T |
229 |
$app->system->mkdirpath($base_path, 0700, $mail_config['mailuser_name'], $mail_config['mailuser_group']); |
f42df0
|
230 |
$app->log('Created Directory: '.$base_path,LOGLEVEL_DEBUG); |
T |
231 |
} |
b6b793
|
232 |
|
6cc49f
|
233 |
// Dovecot uses a different mail layout with a separate 'Maildir' subdirectory. |
T |
234 |
if($mail_config['pop3_imap_daemon'] == 'dovecot') { |
b38c88
|
235 |
$app->system->mkdirpath($maildomain_path, 0700, $mail_config['mailuser_name'], $mail_config['mailuser_group']); |
6cc49f
|
236 |
$app->log('Created Directory: '.$base_path,LOGLEVEL_DEBUG); |
T |
237 |
$maildomain_path .= '/Maildir'; |
|
238 |
} |
|
239 |
|
b6b793
|
240 |
//* When the mail user dir exists but it is not a valid maildir, remove it |
T |
241 |
if(!empty($maildomain_path) && is_dir($maildomain_path) && !is_dir($maildomain_path.'/new') && !is_dir($maildomain_path.'/cur')) { |
|
242 |
exec("su -c 'rm -rf ".escapeshellcmd($data['new']['maildir'])."' vmail"); |
663caf
|
243 |
$app->log('Removed invalid maildir and rebuild it: '.escapeshellcmd($data['new']['maildir']),LOGLEVEL_WARN); |
b6b793
|
244 |
} |
f42df0
|
245 |
|
T |
246 |
//* Create the maildir, if it doesn not exist, set permissions, set quota. |
b6b793
|
247 |
if(!empty($maildomain_path) && !is_dir($maildomain_path.'/new')) { |
fdb514
|
248 |
//exec("su -c 'maildirmake ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); |
T |
249 |
//$app->log("Created Maildir "."su -c 'maildirmake ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); |
|
250 |
$app->system->maildirmake($maildomain_path,$mail_config['mailuser_name']); |
06303b
|
251 |
|
f42df0
|
252 |
exec('chown -R '.$mail_config['mailuser_name'].':'.$mail_config['mailuser_group'].' '.escapeshellcmd($data['new']['maildir'])); |
663caf
|
253 |
$app->log('Set ownership on '.escapeshellcmd($data['new']['maildir']),LOGLEVEL_DEBUG); |
f42df0
|
254 |
//* This is to fix the maildrop quota not being rebuilt after the quota is changed. |
2b7e04
|
255 |
if($mail_config['pop3_imap_daemon'] != 'dovecot') { |
1ca823
|
256 |
if($data['new']['quota'] > 0) { |
T |
257 |
exec("su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); // Avoid maildirmake quota bug, see debian bug #214911 |
|
258 |
$app->log('Updated Maildir quota: '."su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); |
|
259 |
} else { |
|
260 |
if(file_exists($data['new']['maildir'].'/maildirsize')) unlink($data['new']['maildir'].'/maildirsize'); |
|
261 |
$app->log('Set Maildir quota to unlimited.',LOGLEVEL_DEBUG); |
|
262 |
} |
2b7e04
|
263 |
} |
b5a23a
|
264 |
} |
T |
265 |
|
0ca0b8
|
266 |
if(!is_dir($data['new']['maildir'].'/.Sent')) { |
T |
267 |
//exec("su -c 'maildirmake -f Sent ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); |
|
268 |
//$app->log('Created submaildir Sent: '."su -c 'maildirmake -f Sent ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); |
|
269 |
$app->system->maildirmake($maildomain_path,$mail_config['mailuser_name'],'Sent'); |
|
270 |
} |
|
271 |
if(!is_dir($data['new']['maildir'].'/.Drafts')) { |
|
272 |
//exec("su -c 'maildirmake -f Drafts ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); |
|
273 |
//$app->log('Created submaildir Drafts: '."su -c 'maildirmake -f Drafts ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); |
|
274 |
$app->system->maildirmake($maildomain_path,$mail_config['mailuser_name'],'Drafts'); |
|
275 |
} |
|
276 |
if(!is_dir($data['new']['maildir'].'/.Trash')) { |
|
277 |
//exec("su -c 'maildirmake -f Trash ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); |
|
278 |
//$app->log('Created submaildir Trash: '."su -c 'maildirmake -f Trash ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); |
|
279 |
$app->system->maildirmake($maildomain_path,$mail_config['mailuser_name'],'Trash'); |
|
280 |
} |
|
281 |
if(!is_dir($data['new']['maildir'].'/.Junk')) { |
|
282 |
//exec("su -c 'maildirmake -f Junk ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); |
|
283 |
//$app->log('Created submaildir Junk: '."su -c 'maildirmake -f Junk ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); |
|
284 |
$app->system->maildirmake($maildomain_path,$mail_config['mailuser_name'],'Junk'); |
|
285 |
} |
|
286 |
|
b5a23a
|
287 |
// Move mailbox, if domain has changed and delete old mailbox |
T |
288 |
if($data['new']['maildir'] != $data['old']['maildir'] && is_dir($data['old']['maildir'])) { |
f12a6c
|
289 |
if(is_dir($data['new']['maildir'])) { |
6f8175
|
290 |
exec("rm -fr ".escapeshellcmd($data['new']['maildir'])); |
F |
291 |
//rmdir($data['new']['maildir']); |
f12a6c
|
292 |
} |
T |
293 |
exec('mv -f '.escapeshellcmd($data['old']['maildir']).' '.escapeshellcmd($data['new']['maildir'])); |
|
294 |
// exec('mv -f '.escapeshellcmd($data['old']['maildir']).'/* '.escapeshellcmd($data['new']['maildir'])); |
|
295 |
// if(is_file($data['old']['maildir'].'.ispconfig_mailsize'))exec('mv -f '.escapeshellcmd($data['old']['maildir']).'.ispconfig_mailsize '.escapeshellcmd($data['new']['maildir'])); |
|
296 |
// rmdir($data['old']['maildir']); |
b5a23a
|
297 |
$app->log('Moved Maildir from: '.$data['old']['maildir'].' to '.$data['new']['maildir'],LOGLEVEL_DEBUG); |
T |
298 |
} |
7cba4d
|
299 |
//This is to fix the maildrop quota not being rebuilt after the quota is changed. |
6cc49f
|
300 |
// Courier Layout |
2b7e04
|
301 |
if(is_dir($data['new']['maildir'].'/new') && $mail_config['pop3_imap_daemon'] != 'dovecot') { |
1ca823
|
302 |
if($data['new']['quota'] > 0) { |
T |
303 |
exec("su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($data['new']['maildir'])."' ".$mail_config['mailuser_name']); |
|
304 |
$app->log('Updated Maildir quota: '."su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($data['new']['maildir'])."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); |
|
305 |
} else { |
|
306 |
if(file_exists($data['new']['maildir'].'/maildirsize')) unlink($data['new']['maildir'].'/maildirsize'); |
|
307 |
$app->log('Set Maildir quota to unlimited.',LOGLEVEL_DEBUG); |
|
308 |
} |
6cc49f
|
309 |
} |
b5a23a
|
310 |
} |
T |
311 |
|
|
312 |
function user_delete($event_name,$data) { |
|
313 |
global $app, $conf; |
|
314 |
|
b23de0
|
315 |
// get the config |
T |
316 |
$app->uses("getconf"); |
|
317 |
$mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail'); |
|
318 |
|
b5a23a
|
319 |
$old_maildir_path = escapeshellcmd($data['old']['maildir']); |
b23de0
|
320 |
if($old_maildir_path != $mail_config['homedir_path'] && strlen($old_maildir_path) > strlen($mail_config['homedir_path']) && !stristr($old_maildir_path,'..') && !stristr($old_maildir_path,'*') && strlen($old_maildir_path) >= 10) { |
958705
|
321 |
exec('rm -rf '.escapeshellcmd($old_maildir_path)); |
b5a23a
|
322 |
$app->log('Deleted the Maildir: '.$data['old']['maildir'],LOGLEVEL_DEBUG); |
T |
323 |
} else { |
|
324 |
$app->log('Possible security violation when deleting the maildir: '.$data['old']['maildir'],LOGLEVEL_ERROR); |
|
325 |
} |
|
326 |
} |
|
327 |
|
0c4be7
|
328 |
function domain_delete($event_name,$data) { |
T |
329 |
global $app, $conf; |
|
330 |
|
|
331 |
// get the config |
|
332 |
$app->uses("getconf"); |
663caf
|
333 |
$mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail'); |
0c4be7
|
334 |
|
06303b
|
335 |
//* Delete maildomain path |
0c4be7
|
336 |
$old_maildomain_path = escapeshellcmd($mail_config['homedir_path'].'/'.$data['old']['domain']); |
b23de0
|
337 |
if($old_maildomain_path != $mail_config['homedir_path'] && !stristr($old_maildomain_path,'//') && !stristr($old_maildomain_path,'..') && !stristr($old_maildomain_path,'*') && !stristr($old_maildomain_path,'&') && strlen($old_maildomain_path) >= 10) { |
0c4be7
|
338 |
exec('rm -rf '.escapeshellcmd($old_maildomain_path)); |
T |
339 |
$app->log('Deleted the mail domain directory: '.$old_maildomain_path,LOGLEVEL_DEBUG); |
|
340 |
} else { |
|
341 |
$app->log('Possible security violation when deleting the mail domain directory: '.$old_maildomain_path,LOGLEVEL_ERROR); |
|
342 |
} |
06303b
|
343 |
|
T |
344 |
//* Delete mailfilter path |
|
345 |
$old_maildomain_path = escapeshellcmd($mail_config['homedir_path'].'/mailfilters/'.$data['old']['domain']); |
b23de0
|
346 |
if($old_maildomain_path != $mail_config['homedir_path'].'/mailfilters/' && !stristr($old_maildomain_path,'//') && !stristr($old_maildomain_path,'..') && !stristr($old_maildomain_path,'*') && !stristr($old_maildomain_path,'&') && strlen($old_maildomain_path) >= 10) { |
06303b
|
347 |
exec('rm -rf '.escapeshellcmd($old_maildomain_path)); |
T |
348 |
$app->log('Deleted the mail domain mailfilter directory: '.$old_maildomain_path,LOGLEVEL_DEBUG); |
|
349 |
} else { |
|
350 |
$app->log('Possible security violation when deleting the mail domain mailfilter directory: '.$old_maildomain_path,LOGLEVEL_ERROR); |
|
351 |
} |
0c4be7
|
352 |
} |
T |
353 |
|
9234cc
|
354 |
function transport_update($event_name,$data) { |
T |
355 |
global $app, $conf; |
|
356 |
|
663caf
|
357 |
exec($conf['init_scripts'] . '/' . 'postfix reload &> /dev/null'); |
9234cc
|
358 |
$app->log('Postfix config reloaded ',LOGLEVEL_DEBUG); |
T |
359 |
|
|
360 |
} |
|
361 |
|
b5a23a
|
362 |
|
T |
363 |
|
|
364 |
|
|
365 |
} // end class |
|
366 |
|
663caf
|
367 |
?> |