tbrehm
2010-06-22 2a6eaceb0df52f14b899718682654830600d18f0
Fixed some awstats problems.
6 files modified
29 ■■■■■ changed files
install/tpl/server.ini.master 2 ●●● patch | view | raw | blame | history
interface/web/admin/form/server_config.tform.php 2 ●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/en_server_config.lng 2 ●●● patch | view | raw | blame | history
interface/web/admin/templates/server_config_web_edit.htm 4 ●●●● patch | view | raw | blame | history
server/cron_daily.php 9 ●●●●● patch | view | raw | blame | history
server/plugins-available/apache2_plugin.inc.php 10 ●●●●● patch | view | raw | blame | history
install/tpl/server.ini.master
@@ -49,7 +49,7 @@
awstats_conf_dir=/etc/awstats
awstats_data_dir=/var/lib/awstats
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]
bind_user=root
interface/web/admin/form/server_config.tform.php
@@ -463,7 +463,7 @@
            'width'        => '40',
            'maxlength'    => '255'
        ),
        'awstats_updateall_pl' => array (
        'awstats_buildstaticpages_pl' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
interface/web/admin/lib/lang/en_server_config.lng
@@ -68,5 +68,5 @@
$wb["awstats_conf_dir_txt"] = 'awstats conf folder';
$wb["awstats_data_dir_txt"] = 'awstats data folder';
$wb["awstats_pl_txt"] = 'awstats.pl script';
$wb["awstats_updateall_pl_txt"] = 'awstats_updateall script';
$wb["awstats_buildstaticpages_pl_txt"] = 'awstats_buildstaticpages.pl script';
?>
interface/web/admin/templates/server_config_web_edit.htm
@@ -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" />
      </div>
      <div class="ctrlHolder">
          <label for="awstats_updateall_pl">{tmpl_var name='awstats_updateall_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" />
          <label for="awstats_buildstaticpages_pl">{tmpl_var name='awstats_buildstaticpages_pl_txt'}</label>
        <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>
    </fieldset>
server/cron_daily.php
@@ -168,19 +168,20 @@
    $domain = escapeshellcmd($rec["domain"]);
    $statsdir = escapeshellcmd($rec["document_root"].'/web/stats');
    $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);
    
    // 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);
        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);
    } 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);
    }
    
}
server/plugins-available/apache2_plugin.inc.php
@@ -1211,16 +1211,18 @@
    private function awstats_update ($data,$web_config) {
        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["old"]["domain"].".conf") ) {
                unlink($awstats_conf_dir."/awstats.".$data["old"]["domain"].".conf");
            }
            
            $content = '';
            $content .= "Include '".$awstats_conf_dir."/awstats.conf'\n";
            $content .= "LogFile='/var/log/ispconfig/httpd/".$data["new"]["domain"]."/access.log'\n";
            $content .= "SiteDomain='".$data["new"]["domain"]."'\n";
            $content .= "HostAliases='www.".$data["new"]["domain"]."  localhost 127.0.0.1'\n";
            $content .= "Include \"".$awstats_conf_dir."/awstats.conf\"\n";
            $content .= "LogFile=\"/var/log/ispconfig/httpd/".$data["new"]["domain"]."/access.log\"\n";
            $content .= "SiteDomain=\"".$data["new"]["domain"]."\"\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);
            $app->log("Created awstats config file: ".$awstats_conf_dir.'/awstats.'.$data["new"]["domain"].'.conf',LOGLEVEL_DEBUG);