Some code to spit out awstats config files from your Apache vhosts file ("hosts.conf") based on a template ("awstats.conf")
PHP Code:
<?php
/* * Generates awstats config files * LogFile="C:/Apache24/logs/mysite-access.log" * SiteDomain="mysite.com" */
$hosts file_get_contents("hosts.conf");$conf file_get_contents("awstats.conf");
preg_match_all("@ServerName ([.\-a-z1-9]+)@"$hosts$matches);
preg_match_all("@CustomLog logs/([-a-z1-9]+)-access.log combined@"$hosts$matches2);
foreach(
$matches[1] as $key => $domain){    $content sprintf("LogFile=\"C:/Apache24/logs/%s-access.log\"\nSiteDomain=\"%s\"\n%s"$matches2[1][$key], $domain$conf);    file_put_contents(sprintf("awstats.%s.conf"$domain), $content);}?>