@@ -111,7 +111,7 @@ function check_system($data) {
111111
112112 //* When we can use 60-dkim for the dkim-keys create the file if it does not exists.
113113 if (substr_compare ($ amavis_configfile , '60-dkim ' , -7 ) === 0 && !file_exists ($ amavis_configfile ))
114- $ app ->system ->file_put_contents ($ amavis_configfile, '' );
114+ $ app ->system ->touch ($ amavis_configfile );
115115
116116 if ( $ amavis_configfile == '' || !is_writeable ($ amavis_configfile ) ) {
117117 $ app ->log ('Amavis-config not found or not writeable. ' , LOGLEVEL_ERROR );
@@ -141,8 +141,7 @@ function check_system($data) {
141141 $ app ->system ->chown ($ mail_config ['dkim_path ' ], $ amavis_user );
142142 } else {
143143 mkdir ($ mail_config ['dkim_path ' ], 0755 , true );
144- $ app ->log ('No user amavis or vscan found - using root for ' .$ mail_config ['dkim_path ' ]
145- , LOGLEVEL_WARNING );
144+ $ app ->log ('No user amavis or vscan found - using root for ' .$ mail_config ['dkim_path ' ], LOGLEVEL_WARNING );
146145 }
147146 }
148147
@@ -240,20 +239,20 @@ function add_to_amavis($key_domain, $selector, $old_selector) {
240239 //* If we are using seperate config-files with amavis remove existing keys from 50-user to avoid duplicate keys
241240 if (substr_compare ($ amavis_configfile , '60-dkim ' , -7 ) === 0 ) {
242241 $ temp_configfile = str_replace ('60-dkim ' , '50-user ' , $ amavis_configfile );
243- $ temp_config = $ app ->system ->file_get_contents ($ temp_configfile );
242+ $ temp_config = $ app ->system ->file_get_contents ($ temp_configfile, true );
244243 if (preg_match ($ search_regex , $ temp_config )) {
245244 $ temp_config = preg_replace ($ search_regex , '' , $ temp_config )."\n" ;
246- $ app ->system ->file_put_contents ($ temp_configfile , $ temp_config );
245+ $ app ->system ->file_put_contents ($ temp_configfile , $ temp_config, true );
247246 }
248247 unset($ temp_configfile );
249248 unset($ temp_config );
250249 }
251250
252251 $ key_value ="dkim_key(' " .$ key_domain ."', ' " .$ selector ."', ' " .$ mail_config ['dkim_path ' ]."/ " .$ key_domain .".private'); \n" ;
253- $ amavis_config = $ app ->system ->file_get_contents ($ amavis_configfile );
252+ $ amavis_config = $ app ->system ->file_get_contents ($ amavis_configfile, true );
254253 $ amavis_config = preg_replace ($ search_regex , '' , $ amavis_config ).$ key_value ;
255254
256- if ( $ app ->system ->file_put_contents ($ amavis_configfile , $ amavis_config ) ) {
255+ if ( $ app ->system ->file_put_contents ($ amavis_configfile , $ amavis_config, true ) ) {
257256 $ app ->log ('Adding DKIM Private-key to amavis-config. ' , LOGLEVEL_DEBUG );
258257 $ restart = true ;
259258 } else {
@@ -272,24 +271,24 @@ function remove_from_amavis($key_domain) {
272271
273272 $ restart = false ;
274273 $ amavis_configfile = $ this ->get_amavis_config ();
275- $ amavis_config = $ app ->system ->file_get_contents ($ amavis_configfile );
274+ $ amavis_config = $ app ->system ->file_get_contents ($ amavis_configfile, true );
276275
277276 $ search_regex = "/( \n| \r)?dkim_key.* " .$ key_domain .".*( \n| \r)?/ " ;
278277
279278 if (preg_match ($ search_regex , $ amavis_config )) {
280279 $ amavis_config = preg_replace ($ search_regex , '' , $ amavis_config );
281- $ app ->system ->file_put_contents ($ amavis_configfile , $ amavis_config );
280+ $ app ->system ->file_put_contents ($ amavis_configfile , $ amavis_config, true );
282281 $ app ->log ('Deleted the DKIM settings from amavis-config for ' .$ key_domain .'. ' , LOGLEVEL_DEBUG );
283282 $ restart = true ;
284283 }
285284
286285 //* If we are using seperate config-files with amavis remove existing keys from 50-user, too
287286 if (substr_compare ($ amavis_configfile , '60-dkim ' , -7 ) === 0 ) {
288287 $ temp_configfile = str_replace ('60-dkim ' , '50-user ' , $ amavis_configfile );
289- $ temp_config = $ app ->system ->file_get_contents ($ temp_configfile );
288+ $ temp_config = $ app ->system ->file_get_contents ($ temp_configfile, true );
290289 if (preg_match ($ search_regex , $ temp_config )) {
291290 $ temp_config = preg_replace ($ search_regex , '' , $ temp_config );
292- $ app ->system ->file_put_contents ($ temp_configfile , $ temp_config );
291+ $ app ->system ->file_put_contents ($ temp_configfile , $ temp_config, true );
293292 $ restart = true ;
294293 }
295294 unset($ temp_configfile );
0 commit comments