From aaedeebd3a552b36295a9fe2c6c68c87200789f8 Mon Sep 17 00:00:00 2001 From: Michael Seevogel <git@michaelseevogel.de> Date: Mon, 17 Aug 2020 16:56:10 +0200 Subject: [PATCH] nginx_plugin: delete statistic generator configuration files if they have been changed to something else --- server/plugins-available/nginx_plugin.inc.php | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/server/plugins-available/nginx_plugin.inc.php b/server/plugins-available/nginx_plugin.inc.php index e4d59a02bb..5bc5cab79d 100644 --- a/server/plugins-available/nginx_plugin.inc.php +++ b/server/plugins-available/nginx_plugin.inc.php @@ -1939,6 +1939,16 @@ class nginx_plugin { $this->goaccess_update($data, $web_config); } + //* Remove the GoAccess configuration file + if($data['old']['stats_type'] == 'goaccess') { + $this->goaccess_delete($data, $web_config); + } + + //* Remove the Webalizer configuration file + if($data['old']['stats_type'] == 'webalizer') { + $this->webalizer_delete($data, $web_config); + } + //* Remove Stats-Folder when Statistics set to none if($data['new']['stats_type'] == '' && ($data['new']['type'] == 'vhost' || $data['new']['type'] == 'vhostsubdomain' || $data['new']['type'] == 'vhostalias')) { $app->file->removeDirectory($data['new']['document_root'].'/web/stats'); @@ -2653,6 +2663,18 @@ class nginx_plugin { } } + //* Delete the Webalizer configuration file + private function webalizer_delete ($data, $web_config) { + global $app; + + $webalizer_conf = $data['old']['document_root'] . "/log/webalizer.conf"; + + if ( @is_file($webalizer_conf) ) { + $app->system->unlink($webalizer_conf); + $app->log('Removed Webalizer config file: '.$webalizer_conf, LOGLEVEL_DEBUG); + } + } + //* Update the awstats configuration file private function awstats_update ($data, $web_config) { global $app; -- GitLab