diff --git a/server/lib/classes/.system.inc.php.swp b/server/lib/classes/.system.inc.php.swp
new file mode 100644
index 0000000000000000000000000000000000000000..ffcf3125ccd5c07ce14da979526066c47c98501c
Binary files /dev/null and b/server/lib/classes/.system.inc.php.swp differ
diff --git a/server/lib/classes/cron.d/150-goaccess.inc.php b/server/lib/classes/cron.d/150-goaccess.inc.php
index 7c704863177f49991cb14cd2005bd4ef60555f10..8f5c2a4323594af633cadb2dc39777598b7c94e6 100644
--- a/server/lib/classes/cron.d/150-goaccess.inc.php
+++ b/server/lib/classes/cron.d/150-goaccess.inc.php
@@ -51,6 +51,7 @@ class cronjob_goaccess extends cronjob {
 	public function onRunJob() {
 		global $app, $conf;
 
+
 		//######################################################################################################
 		// Create goaccess statistics
 		//######################################################################################################
@@ -76,7 +77,7 @@ class cronjob_goaccess extends cronjob {
                 }
 
 
-                /* Check wether the goaccess binary is in path */
+                /* Check if goaccess binary is in path */
                 system("type goaccess 2>&1>/dev/null", $retval);
 		if ($retval === 0) {
 
@@ -113,40 +114,43 @@ class cronjob_goaccess extends cronjob {
 				*/
 
 				if(file_exists("/usr/local/ispconfig/server/conf-custom/goaccess.conf.master") && (!file_exists($goaccess_conf))) {
-					copy("/usr/local/ispconfig/server/conf-custom/goaccess.conf.master", $goaccess_conf);
+					$app->system->copy("/usr/local/ispconfig/server/conf-custom/goaccess.conf.master", $goaccess_conf);
 				} elseif(!file_exists($goaccess_conf)) {
 					/*
 					 By default the goaccess.conf should get copied by the webserver plugin but in case it wasn't, or it got deleted by accident we gonna copy it again to the destination dir.
 					 Also there was no /usr/local/ispconfig/server/conf-custom/goaccess.conf.master, so we gonna use /etc/goaccess.conf as the base conf.
 					*/
-	                        	copy($goaccess_conf_main, $goaccess_conf);
-		                        file_put_contents($goaccess_conf, preg_replace('/^(#)?log-format COMBINED/m', "log-format COMBINED", file_get_contents($goaccess_conf)));
+
+					$app->system->copy($goaccess_conf_main, $goaccess_conf);
+					$content = $app->system->file_get_contents($goaccess_conf, true);
+					$content = preg_replace('/^(#)?log-format COMBINED/m', "log-format COMBINED", $content);
+					$app->system->file_put_contents($goaccess_conf, $content, true);
+					unset($content);
 				}
 
 				/* Update the primary domain name in the title, it could occasionally change */
 				if(is_file($goaccess_conf) && (filesize($goaccess_conf) > 0)) {
-					$goaccess_content = file_get_contents($goaccess_conf);
-					file_put_contents($goaccess_conf, preg_replace('/^(#)?html-report-title(.*)?/m', "html-report-title $domain", file_get_contents($goaccess_conf)));
-					unset($goaccess_content);
+					$content = $app->system->file_get_contents($goaccess_conf, true);
+					$content = preg_replace('/^(#)?html-report-title(.*)/m', "html-report-title $domain", $content);
+					$app->system->file_put_contents($goaccess_conf, $content, true);
+					unset($content);
 				}
 
+                                $username = $rec['system_user'];
+                                $groupname = $rec['system_group'];
+                                $docroot = $rec['document_root'];
 
-
-				if(!@is_dir($statsdir)) mkdir($statsdir);
-				$username = $rec['system_user'];
-				$groupname = $rec['system_group'];
-				$docroot = $rec['document_root'];
+				if(!@is_dir($statsdir)) $app->system->mkdirpath($statsdir, 0755, $username, $groupname);
 
 				$goa_db_dir = $docroot.'/'.$web_folder.'/stats/.db/';
 				$output_html = $docroot.'/'.$web_folder.'/stats/goaindex.html';
-	                        if(!@is_dir($goa_db_dir)) mkdir($goa_db_dir);
+	                        if(!@is_dir($goa_db_dir)) $app->system->mkdirpath($goa_db_dir, 0755, $username, $groupname);
 	
 	                        if(is_link('/var/log/ispconfig/httpd/'.$domain.'/yesterday-access.log')) unlink('/var/log/ispconfig/httpd/'.$domain.'/yesterday-access.log');
 	                        symlink($logfile, '/var/log/ispconfig/httpd/'.$domain.'/yesterday-access.log');
 
 
-				chown($statsdir, $username);
-				chgrp($statsdir, $groupname);
+				$app->system->exec_safe('chown -R ?:? ?', $username, $groupname, $statsdir);
 
 				$goamonth = date("n");
 				$goayear = date("Y");
@@ -159,7 +163,6 @@ class cronjob_goaccess extends cronjob {
 					}
 				}
 
-	
 				if (date("d") == 2) {
 					$goamonth = date("m")-1;
 					if (date("m") == 1) {
@@ -170,7 +173,7 @@ class cronjob_goaccess extends cronjob {
 					$statsdirold = $statsdir."/".$goayear."-".$goamonth."/";
 
 					if(!is_dir($statsdirold)) {
-						mkdir($statsdirold);
+						 $app->system->mkdirpath($statsdirold, 0755, $username, $groupname);
 					}
 
 					// don't rotate db files per month
@@ -180,39 +183,57 @@ class cronjob_goaccess extends cronjob {
 					$files = scandir($statsdir);
 
 					foreach ($files as $file) {
-						if (substr($file, 0, 1) != "." && !is_dir("$statsdir"."/"."$file") && substr($file, 0, 1) != "w" && substr($file, 0, 1) != "i") copy("$statsdir"."/"."$file", "$statsdirold"."$file");
+						if (substr($file, 0, 1) != "." && !is_dir("$statsdir"."/"."$file") && substr($file, 0, 1) != "w" && substr($file, 0, 1) != "i") $app->system->copy("$statsdir"."/"."$file", "$statsdirold"."$file");
 					}
 				}
 
+				// Get the GoAccess version
+				$match = array();
 
-				$output = shell_exec('goaccess --help');
-
-				if(preg_match('/keep-db-files/', $output)) {
-					$app->system->exec_safe("goaccess -f ? --config-file ? --load-from-disk --keep-db-files --db-path=? --output=?", $logfile, $goaccess_conf, $goa_db_dir, $output_html);
-
-					if(!is_file($rec['document_root']."/".$web_folder."/stats/index.php")) {
-						if(file_exists("/usr/local/ispconfig/server/conf-custom/goaccess_index.php.master")) {
-							copy("/usr/local/ispconfig/server/conf-custom/goaccess_index.php.master", $rec['document_root']."/".$web_folder."/stats/index.php");
-						} else {
-							copy("/usr/local/ispconfig/server/conf/goaccess_index.php.master", $rec['document_root']."/".$web_folder."/stats/index.php");
-						}
-					}
+				$goaccess_version = $app->system->system_safe('goaccess --version 2>&1');
 
-		                        $app->log('Created GoAccess statistics for ' . $domain, LOGLEVEL_DEBUG);
-		                        if(is_file($rec['document_root']."/".$web_folder."/stats/index.php")) {
-		                                chown($rec['document_root']."/".$web_folder."/stats/index.php", $rec['system_user']);
-		                                chgrp($rec['document_root']."/".$web_folder."/stats/index.php", $rec['system_group']);
-		                        }
+				if(preg_match('/[0-9]\.[0-9]{1,2}/', $goaccess_version, $match)) {
+					$goaccess_version = $match[0];
+				}
 
-		                        $app->system->exec_safe('chown -R ?:? ?', $username, $groupname, $statsdir);
 
+				/*
+				 * GoAccess removed with 1.4 btree support and supports from this version on only "In-Memory with On-Disk Persitance Storage".
+				 * For versions prior 1.4 you need GoAccess with btree support compiled!
+				 */
+				
+				$cust_lang = $conf['language']."_".strtoupper($conf['language']);
+
+				if(version_compare($goaccess_version,1.4) >= 0) {
+					$app->system->exec_safe("LANG=? goaccess -f ? --config-file ? --restore --persist --db-path=? --output=?", $cust_lang, $logfile, $goaccess_conf, $goa_db_dir, $output_html);
 				} else {
-			                $app->log("Stats not generated. The GoAccess binary was not compiled with btree support. Please recompile/reinstall GoAccess with btree support!", LOGLEVEL_ERROR);
+					$output = $app->system->system_safe('goaccess --help');
+	                                if(preg_match('/keep-db-files/', $output)) {
+						$app->system->exec_safe("LANG=? goaccess -f ? --config-file ? --load-from-disk --keep-db-files --db-path=? --output=?", $cust_lang, $logfile, $goaccess_conf, $goa_db_dir, $output_html);
+					} else {
+	                                        $app->log("Stats not generated. The GoAccess binary was not compiled with btree support. Please recompile/reinstall GoAccess with btree support, or install GoAccess version >= 1.4!", LOGLEVEL_ERROR);
+					}
+	                                unset($output);
 				}
+				unset($cust_lang);
+
+				if(!is_file($rec['document_root']."/".$web_folder."/stats/index.php")) {
+					if(file_exists("/usr/local/ispconfig/server/conf-custom/goaccess_index.php.master")) {
+						$app->system->copy("/usr/local/ispconfig/server/conf-custom/goaccess_index.php.master", $rec['document_root']."/".$web_folder."/stats/index.php");
+					} else {
+						$app->system->copy("/usr/local/ispconfig/server/conf/goaccess_index.php.master", $rec['document_root']."/".$web_folder."/stats/index.php");
+					}
+				}
+
+	                        $app->log('Created GoAccess statistics for ' . $domain, LOGLEVEL_DEBUG);
+	                        if(is_file($rec['document_root']."/".$web_folder."/stats/index.php")) {
+	                                chown($rec['document_root']."/".$web_folder."/stats/index.php", $rec['system_user']);
+	                                chgrp($rec['document_root']."/".$web_folder."/stats/index.php", $rec['system_group']);
+	                        }
 
-				unset($output);
+				$app->system->exec_safe('chown -R ?:? ?', $username, $groupname, $statsdir);
+			}
 
-		}
 	} else {
 		$app->log("Stats not generated. The GoAccess binary couldn't be found. Make sure that GoAccess is installed and that it is in \$PATH", LOGLEVEL_ERROR);
 	}
diff --git a/server/plugins-available/apache2_plugin.inc.php b/server/plugins-available/apache2_plugin.inc.php
index aecab199cd8e3275f0627435c4880e54cbc381a6..b348c823e68bfde9b7e1353a86812df5efbe28f3 100644
--- a/server/plugins-available/apache2_plugin.inc.php
+++ b/server/plugins-available/apache2_plugin.inc.php
@@ -1868,7 +1868,6 @@ class apache2_plugin {
                         $this->goaccess_update($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');
@@ -2282,6 +2281,11 @@ class apache2_plugin {
 				$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);
 			}
@@ -2979,6 +2983,18 @@ class apache2_plugin {
 		}
 	}
 
+        //* Delete the awstats configuration file
+        private function awstats_delete ($data, $web_config) {
+                global $app;
+
+                $awstats_conf_dir = $web_config['awstats_conf_dir'];
+
+                if ( @is_file($awstats_conf_dir.'/awstats.'.$data['old']['domain'].'.conf') ) {
+                        $app->system->unlink($awstats_conf_dir.'/awstats.'.$data['old']['domain'].'.conf');
+                        $app->log('Removed AWStats config file: '.$awstats_conf_dir.'/awstats.'.$data['old']['domain'].'.conf', LOGLEVEL_DEBUG);
+                }
+        }
+
 	//* Update the GoAccess configuration file
         private function goaccess_update ($data, $web_config) {
                 global $app;
@@ -2996,34 +3012,44 @@ class apache2_plugin {
                         } else {
                                 $count++;
                                 if($count == 2) {
-                                        $app->log("No GoAccess base config found. Make sure that GoAccess is installed and that the goaccess.conf does exist in /etc or /etc/goaccess", LOGLEVEL_ERROR);
+                                        $app->log("No GoAccess base config found. Make sure that GoAccess is installed and that the goaccess.conf does exist in /etc or /etc/goaccess", LOGLEVEL_WARN);
                                 }
                         }
                 }
 
-
-                if(!is_dir($data['new']['document_root']."/" . $web_folder . "/stats/")) mkdir($data['new']['document_root']."/" . $web_folder . "/stats/.db");
-                $goaccess_conf = escapeshellcmd($data['new']['document_root'].'/log/goaccess.conf');
-
+                if(!is_dir($data['new']['document_root']."/" . $web_folder . "/stats/")) $app->system->mkdirpath($data['new']['document_root']."/" . $web_folder . "/stats/.db");
+                $goaccess_conf = $data['new']['document_root'].'/log/goaccess.conf';
 
                 /*
                 In case that you use a different log format, you should use a custom goaccess.conf which you'll have to put into /usr/local/ispconfig/server/conf-custom/.
                 By default the originaly with GoAccess shipped goaccess.conf from /etc/ will be used along with the log-format value COMBINED. 
-                */
-                if(file_exists("/usr/local/ispconfig/server/conf-custom/goaccess.conf.master") && (!file_exists($goaccess_conf))) {
-                        copy("/usr/local/ispconfig/server/conf-custom/goaccess.conf.master", $goaccess_conf);
+		*/
+
+                if(file_exists("/usr/local/ispconfig/server/conf-custom/goaccess.conf.master")) {
+                        $app->system->copy("/usr/local/ispconfig/server/conf-custom/goaccess_index.php.master", $goaccess_conf);
+
                 } elseif(!file_exists($goaccess_conf)) {
-                        /*
+
+			/*
                          By default the goaccess.conf should get copied by the webserver plugin but in case it wasn't, or it got deleted by accident we gonna copy it again to the destination dir.
                          Also there was no /usr/local/ispconfig/server/conf-custom/goaccess.conf.master, so we gonna use /etc/goaccess.conf as the base conf.
-                        */
-                        copy($goaccess_conf_main, $goaccess_conf);
-                        file_put_contents($goaccess_conf, preg_replace('/^(#)?log-format COMBINED/m', "log-format COMBINED", file_get_contents($goaccess_conf)));
+			 */
+
+			$app->system->copy($goaccess_conf_main, $goaccess_conf);
+			$content = $app->system->file_get_contents($goaccess_conf, true);
+			$content = preg_replace('/^(#)?log-format COMBINED/m', "log-format COMBINED", $content);
+			$app->system->file_put_contents($goaccess_conf, $content, true);
+			unset($content);
+
                 }
 
                 if(file_exists($goaccess_conf)) {
-                        $domain = escapeshellcmd($data['new']['domain']);
-                        file_put_contents($goaccess_conf, preg_replace('/^(#)?html-report-title(.*)/m', "html-report-title $domain", file_get_contents($goaccess_conf)));
+                        $domain = $data['new']['domain'];
+                        $content = $app->system->file_get_contents($goaccess_conf, true);
+                        $content = preg_replace('/^(#)?html-report-title(.*)/m', "html-report-title $domain", $content);
+                        $app->system->file_put_contents($goaccess_conf, $content, true);
+                        unset($content);
+
                 }
 
                 if(is_file($goaccess_conf) && (filesize($goaccess_conf) > 0)) {
@@ -3040,28 +3066,15 @@ class apache2_plugin {
                 }
         }
 
-        //* Delete the GoAccess configuration file
-        private function goaccess_delete ($data, $web_config) {
-                global $app;
-
-                $goaccess_conf = escapeshellcmd($data['new']['document_root'].'/log/goaccess.conf');
-
-                if ( @is_file($goaccess_conf) ) {
-                        $app->system->unlink($goaccess_conf);
-                        $app->log('Removed GoAccess config file: '.$goaccess_conf, LOGLEVEL_DEBUG);
-                }
-        }
-
-
-	//* Delete the awstats configuration file
-	private function awstats_delete ($data, $web_config) {
+	//* Delete the GoAccess configuration file
+	private function goaccess_delete ($data, $web_config) {
 		global $app;
 
-		$awstats_conf_dir = $web_config['awstats_conf_dir'];
+		$goaccess_conf = $data['old']['document_root'] . "/log/goaccess.conf";
 
-		if ( @is_file($awstats_conf_dir.'/awstats.'.$data['old']['domain'].'.conf') ) {
-			$app->system->unlink($awstats_conf_dir.'/awstats.'.$data['old']['domain'].'.conf');
-			$app->log('Removed AWStats config file: '.$awstats_conf_dir.'/awstats.'.$data['old']['domain'].'.conf', LOGLEVEL_DEBUG);
+		if ( @is_file($goaccess_conf) ) {
+			$app->system->unlink($goaccess_conf);
+			$app->log('Removed GoAccess config file: '.$goaccess_conf, LOGLEVEL_DEBUG);
 		}
 	}
 
diff --git a/server/plugins-available/nginx_plugin.inc.php b/server/plugins-available/nginx_plugin.inc.php
index 3c59011cbb8c80dcf62e6deb1d7c5eb1d3258bfb..2b3223a9d905540ae937ca000cc6cd65deea5115 100644
--- a/server/plugins-available/nginx_plugin.inc.php
+++ b/server/plugins-available/nginx_plugin.inc.php
@@ -1906,6 +1906,11 @@ class nginx_plugin {
 			$this->awstats_update($data, $web_config);
 		}
 
+                //* Create GoAccess configuration
+                if($data['new']['stats_type'] == 'goaccess' && ($data['new']['type'] == 'vhost' || $data['new']['type'] == 'vhostsubdomain' || $data['new']['type'] == 'vhostalias')) {
+                        $this->goaccess_update($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');
@@ -2292,6 +2297,11 @@ 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');
@@ -2534,8 +2544,8 @@ class nginx_plugin {
 
 
 
-        //* Update the GoAccess configuration file
-        private function goaccess_update ($data, $web_config) {
+	//* Update the GoAccess configuration file
+	private function goaccess_update ($data, $web_config) {
                 global $app;
 
                 $web_folder = $data['new']['web_folder'];
@@ -2549,56 +2559,67 @@ class nginx_plugin {
                                 $goaccess_conf_main = $goa_loc;
                                 break;
                         } else {
-                                $count++;
+                                $count++; 
                                 if($count == 2) {
-                                        $app->log("No GoAccess base config found. Make sure that GoAccess is installed and that the goaccess.conf does exist in /etc or /etc/goaccess", LOGLEVEL_ERROR);
+                                        $app->log("No GoAccess base config found. Make sure that GoAccess is installed and that the goaccess.conf does exist in /etc or /etc/goaccess", LOGLEVEL_WARN);
                                 }
                         }
                 }
 
+                if(!is_dir($data['new']['document_root']."/" . $web_folder . "/stats/")) $app->system->mkdirpath($data['new']['document_root']."/" . $web_folder . "/stats/.db");
+                $goaccess_conf = $data['new']['document_root'].'/log/goaccess.conf';
 
-                if(!is_dir($data['new']['document_root']."/" . $web_folder . "/stats/")) mkdir($data['new']['document_root']."/" . $web_folder . "/stats/.db");
-		$goaccess_conf = escapeshellcmd($data['new']['document_root'].'/log/goaccess.conf');
+                /*
+                In case that you use a different log format, you should use a custom goaccess.conf which you'll have to put into /usr/local/ispconfig/server/conf-custom/.
+                By default the originaly with GoAccess shipped goaccess.conf from /etc/ will be used along with the log-format value COMBINED. 
+                */
 
-		/*
-		In case that you use a different log format, you should use a custom goaccess.conf which you'll have to put into /usr/local/ispconfig/server/conf-custom/.
-		By default the originaly with GoAccess shipped goaccess.conf from /etc/ will be used along with the log-format value COMBINED. 
-		*/
-		if(file_exists("/usr/local/ispconfig/server/conf-custom/goaccess.conf.master") && (!file_exists($goaccess_conf))) {
-			copy("/usr/local/ispconfig/server/conf-custom/goaccess.conf.master", $goaccess_conf);
-		} elseif(!file_exists($goaccess_conf)) {
-			/*
-			 By default the goaccess.conf should get copied by the webserver plugin but in case it wasn't, or it got deleted by accident we gonna copy it again to the destination dir.
-			 Also there was no /usr/local/ispconfig/server/conf-custom/goaccess.conf.master, so we gonna use /etc/goaccess.conf as the base conf.
-			*/
-			copy($goaccess_conf_main, $goaccess_conf);
-			file_put_contents($goaccess_conf, preg_replace('/^(#)?log-format COMBINED/m', "log-format COMBINED", file_get_contents($goaccess_conf)));
-		}
+                if(file_exists("/usr/local/ispconfig/server/conf-custom/goaccess.conf.master")) {
+                        $app->system->copy("/usr/local/ispconfig/server/conf-custom/goaccess_index.php.master", $goaccess_conf);
+
+                } elseif(!file_exists($goaccess_conf)) {
+
+                        /*
+                         By default the goaccess.conf should get copied by the webserver plugin but in case it wasn't, or it got deleted by accident we gonna copy it again to the destination dir.
+                         Also there was no /usr/local/ispconfig/server/conf-custom/goaccess.conf.master, so we gonna use /etc/goaccess.conf as the base conf.
+                         */
+
+                        $app->system->copy($goaccess_conf_main, $goaccess_conf);
+                        $content = $app->system->file_get_contents($goaccess_conf, true);
+                        $content = preg_replace('/^(#)?log-format COMBINED/m', "log-format COMBINED", $content);
+                        $app->system->file_put_contents($goaccess_conf, $content, true);
+                        unset($content);
+
+                }
 
                 if(file_exists($goaccess_conf)) {
-                        $domain = escapeshellcmd($data['new']['domain']);
-			file_put_contents($goaccess_conf, preg_replace('/^(#)?html-report-title(.*)/m', "html-report-title $domain", file_get_contents($goaccess_conf)));
-		}
+                        $domain = $data['new']['domain'];
+                        $content = $app->system->file_get_contents($goaccess_conf, true);
+                        $content = preg_replace('/^(#)?html-report-title(.*)/m', "html-report-title $domain", $content);
+                        $app->system->file_put_contents($goaccess_conf, $content, true);
+                        unset($content);
 
-		if(is_file($goaccess_conf) && (filesize($goaccess_conf) > 0)) {
-			$app->log('Created GoAccess config file: '.$goaccess_conf, LOGLEVEL_DEBUG);
-		} else {
-			$app->log("No GoAccess base config found. Make sure that GoAccess is installed and that the goaccess.conf does exist in ".$goaccess_conf_dir.".", LOGLEVEL_WARN);
-		}
+                }
+
+                if(is_file($goaccess_conf) && (filesize($goaccess_conf) > 0)) {
+                        $app->log('Created GoAccess config file: '.$goaccess_conf, LOGLEVEL_DEBUG);
+                } else {
+                        $app->log("No GoAccess base config found. Make sure that GoAccess is installed and that the goaccess.conf does exist in ".$goaccess_conf_dir.".", LOGLEVEL_WARN);
+                }
 
                 if(is_file($data['new']['document_root']."/" . $web_folder . "/stats/index.html")) $app->system->unlink($data['new']['document_root']."/" . $web_folder . "/stats/index.html");
                 if(file_exists("/usr/local/ispconfig/server/conf-custom/goaccess_index.php.master")) {
                         $app->system->copy("/usr/local/ispconfig/server/conf-custom/goaccess_index.php.master", $data['new']['document_root']."/" . $web_folder . "/stats/index.php");
                 } else {
                         $app->system->copy("/usr/local/ispconfig/server/conf/goaccess_index.php.master", $data['new']['document_root']."/" . $web_folder . "/stats/index.php");
-                }
-        }
+		}
+	}
 
         //* Delete the GoAccess configuration file
         private function goaccess_delete ($data, $web_config) {
                 global $app;
 
-                $goaccess_conf = escapeshellcmd($data['new']['document_root'].'/log/goaccess.conf');
+                $goaccess_conf = $data['old']['document_root'] . "/log/goaccess.conf";
 
                 if ( @is_file($goaccess_conf) ) {
                         $app->system->unlink($goaccess_conf);
@@ -2606,9 +2627,6 @@ class nginx_plugin {
                 }
         }
 
-
-
-
 	//* Update the awstats configuration file
 	private function awstats_update ($data, $web_config) {
 		global $app;