Skip to content

Commit 039db24

Browse files
committed
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
1 parent d7151cc commit 039db24

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

server/lib/classes/cron.d/150-awstats.inc.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,14 @@ public function onRunJob() {
8686
$awstats_conf_dir = $web_config['awstats_conf_dir'];
8787
$awstats_website_conf_file = $web_config['awstats_conf_dir'].'/awstats.'.$domain.'.conf';
8888

89-
if(is_file($awstats_website_conf_file)) unlink($awstats_website_conf_file);
89+
$existing_awstats_conf_array = array();
90+
if(is_file($awstats_website_conf_file)) {
91+
$existing_awstats_conf = file($awstats_website_conf_file);
92+
foreach ($existing_awstats_conf as $line) {
93+
if(preg_match("/Lang=/",$line)) $existing_awstats_conf_array['Lang'] = implode('',parse_ini_string($line));
94+
}
95+
unlink($awstats_website_conf_file);
96+
}
9097

9198
$sql = "SELECT domain FROM web_domain WHERE (type = 'alias' OR type = 'subdomain') AND parent_domain_id = ?";
9299
$aliases = $app->db->queryAllRecords($sql, $rec['domain_id']);
@@ -108,6 +115,8 @@ public function onRunJob() {
108115
LogFile="/var/log/ispconfig/httpd/'.$domain.'/yesterday-access.log"
109116
SiteDomain="'.$domain.'"
110117
HostAliases="www.'.$domain.' localhost 127.0.0.1'.$aliasdomain.'"';
118+
if (array_key_exists('Lang',$existing_awstats_conf_array)) $awstats_conf_file_content .='
119+
Lang="'.$existing_awstats_conf_array['Lang'].'"';
111120
if (isset($include_file)) {
112121
file_put_contents($awstats_website_conf_file, $awstats_conf_file_content);
113122
} else {
@@ -134,7 +143,7 @@ public function onRunJob() {
134143
}
135144
}
136145

137-
$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);
146+
$command = escapeshellcmd($awstats_buildstaticpages_pl) . ' -month=' . escapeshellarg($awmonth) . ' -year=' . escapeshellarg($awyear) . ' -update -config=' . escapeshellarg($domain) . ' -dir=' . escapeshellarg($statsdir) . ' -awstatsprog=' . escapeshellarg($awstats_pl) . '";
138147
139148
if (date("d") == 2) {
140149
$awmonth = date("m")-1;

0 commit comments

Comments
 (0)