File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ function onLoad() {
5353 //* Mail Domains
5454 //$app->plugins->registerEvent('mail_domain_insert',$this->plugin_name,'domain_insert');
5555 //$app->plugins->registerEvent('mail_domain_update',$this->plugin_name,'domain_update');
56- // $app->plugins->registerEvent('mail_domain_delete',$this->plugin_name,'domain_delete');
56+ $ app ->plugins ->registerEvent ('mail_domain_delete ' ,$ this ->plugin_name ,'domain_delete ' );
5757
5858 }
5959
@@ -125,6 +125,22 @@ function user_delete($event_name,$data) {
125125 }
126126 }
127127
128+ function domain_delete ($ event_name ,$ data ) {
129+ global $ app , $ conf ;
130+
131+ // get the config
132+ $ app ->uses ("getconf " );
133+ $ mail_config = $ app ->getconf ->get_server_config ($ conf ["server_id " ], 'mail ' );
134+
135+ $ old_maildomain_path = escapeshellcmd ($ mail_config ['homedir_path ' ].'/ ' .$ data ['old ' ]['domain ' ]);
136+ if (!stristr ($ old_maildomain_path ,'.. ' ) && !stristr ($ old_maildomain_path ,'* ' ) && strlen ($ old_maildomain_path ) >= 10 ) {
137+ exec ('rm -rf ' .escapeshellcmd ($ old_maildomain_path ));
138+ $ app ->log ('Deleted the mail domain directory: ' .$ old_maildomain_path ,LOGLEVEL_DEBUG );
139+ } else {
140+ $ app ->log ('Possible security violation when deleting the mail domain directory: ' .$ old_maildomain_path ,LOGLEVEL_ERROR );
141+ }
142+ }
143+
128144
129145
130146
You can’t perform that action at this time.
0 commit comments