Skip to content

Commit 9aaf97d

Browse files
author
Carsten Schoene
committed
errorhandling for awstats.conf / awstats.model.conf
Catch situation where no basic awstats configuration can be found and create a warning message.
1 parent e6abfe7 commit 9aaf97d

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ public function onRunJob() {
109109
LogFile="/var/log/ispconfig/httpd/'.$domain.'/yesterday-access.log"
110110
SiteDomain="'.$domain.'"
111111
HostAliases="www.'.$domain.' localhost 127.0.0.1'.$aliasdomain.'"';
112-
file_put_contents($awstats_website_conf_file, $awstats_conf_file_content);
112+
if (isset($include_file)) {
113+
file_put_contents($awstats_website_conf_file, $awstats_conf_file_content);
114+
} else {
115+
$app->log("No awstats base config found. Either awstats.conf or awstats.model.conf must exist in ".$awstats_conf_dir.".", LOGLEVEL_WARN);
116+
}
113117
}
114118

115119
if(!@is_dir($statsdir)) mkdir($statsdir);

server/plugins-available/apache2_plugin.inc.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2636,8 +2636,12 @@ private function awstats_update ($data, $web_config) {
26362636
$content .= "SiteDomain=\"".$data['new']['domain']."\"\n";
26372637
$content .= "HostAliases=\"www.".$data['new']['domain']." localhost 127.0.0.1\"\n";
26382638

2639-
$app->system->file_put_contents($awstats_conf_dir.'/awstats.'.$data['new']['domain'].'.conf', $content);
2640-
$app->log('Created AWStats config file: '.$awstats_conf_dir.'/awstats.'.$data['new']['domain'].'.conf', LOGLEVEL_DEBUG);
2639+
if (isset($include_file)) {
2640+
$app->system->file_put_contents($awstats_conf_dir.'/awstats.'.$data['new']['domain'].'.conf', $content);
2641+
$app->log('Created AWStats config file: '.$awstats_conf_dir.'/awstats.'.$data['new']['domain'].'.conf', LOGLEVEL_DEBUG);
2642+
} else {
2643+
$app->log("No awstats base config found. Either awstats.conf or awstats.model.conf must exist in ".$awstats_conf_dir.".", LOGLEVEL_WARN);
2644+
}
26412645
}
26422646

26432647
if(is_file($data['new']['document_root']."/" . $web_folder . "/stats/index.html")) $app->system->unlink($data['new']['document_root']."/" . $web_folder . "/stats/index.html");

server/plugins-available/nginx_plugin.inc.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2246,8 +2246,12 @@ private function awstats_update ($data, $web_config) {
22462246
$content .= "SiteDomain=\"".$data['new']['domain']."\"\n";
22472247
$content .= "HostAliases=\"www.".$data['new']['domain']." localhost 127.0.0.1\"\n";
22482248

2249-
$app->system->file_put_contents($awstats_conf_dir.'/awstats.'.$data['new']['domain'].'.conf', $content);
2250-
$app->log('Created AWStats config file: '.$awstats_conf_dir.'/awstats.'.$data['new']['domain'].'.conf', LOGLEVEL_DEBUG);
2249+
if (isset($include_file)) {
2250+
$app->system->file_put_contents($awstats_conf_dir.'/awstats.'.$data['new']['domain'].'.conf', $content);
2251+
$app->log('Created AWStats config file: '.$awstats_conf_dir.'/awstats.'.$data['new']['domain'].'.conf', LOGLEVEL_DEBUG);
2252+
} else {
2253+
$app->log("No awstats base config found. Either awstats.conf or awstats.model.conf must exist in ".$awstats_conf_dir.".", LOGLEVEL_WARN);
2254+
}
22512255
}
22522256

22532257
if(is_file($data['new']['document_root']."/" . $web_folder . "/stats/index.html")) $app->system->unlink($data['new']['document_root']."/" . $web_folder . "/stats/index.html");

0 commit comments

Comments
 (0)