Marius Cramer
2014-05-12 1d258eef7ce12c81cf4707ea62b4d2f1ae7b1a91
server/lib/classes/cron.d/150-awstats.inc.php
@@ -54,7 +54,7 @@
      // Create awstats statistics
      //######################################################################################################
      $sql = "SELECT domain_id, domain, document_root, web_folder, type, system_user, system_group, parent_domain_id FROM web_domain WHERE (type = 'vhost' or type = 'vhostsubdomain') and stats_type = 'awstats' AND server_id = ".$conf['server_id'];
      $sql = "SELECT domain_id, domain, document_root, web_folder, type, system_user, system_group, parent_domain_id FROM web_domain WHERE (type = 'vhost' or type = 'vhostsubdomain' or type = 'vhostalias') and stats_type = 'awstats' AND server_id = ".$conf['server_id'];
      $records = $app->db->queryAllRecords($sql);
      $web_config = $app->getconf->get_server_config($conf['server_id'], 'web');
@@ -64,7 +64,7 @@
         $yesterday = date('Ymd', strtotime("-1 day", time()));
         $log_folder = 'log';
         if($rec['type'] == 'vhostsubdomain') {
         if($rec['type'] == 'vhostsubdomain' || $rec['type'] == 'vhostalias') {
            $tmp = $app->db->queryOneRecord('SELECT `domain` FROM web_domain WHERE domain_id = '.intval($rec['parent_domain_id']));
            $subdomain_host = preg_replace('/^(.*)\.' . preg_quote($tmp['domain'], '/') . '$/', '$1', $rec['domain']);
            if($subdomain_host == '') $subdomain_host = 'web'.$rec['domain_id'];
@@ -78,7 +78,7 @@
               continue;
            }
         }
         $web_folder = ($rec['type'] == 'vhostsubdomain' ? $rec['web_folder'] : 'web');
         $web_folder = (($rec['type'] == 'vhostsubdomain' || $rec['type'] == 'vhostalias') ? $rec['web_folder'] : 'web');
         $domain = escapeshellcmd($rec['domain']);
         $statsdir = escapeshellcmd($rec['document_root'].'/'.$web_folder.'/stats');
         $awstats_pl = $web_config['awstats_pl'];
@@ -109,7 +109,11 @@
        LogFile="/var/log/ispconfig/httpd/'.$domain.'/yesterday-access.log"
        SiteDomain="'.$domain.'"
        HostAliases="www.'.$domain.' localhost 127.0.0.1'.$aliasdomain.'"';
            file_put_contents($awstats_website_conf_file, $awstats_conf_file_content);
            if (isset($include_file)) {
               file_put_contents($awstats_website_conf_file, $awstats_conf_file_content);
            } else {
               $app->log("No awstats base config found. Either awstats.conf or awstats.model.conf must exist in ".$awstats_conf_dir.".", LOGLEVEL_WARN);
            }
         }
         if(!@is_dir($statsdir)) mkdir($statsdir);