From 039db24f9a900b4b2c0141bfd5eb6d665dc19ed6 Mon Sep 17 00:00:00 2001 From: Robert Breithuber Date: Wed, 9 Sep 2020 17:59:52 +0200 Subject: [PATCH 1/2] makes the language configurable for each site, it reads the "Lang" parameter from awstats.DOMAIN.conf before it gets deleted and adds the parameter to the content before the new config file is written. the "-lang" parameter is removed from the awstats-command, so the global value for lang in awstats.conf.local or the value in awstats.DOMAIN.conf gets respected. Closes #3668 --- server/lib/classes/cron.d/150-awstats.inc.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/server/lib/classes/cron.d/150-awstats.inc.php b/server/lib/classes/cron.d/150-awstats.inc.php index 891919cb02..2edf0222f0 100644 --- a/server/lib/classes/cron.d/150-awstats.inc.php +++ b/server/lib/classes/cron.d/150-awstats.inc.php @@ -86,7 +86,14 @@ class cronjob_awstats extends cronjob { $awstats_conf_dir = $web_config['awstats_conf_dir']; $awstats_website_conf_file = $web_config['awstats_conf_dir'].'/awstats.'.$domain.'.conf'; - if(is_file($awstats_website_conf_file)) unlink($awstats_website_conf_file); + $existing_awstats_conf_array = array(); + if(is_file($awstats_website_conf_file)) { + $existing_awstats_conf = file($awstats_website_conf_file); + foreach ($existing_awstats_conf as $line) { + if(preg_match("/Lang=/",$line)) $existing_awstats_conf_array['Lang'] = implode('',parse_ini_string($line)); + } + unlink($awstats_website_conf_file); + } $sql = "SELECT domain FROM web_domain WHERE (type = 'alias' OR type = 'subdomain') AND parent_domain_id = ?"; $aliases = $app->db->queryAllRecords($sql, $rec['domain_id']); @@ -108,6 +115,8 @@ class cronjob_awstats extends cronjob { LogFile="/var/log/ispconfig/httpd/'.$domain.'/yesterday-access.log" SiteDomain="'.$domain.'" HostAliases="www.'.$domain.' localhost 127.0.0.1'.$aliasdomain.'"'; + if (array_key_exists('Lang',$existing_awstats_conf_array)) $awstats_conf_file_content .=' + Lang="'.$existing_awstats_conf_array['Lang'].'"'; if (isset($include_file)) { file_put_contents($awstats_website_conf_file, $awstats_conf_file_content); } else { @@ -134,7 +143,7 @@ class cronjob_awstats extends cronjob { } } - $command = escapeshellcmd($awstats_buildstaticpages_pl) . ' -month=' . escapeshellarg($awmonth) . ' -year=' . escapeshellarg($awyear) . ' -update -config=' . escapeshellarg($domain) . ' -lang=' . escapeshellarg($conf['language']) . ' -dir=' . escapeshellarg($statsdir) . ' -awstatsprog=' . escapeshellarg($awstats_pl); + $command = escapeshellcmd($awstats_buildstaticpages_pl) . ' -month=' . escapeshellarg($awmonth) . ' -year=' . escapeshellarg($awyear) . ' -update -config=' . escapeshellarg($domain) . ' -dir=' . escapeshellarg($statsdir) . ' -awstatsprog=' . escapeshellarg($awstats_pl) . '"; if (date("d") == 2) { $awmonth = date("m")-1; -- GitLab From 102a8bfcd55cf2b663e257bcd9a29d6516ba32ae Mon Sep 17 00:00:00 2001 From: Robert Breithuber Date: Wed, 9 Sep 2020 21:04:42 +0200 Subject: [PATCH 2/2] Update 150-awstats.inc.php --- server/lib/classes/cron.d/150-awstats.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/lib/classes/cron.d/150-awstats.inc.php b/server/lib/classes/cron.d/150-awstats.inc.php index 2edf0222f0..cd981baf8a 100644 --- a/server/lib/classes/cron.d/150-awstats.inc.php +++ b/server/lib/classes/cron.d/150-awstats.inc.php @@ -143,7 +143,7 @@ class cronjob_awstats extends cronjob { } } - $command = escapeshellcmd($awstats_buildstaticpages_pl) . ' -month=' . escapeshellarg($awmonth) . ' -year=' . escapeshellarg($awyear) . ' -update -config=' . escapeshellarg($domain) . ' -dir=' . escapeshellarg($statsdir) . ' -awstatsprog=' . escapeshellarg($awstats_pl) . '"; + $command = escapeshellcmd($awstats_buildstaticpages_pl) . ' -month=' . escapeshellarg($awmonth) . ' -year=' . escapeshellarg($awyear) . ' -update -config=' . escapeshellarg($domain) . ' -dir=' . escapeshellarg($statsdir) . ' -awstatsprog=' . escapeshellarg($awstats_pl); if (date("d") == 2) { $awmonth = date("m")-1; -- GitLab