| | |
| | | $tmp_basepath_parts = explode('/',$tmp_basepath); |
| | | unset($tmp_basepath_parts[count($tmp_basepath_parts)-1]); |
| | | $base_path = implode('/',$tmp_basepath_parts); |
| | | |
| | | |
| | | |
| | | //* Create the mail domain directory, if it does not exist |
| | | if(!empty($base_path) && !is_dir($base_path)) { |
| | | exec("su -c 'mkdir -p ".escapeshellcmd($base_path)."' ".$mail_config['mailuser_name']); |
| | | $app->log('Created Directory: '.$base_path,LOGLEVEL_DEBUG); |
| | | } |
| | | |
| | | // Dovecot uses a different mail layout with a separate 'Maildir' subdirectory. |
| | | if($mail_config['pop3_imap_daemon'] == 'dovecot') { |
| | | exec("su -c 'mkdir -p ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); |
| | | $app->log('Created Directory: '.$base_path,LOGLEVEL_DEBUG); |
| | | $maildomain_path .= '/Maildir'; |
| | | } |
| | | |
| | | //* When the mail user dir exists but it is not a valid maildir, remove it |
| | |
| | | $app->log('Created Directory: '.$base_path,LOGLEVEL_DEBUG); |
| | | } |
| | | |
| | | // Dovecot uses a different mail layout with a separate 'Maildir' subdirectory. |
| | | if($mail_config['pop3_imap_daemon'] == 'dovecot') { |
| | | exec("su -c 'mkdir -p ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); |
| | | $app->log('Created Directory: '.$base_path,LOGLEVEL_DEBUG); |
| | | $maildomain_path .= '/Maildir'; |
| | | } |
| | | |
| | | //* When the mail user dir exists but it is not a valid maildir, remove it |
| | | if(!empty($maildomain_path) && is_dir($maildomain_path) && !is_dir($maildomain_path.'/new') && !is_dir($maildomain_path.'/cur')) { |
| | | exec("su -c 'rm -rf ".escapeshellcmd($data['new']['maildir'])."' vmail"); |
| | |
| | | $app->log('Moved Maildir from: '.$data['old']['maildir'].' to '.$data['new']['maildir'],LOGLEVEL_DEBUG); |
| | | } |
| | | //This is to fix the maildrop quota not being rebuilt after the quota is changed. |
| | | // Courier Layout |
| | | if(is_dir($data['new']['maildir'].'/new')) { |
| | | exec("su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($data['new']['maildir'])."' ".$mail_config['mailuser_name']); |
| | | $app->log('Updated Maildir quota: '."su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($data['new']['maildir'])."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); |
| | | } |
| | | // Dovecot Layout |
| | | if(is_dir($data['new']['maildir'].'/Maildir/new')) { |
| | | exec("su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($data['new']['maildir'])."/Maildir' ".$mail_config['mailuser_name']); |
| | | $app->log('Updated Maildir quota: '."su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($data['new']['maildir'])."/Maildir' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | //* Delete maildomain path |
| | | $old_maildomain_path = escapeshellcmd($mail_config['homedir_path'].'/'.$data['old']['domain']); |
| | | if(!stristr($old_maildomain_path,'..') && !stristr($old_maildomain_path,'*') && strlen($old_maildomain_path) >= 10) { |
| | | if(!stristr($old_maildomain_path,'//') && !stristr($old_maildomain_path,'..') && !stristr($old_maildomain_path,'*') && !stristr($old_maildomain_path,'&') && strlen($old_maildomain_path) >= 10) { |
| | | exec('rm -rf '.escapeshellcmd($old_maildomain_path)); |
| | | $app->log('Deleted the mail domain directory: '.$old_maildomain_path,LOGLEVEL_DEBUG); |
| | | } else { |
| | |
| | | |
| | | //* Delete mailfilter path |
| | | $old_maildomain_path = escapeshellcmd($mail_config['homedir_path'].'/mailfilters/'.$data['old']['domain']); |
| | | if(!stristr($old_maildomain_path,'..') && !stristr($old_maildomain_path,'*') && strlen($old_maildomain_path) >= 10) { |
| | | if(!stristr($old_maildomain_path,'//') && !stristr($old_maildomain_path,'..') && !stristr($old_maildomain_path,'*') && !stristr($old_maildomain_path,'&') && strlen($old_maildomain_path) >= 10) { |
| | | exec('rm -rf '.escapeshellcmd($old_maildomain_path)); |
| | | $app->log('Deleted the mail domain mailfilter directory: '.$old_maildomain_path,LOGLEVEL_DEBUG); |
| | | } else { |