Skip to content

Commit 8fde67e

Browse files
author
Till Brehm
committed
Merge branch 'delete-stat-configs' into 'stable-3.1'
Delete stat config if stat_type was changed See merge request ispconfig/ispconfig3!1104
2 parents 80ab2f9 + 03b6cc5 commit 8fde67e

File tree

2 files changed

+55
-11
lines changed

2 files changed

+55
-11
lines changed

server/plugins-available/apache2_plugin.inc.php

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1925,6 +1925,21 @@ function update($event_name, $data) {
19251925
$app->file->removeDirectory($data['new']['document_root'].'/web/stats');
19261926
}
19271927

1928+
//* Remove the AWstats configuration file
1929+
if($data['old']['stats_type'] == 'awstats' && $data['new']['stats_type'] != 'awstats') {
1930+
$this->awstats_delete($data, $web_config);
1931+
}
1932+
1933+
//* Remove the GoAccess configuration file
1934+
if($data['old']['stats_type'] == 'goaccess' && $data['new']['stats_type'] != 'goaccess') {
1935+
$this->goaccess_delete($data, $web_config);
1936+
}
1937+
1938+
//* Remove the Webalizer configuration file
1939+
if($data['old']['stats_type'] == 'webalizer' && $data['new']['stats_type'] != 'webalizer') {
1940+
$this->webalizer_delete($data, $web_config);
1941+
}
1942+
19281943
$this->php_fpm_pool_update($data, $web_config, $pool_dir, $pool_name, $socket_dir, $web_folder);
19291944
$this->hhvm_update($data, $web_config);
19301945

@@ -2328,16 +2343,11 @@ function delete($event_name, $data) {
23282343

23292344
}
23302345

2331-
//* Remove the awstats configuration file
2346+
//* Remove the AWstats configuration file
23322347
if($data['old']['stats_type'] == 'awstats') {
23332348
$this->awstats_delete($data, $web_config);
23342349
}
23352350

2336-
//* Remove the GoAccess configuration file
2337-
if($data['old']['stats_type'] == 'goaccess') {
2338-
$this->goaccess_delete($data, $web_config);
2339-
}
2340-
23412351
if($data['old']['type'] == 'vhostsubdomain' || $data['old']['type'] == 'vhostalias') {
23422352
$app->system->web_folder_protection($parent_web_document_root, true);
23432353
}
@@ -3128,6 +3138,18 @@ private function goaccess_delete ($data, $web_config) {
31283138
}
31293139
}
31303140

3141+
//* Delete the Webalizer configuration file
3142+
private function webalizer_delete ($data, $web_config) {
3143+
global $app;
3144+
3145+
$webalizer_conf = $data['old']['document_root'] . "/log/webalizer.conf";
3146+
3147+
if ( @is_file($webalizer_conf) ) {
3148+
$app->system->unlink($webalizer_conf);
3149+
$app->log('Removed Webalizer config file: '.$webalizer_conf, LOGLEVEL_DEBUG);
3150+
}
3151+
}
3152+
31313153
private function hhvm_update($data, $web_config) {
31323154
global $app, $conf;
31333155

server/plugins-available/nginx_plugin.inc.php

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,6 +1939,21 @@ function update($event_name, $data) {
19391939
$this->goaccess_update($data, $web_config);
19401940
}
19411941

1942+
//* Remove the AWstats configuration file
1943+
if($data['old']['stats_type'] == 'awstats' && $data['new']['stats_type'] != 'awstats') {
1944+
$this->awstats_delete($data, $web_config);
1945+
}
1946+
1947+
//* Remove the GoAccess configuration file
1948+
if($data['old']['stats_type'] == 'goaccess' && $data['new']['stats_type'] != 'goaccess') {
1949+
$this->goaccess_delete($data, $web_config);
1950+
}
1951+
1952+
//* Remove the Webalizer configuration file
1953+
if($data['old']['stats_type'] == 'webalizer' && $data['new']['stats_type'] != 'webalizer') {
1954+
$this->webalizer_delete($data, $web_config);
1955+
}
1956+
19421957
//* Remove Stats-Folder when Statistics set to none
19431958
if($data['new']['stats_type'] == '' && ($data['new']['type'] == 'vhost' || $data['new']['type'] == 'vhostsubdomain' || $data['new']['type'] == 'vhostalias')) {
19441959
$app->file->removeDirectory($data['new']['document_root'].'/web/stats');
@@ -2325,11 +2340,6 @@ function delete($event_name, $data) {
23252340
$this->awstats_delete($data, $web_config);
23262341
}
23272342

2328-
//* Remove the GoAccess configuration file
2329-
if($data['old']['stats_type'] == 'goaccess') {
2330-
$this->goaccess_delete($data, $web_config);
2331-
}
2332-
23332343
//* Delete the web-backups
23342344
if($data['old']['type'] == 'vhost') {
23352345
$server_config = $app->getconf->get_server_config($conf['server_id'], 'server');
@@ -2653,6 +2663,18 @@ private function goaccess_delete ($data, $web_config) {
26532663
}
26542664
}
26552665

2666+
//* Delete the Webalizer configuration file
2667+
private function webalizer_delete ($data, $web_config) {
2668+
global $app;
2669+
2670+
$webalizer_conf = $data['old']['document_root'] . "/log/webalizer.conf";
2671+
2672+
if ( @is_file($webalizer_conf) ) {
2673+
$app->system->unlink($webalizer_conf);
2674+
$app->log('Removed Webalizer config file: '.$webalizer_conf, LOGLEVEL_DEBUG);
2675+
}
2676+
}
2677+
26562678
//* Update the awstats configuration file
26572679
private function awstats_update ($data, $web_config) {
26582680
global $app;

0 commit comments

Comments
 (0)