From 1fa9deec4ece4d08347448d92162e1f861ebe5b6 Mon Sep 17 00:00:00 2001 From: Michael Seevogel Date: Mon, 17 Aug 2020 16:45:48 +0200 Subject: [PATCH 1/5] apache2_plugin: delete statistic generator configuration files if they have been changed to something else --- .../plugins-available/apache2_plugin.inc.php | 34 +++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/server/plugins-available/apache2_plugin.inc.php b/server/plugins-available/apache2_plugin.inc.php index ca14b737be..2ad4d7533b 100644 --- a/server/plugins-available/apache2_plugin.inc.php +++ b/server/plugins-available/apache2_plugin.inc.php @@ -1925,6 +1925,21 @@ class apache2_plugin { $app->file->removeDirectory($data['new']['document_root'].'/web/stats'); } + //* Remove the AWstats configuration file + if($data['old']['stats_type'] == 'awstats') { + $this->awstats_delete($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); + } + $this->php_fpm_pool_update($data, $web_config, $pool_dir, $pool_name, $socket_dir, $web_folder); $this->hhvm_update($data, $web_config); @@ -2328,16 +2343,11 @@ class apache2_plugin { } - //* Remove the awstats configuration file + //* Remove the AWstats configuration file if($data['old']['stats_type'] == 'awstats') { $this->awstats_delete($data, $web_config); } - //* Remove the GoAccess configuration file - if($data['old']['stats_type'] == 'goaccess') { - $this->goaccess_delete($data, $web_config); - } - if($data['old']['type'] == 'vhostsubdomain' || $data['old']['type'] == 'vhostalias') { $app->system->web_folder_protection($parent_web_document_root, true); } @@ -3128,6 +3138,18 @@ class apache2_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); + } + } + private function hhvm_update($data, $web_config) { global $app, $conf; -- GitLab From aaedeebd3a552b36295a9fe2c6c68c87200789f8 Mon Sep 17 00:00:00 2001 From: Michael Seevogel Date: Mon, 17 Aug 2020 16:56:10 +0200 Subject: [PATCH 2/5] 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 From dd1507a4c71cfcbade2bae97063521565729aa40 Mon Sep 17 00:00:00 2001 From: Michael Seevogel Date: Mon, 17 Aug 2020 16:58:50 +0200 Subject: [PATCH 3/5] removed goaccess_delete from function delete --- server/plugins-available/nginx_plugin.inc.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server/plugins-available/nginx_plugin.inc.php b/server/plugins-available/nginx_plugin.inc.php index 5bc5cab79d..9888c7e209 100644 --- a/server/plugins-available/nginx_plugin.inc.php +++ b/server/plugins-available/nginx_plugin.inc.php @@ -1939,6 +1939,11 @@ class nginx_plugin { $this->goaccess_update($data, $web_config); } + //* Remove the AWstats configuration file + if($data['old']['stats_type'] == 'awstats') { + $this->awstats_delete($data, $web_config); + } + //* Remove the GoAccess configuration file if($data['old']['stats_type'] == 'goaccess') { $this->goaccess_delete($data, $web_config); @@ -2335,11 +2340,6 @@ class nginx_plugin { $this->awstats_delete($data, $web_config); } - //* Remove the GoAccess configuration file - if($data['old']['stats_type'] == 'goaccess') { - $this->goaccess_delete($data, $web_config); - } - //* Delete the web-backups if($data['old']['type'] == 'vhost') { $server_config = $app->getconf->get_server_config($conf['server_id'], 'server'); -- GitLab From 20148d62f00065ee14622f71cafdf9d9a9d6b984 Mon Sep 17 00:00:00 2001 From: Michael Seevogel Date: Sat, 22 Aug 2020 14:47:33 +0200 Subject: [PATCH 4/5] delete the stat generator config files only when changed --- server/plugins-available/apache2_plugin.inc.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/plugins-available/apache2_plugin.inc.php b/server/plugins-available/apache2_plugin.inc.php index 2ad4d7533b..f11476b402 100644 --- a/server/plugins-available/apache2_plugin.inc.php +++ b/server/plugins-available/apache2_plugin.inc.php @@ -1926,18 +1926,18 @@ class apache2_plugin { } //* Remove the AWstats configuration file - if($data['old']['stats_type'] == 'awstats') { + if($data['old']['stats_type'] == 'awstats' && $data['new']['stats_type'] != 'awstats') { $this->awstats_delete($data, $web_config); } //* Remove the GoAccess configuration file - if($data['old']['stats_type'] == 'goaccess') { + if($data['old']['stats_type'] == 'goaccess' && $data['new']['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); + if($data['old']['stats_type'] == 'webalizer' && $data['new']['stats_type'] != 'webalizer') { + $this->webalizer_delete($data, $web_config); } $this->php_fpm_pool_update($data, $web_config, $pool_dir, $pool_name, $socket_dir, $web_folder); -- GitLab From 03b6cc5700e51a98c55e2451ade012f3446d96a0 Mon Sep 17 00:00:00 2001 From: Michael Seevogel Date: Sat, 22 Aug 2020 14:50:51 +0200 Subject: [PATCH 5/5] also update the nginx plugin --- server/plugins-available/nginx_plugin.inc.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server/plugins-available/nginx_plugin.inc.php b/server/plugins-available/nginx_plugin.inc.php index 9888c7e209..4b20a03391 100644 --- a/server/plugins-available/nginx_plugin.inc.php +++ b/server/plugins-available/nginx_plugin.inc.php @@ -1940,18 +1940,18 @@ class nginx_plugin { } //* Remove the AWstats configuration file - if($data['old']['stats_type'] == 'awstats') { - $this->awstats_delete($data, $web_config); + if($data['old']['stats_type'] == 'awstats' && $data['new']['stats_type'] != 'awstats') { + $this->awstats_delete($data, $web_config); } //* Remove the GoAccess configuration file - if($data['old']['stats_type'] == 'goaccess') { + if($data['old']['stats_type'] == 'goaccess' && $data['new']['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); + if($data['old']['stats_type'] == 'webalizer' && $data['new']['stats_type'] != 'webalizer') { + $this->webalizer_delete($data, $web_config); } //* Remove Stats-Folder when Statistics set to none -- GitLab