Commit 2a6eaceb authored by tbrehm's avatar tbrehm
Browse files

Fixed some awstats problems.

parent 58c2101b
...@@ -49,7 +49,7 @@ htaccess_allow_override=All ...@@ -49,7 +49,7 @@ htaccess_allow_override=All
awstats_conf_dir=/etc/awstats awstats_conf_dir=/etc/awstats
awstats_data_dir=/var/lib/awstats awstats_data_dir=/var/lib/awstats
awstats_pl=/usr/lib/cgi-bin/awstats.pl awstats_pl=/usr/lib/cgi-bin/awstats.pl
awstats_updateall_pl=/usr/share/doc/awstats/examples/awstats_updateall.pl awstats_buildstaticpages_pl=/usr/share/awstats/tools/awstats_buildstaticpages.pl
[dns] [dns]
bind_user=root bind_user=root
......
...@@ -463,7 +463,7 @@ $form["tabs"]['web'] = array ( ...@@ -463,7 +463,7 @@ $form["tabs"]['web'] = array (
'width' => '40', 'width' => '40',
'maxlength' => '255' 'maxlength' => '255'
), ),
'awstats_updateall_pl' => array ( 'awstats_buildstaticpages_pl' => array (
'datatype' => 'VARCHAR', 'datatype' => 'VARCHAR',
'formtype' => 'TEXT', 'formtype' => 'TEXT',
'default' => '', 'default' => '',
......
...@@ -68,5 +68,5 @@ $wb["htaccess_allow_override_error_empty"] = '.htaccess AllowOverride is empty.' ...@@ -68,5 +68,5 @@ $wb["htaccess_allow_override_error_empty"] = '.htaccess AllowOverride is empty.'
$wb["awstats_conf_dir_txt"] = 'awstats conf folder'; $wb["awstats_conf_dir_txt"] = 'awstats conf folder';
$wb["awstats_data_dir_txt"] = 'awstats data folder'; $wb["awstats_data_dir_txt"] = 'awstats data folder';
$wb["awstats_pl_txt"] = 'awstats.pl script'; $wb["awstats_pl_txt"] = 'awstats.pl script';
$wb["awstats_updateall_pl_txt"] = 'awstats_updateall script'; $wb["awstats_buildstaticpages_pl_txt"] = 'awstats_buildstaticpages.pl script';
?> ?>
\ No newline at end of file
...@@ -74,8 +74,8 @@ ...@@ -74,8 +74,8 @@
<input name="awstats_pl" id="awstats_pl" value="{tmpl_var name='awstats_pl'}" size="40" maxlength="255" type="text" class="textInput" /> <input name="awstats_pl" id="awstats_pl" value="{tmpl_var name='awstats_pl'}" size="40" maxlength="255" type="text" class="textInput" />
</div> </div>
<div class="ctrlHolder"> <div class="ctrlHolder">
<label for="awstats_updateall_pl">{tmpl_var name='awstats_updateall_pl_txt'}</label> <label for="awstats_buildstaticpages_pl">{tmpl_var name='awstats_buildstaticpages_pl_txt'}</label>
<input name="awstats_updateall_pl" id="awstats_updateall_pl" value="{tmpl_var name='awstats_updateall_pl'}" size="40" maxlength="255" type="text" class="textInput" /> <input name="awstats_buildstaticpages_pl" id="awstats_buildstaticpages_pl" value="{tmpl_var name='awstats_buildstaticpages_pl'}" size="40" maxlength="255" type="text" class="textInput" />
</div> </div>
</fieldset> </fieldset>
......
...@@ -168,19 +168,20 @@ foreach($records as $rec) { ...@@ -168,19 +168,20 @@ foreach($records as $rec) {
$domain = escapeshellcmd($rec["domain"]); $domain = escapeshellcmd($rec["domain"]);
$statsdir = escapeshellcmd($rec["document_root"].'/web/stats'); $statsdir = escapeshellcmd($rec["document_root"].'/web/stats');
$awstats_pl = $web_config['awstats_pl']; $awstats_pl = $web_config['awstats_pl'];
$awstats_updateall_pl = $web_config['awstats_updateall_pl']; $awstats_buildstaticpages_pl = $web_config['awstats_buildstaticpages_pl'];
if(!@is_dir($statsdir)) mkdir($statsdir); if(!@is_dir($statsdir)) mkdir($statsdir);
// awstats_buildstaticpages.pl -update -config=mydomain.com -lang=en -dir=/var/www/domain.com/web/stats -awstatsprog=/path/to/awstats.pl // awstats_buildstaticpages.pl -update -config=mydomain.com -lang=en -dir=/var/www/domain.com/web/stats -awstatsprog=/path/to/awstats.pl
$command = "$awstats_updateall_pl -update -config='$domain' -lang=en -dir='$statsdir' -awstatsprog='$awstats_pl'"; $command = "$awstats_buildstaticpages_pl -update -config='$domain' -lang=en -dir='$statsdir' -awstatsprog='$awstats_pl'";
if($awstats_pl != '' && $awstats_updateall_pl != '' && fileowner($awstats_pl) == 0 && fileowner($awstats_updateall_pl) == 0) { if($awstats_pl != '' && $awstats_buildstaticpages_pl != '' && fileowner($awstats_pl) == 0 && fileowner($awstats_buildstaticpages_pl) == 0) {
exec($command); exec($command);
rename($rec["document_root"].'/web/stats/awstats.'.$domain.'.html',$rec["document_root"].'/web/stats/index.html');
$app->log("Created awstats statistics with command: $command",LOGLEVEL_DEBUG); $app->log("Created awstats statistics with command: $command",LOGLEVEL_DEBUG);
} else { } else {
$app->log("No awstats statistics created. Either $awstats_pl or $awstats_updateall_pl is not owned by root user.",LOGLEVEL_WARN); $app->log("No awstats statistics created. Either $awstats_pl or $awstats_buildstaticpages_pl is not owned by root user.",LOGLEVEL_WARN);
} }
} }
......
...@@ -1211,16 +1211,18 @@ class apache2_plugin { ...@@ -1211,16 +1211,18 @@ class apache2_plugin {
private function awstats_update ($data,$web_config) { private function awstats_update ($data,$web_config) {
global $app; global $app;
$awstats_conf_dir = $web_config['awstats_conf_dir'];
if(!@is_file($awstats_conf_dir."/awstats.".$data["new"]["domain"].".conf") || ($data["old"]["domain"] != '' && $data["new"]["domain"] != $data["old"]["domain"])) { if(!@is_file($awstats_conf_dir."/awstats.".$data["new"]["domain"].".conf") || ($data["old"]["domain"] != '' && $data["new"]["domain"] != $data["old"]["domain"])) {
if ( @is_file($awstats_conf_dir."/awstats.".$data["old"]["domain"].".conf") ) { if ( @is_file($awstats_conf_dir."/awstats.".$data["old"]["domain"].".conf") ) {
unlink($awstats_conf_dir."/awstats.".$data["old"]["domain"].".conf"); unlink($awstats_conf_dir."/awstats.".$data["old"]["domain"].".conf");
} }
$content = ''; $content = '';
$content .= "Include '".$awstats_conf_dir."/awstats.conf'\n"; $content .= "Include \"".$awstats_conf_dir."/awstats.conf\"\n";
$content .= "LogFile='/var/log/ispconfig/httpd/".$data["new"]["domain"]."/access.log'\n"; $content .= "LogFile=\"/var/log/ispconfig/httpd/".$data["new"]["domain"]."/access.log\"\n";
$content .= "SiteDomain='".$data["new"]["domain"]."'\n"; $content .= "SiteDomain=\"".$data["new"]["domain"]."\"\n";
$content .= "HostAliases='www.".$data["new"]["domain"]." localhost 127.0.0.1'\n"; $content .= "HostAliases=\"www.".$data["new"]["domain"]." localhost 127.0.0.1\"\n";
file_put_contents($awstats_conf_dir.'/awstats.'.$data["new"]["domain"].'.conf',$content); file_put_contents($awstats_conf_dir.'/awstats.'.$data["new"]["domain"].'.conf',$content);
$app->log("Created awstats config file: ".$awstats_conf_dir.'/awstats.'.$data["new"]["domain"].'.conf',LOGLEVEL_DEBUG); $app->log("Created awstats config file: ".$awstats_conf_dir.'/awstats.'.$data["new"]["domain"].'.conf',LOGLEVEL_DEBUG);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment